@chevre/domain 21.2.0-alpha.10 → 21.2.0-alpha.101
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/aggregation/aggregateSystem.ts +58 -31
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processReserve.ts +4 -1
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchActions.ts +33 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/example/src/playOnMoment.ts +24 -0
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +3 -2
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +3 -55
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +100 -56
- package/lib/chevre/repo/additionalProperty.js +2 -1
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +259 -87
- package/lib/chevre/repo/categoryCode.js +3 -2
- package/lib/chevre/repo/code.js +3 -2
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +22 -6
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +3 -2
- package/lib/chevre/repo/customer.js +2 -1
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +2 -1
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +4 -3
- package/lib/chevre/repo/member.js +4 -3
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +51 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
- package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
- package/lib/chevre/repo/offer.js +3 -2
- package/lib/chevre/repo/offerCatalog.js +0 -27
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +121 -0
- package/lib/chevre/repo/order.d.ts +55 -3
- package/lib/chevre/repo/order.js +62 -10
- package/lib/chevre/repo/ownershipInfo.js +2 -7
- package/lib/chevre/repo/place.js +3 -2
- package/lib/chevre/repo/priceSpecification.js +3 -2
- package/lib/chevre/repo/product.js +2 -1
- package/lib/chevre/repo/project.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +12 -4
- package/lib/chevre/repo/reservation.js +20 -59
- package/lib/chevre/repo/role.js +3 -2
- package/lib/chevre/repo/seller.js +22 -21
- package/lib/chevre/repo/serviceOutput.js +2 -1
- package/lib/chevre/repo/task.d.ts +42 -2
- package/lib/chevre/repo/task.js +93 -11
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +177 -56
- package/lib/chevre/repo/trip.js +2 -1
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
- package/lib/chevre/service/assetTransaction/pay.js +18 -32
- package/lib/chevre/service/assetTransaction/refund.js +1 -23
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
- package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
- package/lib/chevre/service/assetTransaction/reserve.d.ts +10 -1
- package/lib/chevre/service/assetTransaction/reserve.js +85 -69
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize.js +8 -2
- package/lib/chevre/service/offer/event/factory.d.ts +3 -0
- package/lib/chevre/service/offer/event/factory.js +16 -5
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer.d.ts +12 -7
- package/lib/chevre/service/offer.js +57 -2
- package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -0
- package/lib/chevre/service/order/placeOrder.js +41 -24
- package/lib/chevre/service/order/returnOrder.d.ts +1 -0
- package/lib/chevre/service/order/returnOrder.js +7 -12
- package/lib/chevre/service/order/sendOrder.d.ts +1 -0
- package/lib/chevre/service/order/sendOrder.js +7 -10
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +9 -5
- package/lib/chevre/service/payment/any.js +80 -18
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +21 -15
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +7 -6
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +54 -31
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +5 -4
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
- package/lib/chevre/service/reserve/cancelReservation.js +147 -139
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
- package/lib/chevre/service/reserve/checkInReservation.js +77 -3
- package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
- package/lib/chevre/service/reserve/confirmReservation.js +125 -58
- package/lib/chevre/service/reserve/factory.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/useReservation.js +61 -71
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
- package/lib/chevre/service/reserve.d.ts +3 -2
- package/lib/chevre/service/reserve.js +4 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +5 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
- package/lib/chevre/service/task/onEventChanged.d.ts +7 -0
- package/lib/chevre/service/task/{deleteOrder.js → onEventChanged.js} +8 -14
- package/lib/chevre/service/task/placeOrder.js +1 -1
- package/lib/chevre/service/task/reserve.js +10 -7
- package/lib/chevre/service/task/returnOrder.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/sendOrder.js +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/useReservation.js +36 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
- package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder.js +225 -35
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +8 -1
- package/lib/chevre/settings.js +35 -6
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
- package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
- package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
|
@@ -13,18 +13,21 @@ exports.exportTasksById = exports.confirm = exports.start = void 0;
|
|
|
13
13
|
/**
|
|
14
14
|
* 返品取引サービス
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
16
|
+
const createDebug = require("debug");
|
|
17
|
+
const moment = require("moment-timezone");
|
|
17
18
|
const factory = require("../../factory");
|
|
18
19
|
const factory_1 = require("./returnOrder/exportTasks/factory");
|
|
19
20
|
const potentialActions_1 = require("./returnOrder/potentialActions");
|
|
20
21
|
const errorHandler_1 = require("../../errorHandler");
|
|
22
|
+
const debug = createDebug('chevre-domain:service');
|
|
21
23
|
/**
|
|
22
24
|
* 返品取引開始
|
|
23
25
|
*/
|
|
24
26
|
function start(params) {
|
|
27
|
+
// tslint:disable-next-line:max-func-body-length
|
|
25
28
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
29
|
const now = new Date();
|
|
27
|
-
const {
|
|
30
|
+
const { acceptedOffers, eventIds, offerIds, orders } = yield fixOrders(params)(repos);
|
|
28
31
|
// sellerはorderから自動取得
|
|
29
32
|
const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) }, { additionalProperty: 0, paymentAccepted: 0 });
|
|
30
33
|
yield validateOrder({ orders })(repos);
|
|
@@ -36,14 +39,43 @@ function start(params) {
|
|
|
36
39
|
}
|
|
37
40
|
// tslint:disable-next-line:no-console
|
|
38
41
|
// console.log('validating ', offers.length, 'offers before starting returnOrder... offerIds:', offerIds);
|
|
42
|
+
// イベント開始日時取得
|
|
43
|
+
let events = [];
|
|
44
|
+
if (eventIds.length > 0) {
|
|
45
|
+
events = yield repos.event.search({
|
|
46
|
+
id: { $in: eventIds },
|
|
47
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
48
|
+
}, {
|
|
49
|
+
startDate: 1
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
let returnPolicies = seller.hasMerchantReturnPolicy;
|
|
53
|
+
if (!Array.isArray(returnPolicies)) {
|
|
54
|
+
returnPolicies = [];
|
|
55
|
+
}
|
|
56
|
+
// アイテムコンディション取得
|
|
57
|
+
let offerItemConditions = [];
|
|
58
|
+
const itemConditionIds = returnPolicies
|
|
59
|
+
.filter((returnPolicy) => { var _a; return typeof ((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id) === 'string'; })
|
|
60
|
+
.map((returnPolicy) => { var _a; return String((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id); });
|
|
61
|
+
if (itemConditionIds.length > 0) {
|
|
62
|
+
offerItemConditions = yield repos.offerItemCondition.search({
|
|
63
|
+
id: { $in: itemConditionIds }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
39
66
|
const policiesByOffer = yield searchPoliciesByOffer({ offers })(repos);
|
|
67
|
+
const { usedReservationExists } = yield checkUsedReservationExists({ orders })(repos);
|
|
40
68
|
const appliedReturnPolicy = findApplicableReturnPolicy({
|
|
69
|
+
acceptedOffers,
|
|
70
|
+
events,
|
|
71
|
+
offerItemConditions,
|
|
41
72
|
orders,
|
|
42
73
|
returningDate: now,
|
|
43
74
|
reason: params.object.reason,
|
|
44
|
-
|
|
75
|
+
returnPolicies,
|
|
45
76
|
offers,
|
|
46
|
-
policiesByOffer
|
|
77
|
+
policiesByOffer,
|
|
78
|
+
usedReservationExists
|
|
47
79
|
});
|
|
48
80
|
validateAppliedReturnPolicy({ merchantReturnPolicy: appliedReturnPolicy });
|
|
49
81
|
// アイテム検証
|
|
@@ -115,7 +147,8 @@ function fixOrders(params) {
|
|
|
115
147
|
// 不要な属性は参照しない
|
|
116
148
|
acceptedOffers: 0,
|
|
117
149
|
customer: 0,
|
|
118
|
-
orderedItem: 0
|
|
150
|
+
orderedItem: 0,
|
|
151
|
+
paymentMethods: 0
|
|
119
152
|
});
|
|
120
153
|
if (orders.length !== params.object.order.length) {
|
|
121
154
|
throw new factory.errors.NotFound('Order');
|
|
@@ -125,7 +158,13 @@ function fixOrders(params) {
|
|
|
125
158
|
confirmationNumbers: [params.object.order[0].confirmationNumber],
|
|
126
159
|
orderNumbers: [params.object.order[0].orderNumber]
|
|
127
160
|
});
|
|
128
|
-
|
|
161
|
+
const eventIds = yield repos.order.searchReservationForIdsByOrderNumbers({
|
|
162
|
+
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
163
|
+
});
|
|
164
|
+
const acceptedOffers = yield repos.order.searchAcceptedOffersByOrderNumbers({
|
|
165
|
+
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
166
|
+
});
|
|
167
|
+
return { acceptedOffers, eventIds, offerIds, orders };
|
|
129
168
|
});
|
|
130
169
|
}
|
|
131
170
|
function validateOrder(params) {
|
|
@@ -137,12 +176,9 @@ function validateOrder(params) {
|
|
|
137
176
|
}
|
|
138
177
|
});
|
|
139
178
|
}
|
|
140
|
-
function
|
|
179
|
+
function checkUsedReservationExists(params) {
|
|
141
180
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
|
|
143
|
-
// 販売者都合の場合、特に検証しない
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
181
|
+
let usedReservationExists = false;
|
|
146
182
|
// 注文に含まれる予約の状態検証
|
|
147
183
|
const reservationNumbers = yield repos.order.searchReservationNumbersByOrderNumbers({
|
|
148
184
|
orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
@@ -155,11 +191,38 @@ function validateItems(params) {
|
|
|
155
191
|
typeOf: factory.reservationType.EventReservation,
|
|
156
192
|
reservationNumber: { $in: reservationNumbers },
|
|
157
193
|
attended: true
|
|
158
|
-
});
|
|
194
|
+
}, { _id: 1 });
|
|
159
195
|
if (existingUsedReservations.length > 0) {
|
|
160
|
-
|
|
196
|
+
usedReservationExists = true;
|
|
161
197
|
}
|
|
162
198
|
}
|
|
199
|
+
return { usedReservationExists };
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function validateItems(params) {
|
|
203
|
+
return (__) => __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
205
|
+
// 販売者都合の場合、特に検証しない
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// アイテムコンディション検証へ移行
|
|
209
|
+
// 注文に含まれる予約の状態検証
|
|
210
|
+
// const reservationNumbers = await repos.order.searchReservationNumbersByOrderNumbers({
|
|
211
|
+
// orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
212
|
+
// });
|
|
213
|
+
// if (reservationNumbers.length > 0) {
|
|
214
|
+
// // 使用済の予約がひとつでもあれば不可
|
|
215
|
+
// const existingUsedReservations = await repos.reservation.search({
|
|
216
|
+
// limit: 1,
|
|
217
|
+
// page: 1,
|
|
218
|
+
// typeOf: factory.reservationType.EventReservation,
|
|
219
|
+
// reservationNumber: { $in: reservationNumbers },
|
|
220
|
+
// attended: true
|
|
221
|
+
// });
|
|
222
|
+
// if (existingUsedReservations.length > 0) {
|
|
223
|
+
// throw new factory.errors.Argument('orderNumber', 'some reservations already used');
|
|
224
|
+
// }
|
|
225
|
+
// }
|
|
163
226
|
});
|
|
164
227
|
}
|
|
165
228
|
function searchPoliciesByOffer(params) {
|
|
@@ -186,7 +249,9 @@ function searchPoliciesByOffer(params) {
|
|
|
186
249
|
/**
|
|
187
250
|
* 販売者の返品ポリシーを確認する
|
|
188
251
|
*/
|
|
252
|
+
// tslint:disable-next-line:max-func-body-length
|
|
189
253
|
function findApplicableReturnPolicy(params) {
|
|
254
|
+
var _a;
|
|
190
255
|
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
191
256
|
// 販売者都合の場合、手数料なしの返金返品ポリシーを適用
|
|
192
257
|
return {
|
|
@@ -194,14 +259,23 @@ function findApplicableReturnPolicy(params) {
|
|
|
194
259
|
returnFees: factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn
|
|
195
260
|
};
|
|
196
261
|
}
|
|
197
|
-
|
|
198
|
-
if (!Array.isArray(returnPolicies)) {
|
|
199
|
-
returnPolicies = [];
|
|
200
|
-
}
|
|
262
|
+
const returnPolicies = params.returnPolicies;
|
|
201
263
|
const returningDate = moment(params.returningDate);
|
|
202
|
-
|
|
264
|
+
let applicalbleReturnPolicies = [];
|
|
203
265
|
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
204
|
-
|
|
266
|
+
// 適用可能なポリシーにフィルター
|
|
267
|
+
// tslint:disable-next-line:max-func-body-length
|
|
268
|
+
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
269
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
270
|
+
let satisfyMerchantReturnDays = false;
|
|
271
|
+
let offerItemCondition;
|
|
272
|
+
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
273
|
+
if (typeof itemConditionId === 'string') {
|
|
274
|
+
offerItemCondition = params.offerItemConditions.find((o) => o.id === itemConditionId);
|
|
275
|
+
if (offerItemCondition === undefined) {
|
|
276
|
+
throw new factory.errors.NotFound('OfferItemCondition');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
205
279
|
const merchantReturnDays = returnPolicy.merchantReturnDays;
|
|
206
280
|
if (typeof merchantReturnDays === 'number') {
|
|
207
281
|
// 返品適用日数を確認する
|
|
@@ -212,13 +286,78 @@ function findApplicableReturnPolicy(params) {
|
|
|
212
286
|
});
|
|
213
287
|
// 全注文について日数の確認ができれば適用
|
|
214
288
|
if (everyOrderApplicable) {
|
|
215
|
-
|
|
289
|
+
satisfyMerchantReturnDays = true;
|
|
216
290
|
}
|
|
217
291
|
}
|
|
218
292
|
else {
|
|
219
293
|
// 日数制限なし
|
|
220
|
-
|
|
294
|
+
satisfyMerchantReturnDays = true;
|
|
221
295
|
}
|
|
296
|
+
// イベント開始猶予を検証する(2023-05-22~)
|
|
297
|
+
let satisfyItemCondition = true;
|
|
298
|
+
if (offerItemCondition !== undefined) {
|
|
299
|
+
let satisfyGracePeriodMaxValue = true;
|
|
300
|
+
let satisfyGracePeriodMinValue = true;
|
|
301
|
+
// 全イベントについて猶予の確認ができれば適用
|
|
302
|
+
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
303
|
+
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
304
|
+
if (typeof gracePeriodMaxValue === 'number') {
|
|
305
|
+
satisfyGracePeriodMaxValue = params.events.every((event) => {
|
|
306
|
+
return moment(event.startDate)
|
|
307
|
+
.isSameOrBefore(moment(params.returningDate)
|
|
308
|
+
.add(gracePeriodMaxValue, 'seconds'));
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (typeof gracePeriodMinValue === 'number') {
|
|
312
|
+
satisfyGracePeriodMinValue = params.events.every((event) => {
|
|
313
|
+
return moment(event.startDate)
|
|
314
|
+
.isAfter(moment(params.returningDate)
|
|
315
|
+
.add(gracePeriodMinValue, 'seconds'));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
let satisfyGracePeriodInDaysMax = true;
|
|
319
|
+
let satisfyGracePeriodInDaysMin = true;
|
|
320
|
+
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
321
|
+
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
322
|
+
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
323
|
+
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
324
|
+
const maxDate = moment(event.startDate)
|
|
325
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
326
|
+
.startOf('days')
|
|
327
|
+
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
328
|
+
.format('YYYY-MM-DD');
|
|
329
|
+
const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
|
|
330
|
+
debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
|
|
331
|
+
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
|
|
335
|
+
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
336
|
+
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
337
|
+
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
338
|
+
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
339
|
+
const minDate = moment(event.startDate)
|
|
340
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
341
|
+
.startOf('days')
|
|
342
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
343
|
+
.format('YYYY-MM-DD');
|
|
344
|
+
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
345
|
+
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
346
|
+
return returnMaxDate.isAfter(moment(returningDate));
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
350
|
+
let satisfyOnlyUnused = true;
|
|
351
|
+
if (((_k = offerItemCondition.itemOffered.serviceOutput) === null || _k === void 0 ? void 0 : _k.onlyUnused) === true) {
|
|
352
|
+
if (params.usedReservationExists) {
|
|
353
|
+
satisfyOnlyUnused = false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
debug('usedReservationExists:', params.usedReservationExists, 'satisfyOnlyUnused:', satisfyOnlyUnused);
|
|
357
|
+
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
358
|
+
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin && satisfyOnlyUnused;
|
|
359
|
+
}
|
|
360
|
+
return satisfyMerchantReturnDays && satisfyItemCondition;
|
|
222
361
|
});
|
|
223
362
|
}
|
|
224
363
|
// 販売者にポリシーが存在しなければ返品不可
|
|
@@ -226,13 +365,35 @@ function findApplicableReturnPolicy(params) {
|
|
|
226
365
|
throw new factory.errors.Argument('Seller', 'has no applicable return policies');
|
|
227
366
|
}
|
|
228
367
|
// オファーの返品ポリシーから返品手数料タイプを決定する
|
|
229
|
-
const { returnFees } = validateOffersReturnPolicy({
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
368
|
+
const { returnFees, returnFeesMovieTicket } = validateOffersReturnPolicy({
|
|
369
|
+
acceptedOffers: params.acceptedOffers,
|
|
370
|
+
offers: params.offers,
|
|
371
|
+
policiesByOffer: params.policiesByOffer
|
|
372
|
+
});
|
|
373
|
+
// restockingFeeが最低のポリシーを自動選択
|
|
374
|
+
let appliedReturnPolicy = applicalbleReturnPolicies[0];
|
|
375
|
+
applicalbleReturnPolicies.forEach((returnPolicy) => {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
const appliedReturnPolicyRestockingFeeValue = (_a = appliedReturnPolicy.restockingFee) === null || _a === void 0 ? void 0 : _a.value;
|
|
378
|
+
const restockingFeeValue = (_b = returnPolicy.restockingFee) === null || _b === void 0 ? void 0 : _b.value;
|
|
379
|
+
const appliedReturnPolicyRestockingFee = (typeof appliedReturnPolicyRestockingFeeValue === 'number')
|
|
380
|
+
? appliedReturnPolicyRestockingFeeValue
|
|
381
|
+
: 0;
|
|
382
|
+
const restockingFee = (typeof restockingFeeValue === 'number') ? restockingFeeValue : 0;
|
|
383
|
+
if (restockingFee < appliedReturnPolicyRestockingFee) {
|
|
384
|
+
appliedReturnPolicy = returnPolicy;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
let appliedItemCondition;
|
|
388
|
+
const appliedItemConditionId = (_a = appliedReturnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
389
|
+
if (typeof appliedItemConditionId === 'string') {
|
|
390
|
+
appliedItemCondition = params.offerItemConditions.find((o) => o.id === appliedItemConditionId);
|
|
391
|
+
if (appliedItemCondition === undefined) {
|
|
392
|
+
throw new factory.errors.NotFound('OfferItemCondition');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return Object.assign({ merchantReturnDays: appliedReturnPolicy.merchantReturnDays, restockingFee: appliedReturnPolicy.restockingFee, returnFees,
|
|
396
|
+
returnFeesMovieTicket, typeOf: appliedReturnPolicy.typeOf }, (typeof (appliedItemCondition === null || appliedItemCondition === void 0 ? void 0 : appliedItemCondition.typeOf) === 'string') ? { itemCondition: appliedItemCondition } : undefined);
|
|
236
397
|
}
|
|
237
398
|
/**
|
|
238
399
|
* 注文中のオファーの返品ポリシーを検証
|
|
@@ -271,8 +432,41 @@ function validateOffersReturnPolicy(params) {
|
|
|
271
432
|
else {
|
|
272
433
|
throw new factory.errors.NotImplemented('returnFees not defined');
|
|
273
434
|
}
|
|
274
|
-
//
|
|
275
|
-
|
|
435
|
+
// 決済カード取消ポリシーを確定(2023-05-23~)
|
|
436
|
+
const returnFeesMovieTicket = [];
|
|
437
|
+
params.acceptedOffers.forEach((acceptedOffer) => {
|
|
438
|
+
const unitPriceOffer = params.offers.find((offer) => offer.id === acceptedOffer.id);
|
|
439
|
+
if (unitPriceOffer === undefined) {
|
|
440
|
+
throw new factory.errors.NotFound(`UnitPriceOffer ${acceptedOffer.id}`);
|
|
441
|
+
}
|
|
442
|
+
if (!Array.isArray(unitPriceOffer.hasMerchantReturnPolicy) || unitPriceOffer.hasMerchantReturnPolicy.length === 0) {
|
|
443
|
+
throw new factory.errors.NotFound(`offer.hasMerchantReturnPolicy ${acceptedOffer.id}`);
|
|
444
|
+
}
|
|
445
|
+
const hasMerchantReturnPolicy = unitPriceOffer.hasMerchantReturnPolicy[0];
|
|
446
|
+
const policyByOffer = params.policiesByOffer.find((policy) => policy.id === hasMerchantReturnPolicy.id);
|
|
447
|
+
if (policyByOffer === undefined) {
|
|
448
|
+
throw new factory.errors.NotFound(`MerchantReturnPolicy acceptedOffer:${acceptedOffer.id}`);
|
|
449
|
+
}
|
|
450
|
+
const movieTicketTypeChargeSpecExists = acceptedOffer.priceSpecification.priceComponent.some((component) => {
|
|
451
|
+
return component.typeOf === factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
|
|
452
|
+
});
|
|
453
|
+
if (movieTicketTypeChargeSpecExists) {
|
|
454
|
+
acceptedOffer.priceSpecification.priceComponent.forEach((component) => {
|
|
455
|
+
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
456
|
+
if (Array.isArray(component.appliesToMovieTicket)) {
|
|
457
|
+
component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
458
|
+
returnFeesMovieTicket.push({
|
|
459
|
+
identifier: String(appliesToMovieTicket.identifier),
|
|
460
|
+
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket,
|
|
461
|
+
serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
return { returnFees, returnFeesMovieTicket };
|
|
276
470
|
}
|
|
277
471
|
function validateAppliedReturnPolicy(params) {
|
|
278
472
|
var _a;
|
|
@@ -384,11 +578,7 @@ function exportTasksById(params) {
|
|
|
384
578
|
transaction,
|
|
385
579
|
runsAt: taskRunsAt
|
|
386
580
|
});
|
|
387
|
-
|
|
388
|
-
yield repos.task.saveMany(taskAttributes);
|
|
389
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
390
|
-
// await repos.task.save(taskAttribute);
|
|
391
|
-
// }));
|
|
581
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
392
582
|
});
|
|
393
583
|
}
|
|
394
584
|
exports.exportTasksById = exportTasksById;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
|
-
import { MongoRepository as ActionRepo } from '../repo/action';
|
|
3
|
-
import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
|
|
4
|
-
import { MongoRepository as ReservationRepo } from '../repo/reservation';
|
|
5
2
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
6
3
|
import { MongoRepository as TransactionRepo } from '../repo/transaction';
|
|
4
|
+
import { deleteTransaction } from './transaction/deleteTransaction';
|
|
7
5
|
import * as MoneyTransferTransactionService from './transaction/moneyTransfer';
|
|
8
6
|
import * as PlaceOrderTransactionService from './transaction/placeOrder';
|
|
9
7
|
import * as PlaceOrderInProgressTransactionService from './transaction/placeOrderInProgress';
|
|
@@ -15,6 +13,7 @@ export import moneyTransfer = MoneyTransferTransactionService;
|
|
|
15
13
|
export import placeOrder = PlaceOrderTransactionService;
|
|
16
14
|
export import placeOrderInProgress = PlaceOrderInProgressTransactionService;
|
|
17
15
|
export import returnOrder = ReturnOrderTransactionService;
|
|
16
|
+
export { deleteTransaction };
|
|
18
17
|
/**
|
|
19
18
|
* 取引人プロフィール更新
|
|
20
19
|
*/
|
|
@@ -45,14 +44,10 @@ export declare function exportTasks<T extends factory.transactionType>(params: {
|
|
|
45
44
|
typeOf?: {
|
|
46
45
|
$in: T[];
|
|
47
46
|
};
|
|
47
|
+
id?: string;
|
|
48
|
+
tasksExportAction?: {
|
|
49
|
+
agent: {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
48
53
|
}): IExportTasksOperation<void>;
|
|
49
|
-
/**
|
|
50
|
-
* 取引に関わるリソースを削除する
|
|
51
|
-
* 冪等性を確保すること
|
|
52
|
-
*/
|
|
53
|
-
export declare function deleteTransaction(params: factory.task.IData<factory.taskName.DeleteTransaction>): (repos: {
|
|
54
|
-
action: ActionRepo;
|
|
55
|
-
assetTransaction: AssetTransactionRepo;
|
|
56
|
-
reservation: ReservationRepo;
|
|
57
|
-
transaction: TransactionRepo;
|
|
58
|
-
}) => Promise<void>;
|
|
@@ -9,16 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.exportTasks = exports.updateAgent = exports.deleteTransaction = exports.returnOrder = exports.placeOrderInProgress = exports.placeOrder = exports.moneyTransfer = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 取引サービス
|
|
15
15
|
*/
|
|
16
16
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
17
17
|
const factory = require("../factory");
|
|
18
|
+
const deleteTransaction_1 = require("./transaction/deleteTransaction");
|
|
19
|
+
Object.defineProperty(exports, "deleteTransaction", { enumerable: true, get: function () { return deleteTransaction_1.deleteTransaction; } });
|
|
18
20
|
const MoneyTransferTransactionService = require("./transaction/moneyTransfer");
|
|
19
21
|
const PlaceOrderTransactionService = require("./transaction/placeOrder");
|
|
20
22
|
const PlaceOrderInProgressTransactionService = require("./transaction/placeOrderInProgress");
|
|
21
23
|
const ReturnOrderTransactionService = require("./transaction/returnOrder");
|
|
24
|
+
const settings_1 = require("../settings");
|
|
22
25
|
exports.moneyTransfer = MoneyTransferTransactionService;
|
|
23
26
|
exports.placeOrder = PlaceOrderTransactionService;
|
|
24
27
|
exports.placeOrderInProgress = PlaceOrderInProgressTransactionService;
|
|
@@ -77,15 +80,17 @@ exports.updateAgent = updateAgent;
|
|
|
77
80
|
*/
|
|
78
81
|
function exportTasks(params) {
|
|
79
82
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
const transaction = yield repos.transaction.startExportTasks(Object.assign({ project: params.project, typeOf: params.typeOf, status: params.status, tasksExportAction: {
|
|
85
|
+
agent: {
|
|
86
|
+
name: (typeof ((_a = params.tasksExportAction) === null || _a === void 0 ? void 0 : _a.agent.name) === 'string')
|
|
87
|
+
? params.tasksExportAction.agent.name
|
|
88
|
+
: settings_1.DEFAULT_TASKS_EXPORT_AGENT_NAME
|
|
89
|
+
}
|
|
90
|
+
} }, (typeof params.id === 'string') ? { id: params.id } : undefined));
|
|
85
91
|
if (transaction === null) {
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
|
-
// let tasks: factory.task.ITask<factory.taskName>[] = [];
|
|
89
94
|
// 失敗してもここでは戻さない(RUNNINGのまま待機)
|
|
90
95
|
switch (transaction.typeOf) {
|
|
91
96
|
case factory.transactionType.MoneyTransfer:
|
|
@@ -109,144 +114,6 @@ function exportTasks(params) {
|
|
|
109
114
|
default:
|
|
110
115
|
}
|
|
111
116
|
yield repos.transaction.setTasksExportedById({ id: transaction.id });
|
|
112
|
-
// return tasks;
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
exports.exportTasks = exportTasks;
|
|
116
|
-
/**
|
|
117
|
-
* 取引に関わるリソースを削除する
|
|
118
|
-
* 冪等性を確保すること
|
|
119
|
-
*/
|
|
120
|
-
function deleteTransaction(params) {
|
|
121
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
var _a;
|
|
123
|
-
const transaction = params.object;
|
|
124
|
-
// DeleteTransactionアクションを作成(logとしての意味合いも含めて)
|
|
125
|
-
const actionAttributes = {
|
|
126
|
-
typeOf: factory.actionType.DeleteAction,
|
|
127
|
-
project: transaction.project,
|
|
128
|
-
object: transaction,
|
|
129
|
-
agent: {
|
|
130
|
-
typeOf: transaction.seller.typeOf,
|
|
131
|
-
id: transaction.seller.id,
|
|
132
|
-
name: (typeof transaction.seller.name === 'string')
|
|
133
|
-
? transaction.seller.name
|
|
134
|
-
: String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
let deleteReservationsResult;
|
|
138
|
-
let deleteReserveTransactionResult;
|
|
139
|
-
let deletedReservationNumbers = [];
|
|
140
|
-
const action = yield repos.action.start(actionAttributes);
|
|
141
|
-
try {
|
|
142
|
-
const transactionTypeOf = transaction.typeOf;
|
|
143
|
-
switch (transactionTypeOf) {
|
|
144
|
-
case factory.transactionType.PlaceOrder:
|
|
145
|
-
switch (transaction.status) {
|
|
146
|
-
// 中止あるいは期限切れ取引の場合
|
|
147
|
-
case factory.transactionStatusType.Canceled:
|
|
148
|
-
case factory.transactionStatusType.Expired:
|
|
149
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
150
|
-
// TODO サービス登録取引を削除
|
|
151
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
152
|
-
// TODO 決済取引を削除
|
|
153
|
-
// 取引上での予約を削除
|
|
154
|
-
const deleteReservationsByTransactionResult = yield deleteReservationsByTransaction({ transaction })(repos);
|
|
155
|
-
deleteReservationsResult = deleteReservationsByTransactionResult.deleteResult;
|
|
156
|
-
deleteReserveTransactionResult = deleteReservationsByTransactionResult.deleteReserveTransactionResult;
|
|
157
|
-
deletedReservationNumbers = deleteReservationsByTransactionResult.reserveTransactionNumbers;
|
|
158
|
-
break;
|
|
159
|
-
case factory.transactionStatusType.Confirmed:
|
|
160
|
-
// no op
|
|
161
|
-
break;
|
|
162
|
-
default:
|
|
163
|
-
}
|
|
164
|
-
// 取引削除
|
|
165
|
-
yield repos.transaction.findByIdAndDelete({ id: transaction.id });
|
|
166
|
-
// await repos.transaction.transactionModel.findByIdAndDelete(transaction.id)
|
|
167
|
-
// .exec();
|
|
168
|
-
break;
|
|
169
|
-
// implemented(2022-06-09~)
|
|
170
|
-
case factory.transactionType.ReturnOrder:
|
|
171
|
-
// 取引削除
|
|
172
|
-
yield repos.transaction.findByIdAndDelete({ id: transaction.id });
|
|
173
|
-
break;
|
|
174
|
-
// implemented(2022-06-09~)
|
|
175
|
-
case factory.transactionType.MoneyTransfer:
|
|
176
|
-
// 取引削除
|
|
177
|
-
yield repos.transaction.findByIdAndDelete({ id: transaction.id });
|
|
178
|
-
break;
|
|
179
|
-
default:
|
|
180
|
-
throw new factory.errors.NotImplemented(`${transactionTypeOf} not implemented`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
// actionにエラー結果を追加
|
|
185
|
-
try {
|
|
186
|
-
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
187
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
188
|
-
}
|
|
189
|
-
catch (__) {
|
|
190
|
-
// 失敗したら仕方ない
|
|
191
|
-
}
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
194
|
-
// アクション完了
|
|
195
|
-
const actionResult = {
|
|
196
|
-
deleteReservationsResult,
|
|
197
|
-
deleteReserveTransactionResult,
|
|
198
|
-
deletedReservationNumbers
|
|
199
|
-
};
|
|
200
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
exports.deleteTransaction = deleteTransaction;
|
|
204
|
-
function deleteReservationsByTransaction(params) {
|
|
205
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
let deleteResult;
|
|
207
|
-
let deleteReserveTransactionResult;
|
|
208
|
-
// 取引に対する全ての承認アクションを検索
|
|
209
|
-
const authorizeActions = yield repos.action.searchByPurpose({
|
|
210
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
211
|
-
purpose: {
|
|
212
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
213
|
-
id: params.transaction.id
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
// 予約取引番号を抽出
|
|
217
|
-
const authorizeReservationOfferActions = authorizeActions
|
|
218
|
-
.filter((a) => {
|
|
219
|
-
var _a, _b;
|
|
220
|
-
const pendingTransactionNumber = (_b = (_a = a.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction) === null || _b === void 0 ? void 0 : _b.transactionNumber;
|
|
221
|
-
return a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation
|
|
222
|
-
&& typeof pendingTransactionNumber === 'string'
|
|
223
|
-
&& pendingTransactionNumber.length > 0;
|
|
224
|
-
});
|
|
225
|
-
const reserveTransactionNumbers = authorizeReservationOfferActions
|
|
226
|
-
.map((a) => { var _a; return String((_a = a.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber); });
|
|
227
|
-
if (reserveTransactionNumbers.length > 0) {
|
|
228
|
-
// 該当予約番号の予約を削除する(プロジェクトでも絞ること)
|
|
229
|
-
const deleteReservationsResult = yield repos.reservation.deleteByReservationNumbers({
|
|
230
|
-
project: { id: params.transaction.project.id },
|
|
231
|
-
reservationNumbers: reserveTransactionNumbers
|
|
232
|
-
});
|
|
233
|
-
deleteResult = {
|
|
234
|
-
n: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.n,
|
|
235
|
-
ok: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.ok,
|
|
236
|
-
deletedCount: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.deletedCount
|
|
237
|
-
};
|
|
238
|
-
// 予約取引を削除(プロジェクトでも絞ること)(2022-06-07~)
|
|
239
|
-
const deleteAssetTransactionsResult = yield repos.assetTransaction.deleteByTransactionNumber({
|
|
240
|
-
project: { id: params.transaction.project.id },
|
|
241
|
-
transactionNumbers: reserveTransactionNumbers,
|
|
242
|
-
typeOf: factory.assetTransactionType.Reserve
|
|
243
|
-
});
|
|
244
|
-
deleteReserveTransactionResult = {
|
|
245
|
-
n: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.n,
|
|
246
|
-
ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
|
|
247
|
-
deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return { deleteResult, deleteReserveTransactionResult, reserveTransactionNumbers };
|
|
251
|
-
});
|
|
252
|
-
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as moment from 'moment';
|
|
2
2
|
import * as factory from './factory';
|
|
3
|
+
export declare const TRIGGER_WEBHOOK_MAX_RETRY_COUNT: number;
|
|
4
|
+
export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
3
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
4
6
|
/**
|
|
5
7
|
* 資産取引保管期間
|
|
@@ -15,6 +17,9 @@ export declare const TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS: number;
|
|
|
15
17
|
export declare const TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS: number;
|
|
16
18
|
export declare const DEFAULT_SENDER_EMAIL: string;
|
|
17
19
|
export type ISettings = factory.project.ISettings & {
|
|
20
|
+
onEventChanged: {
|
|
21
|
+
informEvent?: factory.project.IInformParams[];
|
|
22
|
+
};
|
|
18
23
|
onReservationStatusChanged: {
|
|
19
24
|
informReservation?: factory.project.IInformParams[];
|
|
20
25
|
};
|
|
@@ -27,10 +32,12 @@ export type ISettings = factory.project.ISettings & {
|
|
|
27
32
|
useOfferRateLimitProjects: string[];
|
|
28
33
|
};
|
|
29
34
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
35
|
+
export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
30
36
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
31
37
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
32
38
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
33
|
-
export declare const
|
|
39
|
+
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
40
|
+
export declare const MONGO_MAX_TIME_MS: number;
|
|
34
41
|
/**
|
|
35
42
|
* グローバル設定
|
|
36
43
|
*/
|