@chevre/domain 21.20.0-alpha.2 → 21.20.0-alpha.20
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/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processAcceptOffer.ts +48 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +82 -53
- package/lib/chevre/repo/acceptedOffer.d.ts +21 -1
- package/lib/chevre/repo/acceptedOffer.js +32 -2
- package/lib/chevre/repo/action.d.ts +3 -3
- package/lib/chevre/repo/action.js +4 -6
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +20 -11
- package/lib/chevre/repo/order.js +28 -9
- package/lib/chevre/repo/orderInTransaction.d.ts +27 -0
- package/lib/chevre/repo/orderInTransaction.js +77 -0
- package/lib/chevre/repo/task.d.ts +0 -2
- package/lib/chevre/repo/task.js +56 -46
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +4 -4
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/any.d.ts +29 -0
- package/lib/chevre/service/offer/any.js +55 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +11 -0
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +12 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +12 -5
- package/lib/chevre/service/offer/eventServiceByCOA.js +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +3 -3
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +11 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +113 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +18 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +38 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +11 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +45 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +10 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +86 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +18 -12
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.js +28 -29
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +68 -30
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard.js +102 -133
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +42 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +632 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
|
@@ -8,122 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.exportTasksById = exports.confirm = exports.start = void 0;
|
|
12
|
+
exports.exportTasksById = exports.confirm = exports.start = exports.preStart = void 0;
|
|
24
13
|
/**
|
|
25
14
|
* 返品取引サービス
|
|
26
15
|
*/
|
|
27
16
|
const createDebug = require("debug");
|
|
28
|
-
const http_status_1 = require("http-status");
|
|
29
17
|
const moment = require("moment-timezone");
|
|
30
|
-
const request = require("request");
|
|
31
18
|
const factory = require("../../factory");
|
|
32
19
|
const factory_1 = require("./returnOrder/exportTasks/factory");
|
|
33
20
|
const potentialActions_1 = require("./returnOrder/potentialActions");
|
|
21
|
+
const preStart_1 = require("./returnOrder/preStart");
|
|
22
|
+
Object.defineProperty(exports, "preStart", { enumerable: true, get: function () { return preStart_1.preStart; } });
|
|
34
23
|
const errorHandler_1 = require("../../errorHandler");
|
|
35
24
|
const debug = createDebug('chevre-domain:service');
|
|
36
25
|
/**
|
|
37
26
|
* 返品取引開始
|
|
38
27
|
*/
|
|
39
28
|
function start(params) {
|
|
40
|
-
// tslint:disable-next-line:max-func-body-length
|
|
41
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const
|
|
43
|
-
const { acceptedOffers, eventIds, offerIds, orders } = yield fixOrders(params)(repos);
|
|
44
|
-
// sellerはorderから自動取得
|
|
45
|
-
const sellers = yield repos.seller.search({
|
|
46
|
-
limit: 1,
|
|
47
|
-
page: 1,
|
|
48
|
-
id: { $eq: String(orders[0].seller.id) }
|
|
49
|
-
}, ['name', 'project', 'hasMerchantReturnPolicy', 'typeOf'], []);
|
|
50
|
-
const seller = sellers.shift();
|
|
51
|
-
if (seller === undefined) {
|
|
52
|
-
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
53
|
-
}
|
|
54
|
-
yield validateOrder({ orders })(repos);
|
|
55
|
-
let offers = [];
|
|
56
|
-
if (offerIds.length > 0) {
|
|
57
|
-
offers = yield repos.offer.search({
|
|
58
|
-
id: { $in: offerIds }
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
// tslint:disable-next-line:no-console
|
|
62
|
-
// console.log('validating ', offers.length, 'offers before starting returnOrder... offerIds:', offerIds);
|
|
63
|
-
// イベント開始日時取得
|
|
64
|
-
let events = [];
|
|
65
|
-
if (eventIds.length > 0) {
|
|
66
|
-
events = yield repos.event.search({
|
|
67
|
-
id: { $in: eventIds },
|
|
68
|
-
typeOf: factory.eventType.ScreeningEvent
|
|
69
|
-
}, ['startDate'], []
|
|
70
|
-
// {
|
|
71
|
-
// startDate: 1
|
|
72
|
-
// }
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
let returnPolicies = seller.hasMerchantReturnPolicy;
|
|
76
|
-
if (!Array.isArray(returnPolicies)) {
|
|
77
|
-
returnPolicies = [];
|
|
78
|
-
}
|
|
79
|
-
// アイテムコンディション取得
|
|
80
|
-
let offerItemConditions = [];
|
|
81
|
-
const itemConditionIds = returnPolicies
|
|
82
|
-
.filter((returnPolicy) => { var _a; return typeof ((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id) === 'string'; })
|
|
83
|
-
.map((returnPolicy) => { var _a; return String((_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id); });
|
|
84
|
-
if (itemConditionIds.length > 0) {
|
|
85
|
-
offerItemConditions = yield repos.offerItemCondition.search({
|
|
86
|
-
id: { $in: itemConditionIds }
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const policiesByOffer = yield searchPoliciesByOffer({ offers })(repos);
|
|
90
|
-
const { usedReservationExists } = yield checkUsedReservationExists({ orders })(repos);
|
|
91
|
-
const { hasMerchantReturnPolicy } = yield repos.project.findById({
|
|
92
|
-
id: seller.project.id,
|
|
93
|
-
inclusion: ['hasMerchantReturnPolicy'],
|
|
94
|
-
exclusion: []
|
|
95
|
-
});
|
|
96
|
-
const appliedReturnPolicy = yield findApplicableReturnPolicy({
|
|
97
|
-
acceptedOffers,
|
|
98
|
-
events,
|
|
99
|
-
offerItemConditions,
|
|
100
|
-
orders,
|
|
101
|
-
returningDate: now,
|
|
102
|
-
reason: params.object.reason,
|
|
103
|
-
returnPolicies,
|
|
104
|
-
returnPolicySettingsByProject: hasMerchantReturnPolicy,
|
|
105
|
-
offers,
|
|
106
|
-
policiesByOffer,
|
|
107
|
-
usedReservationExists
|
|
108
|
-
});
|
|
109
|
-
validateAppliedReturnPolicy({ merchantReturnPolicy: appliedReturnPolicy });
|
|
110
|
-
// アイテム検証
|
|
111
|
-
yield validateItems({ orders, reason: params.object.reason })({ order: repos.order, reservation: repos.reservation });
|
|
112
|
-
const transactionObject = {
|
|
113
|
-
order: orders.map((o) => {
|
|
114
|
-
return { confirmationNumber: o.confirmationNumber, orderNumber: o.orderNumber };
|
|
115
|
-
}),
|
|
116
|
-
returnPolicy: appliedReturnPolicy,
|
|
117
|
-
reason: params.object.reason
|
|
118
|
-
};
|
|
119
|
-
// fix expiresInSeconds(2022-11-30~)
|
|
120
|
-
let expiresInSeconds;
|
|
121
|
-
if (typeof params.expiresInSeconds === 'number') {
|
|
122
|
-
expiresInSeconds = params.expiresInSeconds;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw new factory.errors.ArgumentNull('expiresInSeconds');
|
|
126
|
-
}
|
|
30
|
+
const { transactionObject, expiresInSeconds, seller } = yield (0, preStart_1.preStart)(params)(repos);
|
|
127
31
|
const returnOrderAttributes = {
|
|
128
32
|
project: params.project,
|
|
129
33
|
typeOf: factory.transactionType.ReturnOrder,
|
|
@@ -134,7 +38,6 @@ function start(params) {
|
|
|
134
38
|
name: seller.name
|
|
135
39
|
},
|
|
136
40
|
object: transactionObject,
|
|
137
|
-
// expires: params.expires,
|
|
138
41
|
expiresInSeconds
|
|
139
42
|
};
|
|
140
43
|
let returnOrderTransaction;
|
|
@@ -156,521 +59,6 @@ function start(params) {
|
|
|
156
59
|
});
|
|
157
60
|
}
|
|
158
61
|
exports.start = start;
|
|
159
|
-
function fixOrders(params) {
|
|
160
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
if (!Array.isArray(params.object.order)) {
|
|
162
|
-
params.object.order = [params.object.order];
|
|
163
|
-
}
|
|
164
|
-
// ひとまず同時返品可能な注文数を1に限定(2022-04-28~)
|
|
165
|
-
if (params.object.order.length !== 1) {
|
|
166
|
-
throw new factory.errors.Argument('object.order', 'number of orders must be 1');
|
|
167
|
-
}
|
|
168
|
-
// 注文数を1に限定であれば、findByConfirmationNumberに変更できる(2022-04-28~)
|
|
169
|
-
const orders = yield repos.order.search({
|
|
170
|
-
limit: 1,
|
|
171
|
-
page: 1,
|
|
172
|
-
project: { id: { $eq: params.project.id } },
|
|
173
|
-
confirmationNumbers: [params.object.order[0].confirmationNumber],
|
|
174
|
-
orderNumbers: [params.object.order[0].orderNumber]
|
|
175
|
-
},
|
|
176
|
-
// positive projectionで検索(2023-12-08~)
|
|
177
|
-
{
|
|
178
|
-
confirmationNumber: 1, dateReturned: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
|
|
179
|
-
paymentMethods: 1, price: 1, project: 1, seller: 1, typeOf: 1
|
|
180
|
-
}
|
|
181
|
-
// {
|
|
182
|
-
// // acceptedOffers: 0, // カスタム返品ポリシーに必要
|
|
183
|
-
// customer: 0,
|
|
184
|
-
// orderedItem: 0
|
|
185
|
-
// // paymentMethods: 0 // 適用決済方法検証に必要
|
|
186
|
-
// }
|
|
187
|
-
);
|
|
188
|
-
if (orders.length !== params.object.order.length) {
|
|
189
|
-
throw new factory.errors.NotFound('Order');
|
|
190
|
-
}
|
|
191
|
-
const offerIds = yield repos.acceptedOffer.distinctValues({
|
|
192
|
-
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
193
|
-
}, 'acceptedOffers.id');
|
|
194
|
-
const eventIds = yield repos.acceptedOffer.distinctValues({
|
|
195
|
-
orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
196
|
-
}, 'acceptedOffers.itemOffered.reservationFor.id');
|
|
197
|
-
// const acceptedOffers = await repos.acceptedOffer.searchAcceptedOffersByOrderNumbers({
|
|
198
|
-
// orderNumber: { $in: [params.object.order[0].orderNumber] }
|
|
199
|
-
// });
|
|
200
|
-
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
201
|
-
orderNumber: { $eq: params.object.order[0].orderNumber },
|
|
202
|
-
project: { id: { $eq: params.project.id } }
|
|
203
|
-
});
|
|
204
|
-
return { acceptedOffers, eventIds, offerIds, orders };
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function validateOrder(params) {
|
|
208
|
-
return (__) => __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
// 注文ステータスが配送済の場合のみ受け付け
|
|
210
|
-
const allOrdersDelivered = params.orders.every((o) => o.orderStatus === factory.orderStatus.OrderDelivered);
|
|
211
|
-
if (!allOrdersDelivered) {
|
|
212
|
-
throw new factory.errors.Argument('Order Number', 'Invalid Order Status');
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
function checkUsedReservationExists(params) {
|
|
217
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
-
let usedReservationExists = false;
|
|
219
|
-
// 注文に含まれる予約の状態検証
|
|
220
|
-
// const reservationNumbers = await repos.acceptedOffer.searchReservationNumbersByOrderNumbers({
|
|
221
|
-
// orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
222
|
-
// });
|
|
223
|
-
const reservationNumbers = yield repos.acceptedOffer.distinctValues({
|
|
224
|
-
orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
225
|
-
}, 'acceptedOffers.itemOffered.reservationNumber');
|
|
226
|
-
if (reservationNumbers.length > 0) {
|
|
227
|
-
// 使用済の予約がひとつでもあれば不可
|
|
228
|
-
const existingUsedReservations = yield repos.reservation.search({
|
|
229
|
-
limit: 1,
|
|
230
|
-
page: 1,
|
|
231
|
-
typeOf: factory.reservationType.EventReservation,
|
|
232
|
-
reservationNumber: { $in: reservationNumbers },
|
|
233
|
-
attended: true
|
|
234
|
-
}, { _id: 1 });
|
|
235
|
-
if (existingUsedReservations.length > 0) {
|
|
236
|
-
usedReservationExists = true;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return { usedReservationExists };
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
function validateItems(params) {
|
|
243
|
-
return (__) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
245
|
-
// 販売者都合の場合、特に検証しない
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
// アイテムコンディション検証へ移行
|
|
249
|
-
// 注文に含まれる予約の状態検証
|
|
250
|
-
// const reservationNumbers = await repos.order.searchReservationNumbersByOrderNumbers({
|
|
251
|
-
// orderNumber: { $in: params.orders.map((order) => order.orderNumber) }
|
|
252
|
-
// });
|
|
253
|
-
// if (reservationNumbers.length > 0) {
|
|
254
|
-
// // 使用済の予約がひとつでもあれば不可
|
|
255
|
-
// const existingUsedReservations = await repos.reservation.search({
|
|
256
|
-
// limit: 1,
|
|
257
|
-
// page: 1,
|
|
258
|
-
// typeOf: factory.reservationType.EventReservation,
|
|
259
|
-
// reservationNumber: { $in: reservationNumbers },
|
|
260
|
-
// attended: true
|
|
261
|
-
// });
|
|
262
|
-
// if (existingUsedReservations.length > 0) {
|
|
263
|
-
// throw new factory.errors.Argument('orderNumber', 'some reservations already used');
|
|
264
|
-
// }
|
|
265
|
-
// }
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function searchPoliciesByOffer(params) {
|
|
269
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
let merchantReturnPolicyIds = [];
|
|
271
|
-
params.offers.forEach((offer) => {
|
|
272
|
-
if (Array.isArray(offer.hasMerchantReturnPolicy) && offer.hasMerchantReturnPolicy.length > 0) {
|
|
273
|
-
merchantReturnPolicyIds.push(offer.hasMerchantReturnPolicy[0].id);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
merchantReturnPolicyIds = [...new Set(merchantReturnPolicyIds)];
|
|
277
|
-
let policiesByOffer = [];
|
|
278
|
-
if (merchantReturnPolicyIds.length > 0) {
|
|
279
|
-
policiesByOffer = yield repos.merchantReturnPolicy.search({
|
|
280
|
-
id: { $in: merchantReturnPolicyIds }
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (merchantReturnPolicyIds.length !== policiesByOffer.length) {
|
|
284
|
-
throw new factory.errors.NotFound('MerchantReturnPolicy with offers');
|
|
285
|
-
}
|
|
286
|
-
return policiesByOffer;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
function createOrder4returnPolicy(params) {
|
|
290
|
-
return {
|
|
291
|
-
orderDate: params.order.orderDate,
|
|
292
|
-
orderNumber: params.order.orderNumber,
|
|
293
|
-
price: params.order.price,
|
|
294
|
-
acceptedOffers: params.order.acceptedOffers.map((o) => {
|
|
295
|
-
var _a;
|
|
296
|
-
if (o.itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
297
|
-
const reservation = o.itemOffered;
|
|
298
|
-
const priceComponent = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent;
|
|
299
|
-
return {
|
|
300
|
-
itemOffered: {
|
|
301
|
-
additionalProperty: reservation.additionalProperty,
|
|
302
|
-
reservationFor: {
|
|
303
|
-
doorTime: reservation.reservationFor.doorTime,
|
|
304
|
-
endDate: reservation.reservationFor.endDate,
|
|
305
|
-
startDate: reservation.reservationFor.startDate
|
|
306
|
-
// superEvent: reservation.reservationFor.superEvent
|
|
307
|
-
},
|
|
308
|
-
reservedTicket: {
|
|
309
|
-
ticketedSeat: reservation.reservedTicket.ticketedSeat
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
priceSpecification: {
|
|
313
|
-
priceComponent: (Array.isArray(priceComponent))
|
|
314
|
-
? priceComponent.map((component) => {
|
|
315
|
-
const { accounting, name, priceCurrency, valueAddedTaxIncluded } = component, postingComponent = __rest(component, ["accounting", "name", "priceCurrency", "valueAddedTaxIncluded"]);
|
|
316
|
-
return postingComponent;
|
|
317
|
-
})
|
|
318
|
-
: []
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
return {
|
|
324
|
-
priceSpecification: o.priceSpecification
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
})
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
const TIMEOUT = 5000;
|
|
331
|
-
function getReturnPolicyByProject(params) {
|
|
332
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
333
|
-
return new Promise((resolve, reject) => {
|
|
334
|
-
request.post({
|
|
335
|
-
url: params.sameAs,
|
|
336
|
-
body: {
|
|
337
|
-
order: createOrder4returnPolicy({ order: params.order })
|
|
338
|
-
},
|
|
339
|
-
json: true,
|
|
340
|
-
timeout: TIMEOUT
|
|
341
|
-
}, (error, response, body) => {
|
|
342
|
-
var _a;
|
|
343
|
-
if (error instanceof Error) {
|
|
344
|
-
reject(error);
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
switch (response.statusCode) {
|
|
348
|
-
case http_status_1.OK:
|
|
349
|
-
case http_status_1.CREATED:
|
|
350
|
-
case http_status_1.ACCEPTED:
|
|
351
|
-
case http_status_1.NO_CONTENT:
|
|
352
|
-
if (typeof ((_a = body.restockingFee) === null || _a === void 0 ? void 0 : _a.value) !== 'number') {
|
|
353
|
-
reject(new Error('invalid return policy'));
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
resolve({
|
|
357
|
-
typeOf: 'MerchantReturnPolicy',
|
|
358
|
-
restockingFee: {
|
|
359
|
-
currency: factory.priceCurrency.JPY,
|
|
360
|
-
typeOf: 'MonetaryAmount',
|
|
361
|
-
value: body.restockingFee.value
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
break;
|
|
366
|
-
case http_status_1.NOT_FOUND:
|
|
367
|
-
reject(new factory.errors.Argument('Seller', 'has no applicable return policies'));
|
|
368
|
-
break;
|
|
369
|
-
default:
|
|
370
|
-
reject({
|
|
371
|
-
statusCode: response.statusCode,
|
|
372
|
-
body: body
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* 販売者の返品ポリシーを確認する
|
|
382
|
-
*/
|
|
383
|
-
// tslint:disable-next-line:max-func-body-length
|
|
384
|
-
function findApplicableReturnPolicy(params) {
|
|
385
|
-
var _a, _b;
|
|
386
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
387
|
-
if (params.reason === factory.transaction.returnOrder.Reason.Seller) {
|
|
388
|
-
// 販売者都合の場合、手数料なしの返金返品ポリシーを適用
|
|
389
|
-
return {
|
|
390
|
-
typeOf: 'MerchantReturnPolicy',
|
|
391
|
-
returnFees: factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
const returnPolicies = params.returnPolicies;
|
|
395
|
-
let applicalbleReturnPolicies = [];
|
|
396
|
-
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
397
|
-
// プロジェクトの返品ポリシー設定を考慮(2023-11-14~)
|
|
398
|
-
const returnPolicySameAsByPoject = (_a = params.returnPolicySettingsByProject) === null || _a === void 0 ? void 0 : _a.sameAs;
|
|
399
|
-
if (typeof returnPolicySameAsByPoject === 'string' && returnPolicySameAsByPoject.length > 0) {
|
|
400
|
-
const returnPolicyByProject = yield getReturnPolicyByProject({
|
|
401
|
-
sameAs: returnPolicySameAsByPoject,
|
|
402
|
-
order: Object.assign(Object.assign({}, params.orders[0]), { acceptedOffers: params.acceptedOffers })
|
|
403
|
-
});
|
|
404
|
-
applicalbleReturnPolicies.push(returnPolicyByProject);
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
// 適用可能なポリシーにフィルター
|
|
408
|
-
// tslint:disable-next-line:max-func-body-length
|
|
409
|
-
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
410
|
-
return isSellerReturnPolicyApplicable({
|
|
411
|
-
returnPolicy,
|
|
412
|
-
events: params.events,
|
|
413
|
-
offerItemConditions: params.offerItemConditions,
|
|
414
|
-
orders: params.orders,
|
|
415
|
-
returningDate: params.returningDate,
|
|
416
|
-
usedReservationExists: params.usedReservationExists
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
// 販売者にポリシーが存在しなければ返品不可
|
|
422
|
-
if (applicalbleReturnPolicies.length === 0) {
|
|
423
|
-
throw new factory.errors.Argument('Seller', 'has no applicable return policies');
|
|
424
|
-
}
|
|
425
|
-
// オファーの返品ポリシーから返品手数料タイプを決定する
|
|
426
|
-
const { returnFees, returnFeesMovieTicket } = validateOffersReturnPolicy({
|
|
427
|
-
acceptedOffers: params.acceptedOffers,
|
|
428
|
-
offers: params.offers,
|
|
429
|
-
policiesByOffer: params.policiesByOffer
|
|
430
|
-
});
|
|
431
|
-
// restockingFeeが最低のポリシーを自動選択
|
|
432
|
-
let appliedReturnPolicy = applicalbleReturnPolicies[0];
|
|
433
|
-
applicalbleReturnPolicies.forEach((returnPolicy) => {
|
|
434
|
-
var _a, _b;
|
|
435
|
-
const appliedReturnPolicyRestockingFeeValue = (_a = appliedReturnPolicy.restockingFee) === null || _a === void 0 ? void 0 : _a.value;
|
|
436
|
-
const restockingFeeValue = (_b = returnPolicy.restockingFee) === null || _b === void 0 ? void 0 : _b.value;
|
|
437
|
-
const appliedReturnPolicyRestockingFee = (typeof appliedReturnPolicyRestockingFeeValue === 'number')
|
|
438
|
-
? appliedReturnPolicyRestockingFeeValue
|
|
439
|
-
: 0;
|
|
440
|
-
const restockingFee = (typeof restockingFeeValue === 'number') ? restockingFeeValue : 0;
|
|
441
|
-
if (restockingFee < appliedReturnPolicyRestockingFee) {
|
|
442
|
-
appliedReturnPolicy = returnPolicy;
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
let appliedItemCondition;
|
|
446
|
-
const appliedItemConditionId = (_b = appliedReturnPolicy.itemCondition) === null || _b === void 0 ? void 0 : _b.id;
|
|
447
|
-
if (typeof appliedItemConditionId === 'string') {
|
|
448
|
-
appliedItemCondition = params.offerItemConditions.find((o) => o.id === appliedItemConditionId);
|
|
449
|
-
if (appliedItemCondition === undefined) {
|
|
450
|
-
throw new factory.errors.NotFound('OfferItemCondition');
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return Object.assign({ merchantReturnDays: appliedReturnPolicy.merchantReturnDays, restockingFee: appliedReturnPolicy.restockingFee, returnFees,
|
|
454
|
-
returnFeesMovieTicket, typeOf: appliedReturnPolicy.typeOf }, (typeof (appliedItemCondition === null || appliedItemCondition === void 0 ? void 0 : appliedItemCondition.typeOf) === 'string') ? { itemCondition: appliedItemCondition } : undefined);
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
458
|
-
function isSellerReturnPolicyApplicable(params) {
|
|
459
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
460
|
-
const returnPolicy = params.returnPolicy;
|
|
461
|
-
const returningDate = moment(params.returningDate);
|
|
462
|
-
let satisfyMerchantReturnDays = false;
|
|
463
|
-
let satisfyApplicablePaymentMethod = false;
|
|
464
|
-
let offerItemCondition;
|
|
465
|
-
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
466
|
-
if (typeof itemConditionId === 'string') {
|
|
467
|
-
offerItemCondition = params.offerItemConditions.find((o) => o.id === itemConditionId);
|
|
468
|
-
if (offerItemCondition === undefined) {
|
|
469
|
-
throw new factory.errors.NotFound('OfferItemCondition');
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
const merchantReturnDays = returnPolicy.merchantReturnDays;
|
|
473
|
-
if (typeof merchantReturnDays === 'number') {
|
|
474
|
-
// 返品適用日数を確認する
|
|
475
|
-
const everyOrderApplicable = params.orders.every((order) => {
|
|
476
|
-
const mustBeReturnedUntil = moment(order.orderDate)
|
|
477
|
-
.add(merchantReturnDays, 'days');
|
|
478
|
-
return mustBeReturnedUntil.isSameOrAfter(returningDate);
|
|
479
|
-
});
|
|
480
|
-
// 全注文について日数の確認ができれば適用
|
|
481
|
-
if (everyOrderApplicable) {
|
|
482
|
-
satisfyMerchantReturnDays = true;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
// 日数制限なし
|
|
487
|
-
satisfyMerchantReturnDays = true;
|
|
488
|
-
}
|
|
489
|
-
// 適用決済方法検証(2023-08-08~)
|
|
490
|
-
const applicablePaymentMethod = returnPolicy.applicablePaymentMethod;
|
|
491
|
-
if (Array.isArray(applicablePaymentMethod)) {
|
|
492
|
-
const everyOrderApplicable = params.orders.every((order) => {
|
|
493
|
-
// 全決済方法区分がapplicablePaymentMethodに含まれれば適用
|
|
494
|
-
return order.paymentMethods.every((invoice) => {
|
|
495
|
-
var _a;
|
|
496
|
-
return typeof ((_a = invoice.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier) === 'string'
|
|
497
|
-
&& applicablePaymentMethod.includes(invoice.paymentMethod.identifier);
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
// 全注文について確認ができれば適用
|
|
501
|
-
if (everyOrderApplicable) {
|
|
502
|
-
satisfyApplicablePaymentMethod = true;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
satisfyApplicablePaymentMethod = true;
|
|
507
|
-
}
|
|
508
|
-
// イベント開始猶予を検証する(2023-05-22~)
|
|
509
|
-
let satisfyItemCondition = true;
|
|
510
|
-
if (offerItemCondition !== undefined) {
|
|
511
|
-
let satisfyGracePeriodMaxValue = true;
|
|
512
|
-
let satisfyGracePeriodMinValue = true;
|
|
513
|
-
// 全イベントについて猶予の確認ができれば適用
|
|
514
|
-
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
515
|
-
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
516
|
-
if (typeof gracePeriodMaxValue === 'number') {
|
|
517
|
-
satisfyGracePeriodMaxValue = params.events.every((event) => {
|
|
518
|
-
return moment(event.startDate)
|
|
519
|
-
.isSameOrBefore(moment(params.returningDate)
|
|
520
|
-
.add(gracePeriodMaxValue, 'seconds'));
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
if (typeof gracePeriodMinValue === 'number') {
|
|
524
|
-
satisfyGracePeriodMinValue = params.events.every((event) => {
|
|
525
|
-
return moment(event.startDate)
|
|
526
|
-
.isAfter(moment(params.returningDate)
|
|
527
|
-
.add(gracePeriodMinValue, 'seconds'));
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
let satisfyGracePeriodInDaysMax = true;
|
|
531
|
-
let satisfyGracePeriodInDaysMin = true;
|
|
532
|
-
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
533
|
-
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
534
|
-
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
535
|
-
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
536
|
-
const maxDate = moment(event.startDate)
|
|
537
|
-
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
538
|
-
.startOf('days')
|
|
539
|
-
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
540
|
-
.format('YYYY-MM-DD');
|
|
541
|
-
const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
|
|
542
|
-
debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
|
|
543
|
-
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
|
|
547
|
-
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
548
|
-
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
549
|
-
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
550
|
-
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
551
|
-
const minDate = moment(event.startDate)
|
|
552
|
-
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
553
|
-
.startOf('days')
|
|
554
|
-
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
555
|
-
.format('YYYY-MM-DD');
|
|
556
|
-
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
557
|
-
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
558
|
-
return returnMaxDate.isAfter(moment(returningDate));
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
562
|
-
let satisfyOnlyUnused = true;
|
|
563
|
-
if (((_k = offerItemCondition.itemOffered.serviceOutput) === null || _k === void 0 ? void 0 : _k.onlyUnused) === true) {
|
|
564
|
-
if (params.usedReservationExists) {
|
|
565
|
-
satisfyOnlyUnused = false;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
debug('usedReservationExists:', params.usedReservationExists, 'satisfyOnlyUnused:', satisfyOnlyUnused);
|
|
569
|
-
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
570
|
-
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin && satisfyOnlyUnused;
|
|
571
|
-
}
|
|
572
|
-
return satisfyMerchantReturnDays && satisfyApplicablePaymentMethod && satisfyItemCondition;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* 注文中のオファーの返品ポリシーを検証
|
|
576
|
-
*/
|
|
577
|
-
function validateOffersReturnPolicy(params) {
|
|
578
|
-
// オファーに返品ポリシーが設定されているか?
|
|
579
|
-
const everyOffersHaveReturnPolicy = params.offers.every((offer) => {
|
|
580
|
-
return Array.isArray(offer.hasMerchantReturnPolicy) && offer.hasMerchantReturnPolicy.length > 0;
|
|
581
|
-
});
|
|
582
|
-
if (!everyOffersHaveReturnPolicy) {
|
|
583
|
-
throw new factory.errors.NotFound('offer.hasMerchantReturnPolicy');
|
|
584
|
-
}
|
|
585
|
-
let returnFees;
|
|
586
|
-
// 返品手数料設定はどうか?
|
|
587
|
-
const somePolicyWithReturnFeesCustomerResponsibility = params.policiesByOffer.some((policy) => {
|
|
588
|
-
return policy.customerRemorseReturnFees === factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility;
|
|
589
|
-
});
|
|
590
|
-
const somePolicyWithRestockingFees = params.policiesByOffer.some((policy) => {
|
|
591
|
-
return policy.customerRemorseReturnFees === factory.merchantReturnPolicy.ReturnFeesEnumeration.RestockingFees;
|
|
592
|
-
});
|
|
593
|
-
const everyPolicyWithFreeReturn = params.policiesByOffer.every((policy) => {
|
|
594
|
-
return policy.customerRemorseReturnFees === factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn;
|
|
595
|
-
});
|
|
596
|
-
if (somePolicyWithReturnFeesCustomerResponsibility) {
|
|
597
|
-
// ひとつでも返金なしがあれば返金なし
|
|
598
|
-
returnFees = factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility;
|
|
599
|
-
}
|
|
600
|
-
else if (somePolicyWithRestockingFees) {
|
|
601
|
-
// ひとつでも手数料あり返金があれば手数料あり返金
|
|
602
|
-
returnFees = factory.merchantReturnPolicy.ReturnFeesEnumeration.RestockingFees;
|
|
603
|
-
}
|
|
604
|
-
else if (everyPolicyWithFreeReturn) {
|
|
605
|
-
// 全ポリシーが手数料なしであれば手数料なし返金
|
|
606
|
-
returnFees = factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn;
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
throw new factory.errors.NotImplemented('returnFees not defined');
|
|
610
|
-
}
|
|
611
|
-
// 決済カード取消ポリシーを確定(2023-05-23~)
|
|
612
|
-
const returnFeesMovieTicket = [];
|
|
613
|
-
params.acceptedOffers.forEach((acceptedOffer) => {
|
|
614
|
-
var _a, _b;
|
|
615
|
-
const unitPriceOffer = params.offers.find((offer) => offer.id === acceptedOffer.id);
|
|
616
|
-
if (unitPriceOffer === undefined) {
|
|
617
|
-
throw new factory.errors.NotFound(`UnitPriceOffer ${acceptedOffer.id}`);
|
|
618
|
-
}
|
|
619
|
-
if (!Array.isArray(unitPriceOffer.hasMerchantReturnPolicy) || unitPriceOffer.hasMerchantReturnPolicy.length === 0) {
|
|
620
|
-
throw new factory.errors.NotFound(`offer.hasMerchantReturnPolicy ${acceptedOffer.id}`);
|
|
621
|
-
}
|
|
622
|
-
const hasMerchantReturnPolicy = unitPriceOffer.hasMerchantReturnPolicy[0];
|
|
623
|
-
const policyByOffer = params.policiesByOffer.find((policy) => policy.id === hasMerchantReturnPolicy.id);
|
|
624
|
-
if (policyByOffer === undefined) {
|
|
625
|
-
throw new factory.errors.NotFound(`MerchantReturnPolicy acceptedOffer:${acceptedOffer.id}`);
|
|
626
|
-
}
|
|
627
|
-
const movieTicketTypeChargeSpecExists = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent.some((component) => {
|
|
628
|
-
return component.typeOf === factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
|
|
629
|
-
});
|
|
630
|
-
if (movieTicketTypeChargeSpecExists === true) {
|
|
631
|
-
(_b = acceptedOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent.forEach((component) => {
|
|
632
|
-
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
633
|
-
if (Array.isArray(component.appliesToMovieTicket)) {
|
|
634
|
-
component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
635
|
-
returnFeesMovieTicket.push({
|
|
636
|
-
identifier: String(appliesToMovieTicket.identifier),
|
|
637
|
-
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket,
|
|
638
|
-
serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
return { returnFees, returnFeesMovieTicket };
|
|
647
|
-
}
|
|
648
|
-
function validateAppliedReturnPolicy(params) {
|
|
649
|
-
var _a;
|
|
650
|
-
const appliedReturnPolicy = params.merchantReturnPolicy;
|
|
651
|
-
switch (appliedReturnPolicy.returnFees) {
|
|
652
|
-
case factory.merchantReturnPolicy.ReturnFeesEnumeration.RestockingFees:
|
|
653
|
-
// 返品ポリシーに返品手数料が定義されていれば、金額設定が必須
|
|
654
|
-
if (typeof appliedReturnPolicy.restockingFee === 'number') {
|
|
655
|
-
throw new factory.errors.NotImplemented('restockingFee in type of number not implemented');
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
const returnFeeByPolicy = (_a = appliedReturnPolicy.restockingFee) === null || _a === void 0 ? void 0 : _a.value;
|
|
659
|
-
if (typeof returnFeeByPolicy !== 'number') {
|
|
660
|
-
throw new factory.errors.NotFound('appliedReturnPolicy.restockingFee.value');
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
break;
|
|
664
|
-
case factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn:
|
|
665
|
-
// 返品手数料設定不要なのでスルー
|
|
666
|
-
break;
|
|
667
|
-
case factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility:
|
|
668
|
-
// 返金処理なしなのでスルー
|
|
669
|
-
break;
|
|
670
|
-
default:
|
|
671
|
-
throw new factory.errors.NotImplemented(`returnFees of returnPolicy: ${appliedReturnPolicy.returnFees} not implemented`);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
62
|
/**
|
|
675
63
|
* 取引確定
|
|
676
64
|
*/
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -37,13 +37,15 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
|
37
37
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
38
38
|
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
39
39
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
40
|
-
export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
|
|
41
40
|
export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
|
|
42
41
|
export declare const USE_ORDER_PAYMENT_METHOD_TYPE_OF: boolean;
|
|
43
42
|
export declare const USE_FETCH_API: boolean;
|
|
43
|
+
export declare const USE_SEND_ORDER_ON_ORDER_PROCESSING: boolean;
|
|
44
|
+
export declare const USE_ORDER_IN_TRANSIT: boolean;
|
|
44
45
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
45
46
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
46
47
|
export declare const MONGO_AUTO_INDEX: boolean;
|
|
48
|
+
export declare const DELIVER_ORDER_LIMIT: number;
|
|
47
49
|
/**
|
|
48
50
|
* グローバル設定
|
|
49
51
|
*/
|