@chevre/domain 21.20.0-alpha.8 → 21.20.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/example/src/chevre/findTransactionById.ts +21 -0
- package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
- package/example/src/chevre/importOffersFromCOA.ts +2 -1
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
- package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
- package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
- package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
- package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchActions.ts +13 -7
- package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -3
- package/example/src/verifyToken.ts +44 -0
- package/lib/chevre/credentials.d.ts +2 -0
- package/lib/chevre/credentials.js +4 -2
- package/lib/chevre/errorHandler.js +3 -0
- package/lib/chevre/factory/order.d.ts +1 -0
- package/lib/chevre/factory/order.js +2 -1
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
- package/lib/chevre/factory/transaction.d.ts +10 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
- package/lib/chevre/repo/acceptedOffer.js +100 -4
- package/lib/chevre/repo/accountingReport.d.ts +33 -7
- package/lib/chevre/repo/accountingReport.js +157 -5
- package/lib/chevre/repo/action.d.ts +32 -8
- package/lib/chevre/repo/action.js +114 -54
- package/lib/chevre/repo/event.d.ts +20 -0
- package/lib/chevre/repo/event.js +22 -0
- package/lib/chevre/repo/member.d.ts +8 -1
- package/lib/chevre/repo/member.js +7 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
- package/lib/chevre/repo/offer.d.ts +42 -0
- package/lib/chevre/repo/offer.js +35 -0
- package/lib/chevre/repo/order.js +43 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
- package/lib/chevre/repo/orderInTransaction.js +164 -0
- package/lib/chevre/repo/paymentServiceProvider.js +2 -1
- package/lib/chevre/repo/person.js +1 -4
- package/lib/chevre/repo/task.d.ts +26 -3
- package/lib/chevre/repo/task.js +61 -46
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transaction.js +13 -36
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
- package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
- package/lib/chevre/service/assetTransaction/pay.d.ts +21 -6
- package/lib/chevre/service/assetTransaction/pay.js +64 -23
- package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
- package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +16 -24
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +71 -66
- package/lib/chevre/service/offer/any.d.ts +35 -0
- package/lib/chevre/service/offer/any.js +67 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +27 -17
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +13 -1
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +11 -22
- package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product/factory.js +2 -5
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +11 -23
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +5 -5
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +3 -1
- package/lib/chevre/service/order/placeOrder.js +157 -50
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +67 -33
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -5
- package/lib/chevre/service/payment/any.js +3 -2
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +62 -68
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -5
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -7
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -3
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.d.ts +5 -0
- package/lib/chevre/service/payment.js +40 -5
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/checkInReservation.js +6 -5
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/factory.js +0 -8
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/searchByOrder.js +2 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/useReservation.js +10 -9
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
- package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
- package/lib/chevre/service/task/createAccountingReport.js +80 -0
- package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/pay.js +6 -0
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/useReservation.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
- package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
- package/lib/chevre/service/transaction/placeOrder.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
- package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
- package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
- package/lib/chevre/service/transaction/returnOrder.js +3 -10
- package/lib/chevre/service.js +0 -10
- package/lib/chevre/settings.d.ts +7 -3
- package/lib/chevre/settings.js +13 -4
- package/package.json +5 -9
- package/example/src/chevre/cleanAccountingReports.ts +0 -57
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
- package/lib/chevre/service/util.d.ts +0 -19
- package/lib/chevre/service/util.js +0 -126
|
@@ -9,291 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.voidAward = exports.
|
|
13
|
-
/**
|
|
14
|
-
* 進行中注文取引サービス
|
|
15
|
-
*/
|
|
16
|
-
const moment = require("moment");
|
|
12
|
+
exports.voidAward = exports.start = exports.publishOrderNumberIfNotExist = exports.publishConfirmationNumberIfNotExist = exports.POINT_AWARD_IDENTIFIER_NAME = exports.confirm = exports.authorizeAward = void 0;
|
|
17
13
|
const factory = require("../../factory");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* 取引開始
|
|
29
|
-
*/
|
|
30
|
-
function start(params) {
|
|
31
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
var _a;
|
|
33
|
-
const { passport, customerType } = yield (0, validation_2.validateWaiterPassport)(params);
|
|
34
|
-
const sellers = yield repos.seller.search({
|
|
35
|
-
limit: 1,
|
|
36
|
-
page: 1,
|
|
37
|
-
id: { $eq: params.seller.id }
|
|
38
|
-
}, ['name', 'project', 'typeOf', 'makesOffer', 'additionalProperty'], []);
|
|
39
|
-
const seller = sellers.shift();
|
|
40
|
-
if (seller === undefined) {
|
|
41
|
-
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
42
|
-
}
|
|
43
|
-
let makesOfferFromClient;
|
|
44
|
-
const validateSellerResult = (0, validateSeller_1.validateSeller)(Object.assign({ seller, clientUser: params.object.clientUser }, (params.validateEligibleCustomerType === true
|
|
45
|
-
&& typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { customerType } : undefined));
|
|
46
|
-
makesOfferFromClient = validateSellerResult.makesOfferFromClient;
|
|
47
|
-
const expiresInSeconds = (_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue;
|
|
48
|
-
if (typeof expiresInSeconds !== 'number') {
|
|
49
|
-
throw new factory.errors.NotFound('eligibleTransactionDuration.maxValue');
|
|
50
|
-
}
|
|
51
|
-
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
52
|
-
const startParams = (0, factory_1.createStartParams)(params, expiresInSeconds, passport, seller, params.broker, customerType);
|
|
53
|
-
let transaction;
|
|
54
|
-
try {
|
|
55
|
-
transaction = yield repos.transaction.start(startParams);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
59
|
-
// no op
|
|
60
|
-
}
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
return transaction;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
exports.start = start;
|
|
67
|
-
/**
|
|
68
|
-
* 注文取引を確定する
|
|
69
|
-
*/
|
|
70
|
-
function confirm(params) {
|
|
71
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
var _a;
|
|
73
|
-
// 確認番号を事前発行
|
|
74
|
-
yield publishConfirmationNumberIfNotExist({
|
|
75
|
-
id: params.id,
|
|
76
|
-
object: { orderDate: params.result.order.orderDate }
|
|
77
|
-
})(repos);
|
|
78
|
-
const transaction = yield repos.transaction.findById({
|
|
79
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
80
|
-
id: params.id
|
|
81
|
-
});
|
|
82
|
-
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
83
|
-
// すでに確定済の場合
|
|
84
|
-
return transaction.result;
|
|
85
|
-
}
|
|
86
|
-
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
87
|
-
throw new factory.errors.Argument('transactionId', 'Transaction already expired');
|
|
88
|
-
}
|
|
89
|
-
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
90
|
-
throw new factory.errors.Argument('transactionId', 'Transaction already canceled');
|
|
91
|
-
}
|
|
92
|
-
if (typeof ((_a = params.agent) === null || _a === void 0 ? void 0 : _a.id) === 'string' && transaction.agent.id !== params.agent.id) {
|
|
93
|
-
throw new factory.errors.Forbidden('Transaction not yours');
|
|
94
|
-
}
|
|
95
|
-
// 取引に対する全ての承認アクションをマージ
|
|
96
|
-
const completedAuthorizeActions = yield searchAuthorizeActions(params)(repos);
|
|
97
|
-
// 注文番号を発行
|
|
98
|
-
const orderNumber = yield publishOrderNumberIfNotExist({
|
|
99
|
-
project: { id: transaction.project.id },
|
|
100
|
-
id: transaction.id,
|
|
101
|
-
object: { orderDate: params.result.order.orderDate }
|
|
102
|
-
})(repos);
|
|
103
|
-
const result = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions }));
|
|
104
|
-
// デフォルトEメールメッセージを検索
|
|
105
|
-
let emailMessageOnOrderSent;
|
|
106
|
-
if (repos.emailMessage !== undefined) {
|
|
107
|
-
const searchEmailMessagesResult = yield repos.emailMessage.search({
|
|
108
|
-
limit: 1,
|
|
109
|
-
page: 1,
|
|
110
|
-
project: { id: { $eq: transaction.project.id } },
|
|
111
|
-
about: { identifier: { $eq: factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
|
|
112
|
-
});
|
|
113
|
-
emailMessageOnOrderSent = searchEmailMessagesResult.shift();
|
|
114
|
-
}
|
|
115
|
-
// ポストアクションを作成
|
|
116
|
-
const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
|
|
117
|
-
order: result.order,
|
|
118
|
-
potentialActions: params.potentialActions,
|
|
119
|
-
transaction: transaction,
|
|
120
|
-
emailMessage: emailMessageOnOrderSent,
|
|
121
|
-
authorizeActions: completedAuthorizeActions
|
|
122
|
-
});
|
|
123
|
-
// ステータス変更
|
|
124
|
-
try {
|
|
125
|
-
yield repos.transaction.confirm({
|
|
126
|
-
typeOf: transaction.typeOf,
|
|
127
|
-
id: transaction.id,
|
|
128
|
-
result: result,
|
|
129
|
-
potentialActions: potentialActions
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
134
|
-
// 万が一同一注文番号で確定しようとすると、MongoDBでE11000 duplicate key errorが発生する
|
|
135
|
-
// message: 'E11000 duplicate key error collection: prodttts.transactions index:result.order.orderNumber_1 dup key:...',
|
|
136
|
-
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
137
|
-
throw new factory.errors.AlreadyInUse('transaction', ['result.order.orderNumber']);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
143
|
-
// if (typeof transaction.result?.order.typeOf !== 'string') {
|
|
144
|
-
// throw new factory.errors.ServiceUnavailable('transaction.result not found');
|
|
145
|
-
// }
|
|
146
|
-
return result;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
exports.confirm = confirm;
|
|
150
|
-
/**
|
|
151
|
-
* 未発行であれば、注文の確認番号を発行して取引に保管する
|
|
152
|
-
*/
|
|
153
|
-
function publishConfirmationNumberIfNotExist(params) {
|
|
154
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
// 最適化(2023-02-03~)
|
|
156
|
-
let confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
157
|
-
// すでに発行済であれば何もしない
|
|
158
|
-
if (typeof confirmationNumber === 'string') {
|
|
159
|
-
return confirmationNumber;
|
|
160
|
-
}
|
|
161
|
-
// 確認番号を発行
|
|
162
|
-
confirmationNumber = yield repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
|
|
163
|
-
// 取引に存在しなければ保管
|
|
164
|
-
yield repos.transaction.saveConfirmationNumberIfNotExist({
|
|
165
|
-
id: params.id,
|
|
166
|
-
confirmationNumber
|
|
167
|
-
});
|
|
168
|
-
// 確認番号を取引から再取得
|
|
169
|
-
// 最適化(2023-02-03~)
|
|
170
|
-
confirmationNumber = yield repos.transaction.findInProgressConfirmationNumberById({ id: params.id });
|
|
171
|
-
// 万が一処理が想定通りでない場合confirmationNumberが存在しない
|
|
172
|
-
if (typeof confirmationNumber !== 'string') {
|
|
173
|
-
throw new factory.errors.ServiceUnavailable('transaction.object.confirmationNumber not found');
|
|
174
|
-
}
|
|
175
|
-
return confirmationNumber;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
exports.publishConfirmationNumberIfNotExist = publishConfirmationNumberIfNotExist;
|
|
179
|
-
/**
|
|
180
|
-
* 未発行であれば、注文番号を発行して取引に保管する
|
|
181
|
-
*/
|
|
182
|
-
function publishOrderNumberIfNotExist(params) {
|
|
183
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
// 最適化(2023-02-03~)
|
|
185
|
-
let orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
186
|
-
// すでに発行済であれば何もしない
|
|
187
|
-
if (typeof orderNumber === 'string') {
|
|
188
|
-
return orderNumber;
|
|
189
|
-
}
|
|
190
|
-
// 注文番号を発行
|
|
191
|
-
const { alternateName } = yield repos.project.findAlternateNameById({ id: params.project.id });
|
|
192
|
-
if (typeof alternateName !== 'string') {
|
|
193
|
-
throw new factory.errors.NotFound('project.alternateName');
|
|
194
|
-
}
|
|
195
|
-
orderNumber = yield repos.orderNumber.publishByTimestamp({
|
|
196
|
-
project: { alternateName },
|
|
197
|
-
orderDate: params.object.orderDate
|
|
198
|
-
});
|
|
199
|
-
// 取引に存在しなければ保管
|
|
200
|
-
yield repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
|
|
201
|
-
// 注文番号を取引から再取得
|
|
202
|
-
// 最適化(2023-02-03~)
|
|
203
|
-
orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.id });
|
|
204
|
-
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
205
|
-
if (typeof orderNumber !== 'string') {
|
|
206
|
-
throw new factory.errors.ServiceUnavailable('transaction.object.orderNumber not found');
|
|
207
|
-
}
|
|
208
|
-
return orderNumber;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
|
|
212
|
-
function createResult(params) {
|
|
213
|
-
const transaction = params.transaction;
|
|
214
|
-
// 取引の確定条件が全て整っているかどうか確認
|
|
215
|
-
(0, validation_1.validateTransaction)(transaction, params.authorizeActions);
|
|
216
|
-
// 注文作成
|
|
217
|
-
const order = (0, result_1.createOrder)({
|
|
218
|
-
orderNumber: params.orderNumber,
|
|
219
|
-
transaction: transaction,
|
|
220
|
-
orderDate: params.result.order.orderDate,
|
|
221
|
-
// OrderPaymentDueオプションを追加(2023-08-25~)
|
|
222
|
-
// 注文作成時のステータスとなる
|
|
223
|
-
orderStatus: (settings_1.USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
|
|
224
|
-
isGift: false,
|
|
225
|
-
authorizeActions: params.authorizeActions
|
|
226
|
-
});
|
|
227
|
-
(0, validation_1.validateEventOffers)({
|
|
228
|
-
transaction: transaction,
|
|
229
|
-
order: order,
|
|
230
|
-
authorizeActions: params.authorizeActions
|
|
231
|
-
});
|
|
232
|
-
// 注文アイテム数制限確認
|
|
233
|
-
(0, validation_1.validateNumItems)({
|
|
234
|
-
order: order,
|
|
235
|
-
result: params.result
|
|
236
|
-
});
|
|
237
|
-
(0, validation_1.validatePaymentMethods)({ order });
|
|
238
|
-
// 確認番号を発行
|
|
239
|
-
const { confirmationNumber, identifier, url } = createConfirmationNumber({
|
|
240
|
-
order: order,
|
|
241
|
-
transaction: transaction,
|
|
242
|
-
result: params.result
|
|
243
|
-
});
|
|
244
|
-
order.confirmationNumber = confirmationNumber;
|
|
245
|
-
order.identifier = identifier;
|
|
246
|
-
order.url = url;
|
|
247
|
-
return { order };
|
|
248
|
-
}
|
|
249
|
-
function searchAuthorizeActions(params) {
|
|
250
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
// 取引に対する全ての承認アクションをマージ
|
|
252
|
-
let authorizeActions = yield repos.action.searchByPurpose({
|
|
253
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
254
|
-
purpose: {
|
|
255
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
256
|
-
id: params.id
|
|
257
|
-
},
|
|
258
|
-
// Completedに絞る(2023-05-16~)
|
|
259
|
-
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
260
|
-
});
|
|
261
|
-
// 万が一このプロセス中に他処理が発生してもそれらを無視するように、endDateでフィルタリング
|
|
262
|
-
authorizeActions = authorizeActions.filter((a) => {
|
|
263
|
-
return (a.endDate instanceof Date) && moment(a.endDate)
|
|
264
|
-
.isBefore(moment(params.result.order.orderDate));
|
|
265
|
-
});
|
|
266
|
-
return authorizeActions;
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
function createConfirmationNumber(params) {
|
|
270
|
-
const confirmationNumber = params.transaction.object.confirmationNumber;
|
|
271
|
-
let url = '';
|
|
272
|
-
let identifier = [];
|
|
273
|
-
// 取引に確認番号が保管されていなければ、確認番号を発行
|
|
274
|
-
if (typeof confirmationNumber !== 'string') {
|
|
275
|
-
// 事前に発行済なはずなので、ありえないフロー
|
|
276
|
-
throw new factory.errors.ServiceUnavailable('object.confirmationNumber undefined');
|
|
277
|
-
}
|
|
278
|
-
// URLの指定があれば上書き
|
|
279
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
280
|
-
/* istanbul ignore if */
|
|
281
|
-
if (typeof params.result.order.url === 'string') {
|
|
282
|
-
url = params.result.order.url;
|
|
283
|
-
}
|
|
284
|
-
else /* istanbul ignore next */ if (typeof params.result.order.url === 'function') {
|
|
285
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
286
|
-
/* istanbul ignore next */
|
|
287
|
-
url = params.result.order.url(params.order);
|
|
288
|
-
}
|
|
289
|
-
// 識別子の指定があれば上書き
|
|
290
|
-
identifier = [
|
|
291
|
-
...(Array.isArray(params.result.order.identifier)) ? params.result.order.identifier : [],
|
|
292
|
-
// 取引に指定があれば追加
|
|
293
|
-
...(Array.isArray(params.transaction.object.identifier)) ? params.transaction.object.identifier : []
|
|
294
|
-
];
|
|
295
|
-
return { confirmationNumber, url, identifier };
|
|
296
|
-
}
|
|
14
|
+
const order_1 = require("../../factory/order");
|
|
15
|
+
Object.defineProperty(exports, "POINT_AWARD_IDENTIFIER_NAME", { enumerable: true, get: function () { return order_1.POINT_AWARD_IDENTIFIER_NAME; } });
|
|
16
|
+
const confirm_1 = require("./placeOrderInProgress/confirm");
|
|
17
|
+
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return confirm_1.confirm; } });
|
|
18
|
+
const publishConfirmationNumberIfNotExist_1 = require("./placeOrderInProgress/publishConfirmationNumberIfNotExist");
|
|
19
|
+
Object.defineProperty(exports, "publishConfirmationNumberIfNotExist", { enumerable: true, get: function () { return publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist; } });
|
|
20
|
+
const publishOrderNumberIfNotExist_1 = require("./placeOrderInProgress/publishOrderNumberIfNotExist");
|
|
21
|
+
Object.defineProperty(exports, "publishOrderNumberIfNotExist", { enumerable: true, get: function () { return publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist; } });
|
|
22
|
+
const start_1 = require("./placeOrderInProgress/start");
|
|
23
|
+
Object.defineProperty(exports, "start", { enumerable: true, get: function () { return start_1.start; } });
|
|
297
24
|
/**
|
|
298
25
|
* インセンティブ承認
|
|
299
26
|
*/
|
|
@@ -325,7 +52,7 @@ function authorizeAward(params) {
|
|
|
325
52
|
'object.potentialActions.givePointAward': givePointAwardParams
|
|
326
53
|
},
|
|
327
54
|
// order.identifierに入金識別子を保管する
|
|
328
|
-
$push: { 'object.identifier': { name:
|
|
55
|
+
$push: { 'object.identifier': { name: order_1.POINT_AWARD_IDENTIFIER_NAME, value: JSON.stringify(pointAwardIdentifiers) } }
|
|
329
56
|
}
|
|
330
57
|
});
|
|
331
58
|
}
|
|
@@ -352,7 +79,7 @@ function voidAward(params) {
|
|
|
352
79
|
$unset: {
|
|
353
80
|
'object.potentialActions.givePointAward': 1
|
|
354
81
|
},
|
|
355
|
-
$pull: { 'object.identifier': { name:
|
|
82
|
+
$pull: { 'object.identifier': { name: order_1.POINT_AWARD_IDENTIFIER_NAME } }
|
|
356
83
|
}
|
|
357
84
|
});
|
|
358
85
|
});
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.createReturnPointAwardActions = void 0;
|
|
13
13
|
const factory = require("../../../../factory");
|
|
14
14
|
const order_1 = require("../../../../factory/order");
|
|
15
|
-
const placeOrderInProgress_1 = require("../../placeOrderInProgress");
|
|
16
15
|
/**
|
|
17
16
|
* ポイント特典返却アクションを作成する
|
|
18
17
|
*/
|
|
@@ -22,7 +21,7 @@ function createReturnPointAwardActions(params) {
|
|
|
22
21
|
const returnPointAwardActions = [];
|
|
23
22
|
// 入金識別子はorder.identifierに保管されている
|
|
24
23
|
let pointAwardIdentifiers = [];
|
|
25
|
-
const pointAwardIdentifierStr = (_b = (_a = params.order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name ===
|
|
24
|
+
const pointAwardIdentifierStr = (_b = (_a = params.order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === order_1.POINT_AWARD_IDENTIFIER_NAME)) === null || _b === void 0 ? void 0 : _b.value;
|
|
26
25
|
if (typeof pointAwardIdentifierStr === 'string') {
|
|
27
26
|
try {
|
|
28
27
|
pointAwardIdentifiers = JSON.parse(pointAwardIdentifierStr);
|
|
@@ -9,5 +9,4 @@ export declare function createPotentialActions(params: {
|
|
|
9
9
|
potentialActions?: factory.transaction.returnOrder.IPotentialActionsParams;
|
|
10
10
|
transaction: factory.transaction.returnOrder.ITransaction;
|
|
11
11
|
emailMessageOnOrderReturned?: factory.creativeWork.message.email.ICreativeWork;
|
|
12
|
-
moneyTransferAcceptedOffers: Pick<factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>, 'itemOffered'>[];
|
|
13
12
|
}): Promise<factory.transaction.returnOrder.IPotentialActions>;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.createPotentialActions = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
14
|
const order_1 = require("../../../factory/order");
|
|
15
|
-
|
|
15
|
+
// import { createReturnMoneyTransferActions } from './potentialActions/returnMoneyTransfer';
|
|
16
16
|
const returnPaymentMethod_1 = require("./potentialActions/returnPaymentMethod");
|
|
17
17
|
const returnPointAward_1 = require("./potentialActions/returnPointAward");
|
|
18
18
|
const sendEmailMessage_1 = require("./potentialActions/sendEmailMessage");
|
|
@@ -34,12 +34,17 @@ function createPotentialActions(params) {
|
|
|
34
34
|
const returnPaymentMethodActions = yield (0, returnPaymentMethod_1.createReturnPaymentMethodActions)(Object.assign(Object.assign({}, params), { order, returnOrderActionParams }));
|
|
35
35
|
// ポイント特典の数だけ、返却アクションを作成
|
|
36
36
|
const returnPointAwardActions = yield (0, returnPointAward_1.createReturnPointAwardActions)(Object.assign(Object.assign({}, params), { order }));
|
|
37
|
-
|
|
37
|
+
// onOrderReturnedで生成へ移行(2024-02-04~)
|
|
38
|
+
// const returnMoneyTransferActions = await createReturnMoneyTransferActions({
|
|
39
|
+
// ...params,
|
|
40
|
+
// order,
|
|
41
|
+
// moneyTransferAcceptedOffers: params.moneyTransferAcceptedOffers
|
|
42
|
+
// });
|
|
38
43
|
// 返品後のEメール送信アクション
|
|
39
44
|
const sendEmailMessaegActionsOnReturn = yield (0, sendEmailMessage_1.createSendEmailMessaegActionsOnReturn)(Object.assign(Object.assign({}, params), { order, returnOrderActionParams }));
|
|
40
45
|
const potentialActionsOnReturnOrder = {
|
|
41
46
|
returnPaymentMethod: returnPaymentMethodActions,
|
|
42
|
-
returnMoneyTransfer: returnMoneyTransferActions,
|
|
47
|
+
// returnMoneyTransfer: returnMoneyTransferActions, // onOrderReturnedで生成へ移行(2024-02-04~)
|
|
43
48
|
returnPointAward: returnPointAwardActions,
|
|
44
49
|
sendEmailMessage: sendEmailMessaegActionsOnReturn
|
|
45
50
|
};
|
|
@@ -24,7 +24,7 @@ exports.preStart = void 0;
|
|
|
24
24
|
const createDebug = require("debug");
|
|
25
25
|
const http_status_1 = require("http-status");
|
|
26
26
|
const moment = require("moment-timezone");
|
|
27
|
-
|
|
27
|
+
// import * as request from 'request';
|
|
28
28
|
const factory = require("../../../factory");
|
|
29
29
|
const debug = createDebug('chevre-domain:service');
|
|
30
30
|
/**
|
|
@@ -45,7 +45,7 @@ function preStart(params) {
|
|
|
45
45
|
if (seller === undefined) {
|
|
46
46
|
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
47
47
|
}
|
|
48
|
-
yield validateOrder({ orders })(
|
|
48
|
+
yield validateOrder({ orders })();
|
|
49
49
|
let offers = [];
|
|
50
50
|
if (offerIds.length > 0) {
|
|
51
51
|
offers = yield repos.offer.search({
|
|
@@ -162,13 +162,14 @@ function fixOrders(params) {
|
|
|
162
162
|
return { acceptedOffers, eventIds, offerIds, orders };
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
function validateOrder(
|
|
166
|
-
return (
|
|
165
|
+
function validateOrder(__) {
|
|
166
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
// returnOrderタスクの処理の中でステータス整合性を担保しているので検証不要(2024-01-10~)
|
|
167
168
|
// 注文ステータスが配送済の場合のみ受け付け
|
|
168
|
-
const allOrdersDelivered = params.orders.every((o) => o.orderStatus === factory.orderStatus.OrderDelivered);
|
|
169
|
-
if (!allOrdersDelivered) {
|
|
170
|
-
|
|
171
|
-
}
|
|
169
|
+
// const allOrdersDelivered = params.orders.every((o) => o.orderStatus === factory.orderStatus.OrderDelivered);
|
|
170
|
+
// if (!allOrdersDelivered) {
|
|
171
|
+
// throw new factory.errors.Argument('Order Number', 'Invalid Order Status');
|
|
172
|
+
// }
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
function checkUsedReservationExists(params) {
|
|
@@ -286,53 +287,80 @@ function createOrder4returnPolicy(params) {
|
|
|
286
287
|
};
|
|
287
288
|
}
|
|
288
289
|
const TIMEOUT = 5000;
|
|
290
|
+
// tslint:disable-next-line:max-func-body-length
|
|
289
291
|
function getReturnPolicyByProject(params) {
|
|
292
|
+
var _a;
|
|
290
293
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
// implement with fetch(2024-01-20~)
|
|
295
|
+
try {
|
|
296
|
+
const res = yield fetch(params.sameAs, {
|
|
297
|
+
method: 'POST',
|
|
298
|
+
headers: {
|
|
299
|
+
'Content-Type': 'application/json'
|
|
296
300
|
},
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
301
|
+
body: JSON.stringify({
|
|
302
|
+
order: createOrder4returnPolicy({ order: params.order })
|
|
303
|
+
}),
|
|
304
|
+
// body data type must match "Content-Type" header
|
|
305
|
+
signal: AbortSignal.timeout(TIMEOUT)
|
|
306
|
+
});
|
|
307
|
+
let body;
|
|
308
|
+
try {
|
|
309
|
+
body = yield res.json();
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
// no op
|
|
313
|
+
}
|
|
314
|
+
let returnPolicy;
|
|
315
|
+
switch (res.status) {
|
|
316
|
+
case http_status_1.OK:
|
|
317
|
+
case http_status_1.CREATED:
|
|
318
|
+
case http_status_1.ACCEPTED:
|
|
319
|
+
case http_status_1.NO_CONTENT:
|
|
320
|
+
if (typeof ((_a = body === null || body === void 0 ? void 0 : body.restockingFee) === null || _a === void 0 ? void 0 : _a.value) !== 'number') {
|
|
321
|
+
throw new Error('invalid return policy');
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
returnPolicy = {
|
|
325
|
+
typeOf: 'MerchantReturnPolicy',
|
|
326
|
+
restockingFee: {
|
|
327
|
+
currency: factory.priceCurrency.JPY,
|
|
328
|
+
typeOf: 'MonetaryAmount',
|
|
329
|
+
value: body.restockingFee.value
|
|
322
330
|
}
|
|
323
|
-
|
|
324
|
-
case http_status_1.NOT_FOUND:
|
|
325
|
-
reject(new factory.errors.Argument('Seller', 'has no applicable return policies'));
|
|
326
|
-
break;
|
|
327
|
-
default:
|
|
328
|
-
reject({
|
|
329
|
-
statusCode: response.statusCode,
|
|
330
|
-
body: body
|
|
331
|
-
});
|
|
331
|
+
};
|
|
332
332
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
break;
|
|
334
|
+
case http_status_1.NOT_FOUND:
|
|
335
|
+
throw new factory.errors.Argument('Seller', 'has no applicable return policies');
|
|
336
|
+
// break;
|
|
337
|
+
default:
|
|
338
|
+
// tslint:disable-next-line:no-console
|
|
339
|
+
console.error('custom return policy temporarily unavailable.', res.status, body);
|
|
340
|
+
throw new factory.errors.ServiceUnavailable(`custom return policy temporarily unavailable. statusCode: ${res.status} body: ${body}`);
|
|
341
|
+
}
|
|
342
|
+
return returnPolicy;
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
if (err.name === 'TimeoutError') {
|
|
346
|
+
// tslint:disable-next-line:no-console
|
|
347
|
+
console.error('getReturnPolicyByProject: Timeout: It took more than 5 seconds to get the result!', err);
|
|
348
|
+
}
|
|
349
|
+
else if (err.name === 'AbortError') {
|
|
350
|
+
// tslint:disable-next-line:no-console
|
|
351
|
+
console.error('getReturnPolicyByProject: Fetch aborted by user action (browser stop button, closing tab, etc.', err);
|
|
352
|
+
}
|
|
353
|
+
else if (err.name === 'TypeError') {
|
|
354
|
+
// tslint:disable-next-line:no-console
|
|
355
|
+
console.error('getReturnPolicyByProject: AbortSignal.timeout() method is not supported', err);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// A network error, or some other problem.
|
|
359
|
+
// tslint:disable-next-line:no-console
|
|
360
|
+
console.error(`getReturnPolicyByProject: Error: type: ${err.name}, message: ${err.message}`, err);
|
|
361
|
+
}
|
|
362
|
+
throw err;
|
|
363
|
+
}
|
|
336
364
|
});
|
|
337
365
|
}
|
|
338
366
|
/**
|
|
@@ -13,7 +13,7 @@ exports.exportTasksById = exports.confirm = exports.start = exports.preStart = v
|
|
|
13
13
|
/**
|
|
14
14
|
* 返品取引サービス
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
// import * as createDebug from 'debug';
|
|
17
17
|
const moment = require("moment-timezone");
|
|
18
18
|
const factory = require("../../factory");
|
|
19
19
|
const factory_1 = require("./returnOrder/exportTasks/factory");
|
|
@@ -21,7 +21,7 @@ const potentialActions_1 = require("./returnOrder/potentialActions");
|
|
|
21
21
|
const preStart_1 = require("./returnOrder/preStart");
|
|
22
22
|
Object.defineProperty(exports, "preStart", { enumerable: true, get: function () { return preStart_1.preStart; } });
|
|
23
23
|
const errorHandler_1 = require("../../errorHandler");
|
|
24
|
-
const debug = createDebug('chevre-domain:service');
|
|
24
|
+
// const debug = createDebug('chevre-domain:service');
|
|
25
25
|
/**
|
|
26
26
|
* 返品取引開始
|
|
27
27
|
*/
|
|
@@ -105,19 +105,12 @@ function confirm(params) {
|
|
|
105
105
|
emailMessageOnOrderReturned = searchEmailMessagesResult.shift();
|
|
106
106
|
}
|
|
107
107
|
const result = {};
|
|
108
|
-
const moneyTransferAcceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
109
|
-
orderNumber: { $eq: transaction.object.order[0].orderNumber },
|
|
110
|
-
project: { id: { $eq: transaction.project.id } },
|
|
111
|
-
acceptedOffers: { itemOffered: { typeOf: { $in: [factory.actionType.MoneyTransfer] } } }
|
|
112
|
-
}, ['itemOffered']);
|
|
113
|
-
debug(moneyTransferAcceptedOffers.length, 'moneyTransferAcceptedOffers found.', moneyTransferAcceptedOffers);
|
|
114
108
|
const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
|
|
115
109
|
dateReturned: params.object.order.dateReturned,
|
|
116
110
|
orders: orders,
|
|
117
111
|
potentialActions: params.potentialActions,
|
|
118
112
|
transaction: transaction,
|
|
119
|
-
emailMessageOnOrderReturned: emailMessageOnOrderReturned
|
|
120
|
-
moneyTransferAcceptedOffers
|
|
113
|
+
emailMessageOnOrderReturned: emailMessageOnOrderReturned
|
|
121
114
|
});
|
|
122
115
|
// ステータス変更
|
|
123
116
|
yield repos.transaction.confirm({
|
package/lib/chevre/service.js
CHANGED
|
@@ -18,7 +18,6 @@ const EventFactory = require("./factory/event");
|
|
|
18
18
|
const OrderFactory = require("./factory/order");
|
|
19
19
|
const ReservedAgentIdentifireNamesFactory = require("./factory/reservedAgentIdentifireNames");
|
|
20
20
|
const TransactionFactory = require("./factory/transaction");
|
|
21
|
-
// import type * as UtilService from './service/util';
|
|
22
21
|
// import all lazily(2023-10-11~)
|
|
23
22
|
var account;
|
|
24
23
|
(function (account) {
|
|
@@ -257,15 +256,6 @@ var transaction;
|
|
|
257
256
|
}
|
|
258
257
|
transaction.createService = createService;
|
|
259
258
|
})(transaction = exports.transaction || (exports.transaction = {}));
|
|
260
|
-
// export namespace util {
|
|
261
|
-
// let service: typeof UtilService | undefined;
|
|
262
|
-
// export async function createService() {
|
|
263
|
-
// if (service === undefined) {
|
|
264
|
-
// service = await import('./service/util');
|
|
265
|
-
// }
|
|
266
|
-
// return service;
|
|
267
|
-
// }
|
|
268
|
-
// }
|
|
269
259
|
var factory;
|
|
270
260
|
(function (factory) {
|
|
271
261
|
factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -35,15 +35,19 @@ export type ISettings = factory.project.ISettings & {
|
|
|
35
35
|
};
|
|
36
36
|
export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
37
37
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
38
|
-
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
39
38
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
40
|
-
export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
|
|
41
39
|
export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
|
|
42
|
-
export declare const USE_ORDER_PAYMENT_METHOD_TYPE_OF: boolean;
|
|
43
40
|
export declare const USE_FETCH_API: boolean;
|
|
41
|
+
export declare const USE_INFORM_ORDER_IN_TRANSIT: boolean;
|
|
42
|
+
export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
|
|
43
|
+
export declare const USE_VERIFY_ACCEPTED_OFFERS: boolean;
|
|
44
|
+
export declare const USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT: boolean;
|
|
45
|
+
export declare const USE_MINIMIZED_PAY_TASK: boolean;
|
|
46
|
+
export declare const USE_KANA_NAME_IN_ACCEPTED_OFFER: boolean;
|
|
44
47
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
45
48
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
46
49
|
export declare const MONGO_AUTO_INDEX: boolean;
|
|
50
|
+
export declare const DELIVER_ORDER_LIMIT: number;
|
|
47
51
|
/**
|
|
48
52
|
* グローバル設定
|
|
49
53
|
*/
|