@chevre/domain 25.2.0-alpha.54 → 25.2.0-alpha.56
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/adminTask.d.ts +37 -0
- package/lib/chevre/repo/adminTask.js +163 -0
- package/lib/chevre/repo/aggregateTask.d.ts +38 -0
- package/lib/chevre/repo/aggregateTask.js +136 -0
- package/lib/chevre/repo/scheduledTask.d.ts +52 -0
- package/lib/chevre/repo/scheduledTask.js +113 -0
- package/lib/chevre/repo/task.d.ts +2 -64
- package/lib/chevre/repo/task.js +2 -318
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +35 -2
- package/lib/chevre/service/aggregation/system.d.ts +2 -2
- package/lib/chevre/service/aggregation/system.js +1 -1
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +2 -2
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +0 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +72 -43
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onOrderPaymentDue = onOrderPaymentDue;
|
|
4
|
+
/**
|
|
5
|
+
* 注文決済時処理
|
|
6
|
+
*/
|
|
7
|
+
const util_1 = require("util");
|
|
4
8
|
const factory_1 = require("../../../factory");
|
|
5
9
|
function onOrderPaymentDue(params) {
|
|
6
10
|
return async (repos) => {
|
|
@@ -13,8 +17,9 @@ function onOrderPaymentDue(params) {
|
|
|
13
17
|
switch (params.order.orderStatus) {
|
|
14
18
|
// OrderPaymentDueを追加(2023-08-23~)
|
|
15
19
|
case factory_1.factory.orderStatus.OrderPaymentDue:
|
|
20
|
+
await createConfirmPayTransactionTasks(params.order, simpleOrder)(repos);
|
|
16
21
|
tasks = [
|
|
17
|
-
...await createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
22
|
+
// ...await createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
18
23
|
...createCreateAccountingReportTask(params.order) // 経理レポート作成タスク(2024-02-02~)
|
|
19
24
|
];
|
|
20
25
|
break;
|
|
@@ -27,55 +32,79 @@ function onOrderPaymentDue(params) {
|
|
|
27
32
|
function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
28
33
|
return async (repos) => {
|
|
29
34
|
const taskRunsAt = new Date();
|
|
30
|
-
const tasks = [];
|
|
35
|
+
// const tasks: factory.task.IAttributes<factory.taskName.ConfirmPayTransaction>[] = [];
|
|
31
36
|
await Promise.all(order.paymentMethods.map(async (invoice) => {
|
|
32
37
|
// PaymentAutomaticallyAppliedであれば、自動決済処理を実行(2023-08-24~)
|
|
33
38
|
if (invoice.paymentStatus !== factory_1.factory.paymentStatusType.PaymentAutomaticallyApplied) {
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
|
-
//
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// 識別子指定でタスク作成(2026-07-30~)
|
|
42
|
+
const data = {
|
|
43
|
+
project: order.project,
|
|
44
|
+
typeOf: factory_1.factory.actionType.ConfirmAction,
|
|
45
|
+
object: [{ typeOf: factory_1.factory.assetTransactionType.Pay, transactionNumber: invoice.paymentMethodId }],
|
|
46
|
+
agent: order.project,
|
|
47
|
+
purpose: {
|
|
48
|
+
...simpleOrder,
|
|
49
|
+
confirmationNumber: order.confirmationNumber
|
|
50
|
+
},
|
|
51
|
+
processOrder: order.orderStatus === factory_1.factory.orderStatus.OrderPaymentDue, // OrderPaymentDueの場合、processOrderを実行する
|
|
52
|
+
useOnOrderStatusChanged: true
|
|
53
|
+
};
|
|
54
|
+
const taskIdentifier = (0, util_1.format)('%s:%s:%s:%s:%s:%s', order.project.id, factory_1.factory.taskName.ConfirmPayTransaction, data.purpose.typeOf, data.purpose.orderNumber, factory_1.factory.assetTransactionType.Pay, invoice.paymentMethodId);
|
|
55
|
+
const confirmPayTransactionTask = {
|
|
56
|
+
alternateName: taskIdentifier,
|
|
57
|
+
identifier: taskIdentifier,
|
|
58
|
+
project: order.project,
|
|
41
59
|
name: factory_1.factory.taskName.ConfirmPayTransaction,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
60
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
61
|
+
runsAt: taskRunsAt,
|
|
62
|
+
remainingNumberOfTries: 10,
|
|
63
|
+
numberOfTried: 0,
|
|
64
|
+
executionResults: [],
|
|
65
|
+
data
|
|
66
|
+
};
|
|
67
|
+
await repos.task.createIfNotExistByAlternateName(confirmPayTransactionTask, { emitImmediately: true });
|
|
68
|
+
// 冗長なタスク作成を回避
|
|
69
|
+
// const existingTasks = await repos.task.projectFields(
|
|
70
|
+
// {
|
|
71
|
+
// limit: 1,
|
|
72
|
+
// page: 1,
|
|
73
|
+
// project: { id: { $eq: order.project.id } },
|
|
74
|
+
// name: factory.taskName.ConfirmPayTransaction,
|
|
75
|
+
// data: {
|
|
76
|
+
// object: { transactionNumber: { $eq: invoice.paymentMethodId } },
|
|
77
|
+
// purpose: { orderNumber: { $eq: order.orderNumber } }
|
|
78
|
+
// }
|
|
79
|
+
// },
|
|
80
|
+
// ['id']
|
|
81
|
+
// ) as { id: string }[];
|
|
82
|
+
// if (existingTasks.length === 0) {
|
|
83
|
+
// const data: factory.task.IData<factory.taskName.ConfirmPayTransaction> = {
|
|
84
|
+
// project: order.project,
|
|
85
|
+
// typeOf: factory.actionType.ConfirmAction,
|
|
86
|
+
// object: [{ typeOf: factory.assetTransactionType.Pay, transactionNumber: invoice.paymentMethodId }],
|
|
87
|
+
// agent: order.project,
|
|
88
|
+
// purpose: {
|
|
89
|
+
// ...simpleOrder,
|
|
90
|
+
// confirmationNumber: order.confirmationNumber
|
|
91
|
+
// },
|
|
92
|
+
// processOrder: order.orderStatus === factory.orderStatus.OrderPaymentDue, // OrderPaymentDueの場合、processOrderを実行する
|
|
93
|
+
// useOnOrderStatusChanged: true
|
|
94
|
+
// };
|
|
95
|
+
// tasks.push({
|
|
96
|
+
// project: order.project,
|
|
97
|
+
// name: factory.taskName.ConfirmPayTransaction,
|
|
98
|
+
// status: factory.taskStatus.Ready,
|
|
99
|
+
// runsAt: taskRunsAt,
|
|
100
|
+
// remainingNumberOfTries: 10,
|
|
101
|
+
// numberOfTried: 0,
|
|
102
|
+
// executionResults: [],
|
|
103
|
+
// data
|
|
104
|
+
// });
|
|
105
|
+
// }
|
|
77
106
|
}));
|
|
78
|
-
return tasks;
|
|
107
|
+
// return tasks;
|
|
79
108
|
};
|
|
80
109
|
}
|
|
81
110
|
function createCreateAccountingReportTask(order) {
|
package/package.json
CHANGED