@chevre/domain 21.18.0-alpha.4 → 21.18.0-alpha.41
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/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
- package/example/src/chevre/offerCatalog2offerCatalogItem.ts +4 -0
- package/example/src/chevre/searchAcceptedOfferIds.ts +57 -0
- package/example/src/chevre/searchOffers.ts +41 -37
- package/example/src/chevre/searchOrderAcceptedOffers.ts +12 -12
- package/example/src/chevre/searchOrders.ts +36 -19
- package/example/src/chevre/searchReservationsByOrder.ts +30 -0
- package/example/src/chevre/searchTransactions.ts +41 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/example/src/chevre/upsertMoviesByIdentifier.ts +5 -4
- package/example/src/chevre/upsertOfferCatalogsByIdentifier.ts +46 -0
- package/example/src/chevre/upsertOffersByIdentifier.ts +94 -0
- package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +104 -0
- package/lib/chevre/credentials.d.ts +0 -3
- package/lib/chevre/credentials.js +4 -3
- package/lib/chevre/repo/acceptedOffer.d.ts +60 -0
- package/lib/chevre/repo/acceptedOffer.js +158 -0
- package/lib/chevre/repo/creativeWork.d.ts +12 -2
- package/lib/chevre/repo/creativeWork.js +39 -25
- package/lib/chevre/repo/event.d.ts +15 -0
- package/lib/chevre/repo/event.js +66 -0
- package/lib/chevre/repo/offer.d.ts +14 -5
- package/lib/chevre/repo/offer.js +94 -19
- package/lib/chevre/repo/offerCatalog.d.ts +18 -1
- package/lib/chevre/repo/offerCatalog.js +51 -39
- package/lib/chevre/repo/order.d.ts +14 -54
- package/lib/chevre/repo/order.js +46 -180
- package/lib/chevre/repo/paymentService.d.ts +30 -0
- package/lib/chevre/repo/paymentService.js +75 -0
- package/lib/chevre/repo/place.js +14 -10
- package/lib/chevre/repo/product.d.ts +41 -10
- package/lib/chevre/repo/product.js +94 -47
- package/lib/chevre/repo/transaction.d.ts +5 -4
- package/lib/chevre/repository.d.ts +10 -7
- package/lib/chevre/repository.js +28 -17
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -1
- package/lib/chevre/service/aggregation/event/findEventOffers.js +10 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/pay.js +47 -34
- package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund/factory.js +0 -5
- package/lib/chevre/service/assetTransaction/refund.js +15 -3
- package/lib/chevre/service/assetTransaction/registerService.js +18 -2
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve.js +32 -2
- package/lib/chevre/service/delivery/factory.d.ts +3 -1
- package/lib/chevre/service/delivery/factory.js +4 -2
- package/lib/chevre/service/delivery.d.ts +1 -2
- package/lib/chevre/service/delivery.js +1 -3
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/moneyTransfer.js +11 -1
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +4 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +40 -5
- package/lib/chevre/service/offer/product/factory.js +1 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +10 -1
- package/lib/chevre/service/offer/product.d.ts +0 -14
- package/lib/chevre/service/offer/product.js +61 -44
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +2 -0
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
- package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +15 -4
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +15 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +54 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +38 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +111 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +64 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +103 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +23 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +180 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +214 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +110 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +164 -0
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +9 -15
- package/lib/chevre/service/order/onOrderStatusChanged.js +11 -446
- package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +6 -0
- package/lib/chevre/service/order/onOrderUpdated/factory.js +45 -0
- package/lib/chevre/service/order/onOrderUpdated.js +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder.d.ts +2 -3
- package/lib/chevre/service/order/placeOrder.js +65 -22
- package/lib/chevre/service/order/returnOrder.d.ts +2 -2
- package/lib/chevre/service/order/returnOrder.js +34 -13
- package/lib/chevre/service/order/sendOrder.d.ts +2 -2
- package/lib/chevre/service/order/sendOrder.js +19 -6
- package/lib/chevre/service/order.d.ts +2 -2
- package/lib/chevre/service/order.js +2 -2
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -2
- package/lib/chevre/service/payment/paymentCard.js +9 -2
- package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
- package/lib/chevre/service/reserve/searchByOrder.js +113 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
- package/lib/chevre/service/reserve.d.ts +2 -1
- package/lib/chevre/service/reserve.js +3 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +5 -6
- package/lib/chevre/service/task/onAuthorizationCreated.js +9 -18
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +5 -6
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/lib/chevre/service/task/placeOrder.js +10 -17
- package/lib/chevre/service/task/returnOrder.js +10 -17
- package/lib/chevre/service/task/sendOrder.js +10 -17
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +0 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -86
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.d.ts +3 -0
- package/lib/chevre/service/transaction/returnOrder.js +73 -55
- package/package.json +3 -3
- package/example/src/chevre/transaction/findPaymentCardPermit.ts +0 -29
- package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
- package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -42
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +0 -467
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +0 -26
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +0 -65
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.voidTransaction = exports.authorize = exports.search = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
15
|
const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
|
|
@@ -26,7 +26,7 @@ function search(params) {
|
|
|
26
26
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
var _a;
|
|
28
28
|
const now = moment();
|
|
29
|
-
const searchProductsResult = yield repos.product.
|
|
29
|
+
const searchProductsResult = yield repos.product.searchProducts({
|
|
30
30
|
limit: 1,
|
|
31
31
|
page: 1,
|
|
32
32
|
project: { id: { $eq: params.project.id } },
|
|
@@ -129,11 +129,12 @@ function authorize(params) {
|
|
|
129
129
|
try {
|
|
130
130
|
// 会員の場合のみ排他ロック
|
|
131
131
|
if (params.agent.typeOf === factory.personType.Person) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
132
|
+
// 廃止(2023-12-07~)
|
|
133
|
+
// await processLockRegisterMembershipService({
|
|
134
|
+
// agent: params.agent,
|
|
135
|
+
// product: product,
|
|
136
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
137
|
+
// })(repos);
|
|
137
138
|
}
|
|
138
139
|
// サービス登録開始
|
|
139
140
|
const startParams = (0, factory_1.createRegisterServiceStartParams)({
|
|
@@ -155,11 +156,12 @@ function authorize(params) {
|
|
|
155
156
|
// no op
|
|
156
157
|
}
|
|
157
158
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
159
|
+
// 廃止(2023-12-07~)
|
|
160
|
+
// await processUnlockRegisterMembershipService({
|
|
161
|
+
// agent: params.agent,
|
|
162
|
+
// product: { id: String(product.id) },
|
|
163
|
+
// purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
164
|
+
// })(repos);
|
|
163
165
|
}
|
|
164
166
|
catch (error) {
|
|
165
167
|
// 失敗したら仕方ない
|
|
@@ -176,7 +178,7 @@ function fixProductAndOffers(params) {
|
|
|
176
178
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
177
179
|
var _a, _b, _c;
|
|
178
180
|
const productId = String((_b = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id);
|
|
179
|
-
const searchProductsResult = yield repos.product.
|
|
181
|
+
const searchProductsResult = yield repos.product.searchProducts({
|
|
180
182
|
limit: 1,
|
|
181
183
|
page: 1,
|
|
182
184
|
project: { id: { $eq: params.project.id } },
|
|
@@ -233,11 +235,12 @@ function voidTransaction(params) {
|
|
|
233
235
|
var _b, _c;
|
|
234
236
|
const productId = (_c = (_b = action.object[0]) === null || _b === void 0 ? void 0 : _b.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
|
|
235
237
|
if (typeof productId === 'string') {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
// 廃止(2023-12-07~)
|
|
239
|
+
// await processUnlockRegisterMembershipService({
|
|
240
|
+
// agent: { id: transaction.agent.id },
|
|
241
|
+
// product: { id: productId },
|
|
242
|
+
// purpose: params.purpose
|
|
243
|
+
// })(repos);
|
|
241
244
|
}
|
|
242
245
|
yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
|
|
243
246
|
yield processVoidRegisterServiceTransaction({
|
|
@@ -382,29 +385,43 @@ function createServiceOutputIdentifier(params) {
|
|
|
382
385
|
})));
|
|
383
386
|
});
|
|
384
387
|
}
|
|
385
|
-
function processLockRegisterMembershipService(params
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
388
|
+
// function processLockRegisterMembershipService(params: {
|
|
389
|
+
// agent: { id: string };
|
|
390
|
+
// product: factory.product.IProduct;
|
|
391
|
+
// purpose: factory.action.authorize.offer.product.IPurpose;
|
|
392
|
+
// }) {
|
|
393
|
+
// return async (repos: {
|
|
394
|
+
// registerActionInProgress: RegisterServiceInProgressRepo;
|
|
395
|
+
// }) => {
|
|
396
|
+
// if (params.product.typeOf === factory.product.ProductType.MembershipService) {
|
|
397
|
+
// await repos.registerActionInProgress.lock(
|
|
398
|
+
// {
|
|
399
|
+
// agent: { id: params.agent.id },
|
|
400
|
+
// product: { id: String(params.product.id) }
|
|
401
|
+
// },
|
|
402
|
+
// params.purpose.id
|
|
403
|
+
// );
|
|
404
|
+
// }
|
|
405
|
+
// };
|
|
406
|
+
// }
|
|
407
|
+
// export function processUnlockRegisterMembershipService(params: {
|
|
408
|
+
// agent: { id: string };
|
|
409
|
+
// product: { id: string };
|
|
410
|
+
// purpose: factory.action.authorize.offer.product.IPurpose;
|
|
411
|
+
// }) {
|
|
412
|
+
// return async (repos: {
|
|
413
|
+
// registerActionInProgress: RegisterServiceInProgressRepo;
|
|
414
|
+
// }) => {
|
|
415
|
+
// // 登録ロックIDが取引IDであればロック解除
|
|
416
|
+
// const holder = await repos.registerActionInProgress.getHolder({
|
|
417
|
+
// agent: { id: params.agent.id },
|
|
418
|
+
// product: { id: params.product.id }
|
|
419
|
+
// });
|
|
420
|
+
// if (holder === params.purpose.id) {
|
|
421
|
+
// await repos.registerActionInProgress.unlock({
|
|
422
|
+
// agent: { id: params.agent.id },
|
|
423
|
+
// product: { id: params.product.id }
|
|
424
|
+
// });
|
|
425
|
+
// }
|
|
426
|
+
// };
|
|
427
|
+
// }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
3
|
import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
4
|
import type { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
5
|
import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
@@ -9,6 +10,7 @@ import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
|
9
10
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
10
11
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
11
12
|
declare function confirmPayTransaction(data: factory.task.IData<factory.taskName.ConfirmPayTransaction>): (repos: {
|
|
13
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
12
14
|
action: ActionRepo;
|
|
13
15
|
assetTransaction: AssetTransactionRepo;
|
|
14
16
|
order: OrderRepo;
|
|
@@ -30,6 +30,7 @@ function confirmPayTransaction(data) {
|
|
|
30
30
|
} }, (typeof ((_b = (_a = confirmingTransaction.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
31
31
|
? { object: { paymentMethod: { identifier: confirmingTransaction.object.paymentMethod.identifier } } }
|
|
32
32
|
: undefined))({
|
|
33
|
+
acceptedOffer: repos.acceptedOffer,
|
|
33
34
|
action: repos.action,
|
|
34
35
|
accountingReport: repos.accountingReport,
|
|
35
36
|
assetTransaction: repos.assetTransaction,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
|
-
export declare function createAccountingReportIfNotExist(params: factory.order.IOrder
|
|
3
|
+
export declare function createAccountingReportIfNotExist(params: factory.order.IOrder & {
|
|
4
|
+
acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
5
|
+
}): (repos: {
|
|
4
6
|
accountingReport: AccountingReportRepo;
|
|
5
7
|
}) => Promise<void>;
|
|
@@ -28,7 +28,10 @@ exports.createAccountingReportIfNotExist = createAccountingReportIfNotExist;
|
|
|
28
28
|
// 最適化(2023-06-30~)
|
|
29
29
|
function createOrder4report(params) {
|
|
30
30
|
var _a;
|
|
31
|
-
|
|
31
|
+
if (!Array.isArray(params.acceptedOffers)) {
|
|
32
|
+
throw new factory.errors.ArgumentNull('order.acceptedOffers');
|
|
33
|
+
}
|
|
34
|
+
const numItems = params.acceptedOffers.length;
|
|
32
35
|
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
33
36
|
const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
34
37
|
? params.acceptedOffers.map((o) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
1
2
|
import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
3
|
import type { MongoRepository as EventRepo } from '../../repo/event';
|
|
3
4
|
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
@@ -11,6 +12,7 @@ import * as factory from '../../factory';
|
|
|
11
12
|
declare function deleteOrder(params: {
|
|
12
13
|
object: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'confirmationNumber' | 'orderDate' | 'orderNumber'>;
|
|
13
14
|
}): (repos: {
|
|
15
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
14
16
|
accountingReport: AccountingReportRepo;
|
|
15
17
|
event: EventRepo;
|
|
16
18
|
order: OrderRepo;
|
|
@@ -21,7 +21,7 @@ function deleteOrder(params) {
|
|
|
21
21
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const orders = yield repos.order.search({
|
|
23
23
|
orderNumbers: [params.object.orderNumber]
|
|
24
|
-
});
|
|
24
|
+
}, { orderDate: 1, project: 1, customer: 1, orderNumber: 1, seller: 1 });
|
|
25
25
|
const order = orders.shift();
|
|
26
26
|
if (order === undefined) {
|
|
27
27
|
// すでに削除済
|
|
@@ -50,7 +50,10 @@ function deleteOrder(params) {
|
|
|
50
50
|
exports.deleteOrder = deleteOrder;
|
|
51
51
|
function deleteReservationsByOrder(order) {
|
|
52
52
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const acceptedOffers =
|
|
53
|
+
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
54
|
+
orderNumber: { $eq: order.orderNumber },
|
|
55
|
+
project: { id: { $eq: order.project.id } }
|
|
56
|
+
});
|
|
54
57
|
const reservationIds = acceptedOffers.filter((o) => {
|
|
55
58
|
return o.itemOffered.typeOf === factory.reservationType.EventReservation;
|
|
56
59
|
})
|
|
@@ -66,7 +69,12 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
66
69
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
70
|
const now = new Date();
|
|
68
71
|
// 所有権作成
|
|
69
|
-
const ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({
|
|
72
|
+
const ownershipInfos = (0, factory_1.createOwnershipInfosFromOrder)({
|
|
73
|
+
order: Object.assign(Object.assign({}, order), { acceptedOffers: yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
74
|
+
orderNumber: { $eq: order.orderNumber },
|
|
75
|
+
project: { id: { $eq: order.project.id } }
|
|
76
|
+
}) })
|
|
77
|
+
});
|
|
70
78
|
const ownershipIdentifiers = ownershipInfos.map((o) => String(o.identifier));
|
|
71
79
|
if (ownershipIdentifiers.length > 0) {
|
|
72
80
|
yield repos.ownershipInfo.deleteExpiredByIdentifiers({
|
|
@@ -81,7 +89,10 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
81
89
|
function deleteEventsByOrder(order) {
|
|
82
90
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
83
91
|
const now = new Date();
|
|
84
|
-
const acceptedOffers =
|
|
92
|
+
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
93
|
+
orderNumber: { $eq: order.orderNumber },
|
|
94
|
+
project: { id: { $eq: order.project.id } }
|
|
95
|
+
});
|
|
85
96
|
const reservationForIds = acceptedOffers.filter((o) => {
|
|
86
97
|
return (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
87
98
|
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
|
+
type ITransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'potentialActions' | 'project' | 'typeOf'>;
|
|
3
4
|
export declare function findPlaceOrderTransaction(params: {
|
|
4
5
|
project: {
|
|
5
6
|
id: string;
|
|
@@ -8,4 +9,5 @@ export declare function findPlaceOrderTransaction(params: {
|
|
|
8
9
|
orderNumber: string;
|
|
9
10
|
}): (repos: {
|
|
10
11
|
transaction: TransactionRepo;
|
|
11
|
-
}) => Promise<
|
|
12
|
+
}) => Promise<ITransaction>;
|
|
13
|
+
export {};
|
|
@@ -13,7 +13,6 @@ exports.findPlaceOrderTransaction = void 0;
|
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
function findPlaceOrderTransaction(params) {
|
|
15
15
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
// 注文取引検索
|
|
17
16
|
const placeOrderTransactions = yield repos.transaction.search({
|
|
18
17
|
limit: 1,
|
|
19
18
|
page: 1,
|
|
@@ -26,7 +25,7 @@ function findPlaceOrderTransaction(params) {
|
|
|
26
25
|
orderNumbers: [params.orderNumber]
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
|
-
inclusion: [],
|
|
28
|
+
inclusion: ['id', 'potentialActions', 'project', 'typeOf'],
|
|
30
29
|
exclusion: []
|
|
31
30
|
});
|
|
32
31
|
const placeOrderTransaction = placeOrderTransactions.shift();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
2
|
import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
3
3
|
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
4
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
5
|
import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
6
|
import * as factory from '../../factory';
|
|
7
7
|
declare function onAssetTransactionStatusChanged(params: factory.task.IData<factory.taskName.OnAssetTransactionStatusChanged>): (repos: {
|
|
8
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
8
9
|
assetTransaction: AssetTransactionRepo;
|
|
9
10
|
order: OrderRepo;
|
|
10
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
11
11
|
task: TaskRepo;
|
|
12
12
|
transaction: TransactionRepo;
|
|
13
13
|
}) => Promise<void>;
|
|
@@ -19,8 +19,8 @@ declare function paymentDue2Processing(params: {
|
|
|
19
19
|
orderNumber: string;
|
|
20
20
|
useOnOrderStatusChanged: boolean;
|
|
21
21
|
}): (repos: {
|
|
22
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
22
23
|
order: OrderRepo;
|
|
23
|
-
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
24
24
|
task: TaskRepo;
|
|
25
25
|
transaction: TransactionRepo;
|
|
26
26
|
}) => Promise<void>;
|
|
@@ -138,7 +138,7 @@ function paymentDue2Processing(params) {
|
|
|
138
138
|
orderNumber: params.orderNumber,
|
|
139
139
|
project: { id: params.project.id },
|
|
140
140
|
inclusion: [],
|
|
141
|
-
exclusion: []
|
|
141
|
+
exclusion: ['acceptedOffers']
|
|
142
142
|
});
|
|
143
143
|
try {
|
|
144
144
|
order = yield repos.order.changeStatus({
|
|
@@ -155,7 +155,7 @@ function paymentDue2Processing(params) {
|
|
|
155
155
|
orderNumber: params.orderNumber,
|
|
156
156
|
project: { id: params.project.id },
|
|
157
157
|
inclusion: [],
|
|
158
|
-
exclusion: []
|
|
158
|
+
exclusion: ['acceptedOffers']
|
|
159
159
|
});
|
|
160
160
|
if (order.orderStatus === factory.orderStatus.OrderDelivered
|
|
161
161
|
|| order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
@@ -166,12 +166,16 @@ function paymentDue2Processing(params) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
if (params.useOnOrderStatusChanged) {
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
// 全acceptedOffersを検索(2023-12-08~)
|
|
170
|
+
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
171
|
+
orderNumber: { $eq: order.orderNumber },
|
|
172
|
+
project: { id: { $eq: params.project.id } }
|
|
173
|
+
});
|
|
174
|
+
yield (0, onOrderStatusChanged_1.onOrderProcessing)({
|
|
175
|
+
order: Object.assign(Object.assign({}, order), { acceptedOffers, orderStatus: factory.orderStatus.OrderProcessing // 強制的にOrderProcessingとして処理する
|
|
171
176
|
}),
|
|
172
177
|
placeOrderTransaction
|
|
173
178
|
})({
|
|
174
|
-
registerActionInProgress: repos.registerActionInProgress,
|
|
175
179
|
task: repos.task
|
|
176
180
|
});
|
|
177
181
|
}
|
|
@@ -212,12 +216,14 @@ function cancelOrderIfExist(params) {
|
|
|
212
216
|
throw error;
|
|
213
217
|
}
|
|
214
218
|
if (params.useOnOrderStatusChanged) {
|
|
215
|
-
yield (0, onOrderStatusChanged_1.
|
|
216
|
-
order:
|
|
217
|
-
|
|
219
|
+
yield (0, onOrderStatusChanged_1.onOrderCancelled)({
|
|
220
|
+
order: {
|
|
221
|
+
orderDate: order.orderDate,
|
|
222
|
+
orderNumber: order.orderNumber,
|
|
223
|
+
orderStatus: factory.orderStatus.OrderCancelled // 強制的にOrderCancelledとして処理する
|
|
224
|
+
},
|
|
218
225
|
placeOrderTransaction
|
|
219
226
|
})({
|
|
220
|
-
registerActionInProgress: repos.registerActionInProgress,
|
|
221
227
|
task: repos.task
|
|
222
228
|
});
|
|
223
229
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 注文ステータス変更時処理
|
|
3
|
+
*/
|
|
4
|
+
import * as factory from '../../../../factory';
|
|
5
|
+
/**
|
|
6
|
+
* 注文中止時のアクション
|
|
7
|
+
*/
|
|
8
|
+
declare function createOnOrderCancelledTasksByTransaction(params: {
|
|
9
|
+
transaction?: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
10
|
+
}): (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/onAssetTransactionStatusChanged").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)[];
|
|
11
|
+
export { createOnOrderCancelledTasksByTransaction };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOnOrderCancelledTasksByTransaction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 注文ステータス変更時処理
|
|
6
|
+
*/
|
|
7
|
+
const factory = require("../../../../factory");
|
|
8
|
+
/**
|
|
9
|
+
* 注文中止時のアクション
|
|
10
|
+
*/
|
|
11
|
+
function createOnOrderCancelledTasksByTransaction(params) {
|
|
12
|
+
var _a;
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const taskAttributes = [];
|
|
15
|
+
if (typeof ((_a = params.transaction) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
16
|
+
const voidPaymentTaskAttributes = {
|
|
17
|
+
project: params.transaction.project,
|
|
18
|
+
name: factory.taskName.VoidPayTransaction,
|
|
19
|
+
status: factory.taskStatus.Ready,
|
|
20
|
+
runsAt: now,
|
|
21
|
+
remainingNumberOfTries: 10,
|
|
22
|
+
numberOfTried: 0,
|
|
23
|
+
executionResults: [],
|
|
24
|
+
data: {
|
|
25
|
+
project: params.transaction.project,
|
|
26
|
+
purpose: {
|
|
27
|
+
typeOf: params.transaction.typeOf,
|
|
28
|
+
id: params.transaction.id,
|
|
29
|
+
result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const voidReserveTaskAttributes = {
|
|
34
|
+
project: params.transaction.project,
|
|
35
|
+
name: factory.taskName.VoidReserveTransaction,
|
|
36
|
+
status: factory.taskStatus.Ready,
|
|
37
|
+
runsAt: now,
|
|
38
|
+
remainingNumberOfTries: 10,
|
|
39
|
+
numberOfTried: 0,
|
|
40
|
+
executionResults: [],
|
|
41
|
+
data: {
|
|
42
|
+
project: params.transaction.project,
|
|
43
|
+
purpose: {
|
|
44
|
+
typeOf: params.transaction.typeOf,
|
|
45
|
+
id: params.transaction.id,
|
|
46
|
+
result: { order: { orderStatus: factory.orderStatus.OrderCancelled } }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
taskAttributes.push(voidPaymentTaskAttributes, voidReserveTaskAttributes);
|
|
51
|
+
}
|
|
52
|
+
return taskAttributes;
|
|
53
|
+
}
|
|
54
|
+
exports.createOnOrderCancelledTasksByTransaction = createOnOrderCancelledTasksByTransaction;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
|
|
4
|
+
declare function onOrderCancelled(params: {
|
|
5
|
+
order: Pick<factory.order.IOrder, 'orderNumber' | 'orderDate' | 'orderStatus'>;
|
|
6
|
+
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
7
|
+
}): (repos: {
|
|
8
|
+
task: TaskRepo;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export { onOrderCancelled };
|
|
@@ -0,0 +1,38 @@
|
|
|
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.onOrderCancelled = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 注文中止時処理
|
|
15
|
+
*/
|
|
16
|
+
const createDebug = require("debug");
|
|
17
|
+
const factory = require("../../../factory");
|
|
18
|
+
const factory_1 = require("./onOrderCancelled/factory");
|
|
19
|
+
const debug = createDebug('chevre-domain:service:order');
|
|
20
|
+
function onOrderCancelled(params) {
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
23
|
+
let tasks = [];
|
|
24
|
+
switch (params.order.orderStatus) {
|
|
25
|
+
// OrderCancelled追加(2023-08-30~)
|
|
26
|
+
case factory.orderStatus.OrderCancelled:
|
|
27
|
+
// 注文取引中止時と同様の処理か
|
|
28
|
+
tasks = [
|
|
29
|
+
...(0, factory_1.createOnOrderCancelledTasksByTransaction)({ transaction: params.placeOrderTransaction })
|
|
30
|
+
];
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw new factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
34
|
+
}
|
|
35
|
+
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.onOrderCancelled = onOrderCancelled;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
type IDeliveredOrder = Pick<factory.order.IOrder, 'id' | 'customer' | 'orderNumber' | 'project' | 'typeOf'> & {
|
|
3
|
+
orderStatus: factory.orderStatus.OrderDelivered;
|
|
4
|
+
};
|
|
5
|
+
declare function createInformTasks(order: IDeliveredOrder): factory.task.IAttributes<factory.taskName.TriggerWebhook>[];
|
|
6
|
+
/**
|
|
7
|
+
* 注文配送後のアクション
|
|
8
|
+
*/
|
|
9
|
+
declare function createOnOrderSentTasksByTransaction(params: {
|
|
10
|
+
potentialActions?: factory.action.transfer.send.order.IPotentialActions;
|
|
11
|
+
}): (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/onAssetTransactionStatusChanged").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)[];
|
|
12
|
+
export { createInformTasks, createOnOrderSentTasksByTransaction };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createOnOrderSentTasksByTransaction = exports.createInformTasks = void 0;
|
|
5
|
+
const factory = require("../../../../factory");
|
|
6
|
+
const settings_1 = require("../../../../settings");
|
|
7
|
+
const informOrder = (_a = settings_1.settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
|
|
8
|
+
function createInformTasks(order) {
|
|
9
|
+
const taskRunsAt = new Date();
|
|
10
|
+
let informTasks = [];
|
|
11
|
+
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
12
|
+
const order4inform = creteOrder4inform(order);
|
|
13
|
+
let recipientId = '';
|
|
14
|
+
recipientId = order.customer.id;
|
|
15
|
+
informTasks = informOrder.map((informOrderParams) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const informActionAttributes = {
|
|
18
|
+
agent: order.project,
|
|
19
|
+
object: order4inform,
|
|
20
|
+
project: order.project,
|
|
21
|
+
recipient: {
|
|
22
|
+
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|
|
23
|
+
id: recipientId,
|
|
24
|
+
name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
|
|
25
|
+
typeOf: factory.creativeWorkType.WebApplication
|
|
26
|
+
},
|
|
27
|
+
typeOf: factory.actionType.InformAction
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
project: order.project,
|
|
31
|
+
name: factory.taskName.TriggerWebhook,
|
|
32
|
+
status: factory.taskStatus.Ready,
|
|
33
|
+
runsAt: taskRunsAt,
|
|
34
|
+
remainingNumberOfTries: 10,
|
|
35
|
+
numberOfTried: 0,
|
|
36
|
+
executionResults: [],
|
|
37
|
+
data: informActionAttributes
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return informTasks;
|
|
42
|
+
}
|
|
43
|
+
exports.createInformTasks = createInformTasks;
|
|
44
|
+
function creteOrder4inform(order) {
|
|
45
|
+
// 配送済注文通知内容を最適化(2022-12-29~)
|
|
46
|
+
return Object.assign({ project: order.project, typeOf: order.typeOf, orderNumber: order.orderNumber, orderStatus: order.orderStatus }, (typeof order.id === 'string') ? { id: order.id } : undefined);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 注文配送後のアクション
|
|
50
|
+
*/
|
|
51
|
+
function createOnOrderSentTasksByTransaction(params) {
|
|
52
|
+
const potentialActions = params.potentialActions;
|
|
53
|
+
const now = new Date();
|
|
54
|
+
const taskAttributes = [];
|
|
55
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
56
|
+
/* istanbul ignore else */
|
|
57
|
+
if (potentialActions !== undefined) {
|
|
58
|
+
if (Array.isArray(potentialActions.registerService)) {
|
|
59
|
+
taskAttributes.push(...potentialActions.registerService.map((a) => {
|
|
60
|
+
return {
|
|
61
|
+
project: a.project,
|
|
62
|
+
name: factory.taskName.ConfirmRegisterService,
|
|
63
|
+
status: factory.taskStatus.Ready,
|
|
64
|
+
runsAt: now,
|
|
65
|
+
remainingNumberOfTries: 10,
|
|
66
|
+
numberOfTried: 0,
|
|
67
|
+
executionResults: [],
|
|
68
|
+
data: a
|
|
69
|
+
};
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
// 通貨転送
|
|
73
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
74
|
+
/* istanbul ignore else */
|
|
75
|
+
if (Array.isArray(potentialActions.moneyTransfer)) {
|
|
76
|
+
taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
77
|
+
return {
|
|
78
|
+
project: a.project,
|
|
79
|
+
name: factory.taskName.ConfirmMoneyTransfer,
|
|
80
|
+
status: factory.taskStatus.Ready,
|
|
81
|
+
runsAt: now,
|
|
82
|
+
remainingNumberOfTries: 10,
|
|
83
|
+
numberOfTried: 0,
|
|
84
|
+
executionResults: [],
|
|
85
|
+
data: a
|
|
86
|
+
};
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
90
|
+
/* istanbul ignore else */
|
|
91
|
+
if (Array.isArray(potentialActions.sendEmailMessage)) {
|
|
92
|
+
potentialActions.sendEmailMessage.forEach((s) => {
|
|
93
|
+
const sendEmailMessageTask = {
|
|
94
|
+
project: s.project,
|
|
95
|
+
name: factory.taskName.SendEmailMessage,
|
|
96
|
+
status: factory.taskStatus.Ready,
|
|
97
|
+
runsAt: now,
|
|
98
|
+
remainingNumberOfTries: 3,
|
|
99
|
+
numberOfTried: 0,
|
|
100
|
+
executionResults: [],
|
|
101
|
+
data: {
|
|
102
|
+
actionAttributes: s
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return taskAttributes;
|
|
110
|
+
}
|
|
111
|
+
exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'potentialActions'>;
|
|
4
|
+
declare function onOrderDelivered(params: {
|
|
5
|
+
order: Pick<factory.order.IOrder, 'id' | 'customer' | 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> & {
|
|
6
|
+
orderStatus: factory.orderStatus.OrderDelivered;
|
|
7
|
+
};
|
|
8
|
+
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
9
|
+
}): (repos: {
|
|
10
|
+
task: TaskRepo;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
export { onOrderDelivered };
|