@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,9 @@ export declare class MongoRepository {
35
35
  * 取引削除タスク冪等作成
36
36
  */
37
37
  createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
38
+ createConfirmReserveTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>, options: IOptionOnCreate): Promise<void>;
38
39
  createSendOrderTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.SendOrder>, options: IOptionOnCreate): Promise<void>;
40
+ createOnOrderPaymentCompletedTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.OnOrderPaymentCompleted>, options: IOptionOnCreate): Promise<void>;
39
41
  executeById(params: {
40
42
  id: string;
41
43
  executor: {
@@ -68,7 +70,7 @@ export declare class MongoRepository {
68
70
  */
69
71
  $nin?: factory.taskName[];
70
72
  };
71
- }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
73
+ }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
72
74
  retry(params: {
73
75
  intervalInMinutes: number;
74
76
  }): Promise<void>;
@@ -219,6 +219,31 @@ class MongoRepository {
219
219
  }
220
220
  });
221
221
  }
222
+ createConfirmReserveTransactionTaskIfNotExist(params, options) {
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ const createdTask = yield this.taskModel.findOneAndUpdate({
225
+ 'project.id': { $eq: params.project.id },
226
+ name: { $eq: params.name },
227
+ 'data.object.transactionNumber': {
228
+ $exists: true,
229
+ $eq: String(params.data.object.transactionNumber)
230
+ },
231
+ 'data.purpose.orderNumber': {
232
+ $exists: true,
233
+ $eq: String(params.data.purpose.orderNumber)
234
+ }
235
+ }, { $setOnInsert: params }, { new: true, upsert: true })
236
+ .select({ _id: 1 })
237
+ .exec();
238
+ if (options.emitImmediately) {
239
+ task_2.taskEventEmitter.emitTaskStatusChanged({
240
+ id: createdTask.id,
241
+ name: params.name,
242
+ status: factory.taskStatus.Ready
243
+ });
244
+ }
245
+ });
246
+ }
222
247
  createSendOrderTaskIfNotExist(params, options) {
223
248
  return __awaiter(this, void 0, void 0, function* () {
224
249
  const createdTask = yield this.taskModel.findOneAndUpdate({
@@ -240,6 +265,27 @@ class MongoRepository {
240
265
  }
241
266
  });
242
267
  }
268
+ createOnOrderPaymentCompletedTaskIfNotExist(params, options) {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ const createdTask = yield this.taskModel.findOneAndUpdate({
271
+ 'project.id': { $eq: params.project.id },
272
+ name: { $eq: params.name },
273
+ 'data.object.orderNumber': {
274
+ $exists: true,
275
+ $eq: String(params.data.object.orderNumber)
276
+ }
277
+ }, { $setOnInsert: params }, { new: true, upsert: true })
278
+ .select({ _id: 1 })
279
+ .exec();
280
+ if (options.emitImmediately) {
281
+ task_2.taskEventEmitter.emitTaskStatusChanged({
282
+ id: createdTask.id,
283
+ name: params.name,
284
+ status: factory.taskStatus.Ready
285
+ });
286
+ }
287
+ });
288
+ }
243
289
  executeById(params) {
244
290
  return __awaiter(this, void 0, void 0, function* () {
245
291
  const doc = yield this.taskModel.findOneAndUpdate({
@@ -29,6 +29,23 @@ const accountTransactionIdentifier_1 = require("../factory/accountTransactionIde
29
29
  */
30
30
  function givePointAward(params) {
31
31
  return (repos) => __awaiter(this, void 0, void 0, function* () {
32
+ // 入金識別子が存在する場合、冪等性の確保(2023-08-24~)
33
+ const pendingTransactionIdentifier = params.object.identifier;
34
+ if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
35
+ // すでにConfirmedのMoneyTransfer取引が存在すれば何もしない
36
+ const assetTransactions = yield repos.assetTransaction.search({
37
+ limit: 1,
38
+ project: { id: { $eq: params.project.id } },
39
+ typeOf: factory.assetTransactionType.MoneyTransfer,
40
+ statuses: [factory.transactionStatusType.Confirmed],
41
+ object: {
42
+ pendingTransaction: { identifier: { $eq: pendingTransactionIdentifier } }
43
+ }
44
+ }, ['_id']);
45
+ if (assetTransactions.length > 0) {
46
+ return;
47
+ }
48
+ }
32
49
  // アクション開始
33
50
  const action = yield repos.action.start(params);
34
51
  try {
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.confirmPayTransaction = void 0;
13
13
  const factory = require("../../factory");
14
14
  const PayTransactionService = require("../assetTransaction/pay");
15
- const payOrder_1 = require("../order/payOrder");
16
15
  function confirmPayTransaction(data) {
17
16
  return (repos) => __awaiter(this, void 0, void 0, function* () {
18
17
  // アクション開始
@@ -95,14 +94,26 @@ function onConfirmed(params) {
95
94
  allPayTransactionConfirmed = true;
96
95
  }
97
96
  if (allPayTransactionConfirmed) {
98
- yield (0, payOrder_1.payOrder)({
99
- project: { id: params.project.id },
97
+ // onOrderPaymentCompletedタスク冪等作成
98
+ const onPaymentCompletedTaskData = {
99
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
100
100
  object: {
101
101
  confirmationNumber: params.purpose.confirmationNumber,
102
102
  orderNumber: params.purpose.orderNumber
103
103
  },
104
104
  useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
105
- })(repos);
105
+ };
106
+ const onPaymentCompletedTaskAttributes = {
107
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
108
+ name: factory.taskName.OnOrderPaymentCompleted,
109
+ status: factory.taskStatus.Ready,
110
+ runsAt: new Date(),
111
+ remainingNumberOfTries: 10,
112
+ numberOfTried: 0,
113
+ executionResults: [],
114
+ data: onPaymentCompletedTaskData
115
+ };
116
+ yield repos.task.createOnOrderPaymentCompletedTaskIfNotExist(onPaymentCompletedTaskAttributes, { emitImmediately: true });
106
117
  }
107
118
  }
108
119
  });
@@ -30,11 +30,11 @@ export declare function createOnPlaceOrderTasksByTransaction(params: {
30
30
  */
31
31
  export declare function createOnOrderSentTasksByTransaction(params: {
32
32
  potentialActions?: factory.action.transfer.send.order.IPotentialActions;
33
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
33
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
34
34
  /**
35
35
  * 注文返品後のアクション
36
36
  */
37
37
  export declare function createOnOrderReturnedTasksByTransaction(params: {
38
38
  potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
39
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
39
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
40
40
  export {};
@@ -270,7 +270,7 @@ function createOnPlaceOrderTasksByTransaction(params) {
270
270
  // tslint:disable-next-line:no-single-line-block-comment
271
271
  /* istanbul ignore else */
272
272
  if (potentialActions !== undefined) {
273
- // 冗長なsendOrderタスク作成を回避(createSendOrderTransactionTaskIfNotExistへ移行)(2023-08-24~)
273
+ // 冗長なsendOrderタスク作成を回避(createSendOrderTransactionTaskIfNotExistへ移行)(2023-08-25~)
274
274
  // tslint:disable-next-line:no-single-line-block-comment
275
275
  /* istanbul ignore else */
276
276
  // if (potentialActions.sendOrder !== undefined) {
@@ -88,7 +88,8 @@ function onOrderStatusChanged(params) {
88
88
  // 注文作成時のみトークン付加
89
89
  ...(0, factory_1.createInformTasks)(orderWithToken),
90
90
  ...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
91
- ...yield createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
91
+ // createConfirmReserveTransactionTasksIfNotExistへ移行(2023-08-25~)
92
+ // ...await createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
92
93
  ...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
93
94
  // 取引のpotentialActionsを適用(2023-08-17~)
94
95
  ...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
@@ -116,7 +117,9 @@ function onOrderStatusChanged(params) {
116
117
  yield repos.task.saveMany(tasks, { emitImmediately: true });
117
118
  switch (params.order.orderStatus) {
118
119
  case factory.orderStatus.OrderProcessing:
119
- // 冗長なsendOrderタスク作成を回避(2023-08-24~)
120
+ // 冗長なconfirmReserveTransactionタスク作成を回避(2023-08-25~)
121
+ yield createConfirmReserveTransactionTasksIfNotExist(params.order, simpleOrder)(repos);
122
+ // 冗長なsendOrderタスク作成を回避(2023-08-25~)
120
123
  yield createSendOrderTransactionTaskIfNotExist({
121
124
  object: params.order,
122
125
  potentialActions: (_q = (_p = (_o = params.placeOrderTransaction) === null || _o === void 0 ? void 0 : _o.potentialActions) === null || _p === void 0 ? void 0 : _p.order) === null || _q === void 0 ? void 0 : _q.potentialActions
@@ -180,7 +183,7 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
180
183
  });
181
184
  }
182
185
  // const COA_TASK_DELAY_IN_SECONDS = 0;
183
- function createConfirmReserveTransactionTasks(order, simpleOrder) {
186
+ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder) {
184
187
  return (repos) => __awaiter(this, void 0, void 0, function* () {
185
188
  const taskRunsAt = new Date();
186
189
  const taskRunsAt4coa = new Date();
@@ -191,51 +194,32 @@ function createConfirmReserveTransactionTasks(order, simpleOrder) {
191
194
  ...(0, factory_1.createConfirmReservationActionObject4ChevreByOrder)({ order }),
192
195
  ...(0, factory_1.createConfirmReservationActionObject4COAByOrder)({ order })
193
196
  ];
194
- const tasks = [];
195
197
  yield Promise.all(confirmObjects.map((confirmObject) => __awaiter(this, void 0, void 0, function* () {
196
- // 冗長なタスク作成を回避
197
- const existingTasks = yield repos.task.search({
198
- limit: 1,
199
- page: 1,
200
- project: { id: { $eq: order.project.id } },
201
- name: factory.taskName.ConfirmReserveTransaction,
202
- data: {
203
- object: { transactionNumber: { $eq: confirmObject.transactionNumber } },
204
- purpose: { orderNumber: { $eq: order.orderNumber } }
198
+ const data = {
199
+ project: order.project,
200
+ typeOf: factory.actionType.ConfirmAction,
201
+ object: confirmObject,
202
+ agent: order.project,
203
+ purpose: simpleOrder,
204
+ instrument: {
205
+ typeOf: 'WebAPI',
206
+ identifier: (confirmObject.typeOf === 'COAReserveTransaction')
207
+ ? factory.service.webAPI.Identifier.COA
208
+ : factory.service.webAPI.Identifier.Chevre
205
209
  }
206
- }, {
207
- data: 0, executionResults: 0, name: 0, numberOfTried: 0,
208
- remainingNumberOfTries: 0, runsAt: 0, status: 0
209
- });
210
- if (existingTasks.length === 0) {
211
- const data = {
212
- project: order.project,
213
- typeOf: factory.actionType.ConfirmAction,
214
- object: confirmObject,
215
- agent: order.project,
216
- purpose: simpleOrder,
217
- instrument: {
218
- typeOf: 'WebAPI',
219
- identifier: (confirmObject.typeOf === 'COAReserveTransaction')
220
- ? factory.service.webAPI.Identifier.COA
221
- : factory.service.webAPI.Identifier.Chevre
222
- }
223
- };
224
- tasks.push({
225
- project: order.project,
226
- name: factory.taskName.ConfirmReserveTransaction,
227
- status: factory.taskStatus.Ready,
228
- runsAt: (confirmObject.typeOf === 'COAReserveTransaction')
229
- ? taskRunsAt4coa
230
- : taskRunsAt,
231
- remainingNumberOfTries: 10,
232
- numberOfTried: 0,
233
- executionResults: [],
234
- data
235
- });
236
- }
210
+ };
211
+ const confirmReserveTransactionTask = {
212
+ project: order.project,
213
+ name: factory.taskName.ConfirmReserveTransaction,
214
+ status: factory.taskStatus.Ready,
215
+ runsAt: (confirmObject.typeOf === 'COAReserveTransaction') ? taskRunsAt4coa : taskRunsAt,
216
+ remainingNumberOfTries: 10,
217
+ numberOfTried: 0,
218
+ executionResults: [],
219
+ data
220
+ };
221
+ yield repos.task.createConfirmReserveTransactionTaskIfNotExist(confirmReserveTransactionTask, { emitImmediately: true });
237
222
  })));
238
- return tasks;
239
223
  });
240
224
  }
241
225
  function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
@@ -2,19 +2,11 @@ import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/act
2
2
  import { MongoRepository as OrderRepo } from '../../repo/order';
3
3
  import { MongoRepository as TaskRepo } from '../../repo/task';
4
4
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
5
+ import * as factory from '../../factory';
5
6
  /**
6
7
  * 注文を決済する
7
8
  */
8
- declare function payOrder(params: {
9
- project: {
10
- id: string;
11
- };
12
- object: {
13
- confirmationNumber: string;
14
- orderNumber: string;
15
- };
16
- useOnOrderStatusChanged: boolean;
17
- }): (repos: {
9
+ declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): (repos: {
18
10
  order: OrderRepo;
19
11
  registerActionInProgress: RegisterServiceInProgressRepo;
20
12
  task: TaskRepo;
@@ -15,7 +15,6 @@ const order_1 = require("../../factory/order");
15
15
  const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
16
16
  const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
17
17
  const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
18
- const payOrder_1 = require("./payOrder");
19
18
  const factory = require("../../factory");
20
19
  function createOrder(params) {
21
20
  // 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
@@ -244,14 +243,26 @@ function placeOrder(params) {
244
243
  // paymentMethods.length: 0の場合を考慮(2023-08-24~)
245
244
  if (order.paymentMethods.length === 0) {
246
245
  // paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpayOrderを実行する必要がある
247
- yield (0, payOrder_1.payOrder)({
248
- project: { id: order.project.id },
246
+ // onOrderPaymentCompletedタスク作成
247
+ const onPaymentCompletedTaskData = {
248
+ project: { id: order.project.id, typeOf: factory.organizationType.Project },
249
249
  object: {
250
250
  confirmationNumber: order.confirmationNumber,
251
251
  orderNumber: order.orderNumber
252
252
  },
253
- useOnOrderStatusChanged: params.useOnOrderStatusChanged
254
- })(repos);
253
+ useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
254
+ };
255
+ const onPaymentCompletedTaskAttributes = {
256
+ project: { id: order.project.id, typeOf: factory.organizationType.Project },
257
+ name: factory.taskName.OnOrderPaymentCompleted,
258
+ status: factory.taskStatus.Ready,
259
+ runsAt: new Date(),
260
+ remainingNumberOfTries: 10,
261
+ numberOfTried: 0,
262
+ executionResults: [],
263
+ data: onPaymentCompletedTaskData
264
+ };
265
+ yield repos.task.createOnOrderPaymentCompletedTaskIfNotExist(onPaymentCompletedTaskAttributes, { emitImmediately: true });
255
266
  }
256
267
  }
257
268
  else {
@@ -0,0 +1,6 @@
1
+ import { IOperation } from '../task';
2
+ import * as factory from '../../factory';
3
+ /**
4
+ * タスク実行関数
5
+ */
6
+ export declare function call(data: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): IOperation<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.call = void 0;
13
+ const factory = require("../../factory");
14
+ const registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
15
+ const order_1 = require("../../repo/order");
16
+ const task_1 = require("../../repo/task");
17
+ const transaction_1 = require("../../repo/transaction");
18
+ const payOrder_1 = require("../order/payOrder");
19
+ /**
20
+ * タスク実行関数
21
+ */
22
+ function call(data) {
23
+ return (settings) => __awaiter(this, void 0, void 0, function* () {
24
+ if (settings.redisClient === undefined) {
25
+ throw new factory.errors.Argument('settings', 'redisClient required');
26
+ }
27
+ yield (0, payOrder_1.payOrder)(data)({
28
+ order: new order_1.MongoRepository(settings.connection),
29
+ registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
30
+ task: new task_1.MongoRepository(settings.connection),
31
+ transaction: new transaction_1.MongoRepository(settings.connection)
32
+ });
33
+ });
34
+ }
35
+ exports.call = call;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.327.0-alpha.2",
12
+ "@chevre/factory": "4.327.0-alpha.3",
13
13
  "@cinerino/sdk": "3.165.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.6"
120
+ "version": "21.8.0-alpha.8"
121
121
  }