@chevre/domain 21.6.0-alpha.7 → 21.6.0-alpha.9
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/migrateMovieAvailabilityStarts.ts +11 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +1 -15
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -3
- package/lib/chevre/service/order/placeOrder.js +10 -5
- package/lib/chevre/service/order/returnOrder.js +5 -1
- package/lib/chevre/service/order/sendOrder.js +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +15 -15
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +15 -42
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +15 -15
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +5 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +5 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +3 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +5 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -21
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +5 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +5 -4
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +17 -13
- package/lib/chevre/service/transaction/returnOrder.js +124 -95
- package/package.json +2 -2
|
@@ -24,6 +24,7 @@ async function main() {
|
|
|
24
24
|
let i = 0;
|
|
25
25
|
let updateCount = 0;
|
|
26
26
|
let datePublishedUndefinedCount = 0;
|
|
27
|
+
let datePublishedIsAfterNowCount = 0;
|
|
27
28
|
await cursor.eachAsync(async (doc) => {
|
|
28
29
|
i += 1;
|
|
29
30
|
const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
|
|
@@ -38,6 +39,14 @@ async function main() {
|
|
|
38
39
|
|
|
39
40
|
if (alreadyMigrated) {
|
|
40
41
|
console.log('already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
42
|
+
|
|
43
|
+
if (moment(movie.datePublished)
|
|
44
|
+
.isAfter(moment())) {
|
|
45
|
+
datePublishedIsAfterNowCount += 1;
|
|
46
|
+
// tslint:disable-next-line:max-line-length
|
|
47
|
+
// throw new Error(`movie.datePublished isAfter now ${movie.project.id} ${movie.id} ${movie.identifier} ${movie.datePublished}`);
|
|
48
|
+
|
|
49
|
+
}
|
|
41
50
|
} else {
|
|
42
51
|
if (movie.datePublished === undefined) {
|
|
43
52
|
console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
|
|
@@ -63,6 +72,8 @@ async function main() {
|
|
|
63
72
|
console.log(i, 'creativeWorks checked');
|
|
64
73
|
console.log(updateCount, 'creativeWorks updated');
|
|
65
74
|
console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
|
|
75
|
+
console.log(datePublishedIsAfterNowCount, 'datePublishedIsAfterNowCount');
|
|
76
|
+
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
main()
|
|
@@ -9,17 +9,6 @@ function createPayActions(params) {
|
|
|
9
9
|
const payObject = createPayObject(params);
|
|
10
10
|
const informPaymentActions = createInformPaymentActions(params);
|
|
11
11
|
if (payObject !== undefined) {
|
|
12
|
-
// const maskedCustomer = createMaskedCustomer(params.order);
|
|
13
|
-
// const simpleOrder: factory.order.ISimpleOrder = {
|
|
14
|
-
// typeOf: params.order.typeOf,
|
|
15
|
-
// seller: params.order.seller,
|
|
16
|
-
// // mask
|
|
17
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
|
|
18
|
-
// orderNumber: params.order.orderNumber,
|
|
19
|
-
// price: params.order.price,
|
|
20
|
-
// priceCurrency: params.order.priceCurrency,
|
|
21
|
-
// orderDate: params.order.orderDate
|
|
22
|
-
// };
|
|
23
12
|
const payPurpose = {
|
|
24
13
|
typeOf: params.order.typeOf,
|
|
25
14
|
confirmationNumber: params.order.confirmationNumber,
|
|
@@ -28,10 +17,7 @@ function createPayActions(params) {
|
|
|
28
17
|
const payAction = Object.assign({ project: params.transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: params.transaction.project, potentialActions: {
|
|
29
18
|
add2report: true,
|
|
30
19
|
informPayment: informPaymentActions
|
|
31
|
-
},
|
|
32
|
-
// optimize(2023-03-20~)
|
|
33
|
-
// purpose: simpleOrder,
|
|
34
|
-
purpose: payPurpose, recipient: {
|
|
20
|
+
}, purpose: payPurpose, recipient: {
|
|
35
21
|
id: params.transaction.recipient.id,
|
|
36
22
|
name: params.transaction.recipient.name,
|
|
37
23
|
typeOf: params.transaction.recipient.typeOf
|
|
@@ -27,10 +27,12 @@ function onOrderStatusChanged(params) {
|
|
|
27
27
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
28
28
|
const simpleOrder = {
|
|
29
29
|
typeOf: params.order.typeOf,
|
|
30
|
-
seller:
|
|
30
|
+
seller: {
|
|
31
|
+
id: params.order.seller.id,
|
|
32
|
+
typeOf: params.order.seller.typeOf,
|
|
33
|
+
name: params.order.seller.name
|
|
34
|
+
},
|
|
31
35
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
32
|
-
// IOrderへ移行(2022-11-17~)
|
|
33
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
34
36
|
orderNumber: params.order.orderNumber,
|
|
35
37
|
price: params.order.price,
|
|
36
38
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -107,12 +107,13 @@ function placeOrderWithoutTransaction(params) {
|
|
|
107
107
|
// アクションを作成する(2022-04-11~)
|
|
108
108
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
109
109
|
const simpleOrder = {
|
|
110
|
-
// project: order.project,
|
|
111
110
|
typeOf: order.typeOf,
|
|
112
|
-
seller:
|
|
111
|
+
seller: {
|
|
112
|
+
id: order.seller.id,
|
|
113
|
+
typeOf: order.seller.typeOf,
|
|
114
|
+
name: order.seller.name
|
|
115
|
+
},
|
|
113
116
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
114
|
-
// IOrderへ移行(2022-11-17~)
|
|
115
|
-
// confirmationNumber: order.confirmationNumber,
|
|
116
117
|
orderNumber: order.orderNumber,
|
|
117
118
|
price: order.price,
|
|
118
119
|
priceCurrency: order.priceCurrency,
|
|
@@ -171,7 +172,11 @@ function placeOrder(params) {
|
|
|
171
172
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
172
173
|
const simpleOrder = {
|
|
173
174
|
typeOf: order.typeOf,
|
|
174
|
-
seller:
|
|
175
|
+
seller: {
|
|
176
|
+
id: order.seller.id,
|
|
177
|
+
typeOf: order.seller.typeOf,
|
|
178
|
+
name: order.seller.name
|
|
179
|
+
},
|
|
175
180
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
176
181
|
orderNumber: order.orderNumber,
|
|
177
182
|
price: order.price,
|
|
@@ -49,7 +49,11 @@ function returnOrder(params) {
|
|
|
49
49
|
}
|
|
50
50
|
const simpleOrder = {
|
|
51
51
|
typeOf: order.typeOf,
|
|
52
|
-
seller:
|
|
52
|
+
seller: {
|
|
53
|
+
id: order.seller.id,
|
|
54
|
+
typeOf: order.seller.typeOf,
|
|
55
|
+
name: order.seller.name
|
|
56
|
+
},
|
|
53
57
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
54
58
|
orderNumber: order.orderNumber,
|
|
55
59
|
price: order.price,
|
|
@@ -48,7 +48,11 @@ function sendOrder(params) {
|
|
|
48
48
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
49
49
|
const simpleOrder = {
|
|
50
50
|
typeOf: order.typeOf,
|
|
51
|
-
seller:
|
|
51
|
+
seller: {
|
|
52
|
+
id: order.seller.id,
|
|
53
|
+
typeOf: order.seller.typeOf,
|
|
54
|
+
name: order.seller.name
|
|
55
|
+
},
|
|
52
56
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
53
57
|
orderNumber: order.orderNumber,
|
|
54
58
|
price: order.price,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
-
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
|
|
2
|
+
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
|
|
@@ -20,15 +20,12 @@ function createStartParams(params, passport, seller, broker) {
|
|
|
20
20
|
seller: {
|
|
21
21
|
id: seller.id,
|
|
22
22
|
name: seller.name,
|
|
23
|
-
typeOf: seller.typeOf
|
|
23
|
+
typeOf: seller.typeOf,
|
|
24
|
+
// 追加特性を追加(2023-08-08~)
|
|
25
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : []
|
|
24
26
|
},
|
|
25
27
|
object: transactionObject,
|
|
26
|
-
// expires: params.expires,
|
|
27
28
|
expiresInSeconds: params.expiresInSeconds
|
|
28
|
-
// 販売者にexpires設定があれば適用
|
|
29
|
-
// ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
|
|
30
|
-
// ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
|
|
31
|
-
// : undefined
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
31
|
exports.createStartParams = createStartParams;
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js
CHANGED
|
@@ -19,6 +19,20 @@ function createGivePointAwardActions(params) {
|
|
|
19
19
|
// インセンティブ付与アクションの指定があればそちらを反映
|
|
20
20
|
const givePointAwardParams = (_a = params.transaction.object.potentialActions) === null || _a === void 0 ? void 0 : _a.givePointAward;
|
|
21
21
|
if (Array.isArray(givePointAwardParams)) {
|
|
22
|
+
const givePointAwardPurpose = {
|
|
23
|
+
typeOf: params.order.typeOf,
|
|
24
|
+
seller: {
|
|
25
|
+
id: params.order.seller.id,
|
|
26
|
+
typeOf: params.order.seller.typeOf,
|
|
27
|
+
name: params.order.seller.name
|
|
28
|
+
},
|
|
29
|
+
// mask
|
|
30
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
31
|
+
orderNumber: params.order.orderNumber,
|
|
32
|
+
price: params.order.price,
|
|
33
|
+
priceCurrency: params.order.priceCurrency,
|
|
34
|
+
orderDate: params.order.orderDate
|
|
35
|
+
};
|
|
22
36
|
// メンバーシップごとに、特典を確認してインセンティブ付与
|
|
23
37
|
givePointAwardParams.forEach((givePointAwardParam) => {
|
|
24
38
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -31,8 +45,6 @@ function createGivePointAwardActions(params) {
|
|
|
31
45
|
project: params.transaction.project,
|
|
32
46
|
typeOf: factory.actionType.GiveAction,
|
|
33
47
|
agent: params.transaction.project,
|
|
34
|
-
// order.customerからrecipientを生成する(2022-05-25~)
|
|
35
|
-
// recipient: params.transaction.agent,
|
|
36
48
|
recipient: {
|
|
37
49
|
typeOf: params.order.customer.typeOf,
|
|
38
50
|
id: params.order.customer.id,
|
|
@@ -42,19 +54,7 @@ function createGivePointAwardActions(params) {
|
|
|
42
54
|
accountNumber: accountNumber,
|
|
43
55
|
issuedThrough: { id: String((_h = (_g = (_f = givePointAwardParam.object) === null || _f === void 0 ? void 0 : _f.toLocation) === null || _g === void 0 ? void 0 : _g.issuedThrough) === null || _h === void 0 ? void 0 : _h.id) }
|
|
44
56
|
}, description: (typeof description === 'string') ? description : '' }, (typeof pointAwardIdentifier === 'string') ? { identifier: pointAwardIdentifier } : undefined),
|
|
45
|
-
purpose:
|
|
46
|
-
// project: params.order.project,
|
|
47
|
-
typeOf: params.order.typeOf,
|
|
48
|
-
seller: params.order.seller,
|
|
49
|
-
// mask
|
|
50
|
-
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
51
|
-
// IOrderへ移行(2022-11-17~)
|
|
52
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
53
|
-
orderNumber: params.order.orderNumber,
|
|
54
|
-
price: params.order.price,
|
|
55
|
-
priceCurrency: params.order.priceCurrency,
|
|
56
|
-
orderDate: params.order.orderDate
|
|
57
|
-
}
|
|
57
|
+
purpose: givePointAwardPurpose
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
});
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js
CHANGED
|
@@ -19,6 +19,20 @@ function createMoneyTransferActions(params) {
|
|
|
19
19
|
.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus)
|
|
20
20
|
.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
21
21
|
.filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
|
|
22
|
+
const moneyTransferPurpose = {
|
|
23
|
+
typeOf: params.order.typeOf,
|
|
24
|
+
seller: {
|
|
25
|
+
id: params.order.seller.id,
|
|
26
|
+
typeOf: params.order.seller.typeOf,
|
|
27
|
+
name: params.order.seller.name
|
|
28
|
+
},
|
|
29
|
+
// mask
|
|
30
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
31
|
+
orderNumber: params.order.orderNumber,
|
|
32
|
+
price: params.order.price,
|
|
33
|
+
priceCurrency: params.order.priceCurrency,
|
|
34
|
+
orderDate: params.order.orderDate
|
|
35
|
+
};
|
|
22
36
|
// const paymentMethod = params.order.paymentMethods[0];
|
|
23
37
|
authorizeMoneyTransferActions.forEach((a) => {
|
|
24
38
|
var _a;
|
|
@@ -33,49 +47,8 @@ function createMoneyTransferActions(params) {
|
|
|
33
47
|
transactionNumber: pendingTransaction.transactionNumber,
|
|
34
48
|
typeOf: factory.assetTransactionType.MoneyTransfer
|
|
35
49
|
},
|
|
36
|
-
// agent: Projectに統一(2022-05-16~)
|
|
37
50
|
agent: params.transaction.project,
|
|
38
|
-
|
|
39
|
-
// ↓recipient廃止(2022-05-16~)
|
|
40
|
-
// recipient: a.recipient,
|
|
41
|
-
// amount: {
|
|
42
|
-
// typeOf: 'MonetaryAmount',
|
|
43
|
-
// currency: pendingTransaction.object.amount.currency,
|
|
44
|
-
// value: pendingTransaction.object.amount.value
|
|
45
|
-
// },
|
|
46
|
-
// fromLocation: (paymentMethod !== undefined)
|
|
47
|
-
// ? {
|
|
48
|
-
// accountId: paymentMethod.accountId,
|
|
49
|
-
// typeOf: paymentMethod.typeOf,
|
|
50
|
-
// name: paymentMethod.name,
|
|
51
|
-
// paymentMethodId: paymentMethod.paymentMethodId,
|
|
52
|
-
// additionalProperty: paymentMethod.additionalProperty
|
|
53
|
-
// }
|
|
54
|
-
// : {
|
|
55
|
-
// typeOf: params.transaction.agent.typeOf,
|
|
56
|
-
// id: params.transaction.agent.id,
|
|
57
|
-
// name: <string>params.transaction.agent.name
|
|
58
|
-
// },
|
|
59
|
-
// toLocation: {
|
|
60
|
-
// typeOf: pendingTransaction.object.toLocation.typeOf,
|
|
61
|
-
// identifier: pendingTransaction.object.toLocation.identifier
|
|
62
|
-
// },
|
|
63
|
-
purpose: {
|
|
64
|
-
// project: params.order.project,
|
|
65
|
-
typeOf: params.order.typeOf,
|
|
66
|
-
seller: params.order.seller,
|
|
67
|
-
// mask
|
|
68
|
-
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
69
|
-
// IOrderへ移行(2022-11-17~)
|
|
70
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
71
|
-
orderNumber: params.order.orderNumber,
|
|
72
|
-
price: params.order.price,
|
|
73
|
-
priceCurrency: params.order.priceCurrency,
|
|
74
|
-
orderDate: params.order.orderDate
|
|
75
|
-
}
|
|
76
|
-
// ...(typeof pendingTransaction.object.description === 'string')
|
|
77
|
-
// ? { description: pendingTransaction.object.description }
|
|
78
|
-
// : {}
|
|
51
|
+
purpose: moneyTransferPurpose
|
|
79
52
|
});
|
|
80
53
|
}
|
|
81
54
|
});
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js
CHANGED
|
@@ -23,6 +23,20 @@ function createRegisterServiceActions(params) {
|
|
|
23
23
|
&& a.object.length > 0
|
|
24
24
|
&& a.object[0].typeOf === factory.offerType.Offer
|
|
25
25
|
&& availableProductTypes_1.availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0);
|
|
26
|
+
const registerServicePurpose = {
|
|
27
|
+
typeOf: params.order.typeOf,
|
|
28
|
+
seller: {
|
|
29
|
+
id: params.order.seller.id,
|
|
30
|
+
typeOf: params.order.seller.typeOf,
|
|
31
|
+
name: params.order.seller.name
|
|
32
|
+
},
|
|
33
|
+
// mask
|
|
34
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
35
|
+
orderNumber: params.order.orderNumber,
|
|
36
|
+
price: params.order.price,
|
|
37
|
+
priceCurrency: params.order.priceCurrency,
|
|
38
|
+
orderDate: params.order.orderDate
|
|
39
|
+
};
|
|
26
40
|
authorizeProductOfferActions.forEach((a) => {
|
|
27
41
|
var _a;
|
|
28
42
|
const actionResult = a.result;
|
|
@@ -42,22 +56,8 @@ function createRegisterServiceActions(params) {
|
|
|
42
56
|
project: params.transaction.project,
|
|
43
57
|
typeOf: factory.actionType.ConfirmAction,
|
|
44
58
|
object: registerServiceObject,
|
|
45
|
-
// agent: Projectに統一(2022-05-16~)
|
|
46
59
|
agent: params.transaction.project,
|
|
47
|
-
|
|
48
|
-
purpose: {
|
|
49
|
-
// project: params.order.project,
|
|
50
|
-
typeOf: params.order.typeOf,
|
|
51
|
-
seller: params.order.seller,
|
|
52
|
-
// mask
|
|
53
|
-
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
54
|
-
// IOrderへ移行(2022-11-17~)
|
|
55
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
56
|
-
orderNumber: params.order.orderNumber,
|
|
57
|
-
price: params.order.price,
|
|
58
|
-
priceCurrency: params.order.priceCurrency,
|
|
59
|
-
orderDate: params.order.orderDate
|
|
60
|
-
},
|
|
60
|
+
purpose: registerServicePurpose,
|
|
61
61
|
potentialActions: Object.assign({}, (orderProgramMembershipTask !== undefined)
|
|
62
62
|
? { orderProgramMembership: [orderProgramMembershipTask] }
|
|
63
63
|
: undefined)
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js
CHANGED
|
@@ -22,11 +22,13 @@ function createSendEmailMessageActions(params) {
|
|
|
22
22
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
23
23
|
const sendActionPurpose = {
|
|
24
24
|
typeOf: params.order.typeOf,
|
|
25
|
-
seller:
|
|
25
|
+
seller: {
|
|
26
|
+
id: params.order.seller.id,
|
|
27
|
+
typeOf: params.order.seller.typeOf,
|
|
28
|
+
name: params.order.seller.name
|
|
29
|
+
},
|
|
26
30
|
// mask
|
|
27
31
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
28
|
-
// IOrderへ移行(2022-11-17~)
|
|
29
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
30
32
|
orderNumber: params.order.orderNumber,
|
|
31
33
|
price: params.order.price,
|
|
32
34
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -30,13 +30,14 @@ function createPotentialActions(params) {
|
|
|
30
30
|
const sendEmailMessageActions = yield (0, sendEmailMessage_1.createSendEmailMessageActions)(params);
|
|
31
31
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
32
32
|
const simpleOrder = {
|
|
33
|
-
// project: params.order.project,
|
|
34
33
|
typeOf: params.order.typeOf,
|
|
35
|
-
seller:
|
|
34
|
+
seller: {
|
|
35
|
+
id: params.order.seller.id,
|
|
36
|
+
typeOf: params.order.seller.typeOf,
|
|
37
|
+
name: params.order.seller.name
|
|
38
|
+
},
|
|
36
39
|
// mask
|
|
37
40
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
38
|
-
// IOrderへ移行(2022-11-17~)
|
|
39
|
-
// confirmationNumber: params.order.confirmationNumber,
|
|
40
41
|
orderNumber: params.order.orderNumber,
|
|
41
42
|
price: params.order.price,
|
|
42
43
|
priceCurrency: params.order.priceCurrency,
|
|
@@ -34,11 +34,11 @@ function createSeller(params) {
|
|
|
34
34
|
var _a;
|
|
35
35
|
const seller = params.transaction.seller;
|
|
36
36
|
return {
|
|
37
|
-
// 最適化(2022-11-15~)
|
|
38
|
-
// project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
|
|
39
37
|
id: seller.id,
|
|
40
38
|
name: (typeof seller.name === 'string') ? seller.name : String((_a = seller.name) === null || _a === void 0 ? void 0 : _a.ja),
|
|
41
|
-
typeOf: seller.typeOf
|
|
39
|
+
typeOf: seller.typeOf,
|
|
40
|
+
// 追加特性を追加(2023-08-08~)
|
|
41
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : []
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function createCustomer(params) {
|
|
@@ -33,7 +33,7 @@ function start(params) {
|
|
|
33
33
|
limit: 1,
|
|
34
34
|
page: 1,
|
|
35
35
|
id: { $eq: params.seller.id }
|
|
36
|
-
}, ['name', 'project', 'typeOf', 'makesOffer'], []);
|
|
36
|
+
}, ['name', 'project', 'typeOf', 'makesOffer', 'additionalProperty'], []);
|
|
37
37
|
const seller = sellers.shift();
|
|
38
38
|
if (seller === undefined) {
|
|
39
39
|
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
@@ -20,11 +20,13 @@ function createReturnMoneyTransferActions(params) {
|
|
|
20
20
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
21
21
|
const purpose = {
|
|
22
22
|
typeOf: order.typeOf,
|
|
23
|
-
seller:
|
|
23
|
+
seller: {
|
|
24
|
+
id: order.seller.id,
|
|
25
|
+
typeOf: order.seller.typeOf,
|
|
26
|
+
name: order.seller.name
|
|
27
|
+
},
|
|
24
28
|
// mask
|
|
25
29
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
26
|
-
// IOrderへ移行(2022-11-17~)
|
|
27
|
-
// confirmationNumber: order.confirmationNumber,
|
|
28
30
|
orderNumber: order.orderNumber,
|
|
29
31
|
price: order.price,
|
|
30
32
|
priceCurrency: order.priceCurrency,
|
|
@@ -40,13 +40,14 @@ function createReturnPaymentMethodPotentialActions(params) {
|
|
|
40
40
|
email: emailCustomization
|
|
41
41
|
});
|
|
42
42
|
const sendActionPurpose = {
|
|
43
|
-
// project: order.project,
|
|
44
43
|
typeOf: order.typeOf,
|
|
45
|
-
seller:
|
|
44
|
+
seller: {
|
|
45
|
+
id: order.seller.id,
|
|
46
|
+
typeOf: order.seller.typeOf,
|
|
47
|
+
name: order.seller.name
|
|
48
|
+
},
|
|
46
49
|
// mask
|
|
47
50
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
48
|
-
// IOrderへ移行(2022-11-17~)
|
|
49
|
-
// confirmationNumber: order.confirmationNumber,
|
|
50
51
|
orderNumber: order.orderNumber,
|
|
51
52
|
price: order.price,
|
|
52
53
|
priceCurrency: order.priceCurrency,
|
|
@@ -75,6 +76,20 @@ function createReturnPaymentMethodActions(params) {
|
|
|
75
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
77
|
const order = params.order;
|
|
77
78
|
const returnPaymentMethodActions = [];
|
|
79
|
+
const returnPaymentMethodPurpose = {
|
|
80
|
+
typeOf: order.typeOf,
|
|
81
|
+
seller: {
|
|
82
|
+
id: order.seller.id,
|
|
83
|
+
typeOf: order.seller.typeOf,
|
|
84
|
+
name: order.seller.name
|
|
85
|
+
},
|
|
86
|
+
// mask
|
|
87
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
88
|
+
orderNumber: order.orderNumber,
|
|
89
|
+
price: order.price,
|
|
90
|
+
priceCurrency: order.priceCurrency,
|
|
91
|
+
orderDate: order.orderDate
|
|
92
|
+
};
|
|
78
93
|
// MovieTicket決済以外について返品ポリシーのreturnFeesを適用する(2022-08-10~)
|
|
79
94
|
const returnFees = params.transaction.object.returnPolicy.returnFees;
|
|
80
95
|
// ReturnFeesCustomerResponsibilityであれば返金はなし、それ以外は返金する
|
|
@@ -104,19 +119,7 @@ function createReturnPaymentMethodActions(params) {
|
|
|
104
119
|
id: order.customer.id,
|
|
105
120
|
name: String(order.customer.name)
|
|
106
121
|
},
|
|
107
|
-
purpose:
|
|
108
|
-
// project: order.project,
|
|
109
|
-
typeOf: order.typeOf,
|
|
110
|
-
seller: order.seller,
|
|
111
|
-
// mask
|
|
112
|
-
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
113
|
-
// IOrderへ移行(2022-11-17~)
|
|
114
|
-
// confirmationNumber: order.confirmationNumber,
|
|
115
|
-
orderNumber: order.orderNumber,
|
|
116
|
-
price: order.price,
|
|
117
|
-
priceCurrency: order.priceCurrency,
|
|
118
|
-
orderDate: order.orderDate
|
|
119
|
-
},
|
|
122
|
+
purpose: returnPaymentMethodPurpose,
|
|
120
123
|
potentialActions: potentialActionsOnRefund
|
|
121
124
|
};
|
|
122
125
|
}))));
|
|
@@ -184,13 +187,14 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
|
184
187
|
name: String(order.customer.name)
|
|
185
188
|
},
|
|
186
189
|
purpose: {
|
|
187
|
-
// project: order.project,
|
|
188
190
|
typeOf: order.typeOf,
|
|
189
|
-
seller:
|
|
191
|
+
seller: {
|
|
192
|
+
id: order.seller.id,
|
|
193
|
+
typeOf: order.seller.typeOf,
|
|
194
|
+
name: order.seller.name
|
|
195
|
+
},
|
|
190
196
|
// mask
|
|
191
197
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
192
|
-
// IOrderへ移行(2022-11-17~)
|
|
193
|
-
// confirmationNumber: order.confirmationNumber,
|
|
194
198
|
orderNumber: order.orderNumber,
|
|
195
199
|
price: order.price,
|
|
196
200
|
priceCurrency: order.priceCurrency,
|
|
@@ -51,11 +51,13 @@ function createReturnPointAwardActions(params) {
|
|
|
51
51
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
52
52
|
const purpose = {
|
|
53
53
|
typeOf: order.typeOf,
|
|
54
|
-
seller:
|
|
54
|
+
seller: {
|
|
55
|
+
id: order.seller.id,
|
|
56
|
+
typeOf: order.seller.typeOf,
|
|
57
|
+
name: order.seller.name
|
|
58
|
+
},
|
|
55
59
|
// mask
|
|
56
60
|
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
57
|
-
// IOrderへ移行(2022-11-17~)
|
|
58
|
-
// confirmationNumber: order.confirmationNumber,
|
|
59
61
|
orderNumber: order.orderNumber,
|
|
60
62
|
price: order.price,
|
|
61
63
|
priceCurrency: order.priceCurrency,
|
|
@@ -18,13 +18,14 @@ function createSendEmailMessaegActionsOnReturn(params) {
|
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const order = params.order;
|
|
20
20
|
const sendActionPurpose = {
|
|
21
|
-
// project: order.project,
|
|
22
21
|
typeOf: order.typeOf,
|
|
23
|
-
seller:
|
|
22
|
+
seller: {
|
|
23
|
+
id: order.seller.id,
|
|
24
|
+
typeOf: order.seller.typeOf,
|
|
25
|
+
name: order.seller.name
|
|
26
|
+
},
|
|
24
27
|
// mask
|
|
25
28
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
26
|
-
// IOrderへ移行(2022-11-17~)
|
|
27
|
-
// confirmationNumber: order.confirmationNumber,
|
|
28
29
|
orderNumber: order.orderNumber,
|
|
29
30
|
price: order.price,
|
|
30
31
|
priceCurrency: order.priceCurrency,
|
|
@@ -43,24 +43,28 @@ function createPotentialActions(params) {
|
|
|
43
43
|
returnPointAward: returnPointAwardActions,
|
|
44
44
|
sendEmailMessage: sendEmailMessaegActionsOnReturn
|
|
45
45
|
};
|
|
46
|
+
const returnOrderObject = {
|
|
47
|
+
typeOf: order.typeOf,
|
|
48
|
+
seller: {
|
|
49
|
+
id: order.seller.id,
|
|
50
|
+
typeOf: order.seller.typeOf,
|
|
51
|
+
name: order.seller.name
|
|
52
|
+
},
|
|
53
|
+
// mask
|
|
54
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
55
|
+
// confirmationNumber: order.confirmationNumber,
|
|
56
|
+
orderNumber: order.orderNumber,
|
|
57
|
+
price: order.price,
|
|
58
|
+
priceCurrency: order.priceCurrency,
|
|
59
|
+
orderDate: order.orderDate,
|
|
60
|
+
dateReturned: params.dateReturned
|
|
61
|
+
};
|
|
46
62
|
// recipientを最低限の情報に
|
|
47
63
|
const recipient = Object.assign({ id: order.seller.id, typeOf: order.seller.typeOf }, (order.seller.name !== undefined) ? { name: order.seller.name } : undefined);
|
|
48
64
|
return {
|
|
49
65
|
project: order.project,
|
|
50
66
|
typeOf: factory.actionType.ReturnAction,
|
|
51
|
-
object:
|
|
52
|
-
project: order.project,
|
|
53
|
-
typeOf: order.typeOf,
|
|
54
|
-
seller: order.seller,
|
|
55
|
-
// mask
|
|
56
|
-
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
57
|
-
confirmationNumber: order.confirmationNumber,
|
|
58
|
-
orderNumber: order.orderNumber,
|
|
59
|
-
price: order.price,
|
|
60
|
-
priceCurrency: order.priceCurrency,
|
|
61
|
-
orderDate: order.orderDate,
|
|
62
|
-
dateReturned: params.dateReturned
|
|
63
|
-
},
|
|
67
|
+
object: returnOrderObject,
|
|
64
68
|
// ↓agentは注文のreturnerに反映される
|
|
65
69
|
agent: {
|
|
66
70
|
typeOf: params.transaction.agent.typeOf,
|
|
@@ -155,8 +155,8 @@ function fixOrders(params) {
|
|
|
155
155
|
// 不要な属性は参照しない
|
|
156
156
|
acceptedOffers: 0,
|
|
157
157
|
customer: 0,
|
|
158
|
-
orderedItem: 0
|
|
159
|
-
paymentMethods: 0
|
|
158
|
+
orderedItem: 0
|
|
159
|
+
// paymentMethods: 0 // 適用決済方法検証に必要
|
|
160
160
|
});
|
|
161
161
|
if (orders.length !== params.object.order.length) {
|
|
162
162
|
throw new factory.errors.NotFound('Order');
|
|
@@ -268,104 +268,20 @@ function findApplicableReturnPolicy(params) {
|
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
270
|
const returnPolicies = params.returnPolicies;
|
|
271
|
-
const returningDate = moment(params.returningDate);
|
|
271
|
+
// const returningDate = moment(params.returningDate);
|
|
272
272
|
let applicalbleReturnPolicies = [];
|
|
273
273
|
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
274
274
|
// 適用可能なポリシーにフィルター
|
|
275
275
|
// tslint:disable-next-line:max-func-body-length
|
|
276
276
|
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const merchantReturnDays = returnPolicy.merchantReturnDays;
|
|
288
|
-
if (typeof merchantReturnDays === 'number') {
|
|
289
|
-
// 返品適用日数を確認する
|
|
290
|
-
const everyOrderApplicable = params.orders.every((order) => {
|
|
291
|
-
const mustBeReturnedUntil = moment(order.orderDate)
|
|
292
|
-
.add(merchantReturnDays, 'days');
|
|
293
|
-
return mustBeReturnedUntil.isSameOrAfter(returningDate);
|
|
294
|
-
});
|
|
295
|
-
// 全注文について日数の確認ができれば適用
|
|
296
|
-
if (everyOrderApplicable) {
|
|
297
|
-
satisfyMerchantReturnDays = true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
// 日数制限なし
|
|
302
|
-
satisfyMerchantReturnDays = true;
|
|
303
|
-
}
|
|
304
|
-
// イベント開始猶予を検証する(2023-05-22~)
|
|
305
|
-
let satisfyItemCondition = true;
|
|
306
|
-
if (offerItemCondition !== undefined) {
|
|
307
|
-
let satisfyGracePeriodMaxValue = true;
|
|
308
|
-
let satisfyGracePeriodMinValue = true;
|
|
309
|
-
// 全イベントについて猶予の確認ができれば適用
|
|
310
|
-
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
311
|
-
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
312
|
-
if (typeof gracePeriodMaxValue === 'number') {
|
|
313
|
-
satisfyGracePeriodMaxValue = params.events.every((event) => {
|
|
314
|
-
return moment(event.startDate)
|
|
315
|
-
.isSameOrBefore(moment(params.returningDate)
|
|
316
|
-
.add(gracePeriodMaxValue, 'seconds'));
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
if (typeof gracePeriodMinValue === 'number') {
|
|
320
|
-
satisfyGracePeriodMinValue = params.events.every((event) => {
|
|
321
|
-
return moment(event.startDate)
|
|
322
|
-
.isAfter(moment(params.returningDate)
|
|
323
|
-
.add(gracePeriodMinValue, 'seconds'));
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
let satisfyGracePeriodInDaysMax = true;
|
|
327
|
-
let satisfyGracePeriodInDaysMin = true;
|
|
328
|
-
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
329
|
-
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
330
|
-
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
331
|
-
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
332
|
-
const maxDate = moment(event.startDate)
|
|
333
|
-
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
334
|
-
.startOf('days')
|
|
335
|
-
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
336
|
-
.format('YYYY-MM-DD');
|
|
337
|
-
const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
|
|
338
|
-
debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
|
|
339
|
-
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
|
|
343
|
-
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
344
|
-
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
345
|
-
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
346
|
-
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
347
|
-
const minDate = moment(event.startDate)
|
|
348
|
-
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
349
|
-
.startOf('days')
|
|
350
|
-
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
351
|
-
.format('YYYY-MM-DD');
|
|
352
|
-
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
353
|
-
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
354
|
-
return returnMaxDate.isAfter(moment(returningDate));
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
358
|
-
let satisfyOnlyUnused = true;
|
|
359
|
-
if (((_k = offerItemCondition.itemOffered.serviceOutput) === null || _k === void 0 ? void 0 : _k.onlyUnused) === true) {
|
|
360
|
-
if (params.usedReservationExists) {
|
|
361
|
-
satisfyOnlyUnused = false;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
debug('usedReservationExists:', params.usedReservationExists, 'satisfyOnlyUnused:', satisfyOnlyUnused);
|
|
365
|
-
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
366
|
-
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin && satisfyOnlyUnused;
|
|
367
|
-
}
|
|
368
|
-
return satisfyMerchantReturnDays && satisfyItemCondition;
|
|
277
|
+
return isSellerReturnPolicyApplicable({
|
|
278
|
+
returnPolicy,
|
|
279
|
+
events: params.events,
|
|
280
|
+
offerItemConditions: params.offerItemConditions,
|
|
281
|
+
orders: params.orders,
|
|
282
|
+
returningDate: params.returningDate,
|
|
283
|
+
usedReservationExists: params.usedReservationExists
|
|
284
|
+
});
|
|
369
285
|
});
|
|
370
286
|
}
|
|
371
287
|
// 販売者にポリシーが存在しなければ返品不可
|
|
@@ -403,6 +319,119 @@ function findApplicableReturnPolicy(params) {
|
|
|
403
319
|
return Object.assign({ merchantReturnDays: appliedReturnPolicy.merchantReturnDays, restockingFee: appliedReturnPolicy.restockingFee, returnFees,
|
|
404
320
|
returnFeesMovieTicket, typeOf: appliedReturnPolicy.typeOf }, (typeof (appliedItemCondition === null || appliedItemCondition === void 0 ? void 0 : appliedItemCondition.typeOf) === 'string') ? { itemCondition: appliedItemCondition } : undefined);
|
|
405
321
|
}
|
|
322
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
323
|
+
function isSellerReturnPolicyApplicable(params) {
|
|
324
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
325
|
+
const returnPolicy = params.returnPolicy;
|
|
326
|
+
const returningDate = moment(params.returningDate);
|
|
327
|
+
let satisfyMerchantReturnDays = false;
|
|
328
|
+
let satisfyApplicablePaymentMethod = false;
|
|
329
|
+
let offerItemCondition;
|
|
330
|
+
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
331
|
+
if (typeof itemConditionId === 'string') {
|
|
332
|
+
offerItemCondition = params.offerItemConditions.find((o) => o.id === itemConditionId);
|
|
333
|
+
if (offerItemCondition === undefined) {
|
|
334
|
+
throw new factory.errors.NotFound('OfferItemCondition');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const merchantReturnDays = returnPolicy.merchantReturnDays;
|
|
338
|
+
if (typeof merchantReturnDays === 'number') {
|
|
339
|
+
// 返品適用日数を確認する
|
|
340
|
+
const everyOrderApplicable = params.orders.every((order) => {
|
|
341
|
+
const mustBeReturnedUntil = moment(order.orderDate)
|
|
342
|
+
.add(merchantReturnDays, 'days');
|
|
343
|
+
return mustBeReturnedUntil.isSameOrAfter(returningDate);
|
|
344
|
+
});
|
|
345
|
+
// 全注文について日数の確認ができれば適用
|
|
346
|
+
if (everyOrderApplicable) {
|
|
347
|
+
satisfyMerchantReturnDays = true;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// 日数制限なし
|
|
352
|
+
satisfyMerchantReturnDays = true;
|
|
353
|
+
}
|
|
354
|
+
// 適用決済方法検証(2023-08-08~)
|
|
355
|
+
const applicablePaymentMethod = returnPolicy.applicablePaymentMethod;
|
|
356
|
+
if (Array.isArray(applicablePaymentMethod)) {
|
|
357
|
+
const everyOrderApplicable = params.orders.every((order) => {
|
|
358
|
+
// 全決済方法区分がapplicablePaymentMethodに含まれれば適用
|
|
359
|
+
return order.paymentMethods.every((paymentMethod) => applicablePaymentMethod.includes(paymentMethod.typeOf));
|
|
360
|
+
});
|
|
361
|
+
// 全注文について確認ができれば適用
|
|
362
|
+
if (everyOrderApplicable) {
|
|
363
|
+
satisfyApplicablePaymentMethod = true;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
satisfyApplicablePaymentMethod = true;
|
|
368
|
+
}
|
|
369
|
+
// イベント開始猶予を検証する(2023-05-22~)
|
|
370
|
+
let satisfyItemCondition = true;
|
|
371
|
+
if (offerItemCondition !== undefined) {
|
|
372
|
+
let satisfyGracePeriodMaxValue = true;
|
|
373
|
+
let satisfyGracePeriodMinValue = true;
|
|
374
|
+
// 全イベントについて猶予の確認ができれば適用
|
|
375
|
+
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
376
|
+
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
377
|
+
if (typeof gracePeriodMaxValue === 'number') {
|
|
378
|
+
satisfyGracePeriodMaxValue = params.events.every((event) => {
|
|
379
|
+
return moment(event.startDate)
|
|
380
|
+
.isSameOrBefore(moment(params.returningDate)
|
|
381
|
+
.add(gracePeriodMaxValue, 'seconds'));
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (typeof gracePeriodMinValue === 'number') {
|
|
385
|
+
satisfyGracePeriodMinValue = params.events.every((event) => {
|
|
386
|
+
return moment(event.startDate)
|
|
387
|
+
.isAfter(moment(params.returningDate)
|
|
388
|
+
.add(gracePeriodMinValue, 'seconds'));
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
let satisfyGracePeriodInDaysMax = true;
|
|
392
|
+
let satisfyGracePeriodInDaysMin = true;
|
|
393
|
+
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
394
|
+
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
395
|
+
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
396
|
+
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
397
|
+
const maxDate = moment(event.startDate)
|
|
398
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
399
|
+
.startOf('days')
|
|
400
|
+
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
401
|
+
.format('YYYY-MM-DD');
|
|
402
|
+
const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
|
|
403
|
+
debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
|
|
404
|
+
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
|
|
408
|
+
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
409
|
+
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
410
|
+
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
411
|
+
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
412
|
+
const minDate = moment(event.startDate)
|
|
413
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
414
|
+
.startOf('days')
|
|
415
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
416
|
+
.format('YYYY-MM-DD');
|
|
417
|
+
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
418
|
+
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
419
|
+
return returnMaxDate.isAfter(moment(returningDate));
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
423
|
+
let satisfyOnlyUnused = true;
|
|
424
|
+
if (((_k = offerItemCondition.itemOffered.serviceOutput) === null || _k === void 0 ? void 0 : _k.onlyUnused) === true) {
|
|
425
|
+
if (params.usedReservationExists) {
|
|
426
|
+
satisfyOnlyUnused = false;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
debug('usedReservationExists:', params.usedReservationExists, 'satisfyOnlyUnused:', satisfyOnlyUnused);
|
|
430
|
+
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
431
|
+
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin && satisfyOnlyUnused;
|
|
432
|
+
}
|
|
433
|
+
return satisfyMerchantReturnDays && satisfyApplicablePaymentMethod && satisfyItemCondition;
|
|
434
|
+
}
|
|
406
435
|
/**
|
|
407
436
|
* 注文中のオファーの返品ポリシーを検証
|
|
408
437
|
*/
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.324.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.324.0-alpha.5",
|
|
13
13
|
"@cinerino/sdk": "3.162.3",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.6.0-alpha.
|
|
120
|
+
"version": "21.6.0-alpha.9"
|
|
121
121
|
}
|