@chevre/domain 21.8.0-alpha.7 → 21.8.0-alpha.9
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.
- package/lib/chevre/repo/task.d.ts +3 -1
- package/lib/chevre/repo/task.js +46 -0
- package/lib/chevre/service/order/confirmPayTransaction.js +19 -4
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +32 -45
- package/lib/chevre/service/order/payOrder.d.ts +2 -10
- package/lib/chevre/service/order/placeOrder.js +16 -5
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
- package/package.json +2 -2
|
@@ -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>;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -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({
|
|
@@ -10,9 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.confirmPayTransaction = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
13
14
|
const factory = require("../../factory");
|
|
14
15
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
15
|
-
const
|
|
16
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
16
17
|
function confirmPayTransaction(data) {
|
|
17
18
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
// アクション開始
|
|
@@ -83,6 +84,7 @@ function onConfirmed(params) {
|
|
|
83
84
|
const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
|
|
84
85
|
.map((invoice) => invoice.paymentMethodId);
|
|
85
86
|
if (paymentMethodIds.length > 0) {
|
|
87
|
+
debug('checking allPayTransactionConfirmed...', 'orderNumber:', params.purpose.orderNumber);
|
|
86
88
|
const referencedPayTransactions = yield repos.assetTransaction.search({
|
|
87
89
|
project: { id: { $eq: params.project.id } },
|
|
88
90
|
typeOf: factory.assetTransactionType.Pay,
|
|
@@ -90,19 +92,32 @@ function onConfirmed(params) {
|
|
|
90
92
|
}, ['status']);
|
|
91
93
|
allPayTransactionConfirmed =
|
|
92
94
|
referencedPayTransactions.every((payTransation) => payTransation.status === factory.transactionStatusType.Confirmed);
|
|
95
|
+
debug('allPayTransactionConfirmed?:', allPayTransactionConfirmed, 'referencedPayTransactions:', JSON.stringify(referencedPayTransactions), 'orderNumber:', params.purpose.orderNumber);
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
95
98
|
allPayTransactionConfirmed = true;
|
|
96
99
|
}
|
|
97
100
|
if (allPayTransactionConfirmed) {
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
// onOrderPaymentCompletedタスク冪等作成
|
|
102
|
+
const onPaymentCompletedTaskData = {
|
|
103
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
100
104
|
object: {
|
|
101
105
|
confirmationNumber: params.purpose.confirmationNumber,
|
|
102
106
|
orderNumber: params.purpose.orderNumber
|
|
103
107
|
},
|
|
104
108
|
useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
|
|
105
|
-
}
|
|
109
|
+
};
|
|
110
|
+
const onPaymentCompletedTaskAttributes = {
|
|
111
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
112
|
+
name: factory.taskName.OnOrderPaymentCompleted,
|
|
113
|
+
status: factory.taskStatus.Ready,
|
|
114
|
+
runsAt: new Date(),
|
|
115
|
+
remainingNumberOfTries: 10,
|
|
116
|
+
numberOfTried: 0,
|
|
117
|
+
executionResults: [],
|
|
118
|
+
data: onPaymentCompletedTaskData
|
|
119
|
+
};
|
|
120
|
+
yield repos.task.createOnOrderPaymentCompletedTaskIfNotExist(onPaymentCompletedTaskAttributes, { emitImmediately: true });
|
|
106
121
|
}
|
|
107
122
|
}
|
|
108
123
|
});
|
|
@@ -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-
|
|
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) {
|
|
@@ -13,17 +13,20 @@ exports.onOrderStatusChanged = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 注文ステータス変更時処理
|
|
15
15
|
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
16
17
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
17
18
|
const factory = require("../../factory");
|
|
18
19
|
const order_1 = require("../../factory/order");
|
|
19
20
|
const product_1 = require("../offer/product");
|
|
20
21
|
const factory_1 = require("./onOrderStatusChanged/factory");
|
|
22
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
21
23
|
const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTER_SERVICE_TRANSACTION === '1';
|
|
22
24
|
const TOKEN_EXPIRES_IN = 604800;
|
|
23
25
|
function onOrderStatusChanged(params) {
|
|
24
26
|
// tslint:disable-next-line:max-func-body-length
|
|
25
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
29
|
+
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
27
30
|
let tasks = [];
|
|
28
31
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
29
32
|
const simpleOrder = {
|
|
@@ -88,7 +91,8 @@ function onOrderStatusChanged(params) {
|
|
|
88
91
|
// 注文作成時のみトークン付加
|
|
89
92
|
...(0, factory_1.createInformTasks)(orderWithToken),
|
|
90
93
|
...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
91
|
-
|
|
94
|
+
// createConfirmReserveTransactionTasksIfNotExistへ移行(2023-08-25~)
|
|
95
|
+
// ...await createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
|
|
92
96
|
...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
|
|
93
97
|
// 取引のpotentialActionsを適用(2023-08-17~)
|
|
94
98
|
...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
|
|
@@ -116,7 +120,9 @@ function onOrderStatusChanged(params) {
|
|
|
116
120
|
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
117
121
|
switch (params.order.orderStatus) {
|
|
118
122
|
case factory.orderStatus.OrderProcessing:
|
|
119
|
-
// 冗長な
|
|
123
|
+
// 冗長なconfirmReserveTransactionタスク作成を回避(2023-08-25~)
|
|
124
|
+
yield createConfirmReserveTransactionTasksIfNotExist(params.order, simpleOrder)(repos);
|
|
125
|
+
// 冗長なsendOrderタスク作成を回避(2023-08-25~)
|
|
120
126
|
yield createSendOrderTransactionTaskIfNotExist({
|
|
121
127
|
object: params.order,
|
|
122
128
|
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 +186,7 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
180
186
|
});
|
|
181
187
|
}
|
|
182
188
|
// const COA_TASK_DELAY_IN_SECONDS = 0;
|
|
183
|
-
function
|
|
189
|
+
function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder) {
|
|
184
190
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
185
191
|
const taskRunsAt = new Date();
|
|
186
192
|
const taskRunsAt4coa = new Date();
|
|
@@ -191,51 +197,32 @@ function createConfirmReserveTransactionTasks(order, simpleOrder) {
|
|
|
191
197
|
...(0, factory_1.createConfirmReservationActionObject4ChevreByOrder)({ order }),
|
|
192
198
|
...(0, factory_1.createConfirmReservationActionObject4COAByOrder)({ order })
|
|
193
199
|
];
|
|
194
|
-
const tasks = [];
|
|
195
200
|
yield Promise.all(confirmObjects.map((confirmObject) => __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
const data = {
|
|
202
|
+
project: order.project,
|
|
203
|
+
typeOf: factory.actionType.ConfirmAction,
|
|
204
|
+
object: confirmObject,
|
|
205
|
+
agent: order.project,
|
|
206
|
+
purpose: simpleOrder,
|
|
207
|
+
instrument: {
|
|
208
|
+
typeOf: 'WebAPI',
|
|
209
|
+
identifier: (confirmObject.typeOf === 'COAReserveTransaction')
|
|
210
|
+
? factory.service.webAPI.Identifier.COA
|
|
211
|
+
: factory.service.webAPI.Identifier.Chevre
|
|
205
212
|
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
}
|
|
213
|
+
};
|
|
214
|
+
const confirmReserveTransactionTask = {
|
|
215
|
+
project: order.project,
|
|
216
|
+
name: factory.taskName.ConfirmReserveTransaction,
|
|
217
|
+
status: factory.taskStatus.Ready,
|
|
218
|
+
runsAt: (confirmObject.typeOf === 'COAReserveTransaction') ? taskRunsAt4coa : taskRunsAt,
|
|
219
|
+
remainingNumberOfTries: 10,
|
|
220
|
+
numberOfTried: 0,
|
|
221
|
+
executionResults: [],
|
|
222
|
+
data
|
|
223
|
+
};
|
|
224
|
+
yield repos.task.createConfirmReserveTransactionTaskIfNotExist(confirmReserveTransactionTask, { emitImmediately: true });
|
|
237
225
|
})));
|
|
238
|
-
return tasks;
|
|
239
226
|
});
|
|
240
227
|
}
|
|
241
228
|
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
|
-
|
|
248
|
-
|
|
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
|
-
}
|
|
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,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.
|
|
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.
|
|
120
|
+
"version": "21.8.0-alpha.9"
|
|
121
121
|
}
|