@chevre/domain 25.2.0-alpha.8 → 26.0.0-alpha.0
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/eventEmitter/task.d.ts +2 -1
- package/lib/chevre/factory/customerTelephone2COATelNum.d.ts +3 -0
- package/lib/chevre/factory/customerTelephone2COATelNum.js +22 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
- package/lib/chevre/repo/action/acceptPay.js +47 -19
- package/lib/chevre/repo/action/actionProcess.js +57 -57
- package/lib/chevre/repo/action.d.ts +16 -9
- package/lib/chevre/repo/action.js +99 -180
- package/lib/chevre/repo/adminTask.d.ts +37 -0
- package/lib/chevre/repo/adminTask.js +163 -0
- package/lib/chevre/repo/aggregateOffer.d.ts +3 -14
- package/lib/chevre/repo/aggregateOffer.js +16 -125
- package/lib/chevre/repo/aggregateTask.d.ts +37 -0
- package/lib/chevre/repo/aggregateTask.js +136 -0
- package/lib/chevre/repo/asyncAction.d.ts +69 -0
- package/lib/chevre/repo/asyncAction.js +237 -0
- package/lib/chevre/repo/concurrentLock.d.ts +3 -1
- package/lib/chevre/repo/creativeWork.d.ts +2 -3
- package/lib/chevre/repo/credentials.d.ts +2 -1
- package/lib/chevre/repo/customerType.d.ts +2 -3
- package/lib/chevre/repo/event.d.ts +10 -11
- package/lib/chevre/repo/eventOffer.d.ts +4 -5
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +2 -3
- package/lib/chevre/repo/eventSeries.d.ts +4 -5
- package/lib/chevre/repo/message.d.ts +1 -1
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +57 -57
- package/lib/chevre/repo/mongoose/schemas/asyncAction.d.ts +13 -0
- package/lib/chevre/repo/mongoose/schemas/asyncAction.js +89 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/scheduledTasks.d.ts +16 -0
- package/lib/chevre/repo/mongoose/schemas/scheduledTasks.js +103 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +6 -1
- package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
- package/lib/chevre/repo/note.d.ts +3 -4
- package/lib/chevre/repo/noteAboutOrder.d.ts +2 -3
- package/lib/chevre/repo/offer/offerInCatalogReadOnly.d.ts +2 -2
- package/lib/chevre/repo/offer/unitPriceInCatalog.d.ts +2 -2
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +59 -11
- package/lib/chevre/repo/offerCatalog.d.ts +2 -3
- package/lib/chevre/repo/offerCatalogItem.d.ts +2 -3
- package/lib/chevre/repo/order.d.ts +2 -0
- package/lib/chevre/repo/order.js +14 -14
- package/lib/chevre/repo/orderInTransaction.d.ts +68 -1
- package/lib/chevre/repo/orderInTransaction.js +181 -3
- package/lib/chevre/repo/passport.d.ts +2 -1
- package/lib/chevre/repo/person.d.ts +0 -15
- package/lib/chevre/repo/person.js +122 -108
- package/lib/chevre/repo/place/entranceGate.d.ts +4 -5
- package/lib/chevre/repo/place/movieTheater.d.ts +3 -4
- package/lib/chevre/repo/place/screeningRoom.d.ts +4 -5
- package/lib/chevre/repo/place/seat.d.ts +4 -5
- package/lib/chevre/repo/place/section.d.ts +3 -4
- package/lib/chevre/repo/priceSpecification.d.ts +4 -4
- package/lib/chevre/repo/product.d.ts +3 -4
- package/lib/chevre/repo/rateLimit/offer.d.ts +3 -1
- package/lib/chevre/repo/rateLimit/offer.js +0 -12
- package/lib/chevre/repo/reservation.d.ts +2 -3
- package/lib/chevre/repo/scheduledTask.d.ts +90 -0
- package/lib/chevre/repo/scheduledTask.js +223 -0
- package/lib/chevre/repo/sellerMakesOffer.d.ts +3 -4
- package/lib/chevre/repo/stockHolder.d.ts +1 -1
- package/lib/chevre/repo/stockHolder.js +0 -146
- package/lib/chevre/repo/task.d.ts +30 -71
- package/lib/chevre/repo/task.js +59 -345
- package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
- package/lib/chevre/repo/transaction/placeOrder.js +43 -83
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transactionNumberCounter.js +0 -34
- package/lib/chevre/repo/transactionProcess.d.ts +2 -1
- package/lib/chevre/repo/transactionProcess.js +0 -13
- package/lib/chevre/repository.d.ts +20 -0
- package/lib/chevre/repository.js +46 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/aggregation/system.d.ts +2 -2
- package/lib/chevre/service/aggregation/system.js +1 -1
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +1 -1
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -67
- package/lib/chevre/service/asyncAction.d.ts +16 -0
- package/lib/chevre/service/asyncAction.js +36 -0
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +15 -0
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +42 -0
- package/lib/chevre/service/asyncActionHandler.d.ts +13 -0
- package/lib/chevre/service/asyncActionHandler.js +89 -0
- package/lib/chevre/service/notification/factory.d.ts +2 -4
- package/lib/chevre/service/notification/factory.js +26 -24
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +12 -6
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +12 -4
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -5
- package/lib/chevre/service/offer/event/authorize/factory.js +93 -75
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -4
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +15 -12
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +4 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +20 -9
- package/lib/chevre/service/offer/onEventChanged.js +2 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +19 -11
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +1 -7
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +3 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +0 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +73 -44
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +53 -33
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +6 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +3 -7
- package/lib/chevre/service/order/onOrderUpdated.js +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -1
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +13 -58
- package/lib/chevre/service/order/placeOrder/factory.js +3 -21
- package/lib/chevre/service/order/placeOrder.d.ts +4 -5
- package/lib/chevre/service/order/placeOrder.js +20 -31
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
- package/lib/chevre/service/payment/any/authorize.js +13 -37
- package/lib/chevre/service/payment/any/factory.d.ts +7 -7
- package/lib/chevre/service/payment/any/factory.js +19 -22
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +7 -1
- package/lib/chevre/service/payment/any/findAcceptAction.js +34 -15
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +20 -9
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findCheckAction.js +20 -9
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +5 -67
- package/lib/chevre/service/payment/any/onPayActionCompleted.js +1 -1
- package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +1 -1
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
- package/lib/chevre/service/reserve/adminFindReservations.d.ts +15 -0
- package/lib/chevre/service/reserve/adminFindReservations.js +35 -0
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +20 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +1 -1
- package/lib/chevre/service/reserve/searchByOrder.js +2 -6
- package/lib/chevre/service/reserve.d.ts +2 -2
- package/lib/chevre/service/reserve.js +3 -3
- package/lib/chevre/service/scheduledTask.d.ts +11 -0
- package/lib/chevre/service/scheduledTask.js +40 -0
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.d.ts +14 -0
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +56 -0
- package/lib/chevre/service/scheduledTaskHandler.d.ts +12 -0
- package/lib/chevre/service/scheduledTaskHandler.js +66 -0
- package/lib/chevre/service/task/aggregateOffers.d.ts +2 -2
- package/lib/chevre/service/task/aggregateOffers.js +2 -1
- package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/task/authorizePayment.js +3 -1
- package/lib/chevre/service/task/cancelReservation.d.ts +2 -2
- package/lib/chevre/service/task/cancelReservation.js +2 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +0 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +3 -8
- package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
- package/lib/chevre/service/task/deleteTransaction.js +2 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -3
- package/lib/chevre/service/task/onEventChanged.d.ts +2 -2
- package/lib/chevre/service/task/onEventChanged.js +2 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +4 -1
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated.js +10 -9
- package/lib/chevre/service/task/placeOrder.d.ts +2 -2
- package/lib/chevre/service/task/placeOrder.js +6 -3
- package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
- package/lib/chevre/service/task/refund.d.ts +2 -2
- package/lib/chevre/service/task/refund.js +4 -10
- package/lib/chevre/service/task/reserve.d.ts +2 -2
- package/lib/chevre/service/task/reserve.js +2 -1
- package/lib/chevre/service/task/returnOrder.d.ts +2 -2
- package/lib/chevre/service/task/returnOrder.js +2 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.d.ts +2 -2
- package/lib/chevre/service/task/sendOrder.js +2 -1
- package/lib/chevre/service/task/voidPayTransaction.js +3 -7
- package/lib/chevre/service/task/voidPayment.d.ts +2 -2
- package/lib/chevre/service/task/voidPayment.js +2 -1
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +1 -1
- package/lib/chevre/service/taskHandler/onOperationFailed.js +1 -1
- package/lib/chevre/service/taskHandler.d.ts +2 -2
- package/lib/chevre/service/taskHandler.js +36 -37
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +1 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +28 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +11 -12
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +4 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +6 -7
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +32 -4
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +10 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +6 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +23 -9
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +6 -5
- package/lib/chevre/service/transaction/placeOrder/confirm.js +30 -40
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.d.ts +20 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.js +63 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +17 -86
- package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +1 -1
- package/lib/chevre/service.d.ts +8 -0
- package/lib/chevre/service.js +23 -1
- package/lib/chevre/taskSettings.d.ts +3 -4
- package/package.json +8 -11
- package/lib/chevre/service/order/findConfirmedPlaceOrder.d.ts +0 -13
- package/lib/chevre/service/order/findConfirmedPlaceOrder.js +0 -32
- package/lib/chevre/service/reserve/findReservations.d.ts +0 -33
- package/lib/chevre/service/reserve/findReservations.js +0 -61
|
@@ -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,69 +17,94 @@ 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;
|
|
21
26
|
default:
|
|
22
27
|
throw new factory_1.factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
23
28
|
}
|
|
24
|
-
await repos.task.saveMany(tasks
|
|
29
|
+
await repos.task.saveMany(tasks);
|
|
25
30
|
};
|
|
26
31
|
}
|
|
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);
|
|
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) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { MessageRepo } from '../../../../repo/message';
|
|
1
2
|
import type { TaskRepo } from '../../../../repo/task';
|
|
2
3
|
import { factory } from '../../../../factory';
|
|
3
4
|
declare function createSendEmailMessageTaskIfNotExist(params: {
|
|
4
|
-
sendEmailMessage?:
|
|
5
|
+
sendEmailMessage?: {
|
|
6
|
+
object: factory.action.transfer.send.message.email.IOptimizedObject;
|
|
7
|
+
}[];
|
|
5
8
|
order: Pick<factory.order.IOrder, 'customer' | 'orderDate' | 'orderNumber' | 'price' | 'priceCurrency' | 'project' | 'typeOf'>;
|
|
6
9
|
}): (repos: {
|
|
10
|
+
message: MessageRepo;
|
|
7
11
|
task: TaskRepo;
|
|
8
12
|
}) => Promise<void>;
|
|
9
13
|
export { createSendEmailMessageTaskIfNotExist };
|
|
@@ -1,45 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createSendEmailMessageTaskIfNotExist = createSendEmailMessageTaskIfNotExist;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
4
8
|
const util_1 = require("util");
|
|
5
9
|
const factory_1 = require("../../../../factory");
|
|
10
|
+
const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
6
11
|
function createSendEmailMessageTaskIfNotExist(params) {
|
|
7
12
|
return async (repos) => {
|
|
8
13
|
const sendEmailMessageActions = params.sendEmailMessage;
|
|
9
14
|
const now = new Date();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
// 取引のpotentialActions参照を廃止して、messageリポジトリを参照して存在すればタスクを作成(2026-07-16~)
|
|
16
|
+
const message4order = (await repos.message.findMessages({
|
|
17
|
+
limit: 1,
|
|
18
|
+
page: 1,
|
|
19
|
+
about: { identifier: { $eq: factory_1.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } },
|
|
20
|
+
mainEntity: { orderNumber: { $eq: params.order.orderNumber } }
|
|
21
|
+
}, ['identifier'])).shift();
|
|
22
|
+
debug('createSendEmailMessageTaskIfNotExist: message4order:', JSON.stringify(message4order));
|
|
23
|
+
if (typeof message4order?.identifier === 'string') {
|
|
24
|
+
// 取引のpotentialActionsが存在する間は、メッセージ識別子が想定通りか確認する
|
|
25
|
+
const messageIdentifierByTransaction = sendEmailMessageActions?.at(0)?.object.identifier;
|
|
26
|
+
if (typeof messageIdentifierByTransaction === 'string') {
|
|
27
|
+
debug('createSendEmailMessageTaskIfNotExist: identifier matched?', message4order.identifier, messageIdentifierByTransaction);
|
|
28
|
+
if (message4order.identifier !== messageIdentifierByTransaction) {
|
|
29
|
+
throw new factory_1.factory.errors.Internal(`message identifier not matched. ${message4order.identifier} ${messageIdentifierByTransaction}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const taskIdentifier = (0, util_1.format)('%s:%s:%s:%s:%s:%s', params.order.project.id, factory_1.factory.taskName.SendEmailMessage, params.order.typeOf, params.order.orderNumber, factory_1.factory.orderStatus.OrderProcessing, 0 // 複数メッセージに対応していた時期の名残(2026-07-16~)
|
|
33
|
+
);
|
|
34
|
+
const simpleOrder = {
|
|
35
|
+
typeOf: params.order.typeOf,
|
|
36
|
+
orderNumber: params.order.orderNumber,
|
|
37
|
+
orderDate: params.order.orderDate
|
|
38
|
+
};
|
|
39
|
+
const actionAttributes = {
|
|
40
|
+
project: params.order.project,
|
|
41
|
+
typeOf: factory_1.factory.actionType.SendAction,
|
|
42
|
+
object: {
|
|
43
|
+
identifier: message4order.identifier,
|
|
44
|
+
typeOf: factory_1.factory.creativeWorkType.EmailMessage
|
|
45
|
+
},
|
|
46
|
+
agent: params.order.project,
|
|
47
|
+
recipient: { typeOf: params.order.customer.typeOf, id: params.order.customer.id },
|
|
48
|
+
purpose: simpleOrder
|
|
49
|
+
};
|
|
50
|
+
const sendEmailMessageTask = {
|
|
51
|
+
alternateName: taskIdentifier,
|
|
52
|
+
identifier: taskIdentifier,
|
|
53
|
+
project: params.order.project,
|
|
54
|
+
name: factory_1.factory.taskName.SendEmailMessage,
|
|
55
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
56
|
+
runsAt: now, // なるはやで実行
|
|
57
|
+
remainingNumberOfTries: 10,
|
|
58
|
+
numberOfTried: 0,
|
|
59
|
+
executionResults: [],
|
|
60
|
+
data: { actionAttributes }
|
|
61
|
+
};
|
|
62
|
+
await repos.task.createIfNotExistByAlternateName(sendEmailMessageTask);
|
|
43
63
|
}
|
|
44
64
|
};
|
|
45
65
|
}
|
|
@@ -61,7 +61,7 @@ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder, opti
|
|
|
61
61
|
executionResults: [],
|
|
62
62
|
data
|
|
63
63
|
};
|
|
64
|
-
await repos.task.createIfNotExistByAlternateName(confirmReserveTransactionTask
|
|
64
|
+
await repos.task.createIfNotExistByAlternateName(confirmReserveTransactionTask);
|
|
65
65
|
if (options.force === true) {
|
|
66
66
|
const existingTask = await repos.task.findByIdentifier({
|
|
67
67
|
identifier: taskIdentifier,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import type { MessageRepo } from '../../../repo/message';
|
|
1
2
|
import type { SettingRepo } from '../../../repo/setting';
|
|
2
3
|
import type { TaskRepo } from '../../../repo/task';
|
|
3
4
|
import { factory } from '../../../factory';
|
|
4
5
|
import type { IntegrationSettingRepo as Settings } from '../../../repo/setting/integration';
|
|
5
6
|
import { IExternalOrder, IProcessingOrder } from './onOrderProcessing/factory';
|
|
6
7
|
import { processOrder } from './onOrderProcessing/processOrder';
|
|
7
|
-
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
|
|
8
8
|
declare function onOrderProcessing(params: {
|
|
9
9
|
order: IProcessingOrder & {
|
|
10
10
|
itemOfferedTypeOf: factory.order.IItemOffered['typeOf'];
|
|
11
11
|
serialNumbers: string[];
|
|
12
12
|
offeredThroughIdentifier?: factory.service.webAPI.Identifier;
|
|
13
13
|
};
|
|
14
|
-
placeOrderTransaction?: IPlaceOrderTransaction;
|
|
15
14
|
}): (repos: {
|
|
15
|
+
message: MessageRepo;
|
|
16
16
|
setting: SettingRepo;
|
|
17
17
|
task: TaskRepo;
|
|
18
18
|
}, settings: Settings) => Promise<void>;
|
|
@@ -15,6 +15,7 @@ const factory_2 = require("./onOrderProcessing/factory");
|
|
|
15
15
|
const processOrder_1 = require("./onOrderProcessing/processOrder");
|
|
16
16
|
Object.defineProperty(exports, "processOrder", { enumerable: true, get: function () { return processOrder_1.processOrder; } });
|
|
17
17
|
const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
18
|
+
// type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'typeOf'>;
|
|
18
19
|
function onOrderProcessing(params) {
|
|
19
20
|
return async (repos, settings) => {
|
|
20
21
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
|
|
@@ -23,7 +24,8 @@ function onOrderProcessing(params) {
|
|
|
23
24
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
24
25
|
let tasks;
|
|
25
26
|
let creatingCheckResourceTask;
|
|
26
|
-
const sendEmailMessageByOnOrderProcessing =
|
|
27
|
+
// const sendEmailMessageByOnOrderProcessing =
|
|
28
|
+
// params.placeOrderTransaction?.potentialActions?.order?.onOrderProcessing?.sendEmailMessage;
|
|
27
29
|
switch (params.order.orderStatus) {
|
|
28
30
|
case factory_1.factory.orderStatus.OrderProcessing:
|
|
29
31
|
tasks = (0, factory_2.createInformProcessingOrderTasks)(params.order, setting);
|
|
@@ -32,10 +34,10 @@ function onOrderProcessing(params) {
|
|
|
32
34
|
default:
|
|
33
35
|
throw new factory_1.factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
34
36
|
}
|
|
35
|
-
await repos.task.saveMany(tasks
|
|
37
|
+
await repos.task.saveMany(tasks);
|
|
36
38
|
// uniqueness of CheckResource task(2025-03-29~)
|
|
37
39
|
if (creatingCheckResourceTask !== undefined) {
|
|
38
|
-
await repos.task.createIfNotExistByAlternateName(creatingCheckResourceTask
|
|
40
|
+
await repos.task.createIfNotExistByAlternateName(creatingCheckResourceTask);
|
|
39
41
|
}
|
|
40
42
|
switch (params.order.orderStatus) {
|
|
41
43
|
case factory_1.factory.orderStatus.OrderProcessing:
|
|
@@ -49,7 +51,7 @@ function onOrderProcessing(params) {
|
|
|
49
51
|
// OrderProcessingにおけるEメール送信に対応(2024-01-17~)
|
|
50
52
|
await (0, createSendEmailMessageTaskIfNotExist_1.createSendEmailMessageTaskIfNotExist)({
|
|
51
53
|
sendEmailMessage: [
|
|
52
|
-
|
|
54
|
+
// ...(Array.isArray(sendEmailMessageByOnOrderProcessing)) ? sendEmailMessageByOnOrderProcessing : []
|
|
53
55
|
],
|
|
54
56
|
order: params.order
|
|
55
57
|
})(repos);
|
|
@@ -11,5 +11,5 @@ declare function createInformTasks(order: IReturnedOrder, returnOrderAction: IRe
|
|
|
11
11
|
declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
12
12
|
order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'customer' | 'price' | 'priceCurrency' | 'orderDate'>;
|
|
13
13
|
potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
|
|
14
|
-
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/
|
|
14
|
+
}): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes)[];
|
|
15
15
|
export { createInformTasks, createOnOrderReturnedTasksByTransaction, IReturnAction };
|
|
@@ -8,7 +8,7 @@ exports.onOrderReturned = onOrderReturned;
|
|
|
8
8
|
* 注文返品時処理
|
|
9
9
|
*/
|
|
10
10
|
const debug_1 = __importDefault(require("debug"));
|
|
11
|
-
const
|
|
11
|
+
const customerTelephone2COATelNum_1 = require("../../../factory/customerTelephone2COATelNum");
|
|
12
12
|
const factory_1 = require("../../../factory");
|
|
13
13
|
// import { createMaskedCustomer } from '../../../factory/order';
|
|
14
14
|
const factory_2 = require("./onOrderReturned/factory");
|
|
@@ -77,7 +77,7 @@ function onOrderReturned(params) {
|
|
|
77
77
|
default:
|
|
78
78
|
throw new factory_1.factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
79
79
|
}
|
|
80
|
-
await repos.task.saveMany(tasks
|
|
80
|
+
await repos.task.saveMany(tasks);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
@@ -104,11 +104,7 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
|
104
104
|
if (typeof superEventLocationBranchCode !== 'string') {
|
|
105
105
|
throw new factory_1.factory.errors.ArgumentNull('order.reservationForSuperEventLocationBranchCodes');
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
const phoneNumber = phoneUtil.parse(order.customer.telephone, 'JP');
|
|
109
|
-
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
110
|
-
// COAでは数字のみ受け付けるので数字以外を除去
|
|
111
|
-
telNum = telNum.replace(/[^\d]/g, '');
|
|
107
|
+
const telNum = (0, customerTelephone2COATelNum_1.customerTelephone2COATelNum)({ telephone: String(order.customer.telephone) });
|
|
112
108
|
returnReserveTransactionAction = {
|
|
113
109
|
project: order.project,
|
|
114
110
|
typeOf: factory_1.factory.actionType.ReturnAction,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
|
+
import type { MessageRepo } from '../../repo/message';
|
|
2
3
|
import type { OrderRepo } from '../../repo/order';
|
|
3
4
|
import type { SettingRepo } from '../../repo/setting';
|
|
4
5
|
import type { TaskRepo } from '../../repo/task';
|
|
@@ -10,6 +11,7 @@ import type { IntegrationSettingRepo as Settings } from '../../repo/setting/inte
|
|
|
10
11
|
*/
|
|
11
12
|
declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): (repos: {
|
|
12
13
|
acceptedOffer: AcceptedOfferRepo;
|
|
14
|
+
message: MessageRepo;
|
|
13
15
|
order: OrderRepo;
|
|
14
16
|
setting: SettingRepo;
|
|
15
17
|
task: TaskRepo;
|
|
@@ -5,7 +5,6 @@ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
|
5
5
|
import { factory } from '../../../factory';
|
|
6
6
|
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'result' | 'object' | 'seller'>;
|
|
7
7
|
interface ICreatePlacingOrderFromExistingTransactionRepos {
|
|
8
|
-
action?: never;
|
|
9
8
|
authorizeOfferAction: AuthorizeOfferActionRepo;
|
|
10
9
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
11
10
|
orderInTransaction: OrderInTransactionRepo;
|
|
@@ -18,6 +17,8 @@ declare function createPlacingOrderFromExistingTransaction(params: {
|
|
|
18
17
|
confirmationNumber: string;
|
|
19
18
|
orderNumber: string;
|
|
20
19
|
}): (repos: ICreatePlacingOrderFromExistingTransactionRepos) => Promise<{
|
|
20
|
+
orderNumber: string;
|
|
21
|
+
confirmationNumber: string;
|
|
21
22
|
order: IPlacingOrder;
|
|
22
23
|
placeOrderTransaction: IPlaceOrderTransaction;
|
|
23
24
|
serialNumbers: string[];
|
|
@@ -17,12 +17,6 @@ function createPlacingOrderFromExistingTransaction(params) {
|
|
|
17
17
|
object: {
|
|
18
18
|
orderNumber: { $eq: orderNumber },
|
|
19
19
|
},
|
|
20
|
-
// result: {
|
|
21
|
-
// order: {
|
|
22
|
-
// confirmationNumber: { $eq: confirmationNumber },
|
|
23
|
-
// orderNumbers: [orderNumber]
|
|
24
|
-
// }
|
|
25
|
-
// },
|
|
26
20
|
inclusion: ['project', 'typeOf', 'result', 'object', 'seller']
|
|
27
21
|
});
|
|
28
22
|
const placeOrderTransactionWithResult = placeOrderTransactions.shift();
|
|
@@ -39,43 +33,12 @@ function createPlacingOrderFromExistingTransaction(params) {
|
|
|
39
33
|
const authorizeActionsAsResult = placeOrderTransactionWithResult.result?.authorizeActions;
|
|
40
34
|
if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
|
|
41
35
|
const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
|
|
36
|
+
/* istanbul ignore else -- @preserve */
|
|
42
37
|
if (completedAuthorizeActionIds.length > 0) {
|
|
43
|
-
// authorizePaymentActions = <Pick<factory.action.authorize.paymentMethod.any.IAction, 'result'>[]>
|
|
44
|
-
// await repos.action.search<factory.actionType.AuthorizeAction>(
|
|
45
|
-
// {
|
|
46
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
47
|
-
// purpose: {
|
|
48
|
-
// typeOf: { $in: [factory.transactionType.PlaceOrder] },
|
|
49
|
-
// id: { $in: [placeOrderTransactionWithResult.id] }
|
|
50
|
-
// },
|
|
51
|
-
// object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } },
|
|
52
|
-
// id: { $in: completedAuthorizeActionIds }
|
|
53
|
-
// },
|
|
54
|
-
// ['result']
|
|
55
|
-
// );
|
|
56
38
|
authorizePaymentActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodResultsById({
|
|
57
39
|
purpose: { id: placeOrderTransactionWithResult.id },
|
|
58
40
|
ids: completedAuthorizeActionIds
|
|
59
41
|
});
|
|
60
|
-
// authorizeOfferActionsWithInstrument = <IAuthorizeActionWithInstrument[]>await repos.action.search<factory.actionType.AuthorizeAction>(
|
|
61
|
-
// {
|
|
62
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
63
|
-
// purpose: {
|
|
64
|
-
// typeOf: { $in: [factory.transactionType.PlaceOrder] },
|
|
65
|
-
// id: { $in: [placeOrderTransactionWithResult.id] }
|
|
66
|
-
// },
|
|
67
|
-
// object: {
|
|
68
|
-
// typeOf: {
|
|
69
|
-
// $in: [
|
|
70
|
-
// factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
|
|
71
|
-
// factory.offerType.Offer
|
|
72
|
-
// ]
|
|
73
|
-
// }
|
|
74
|
-
// },
|
|
75
|
-
// id: { $in: completedAuthorizeActionIds }
|
|
76
|
-
// },
|
|
77
|
-
// ['instrument']
|
|
78
|
-
// );
|
|
79
42
|
authorizeOfferActionsWithInstrument = await repos.authorizeOfferAction.findAuthorizeOfferInstrumentsByIds({
|
|
80
43
|
purpose: { id: placeOrderTransactionWithResult.id },
|
|
81
44
|
ids: completedAuthorizeActionIds
|
|
@@ -87,26 +50,18 @@ function createPlacingOrderFromExistingTransaction(params) {
|
|
|
87
50
|
const serialNumbers = authorizeOfferActionsWithInstrument
|
|
88
51
|
.filter(({ instrument }) => typeof instrument.transactionNumber === 'string')
|
|
89
52
|
.map(({ instrument }) => String(instrument.transactionNumber));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}))
|
|
97
|
-
.filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
let throwsError = true;
|
|
101
|
-
// すでにtypeOf: Orderに変更済の場合、NotFoundとなる
|
|
102
|
-
if (error instanceof factory_1.factory.errors.NotFound) {
|
|
103
|
-
throwsError = false;
|
|
104
|
-
}
|
|
105
|
-
if (throwsError) {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
53
|
+
// すでにtypeOf: Orderに変更済の場合acceptedOffersは空になるが、そもそもorderedItemはその後上書きされないので、空のまま処理して問題なし
|
|
54
|
+
acceptedOffers = (await repos.orderInTransaction.findAcceptedOffersWithPriceByIdentifier({
|
|
55
|
+
identifier: placeOrderTransactionWithResult.id,
|
|
56
|
+
project: { id: params.project.id }
|
|
57
|
+
}, { onlyPlaceOrder: false } // typeOf:PlaceOrderフィルターを無効化したのでもうNotFoundになる心配はなし(2026-07-20~)
|
|
58
|
+
))
|
|
59
|
+
.filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
|
|
109
60
|
const order = (0, factory_2.createPlacingOrder)({ transaction: placeOrderTransactionWithResult, authorizePaymentActions, acceptedOffers });
|
|
110
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
orderNumber,
|
|
63
|
+
confirmationNumber,
|
|
64
|
+
order, placeOrderTransaction: placeOrderTransactionWithResult, serialNumbers
|
|
65
|
+
};
|
|
111
66
|
};
|
|
112
67
|
}
|
|
@@ -68,7 +68,6 @@ function createSeller(params) {
|
|
|
68
68
|
}
|
|
69
69
|
function createPlacingOrder(params) {
|
|
70
70
|
const { transaction, authorizePaymentActions } = params;
|
|
71
|
-
let orderDateByTransaction;
|
|
72
71
|
const { confirmationNumber, orderDate, orderNumber } = transaction.object;
|
|
73
72
|
if (typeof confirmationNumber !== 'string') {
|
|
74
73
|
// 事前に発行済なはずなので、ありえないフロー
|
|
@@ -79,25 +78,8 @@ function createPlacingOrder(params) {
|
|
|
79
78
|
throw new factory_1.factory.errors.Internal('object.orderNumber undefined');
|
|
80
79
|
}
|
|
81
80
|
if (orderDate === undefined) {
|
|
82
|
-
// orderDateByTransaction = transaction.result?.order?.orderDate
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
orderDateByTransaction = orderDate;
|
|
86
|
-
}
|
|
87
|
-
if (orderDateByTransaction === undefined) {
|
|
88
81
|
throw new factory_1.factory.errors.NotFound('orderDate in the transaction');
|
|
89
82
|
}
|
|
90
|
-
// const orderByTransaction = transaction.result?.order;
|
|
91
|
-
// if (orderByTransaction === undefined) {
|
|
92
|
-
// throw new factory.errors.NotFound('transaction.result.order');
|
|
93
|
-
// }
|
|
94
|
-
// const seller = createSeller({ transaction });
|
|
95
|
-
// discontinue(2026-06-11~)
|
|
96
|
-
// const name: string | undefined =
|
|
97
|
-
// (typeof transaction.object.name === 'string') ? transaction.object.name : undefined;
|
|
98
|
-
// discontinue(2026-06-22~)
|
|
99
|
-
// const broker: factory.order.IBroker | undefined =
|
|
100
|
-
// (typeof transaction.object.broker?.typeOf === 'string') ? transaction.object.broker : undefined;
|
|
101
83
|
const { paymentMethods, price } = createPaymentMethods({ authorizePaymentActions });
|
|
102
84
|
const eventReservationAcceptedOffers = [];
|
|
103
85
|
params.acceptedOffers.forEach((acceptedOffer) => {
|
|
@@ -115,15 +97,15 @@ function createPlacingOrder(params) {
|
|
|
115
97
|
});
|
|
116
98
|
return {
|
|
117
99
|
// ...orderByTransaction, // transaction.result.orderへの依存廃止(2026-06-15~)
|
|
118
|
-
confirmationNumber,
|
|
119
|
-
orderNumber,
|
|
100
|
+
// confirmationNumber, // placeOrder時に上書きする必要なし(2026-07-20~)
|
|
101
|
+
// orderNumber, // placeOrder時に上書きする必要なし(2026-07-20~)
|
|
120
102
|
typeOf: factory_1.factory.order.OrderType.Order, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
121
103
|
orderStatus: factory_1.factory.orderStatus.OrderPaymentDue, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
122
104
|
// seller, // 取引開始時の注文ドキュメント作成へ移行(2026-06-25~)
|
|
123
105
|
paymentMethods, // 2024-06-17~
|
|
124
106
|
price, // 2024-06-17~
|
|
125
107
|
priceCurrency: factory_1.factory.priceCurrency.JPY, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
126
|
-
orderDate: (0, moment_1.default)(
|
|
108
|
+
orderDate: (0, moment_1.default)(orderDate)
|
|
127
109
|
.toDate(),
|
|
128
110
|
orderedItem, // 2024-06-18~
|
|
129
111
|
// ...(typeof name === 'string') ? { name } : undefined, // discontinue(2026-06-11~)
|
|
@@ -3,6 +3,7 @@ import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
|
3
3
|
import type { ActionRepo } from '../../repo/action';
|
|
4
4
|
import type { AuthorizeOfferActionRepo } from '../../repo/action/authorizeOffer';
|
|
5
5
|
import type { AuthorizePaymentMethodActionRepo } from '../../repo/action/authorizePaymentMethod';
|
|
6
|
+
import type { MessageRepo } from '../../repo/message';
|
|
6
7
|
import type { OrderRepo } from '../../repo/order';
|
|
7
8
|
import type { OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
8
9
|
import type { SettingRepo } from '../../repo/setting';
|
|
@@ -10,13 +11,13 @@ import type { TaskRepo } from '../../repo/task';
|
|
|
10
11
|
import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
|
|
11
12
|
import { factory } from '../../factory';
|
|
12
13
|
import type { IntegrationSettingRepo as Settings } from '../../repo/setting/integration';
|
|
13
|
-
import { IPlacingOrder } from './placeOrder/createPlacingOrderFromExistingTransaction';
|
|
14
14
|
interface IPlaceOrderRepos {
|
|
15
15
|
acceptedOffer: AcceptedOfferRepo;
|
|
16
16
|
accountingReport: AccountingReportRepo;
|
|
17
17
|
action: ActionRepo;
|
|
18
18
|
authorizeOfferAction: AuthorizeOfferActionRepo;
|
|
19
19
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
20
|
+
message: MessageRepo;
|
|
20
21
|
order: OrderRepo;
|
|
21
22
|
orderInTransaction: OrderInTransactionRepo;
|
|
22
23
|
setting: SettingRepo;
|
|
@@ -27,7 +28,7 @@ interface IPlaceOrderRepos {
|
|
|
27
28
|
* 注文を作成する
|
|
28
29
|
*/
|
|
29
30
|
declare function placeOrder(params: {
|
|
30
|
-
agent
|
|
31
|
+
agent: factory.action.trade.order.IAgent;
|
|
31
32
|
project: {
|
|
32
33
|
id: string;
|
|
33
34
|
};
|
|
@@ -36,7 +37,5 @@ declare function placeOrder(params: {
|
|
|
36
37
|
orderNumber: string;
|
|
37
38
|
};
|
|
38
39
|
useOnOrderStatusChanged: boolean;
|
|
39
|
-
}): (repos: IPlaceOrderRepos, settings: Settings) => Promise<
|
|
40
|
-
order: IPlacingOrder;
|
|
41
|
-
}>;
|
|
40
|
+
}): (repos: IPlaceOrderRepos, settings: Settings) => Promise<void>;
|
|
42
41
|
export { IPlaceOrderRepos, placeOrder };
|