@chevre/domain 21.2.0-alpha.64 → 21.2.0-alpha.66
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.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const result = await chevre.service.transaction.returnOrder.start({
|
|
12
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
13
|
+
expiresInSeconds: 60,
|
|
14
|
+
agent: { id: 'xxx', typeOf: chevre.factory.creativeWorkType.WebApplication },
|
|
15
|
+
object: {
|
|
16
|
+
order: [{
|
|
17
|
+
confirmationNumber: '99916',
|
|
18
|
+
orderNumber: 'TTT2-8507485-9273468'
|
|
19
|
+
}],
|
|
20
|
+
reason: chevre.factory.transaction.returnOrder.Reason.Customer
|
|
21
|
+
},
|
|
22
|
+
seller: {
|
|
23
|
+
id: 'xxx'
|
|
24
|
+
}
|
|
25
|
+
})({
|
|
26
|
+
event: new chevre.repository.Event(mongoose.connection),
|
|
27
|
+
merchantReturnPolicy: new chevre.repository.MerchantReturnPolicy(mongoose.connection),
|
|
28
|
+
offer: new chevre.repository.Offer(mongoose.connection),
|
|
29
|
+
offerItemCondition: new chevre.repository.OfferItemCondition(mongoose.connection),
|
|
30
|
+
order: new chevre.repository.Order(mongoose.connection),
|
|
31
|
+
reservation: new chevre.repository.Reservation(mongoose.connection),
|
|
32
|
+
seller: new chevre.repository.Seller(mongoose.connection),
|
|
33
|
+
transaction: new chevre.repository.Transaction(mongoose.connection)
|
|
34
|
+
});
|
|
35
|
+
console.log(result);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main()
|
|
39
|
+
.then(console.log)
|
|
40
|
+
.catch(console.error);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
3
|
+
|
|
4
|
+
const startDate = moment('2023-05-27T00:00:00Z')
|
|
5
|
+
.toDate();
|
|
6
|
+
const gracePeriodBeforeStartInDaysMin = {
|
|
7
|
+
timezone: 'Asia/Tokyo',
|
|
8
|
+
time: '09:38:00',
|
|
9
|
+
period: { value: 3 }
|
|
10
|
+
};
|
|
11
|
+
const returningDate = new Date();
|
|
12
|
+
|
|
13
|
+
const minDate: string = moment(startDate)
|
|
14
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
15
|
+
.startOf('days')
|
|
16
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
17
|
+
.format('YYYY-MM-DD');
|
|
18
|
+
console.log('minDate:', minDate);
|
|
19
|
+
|
|
20
|
+
const returnMaxDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`)
|
|
21
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone);
|
|
22
|
+
console.log(returnMaxDate);
|
|
23
|
+
|
|
24
|
+
console.log(returnMaxDate.isSameOrAfter(moment(returningDate)));
|
|
@@ -133,31 +133,39 @@ exports.createReturnPaymentMethodActions = createReturnPaymentMethodActions;
|
|
|
133
133
|
function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
135
|
const order = params.order;
|
|
136
|
-
const
|
|
136
|
+
const returnFeesMovieTicketByTransaction = params.transaction.object.returnPolicy.returnFeesMovieTicket;
|
|
137
137
|
return Promise.all(params.order.paymentMethods
|
|
138
138
|
.filter((paymentMethod) => {
|
|
139
139
|
return paymentMethod.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
140
140
|
})
|
|
141
|
-
//
|
|
141
|
+
// 決済カード着券取消有無設定を適用
|
|
142
142
|
.filter((paymentMethod) => {
|
|
143
|
-
|
|
143
|
+
// デフォルトで実行する
|
|
144
|
+
let returnPaymentMethod = true;
|
|
144
145
|
const movieTicketIdentifier = paymentMethod.accountId;
|
|
145
|
-
const
|
|
146
|
+
const returnFeesMovieTicketSettingsByIdentifier = returnFeesMovieTicketByTransaction === null || returnFeesMovieTicketByTransaction === void 0 ? void 0 : returnFeesMovieTicketByTransaction.filter((r) => {
|
|
147
|
+
var _a;
|
|
148
|
+
return r.identifier === String(movieTicketIdentifier)
|
|
149
|
+
&& ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === paymentMethod.typeOf;
|
|
150
|
+
});
|
|
146
151
|
// 設定がなければスルー
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
if (Array.isArray(returnFeesMovieTicketSettingsByIdentifier) && returnFeesMovieTicketSettingsByIdentifier.length > 0) {
|
|
153
|
+
returnFeesMovieTicketSettingsByIdentifier.forEach((returnFeesMovieTicketSetting) => {
|
|
154
|
+
const returnFeesEnumeration = returnFeesMovieTicketSetting.returnFees;
|
|
155
|
+
switch (returnFeesEnumeration) {
|
|
156
|
+
case factory.merchantReturnPolicy.ReturnFeesEnumeration.FreeReturn:
|
|
157
|
+
break;
|
|
158
|
+
// ひとつでも「取消を実行しない」に設定されていれば、実行しない
|
|
159
|
+
case factory.merchantReturnPolicy.ReturnFeesEnumeration.ReturnFeesCustomerResponsibility:
|
|
160
|
+
// 取消実行しない
|
|
161
|
+
returnPaymentMethod = false;
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
throw new factory.errors.NotImplemented(`returnFees ${returnFeesEnumeration} not implemented`);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
160
167
|
}
|
|
168
|
+
return returnPaymentMethod;
|
|
161
169
|
})
|
|
162
170
|
.map((p) => __awaiter(this, void 0, void 0, function* () {
|
|
163
171
|
const potentialActionsOnRefund = yield createReturnPaymentMethodPotentialActions({
|
|
@@ -13,11 +13,13 @@ 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
|
*/
|
|
@@ -236,7 +238,7 @@ function findApplicableReturnPolicy(params) {
|
|
|
236
238
|
if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
|
|
237
239
|
// 適用可能なポリシーにフィルター
|
|
238
240
|
applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
|
|
239
|
-
var _a, _b, _c, _d, _e;
|
|
241
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
240
242
|
let satisfyMerchantReturnDays = false;
|
|
241
243
|
let offerItemCondition;
|
|
242
244
|
const itemConditionId = (_a = returnPolicy.itemCondition) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -268,6 +270,8 @@ function findApplicableReturnPolicy(params) {
|
|
|
268
270
|
if (offerItemCondition !== undefined) {
|
|
269
271
|
let satisfyGracePeriodMaxValue = true;
|
|
270
272
|
let satisfyGracePeriodMinValue = true;
|
|
273
|
+
let satisfyGracePeriodInDaysMax = true;
|
|
274
|
+
let satisfyGracePeriodInDaysMin = true;
|
|
271
275
|
// 全イベントについて猶予の確認ができれば適用
|
|
272
276
|
const gracePeriodMaxValue = (_c = (_b = offerItemCondition.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor.gracePeriodBeforeStart) === null || _c === void 0 ? void 0 : _c.maxValue;
|
|
273
277
|
const gracePeriodMinValue = (_e = (_d = offerItemCondition.itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservationFor.gracePeriodBeforeStart) === null || _e === void 0 ? void 0 : _e.minValue;
|
|
@@ -285,7 +289,37 @@ function findApplicableReturnPolicy(params) {
|
|
|
285
289
|
.add(gracePeriodMinValue, 'seconds'));
|
|
286
290
|
});
|
|
287
291
|
}
|
|
288
|
-
|
|
292
|
+
const gracePeriodBeforeStartInDaysMax = (_g = (_f = offerItemCondition.itemOffered.serviceOutput) === null || _f === void 0 ? void 0 : _f.reservationFor.gracePeriodBeforeStartInDays) === null || _g === void 0 ? void 0 : _g.max;
|
|
293
|
+
if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
|
|
294
|
+
&& typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
|
|
295
|
+
satisfyGracePeriodInDaysMax = params.events.every((event) => {
|
|
296
|
+
const minDate = moment(event.startDate)
|
|
297
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone)
|
|
298
|
+
.startOf('days')
|
|
299
|
+
.subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
|
|
300
|
+
.format('YYYY-MM-DD');
|
|
301
|
+
const returnMinDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMax.time}`)
|
|
302
|
+
.tz(gracePeriodBeforeStartInDaysMax.timezone);
|
|
303
|
+
return returnMinDate.isSameOrBefore(moment(returningDate));
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
|
|
307
|
+
if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
|
|
308
|
+
&& typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
|
|
309
|
+
satisfyGracePeriodInDaysMin = params.events.every((event) => {
|
|
310
|
+
const minDate = moment(event.startDate)
|
|
311
|
+
.tz(gracePeriodBeforeStartInDaysMin.timezone)
|
|
312
|
+
.startOf('days')
|
|
313
|
+
.subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
|
|
314
|
+
.format('YYYY-MM-DD');
|
|
315
|
+
const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
|
|
316
|
+
debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
|
|
317
|
+
return returnMaxDate.isSameOrAfter(moment(returningDate));
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
|
|
321
|
+
satisfyItemCondition = satisfyGracePeriodMaxValue && satisfyGracePeriodMinValue
|
|
322
|
+
&& satisfyGracePeriodInDaysMax && satisfyGracePeriodInDaysMin;
|
|
289
323
|
}
|
|
290
324
|
return satisfyMerchantReturnDays && satisfyItemCondition;
|
|
291
325
|
});
|
|
@@ -402,7 +436,8 @@ function validateOffersReturnPolicy(params) {
|
|
|
402
436
|
component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
403
437
|
returnFeesMovieTicket.push({
|
|
404
438
|
identifier: String(appliesToMovieTicket.identifier),
|
|
405
|
-
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket
|
|
439
|
+
returnFees: policyByOffer.customerRemorseReturnFeesMovieTicket,
|
|
440
|
+
serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
|
|
406
441
|
});
|
|
407
442
|
});
|
|
408
443
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.8",
|
|
13
13
|
"@cinerino/sdk": "3.156.0",
|
|
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.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.66"
|
|
121
121
|
}
|