@chevre/domain 21.2.0-alpha.12 → 21.2.0-alpha.120
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/aggregation/aggregateSystem.ts +85 -27
- package/example/src/chevre/countDelayedTasks.ts +7 -2
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/findMovieTheaterById.ts +40 -0
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/lockStockHolder.ts +2 -1
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +1 -1
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- package/example/src/chevre/processReserve.ts +5 -2
- 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/searchEventSeats.ts +2 -1
- 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/updateScreeningRoom.ts +41 -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 +42 -2
- package/lib/chevre/repo/action.js +130 -57
- package/lib/chevre/repo/additionalProperty.js +2 -1
- package/lib/chevre/repo/aggregation.d.ts +3 -0
- package/lib/chevre/repo/aggregation.js +3 -0
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +259 -87
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +37 -25
- 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 +2 -4
- package/lib/chevre/repo/creativeWork.js +35 -12
- 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 +27 -1
- package/lib/chevre/repo/event.js +67 -33
- 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/holdReservation.d.ts +75 -0
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +56 -0
- 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.d.ts +20 -5
- package/lib/chevre/repo/place.js +63 -23
- package/lib/chevre/repo/priceSpecification.js +3 -2
- package/lib/chevre/repo/product.d.ts +1 -3
- package/lib/chevre/repo/product.js +25 -4
- package/lib/chevre/repo/project.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +20 -4
- package/lib/chevre/repo/reservation.js +40 -59
- package/lib/chevre/repo/role.js +3 -2
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +44 -23
- package/lib/chevre/repo/serviceOutput.js +2 -1
- package/lib/chevre/repo/stockHolder.d.ts +35 -5
- package/lib/chevre/repo/stockHolder.js +306 -87
- package/lib/chevre/repo/task.d.ts +45 -2
- package/lib/chevre/repo/task.js +94 -15
- 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/event/aggregateUseActionsOnEvent.js +8 -6
- package/lib/chevre/service/aggregation/system.d.ts +110 -23
- package/lib/chevre/service/aggregation/system.js +213 -91
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -24
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
- 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 +20 -34
- package/lib/chevre/service/assetTransaction/refund.js +2 -24
- 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 -0
- package/lib/chevre/service/assetTransaction.js +9 -4
- package/lib/chevre/service/event.js +16 -5
- 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/importFromCOA.js +2 -2
- 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/eventServiceByCOA.js +7 -9
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/offer.d.ts +16 -8
- package/lib/chevre/service/offer.js +69 -8
- 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 +23 -17
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +8 -7
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +55 -32
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +7 -6
- 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 +133 -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/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +6 -2
- package/lib/chevre/service/task/cancelReservation.js +1 -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/onResourceUpdated.d.ts +7 -0
- package/lib/chevre/service/task/onResourceUpdated.js +352 -0
- 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 +4 -2
- 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.d.ts +1 -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 +10 -13
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +7 -3
- 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 +28 -15
- 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 +228 -36
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +12 -1
- package/lib/chevre/settings.js +53 -6
- package/package.json +5 -5
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -205
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
- 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,20 +13,25 @@ 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
|
-
const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) },
|
|
32
|
+
const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) }, ['name', 'project', 'hasMerchantReturnPolicy', 'typeOf'], []
|
|
33
|
+
// { additionalProperty: 0, paymentAccepted: 0 }
|
|
34
|
+
);
|
|
30
35
|
yield validateOrder({ orders })(repos);
|
|
31
36
|
let offers = [];
|
|
32
37
|
if (offerIds.length > 0) {
|
|
@@ -36,14 +41,43 @@ function start(params) {
|
|
|
36
41
|
}
|
|
37
42
|
// tslint:disable-next-line:no-console
|
|
38
43
|
// console.log('validating ', offers.length, 'offers before starting returnOrder... offerIds:', offerIds);
|
|
44
|
+
// イベント開始日時取得
|
|
45
|
+
let events = [];
|
|
46
|
+
if (eventIds.length > 0) {
|
|
47
|
+
events = yield repos.event.search({
|
|
48
|
+
id: { $in: eventIds },
|
|
49
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
50
|
+
}, {
|
|
51
|
+
startDate: 1
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
let returnPolicies = seller.hasMerchantReturnPolicy;
|
|
55
|
+
if (!Array.isArray(returnPolicies)) {
|
|
56
|
+
returnPolicies = [];
|
|
57
|
+
}
|
|
58
|
+
// アイテムコンディション取得
|
|
59
|
+
let offerItemConditions = [];
|
|
60
|
+
const itemConditionIds = returnPolicies
|
|
61
|
+
.filter((returnPolicy) => { var _a; return typeof ((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id) === 'string'; })
|
|
62
|
+
.map((returnPolicy) => { var _a; return String((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id); });
|
|
63
|
+
if (itemConditionIds.length > 0) {
|
|
64
|
+
offerItemConditions = yield repos.offerItemCondition.search({
|
|
65
|
+
id: { $in: itemConditionIds }
|
|
66
|
+
});
|
|
67
|
+
}
|
|
39
68
|
const policiesByOffer = yield searchPoliciesByOffer({ offers })(repos);
|
|
69
|
+
const { usedReservationExists } = yield checkUsedReservationExists({ orders })(repos);
|
|
40
70
|
const appliedReturnPolicy = findApplicableReturnPolicy({
|
|
71
|
+
acceptedOffers,
|
|
72
|
+
events,
|
|
73
|
+
offerItemConditions,
|
|
41
74
|
orders,
|
|
42
75
|
returningDate: now,
|
|
43
76
|
reason: params.object.reason,
|
|
44
|
-
|
|
77
|
+
returnPolicies,
|
|
45
78
|
offers,
|
|
46
|
-
policiesByOffer
|
|
79
|
+
policiesByOffer,
|
|
80
|
+
usedReservationExists
|
|
47
81
|
});
|
|
48
82
|
validateAppliedReturnPolicy({ merchantReturnPolicy: appliedReturnPolicy });
|
|
49
83
|
// アイテム検証
|
|
@@ -115,7 +149,8 @@ function fixOrders(params) {
|
|
|
115
149
|
// 不要な属性は参照しない
|
|
116
150
|
acceptedOffers: 0,
|
|
117
151
|
customer: 0,
|
|
118
|
-
orderedItem: 0
|
|
152
|
+
orderedItem: 0,
|
|
153
|
+
paymentMethods: 0
|
|
119
154
|
});
|
|
120
155
|
if (orders.length !== params.object.order.length) {
|
|
121
156
|
throw new factory.errors.NotFound('Order');
|
|
@@ -125,7 +160,13 @@ function fixOrders(params) {
|
|
|
125
160
|
confirmationNumbers: [params.object.order[0].confirmationNumber],
|
|
126
161
|
orderNumbers: [params.object.order[0].orderNumber]
|
|
127
162
|
});
|
|
128
|
-
|
|
163
|
+
const eventIds = yield repos.order.searchReservationForIdsByOrderNumbers({
|
|
164
|
+
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
165
|
+
});
|
|
166
|
+
const acceptedOffers = yield repos.order.searchAcceptedOffersByOrderNumbers({
|
|
167
|
+
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
168
|
+
});
|
|
169
|
+
return { acceptedOffers, eventIds, offerIds, orders };
|
|
129
170
|
});
|
|
130
171
|
}
|
|
131
172
|
function validateOrder(params) {
|
|
@@ -137,12 +178,9 @@ function validateOrder(params) {
|
|
|
137
178
|
}
|
|
138
179
|
});
|
|
139
180
|
}
|
|
140
|
-
function
|
|
181
|
+
function checkUsedReservationExists(params) {
|
|
141
182
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
|
|
143
|
-
// 販売者都合の場合、特に検証しない
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
183
|
+
let usedReservationExists = false;
|
|
146
184
|
// 注文に含まれる予約の状態検証
|
|
147
185
|
const reservationNumbers = yield repos.order.searchReservationNumbersByOrderNumbers({
|
|
148
186
|
orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
@@ -155,11 +193,38 @@ function validateItems(params) {
|
|
|
155
193
|
typeOf: factory.reservationType.EventReservation,
|
|
156
194
|
reservationNumber: { $in: reservationNumbers },
|
|
157
195
|
attended: true
|
|
158
|
-
});
|
|
196
|
+
}, { _id: 1 });
|
|
159
197
|
if (existingUsedReservations.length > 0) {
|
|
160
|
-
|
|
198
|
+
usedReservationExists = true;
|
|
161
199
|
}
|
|
162
200
|
}
|
|
201
|
+
return { usedReservationExists };
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function validateItems(params) {
|
|
205
|
+
return (__) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
207
|
+
// 販売者都合の場合、特に検証しない
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// アイテムコンディション検証へ移行
|
|
211
|
+
// 注文に含まれる予約の状態検証
|
|
212
|
+
// const reservationNumbers = await repos.order.searchReservationNumbersByOrderNumbers({
|
|
213
|
+
// orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
214
|
+
// });
|
|
215
|
+
// if (reservationNumbers.length > 0) {
|
|
216
|
+
// // 使用済の予約がひとつでもあれば不可
|
|
217
|
+
// const existingUsedReservations = await repos.reservation.search({
|
|
218
|
+
// limit: 1,
|
|
219
|
+
// page: 1,
|
|
220
|
+
// typeOf: factory.reservationType.EventReservation,
|
|
221
|
+
// reservationNumber: { $in: reservationNumbers },
|
|
222
|
+
// attended: true
|
|
223
|
+
// });
|
|
224
|
+
// if (existingUsedReservations.length > 0) {
|
|
225
|
+
// throw new factory.errors.Argument('orderNumber', 'some reservations already used');
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
163
228
|
});
|
|
164
229
|
}
|
|
165
230
|
function searchPoliciesByOffer(params) {
|
|
@@ -186,7 +251,9 @@ function searchPoliciesByOffer(params) {
|
|
|
186
251
|
/**
|
|
187
252
|
* 販売者の返品ポリシーを確認する
|
|
188
253
|
*/
|
|
254
|
+
// tslint:disable-next-line:max-func-body-length
|
|
189
255
|
function findApplicableReturnPolicy(params) {
|
|
256
|
+
var _a;
|
|
190
257
|
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
191
258
|
// 販売者都合の場合、手数料なしの返金返品ポリシーを適用
|
|
192
259
|
return {
|
|
@@ -194,14 +261,23 @@ function findApplicableReturnPolicy(params) {
|
|
|
194
261
|
returnFees: factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn
|
|
195
262
|
};
|
|
196
263
|
}
|
|
197
|
-
|
|
198
|
-
if (!Array.isArray(returnPolicies)) {
|
|
199
|
-
returnPolicies = [];
|
|
200
|
-
}
|
|
264
|
+
const returnPolicies = params.returnPolicies;
|
|
201
265
|
const returningDate = moment(params.returningDate);
|
|
202
|
-
|
|
266
|
+
let applicalbleReturnPolicies = [];
|
|
203
267
|
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
204
|
-
|
|
268
|
+
// 適用可能なポリシーにフィルター
|
|
269
|
+
// tslint:disable-next-line:max-func-body-length
|
|
270
|
+
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
272
|
+
let satisfyMerchantReturnDays = false;
|
|
273
|
+
let offerItemCondition;
|
|
274
|
+
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
275
|
+
if (typeof itemConditionId === 'string') {
|
|
276
|
+
offerItemCondition = params.offerItemConditions.find((o) => o.id === itemConditionId);
|
|
277
|
+
if (offerItemCondition === undefined) {
|
|
278
|
+
throw new factory.errors.NotFound('OfferItemCondition');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
205
281
|
const merchantReturnDays = returnPolicy.merchantReturnDays;
|
|
206
282
|
if (typeof merchantReturnDays === 'number') {
|
|
207
283
|
// 返品適用日数を確認する
|
|
@@ -212,13 +288,78 @@ function findApplicableReturnPolicy(params) {
|
|
|
212
288
|
});
|
|
213
289
|
// 全注文について日数の確認ができれば適用
|
|
214
290
|
if (everyOrderApplicable) {
|
|
215
|
-
|
|
291
|
+
satisfyMerchantReturnDays = true;
|
|
216
292
|
}
|
|
217
293
|
}
|
|
218
294
|
else {
|
|
219
295
|
// 日数制限なし
|
|
220
|
-
|
|
296
|
+
satisfyMerchantReturnDays = true;
|
|
221
297
|
}
|
|
298
|
+
// イベント開始猶予を検証する(2023-05-22~)
|
|
299
|
+
let satisfyItemCondition = true;
|
|
300
|
+
if (offerItemCondition !== undefined) {
|
|
301
|
+
let satisfyGracePeriodMaxValue = true;
|
|
302
|
+
let satisfyGracePeriodMinValue = true;
|
|
303
|
+
// 全イベントについて猶予の確認ができれば適用
|
|
304
|
+
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
305
|
+
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
306
|
+
if (typeof gracePeriodMaxValue === 'number') {
|
|
307
|
+
satisfyGracePeriodMaxValue = params.events.every((event) => {
|
|
308
|
+
return moment(event.startDate)
|
|
309
|
+
.isSameOrBefore(moment(params.returningDate)
|
|
310
|
+
.add(gracePeriodMaxValue, 'seconds'));
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
if (typeof gracePeriodMinValue === 'number') {
|
|
314
|
+
satisfyGracePeriodMinValue = params.events.every((event) => {
|
|
315
|
+
return moment(event.startDate)
|
|
316
|
+
.isAfter(moment(params.returningDate)
|
|
317
|
+
.add(gracePeriodMinValue, 'seconds'));
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
let satisfyGracePeriodInDaysMax = true;
|
|
321
|
+
let satisfyGracePeriodInDaysMin = true;
|
|
322
|
+
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
323
|
+
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
324
|
+
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
325
|
+
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
326
|
+
const maxDate = moment(event.startDate)
|
|
327
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
328
|
+
.startOf('days')
|
|
329
|
+
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
330
|
+
.format('YYYY-MM-DD');
|
|
331
|
+
const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
|
|
332
|
+
debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
|
|
333
|
+
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
|
|
337
|
+
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
338
|
+
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
339
|
+
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
340
|
+
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
341
|
+
const minDate = moment(event.startDate)
|
|
342
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
343
|
+
.startOf('days')
|
|
344
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
345
|
+
.format('YYYY-MM-DD');
|
|
346
|
+
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
347
|
+
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
348
|
+
return returnMaxDate.isAfter(moment(returningDate));
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
352
|
+
let satisfyOnlyUnused = true;
|
|
353
|
+
if (((_k = offerItemCondition.itemOffered.serviceOutput) === null || _k === void 0 ? void 0 : _k.onlyUnused) === true) {
|
|
354
|
+
if (params.usedReservationExists) {
|
|
355
|
+
satisfyOnlyUnused = false;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
debug('usedReservationExists:', params.usedReservationExists, 'satisfyOnlyUnused:', satisfyOnlyUnused);
|
|
359
|
+
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
360
|
+
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin && satisfyOnlyUnused;
|
|
361
|
+
}
|
|
362
|
+
return satisfyMerchantReturnDays && satisfyItemCondition;
|
|
222
363
|
});
|
|
223
364
|
}
|
|
224
365
|
// 販売者にポリシーが存在しなければ返品不可
|
|
@@ -226,13 +367,35 @@ function findApplicableReturnPolicy(params) {
|
|
|
226
367
|
throw new factory.errors.Argument('Seller', 'has no applicable return policies');
|
|
227
368
|
}
|
|
228
369
|
// オファーの返品ポリシーから返品手数料タイプを決定する
|
|
229
|
-
const { returnFees } = validateOffersReturnPolicy({
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
370
|
+
const { returnFees, returnFeesMovieTicket } = validateOffersReturnPolicy({
|
|
371
|
+
acceptedOffers: params.acceptedOffers,
|
|
372
|
+
offers: params.offers,
|
|
373
|
+
policiesByOffer: params.policiesByOffer
|
|
374
|
+
});
|
|
375
|
+
// restockingFeeが最低のポリシーを自動選択
|
|
376
|
+
let appliedReturnPolicy = applicalbleReturnPolicies[0];
|
|
377
|
+
applicalbleReturnPolicies.forEach((returnPolicy) => {
|
|
378
|
+
var _a, _b;
|
|
379
|
+
const appliedReturnPolicyRestockingFeeValue = (_a = appliedReturnPolicy.restockingFee) === null || _a === void 0 ? void 0 : _a.value;
|
|
380
|
+
const restockingFeeValue = (_b = returnPolicy.restockingFee) === null || _b === void 0 ? void 0 : _b.value;
|
|
381
|
+
const appliedReturnPolicyRestockingFee = (typeof appliedReturnPolicyRestockingFeeValue === 'number')
|
|
382
|
+
? appliedReturnPolicyRestockingFeeValue
|
|
383
|
+
: 0;
|
|
384
|
+
const restockingFee = (typeof restockingFeeValue === 'number') ? restockingFeeValue : 0;
|
|
385
|
+
if (restockingFee < appliedReturnPolicyRestockingFee) {
|
|
386
|
+
appliedReturnPolicy = returnPolicy;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
let appliedItemCondition;
|
|
390
|
+
const appliedItemConditionId = (_a = appliedReturnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
391
|
+
if (typeof appliedItemConditionId === 'string') {
|
|
392
|
+
appliedItemCondition = params.offerItemConditions.find((o) => o.id === appliedItemConditionId);
|
|
393
|
+
if (appliedItemCondition === undefined) {
|
|
394
|
+
throw new factory.errors.NotFound('OfferItemCondition');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return Object.assign({ merchantReturnDays: appliedReturnPolicy.merchantReturnDays, restockingFee: appliedReturnPolicy.restockingFee, returnFees,
|
|
398
|
+
returnFeesMovieTicket, typeOf: appliedReturnPolicy.typeOf }, (typeof (appliedItemCondition === null || appliedItemCondition === void 0 ? void 0 : appliedItemCondition.typeOf) === 'string') ? { itemCondition: appliedItemCondition } : undefined);
|
|
236
399
|
}
|
|
237
400
|
/**
|
|
238
401
|
* 注文中のオファーの返品ポリシーを検証
|
|
@@ -271,8 +434,41 @@ function validateOffersReturnPolicy(params) {
|
|
|
271
434
|
else {
|
|
272
435
|
throw new factory.errors.NotImplemented('returnFees not defined');
|
|
273
436
|
}
|
|
274
|
-
//
|
|
275
|
-
|
|
437
|
+
// 決済カード取消ポリシーを確定(2023-05-23~)
|
|
438
|
+
const returnFeesMovieTicket = [];
|
|
439
|
+
params.acceptedOffers.forEach((acceptedOffer) => {
|
|
440
|
+
const unitPriceOffer = params.offers.find((offer) => offer.id === acceptedOffer.id);
|
|
441
|
+
if (unitPriceOffer === undefined) {
|
|
442
|
+
throw new factory.errors.NotFound(`UnitPriceOffer ${acceptedOffer.id}`);
|
|
443
|
+
}
|
|
444
|
+
if (!Array.isArray(unitPriceOffer.hasMerchantReturnPolicy) || unitPriceOffer.hasMerchantReturnPolicy.length === 0) {
|
|
445
|
+
throw new factory.errors.NotFound(`offer.hasMerchantReturnPolicy ${acceptedOffer.id}`);
|
|
446
|
+
}
|
|
447
|
+
const hasMerchantReturnPolicy = unitPriceOffer.hasMerchantReturnPolicy[0];
|
|
448
|
+
const policyByOffer = params.policiesByOffer.find((policy) => policy.id === hasMerchantReturnPolicy.id);
|
|
449
|
+
if (policyByOffer === undefined) {
|
|
450
|
+
throw new factory.errors.NotFound(`MerchantReturnPolicy acceptedOffer:${acceptedOffer.id}`);
|
|
451
|
+
}
|
|
452
|
+
const movieTicketTypeChargeSpecExists = acceptedOffer.priceSpecification.priceComponent.some((component) => {
|
|
453
|
+
return component.typeOf === factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
|
|
454
|
+
});
|
|
455
|
+
if (movieTicketTypeChargeSpecExists) {
|
|
456
|
+
acceptedOffer.priceSpecification.priceComponent.forEach((component) => {
|
|
457
|
+
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
458
|
+
if (Array.isArray(component.appliesToMovieTicket)) {
|
|
459
|
+
component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
460
|
+
returnFeesMovieTicket.push({
|
|
461
|
+
identifier: String(appliesToMovieTicket.identifier),
|
|
462
|
+
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket,
|
|
463
|
+
serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
return { returnFees, returnFeesMovieTicket };
|
|
276
472
|
}
|
|
277
473
|
function validateAppliedReturnPolicy(params) {
|
|
278
474
|
var _a;
|
|
@@ -384,11 +580,7 @@ function exportTasksById(params) {
|
|
|
384
580
|
transaction,
|
|
385
581
|
runsAt: taskRunsAt
|
|
386
582
|
});
|
|
387
|
-
|
|
388
|
-
yield repos.task.saveMany(taskAttributes);
|
|
389
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
390
|
-
// await repos.task.save(taskAttribute);
|
|
391
|
-
// }));
|
|
583
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
392
584
|
});
|
|
393
585
|
}
|
|
394
586
|
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,9 +17,15 @@ 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
|
};
|
|
26
|
+
onResourceUpdated: {
|
|
27
|
+
informResource?: factory.project.IInformParams[];
|
|
28
|
+
};
|
|
21
29
|
maximumReservationGracePeriodInDays: number;
|
|
22
30
|
userPoolIdOld: string;
|
|
23
31
|
userPoolIdNew: string;
|
|
@@ -27,10 +35,13 @@ export type ISettings = factory.project.ISettings & {
|
|
|
27
35
|
useOfferRateLimitProjects: string[];
|
|
28
36
|
};
|
|
29
37
|
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
38
|
+
export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
30
39
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
31
40
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
32
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
33
|
-
export declare const
|
|
42
|
+
export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
|
|
43
|
+
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
44
|
+
export declare const MONGO_MAX_TIME_MS: number;
|
|
34
45
|
/**
|
|
35
46
|
* グローバル設定
|
|
36
47
|
*/
|