@chevre/domain 21.25.0 → 21.26.0-alpha.0
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/validateOrder.ts +78 -0
- package/lib/chevre/service/assetTransaction/reserve.js +16 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +4 -2
- package/lib/chevre/service/payment/any.js +4 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +7 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +17 -15
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +16 -1
- package/lib/chevre/service/validation/validateOrder.d.ts +13 -0
- package/lib/chevre/service/validation/validateOrder.js +158 -0
- package/lib/chevre/settings.d.ts +1 -1
- package/lib/chevre/settings.js +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { validateOrder } from '../../../lib/chevre/service/validation/validateOrder';
|
|
6
|
+
import { chevre } from '../../../lib/index';
|
|
7
|
+
|
|
8
|
+
// const project = { id: <string>process.env.PROJECT_ID };
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
15
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
16
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
17
|
+
const cursor = orderRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
// orderNumber: { $eq: 'SSK6-4203766-8404594' },
|
|
20
|
+
// 'project.id': { $eq: project.id },
|
|
21
|
+
typeOf: { $eq: chevre.factory.order.OrderType.Order },
|
|
22
|
+
orderDate: {
|
|
23
|
+
$gte: moment()
|
|
24
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
+
.add(-31, 'days')
|
|
26
|
+
.toDate()
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
project: 1,
|
|
31
|
+
orderDate: 1,
|
|
32
|
+
orderNumber: 1,
|
|
33
|
+
typeOf: 1
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
console.log('orders found');
|
|
37
|
+
|
|
38
|
+
const unexpextedOrders: (Pick<chevre.factory.order.IOrder, 'orderDate' | 'orderNumber' | 'project'> & {
|
|
39
|
+
message: string;
|
|
40
|
+
})[] = [];
|
|
41
|
+
const unexpextedprojectIds: string[] = [];
|
|
42
|
+
|
|
43
|
+
let i = 0;
|
|
44
|
+
await cursor.eachAsync(async (doc) => {
|
|
45
|
+
i += 1;
|
|
46
|
+
const order: Pick<chevre.factory.order.IOrder, 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> = doc.toObject();
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
console.log('validating order...', order.project.id, order.typeOf, order.orderNumber, order.orderDate, i);
|
|
50
|
+
const result = await validateOrder({
|
|
51
|
+
orderNumber: order.orderNumber,
|
|
52
|
+
project: { id: order.project.id }
|
|
53
|
+
})({
|
|
54
|
+
order: orderRepo,
|
|
55
|
+
acceptedOffer: acceptedOfferRepo,
|
|
56
|
+
assetTransaction: assetTransactionRepo
|
|
57
|
+
});
|
|
58
|
+
console.log(result);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(error);
|
|
61
|
+
unexpextedOrders.push({
|
|
62
|
+
orderDate: order.orderDate,
|
|
63
|
+
orderNumber: order.orderNumber,
|
|
64
|
+
project: order.project,
|
|
65
|
+
message: error.message
|
|
66
|
+
});
|
|
67
|
+
unexpextedprojectIds.push(order.project.id);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
console.log(i, 'orders checked');
|
|
71
|
+
console.log('unexpextedOrders:', unexpextedOrders);
|
|
72
|
+
console.log(unexpextedOrders.length, 'unexpextedOrders');
|
|
73
|
+
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then()
|
|
78
|
+
.catch(console.error);
|
|
@@ -22,6 +22,7 @@ const confirmReservation_1 = require("../reserve/confirmReservation");
|
|
|
22
22
|
const settings_1 = require("../../settings");
|
|
23
23
|
const factory_1 = require("./reserve/factory");
|
|
24
24
|
const validateStartRequest_1 = require("./reserve/validateStartRequest");
|
|
25
|
+
const ONE_MONTH_IN_DAYS = 31;
|
|
25
26
|
/**
|
|
26
27
|
* 取引開始
|
|
27
28
|
*/
|
|
@@ -271,13 +272,23 @@ function validateEvent(params) {
|
|
|
271
272
|
if (params.event.eventStatus === factory.eventStatusType.EventCancelled) {
|
|
272
273
|
throw new factory.errors.Argument('Event', `Event status ${params.event.eventStatus}`);
|
|
273
274
|
}
|
|
274
|
-
//
|
|
275
|
+
// 予約取引開始可能なイベント開始日時範囲を明確に制限(2024-03-11~)
|
|
275
276
|
const reservableThrough = moment(params.now)
|
|
276
|
-
.add(settings_1.
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
277
|
+
.add(settings_1.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, 'days');
|
|
278
|
+
const reservableFrom = moment(params.now)
|
|
279
|
+
.add(-ONE_MONTH_IN_DAYS, 'days');
|
|
280
|
+
if (!moment(params.event.startDate)
|
|
281
|
+
.isBetween(reservableFrom, reservableThrough, 'second', '[]')) {
|
|
282
|
+
throw new factory.errors.Argument('Event', `bookingTime must be between ${settings_1.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS} days before and ${ONE_MONTH_IN_DAYS} days after the event start date`);
|
|
280
283
|
}
|
|
284
|
+
// イベントが一定期間後であれば予約不可
|
|
285
|
+
// if (moment(params.event.startDate)
|
|
286
|
+
// .isAfter(reservableThrough)) {
|
|
287
|
+
// throw new factory.errors.Argument(
|
|
288
|
+
// 'Event',
|
|
289
|
+
// `Maximum reservation grace period is ${MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS} days`
|
|
290
|
+
// );
|
|
291
|
+
// }
|
|
281
292
|
}
|
|
282
293
|
function createAcceptedOffers4transactionObject(params) {
|
|
283
294
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -81,8 +81,10 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
|
|
|
81
81
|
agent: order.project,
|
|
82
82
|
purpose: Object.assign(Object.assign({}, simpleOrder), { confirmationNumber: order.confirmationNumber }),
|
|
83
83
|
instrument: {
|
|
84
|
-
typeOf: 'WebAPI',
|
|
85
|
-
|
|
84
|
+
// typeOf: 'WebAPI',
|
|
85
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
86
|
+
identifier: factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre,
|
|
87
|
+
transactionNumber: invoice.paymentMethodId
|
|
86
88
|
},
|
|
87
89
|
processOrder: order.orderStatus === factory.orderStatus.OrderPaymentDue,
|
|
88
90
|
useOnOrderStatusChanged: true
|
|
@@ -321,8 +321,10 @@ function authorize(params) {
|
|
|
321
321
|
id: transaction.agent.id
|
|
322
322
|
},
|
|
323
323
|
instrument: {
|
|
324
|
-
typeOf: 'WebAPI',
|
|
325
|
-
|
|
324
|
+
// typeOf: 'WebAPI',
|
|
325
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
326
|
+
identifier: factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre,
|
|
327
|
+
transactionNumber
|
|
326
328
|
},
|
|
327
329
|
recipient: {
|
|
328
330
|
typeOf: transaction.seller.typeOf,
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
|
-
type
|
|
2
|
+
export type IMovieTicket4validate = Pick<factory.paymentMethod.paymentCard.movieTicket.IMovieTicket, 'identifier' | 'serviceOutput' | 'serviceType' | 'typeOf'> & {
|
|
3
|
+
serviceOutput: factory.paymentMethod.paymentCard.movieTicket.IServiceOutput & {
|
|
4
|
+
reservationFor: factory.paymentMethod.paymentCard.movieTicket.IReservationFor & {};
|
|
5
|
+
};
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* 興行オファー承認に対して決済承認条件が整っているかどうか検証する
|
|
5
9
|
* 決済方法区分ごとに検証
|
|
@@ -12,11 +16,10 @@ paymentMethodType: string, transaction: {
|
|
|
12
16
|
id: string;
|
|
13
17
|
},
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
19
|
+
* 決済承認で受け付けたmovieTickets
|
|
16
20
|
*/
|
|
17
|
-
|
|
21
|
+
authorizedMovieTickets: IMovieTicket4validate[],
|
|
18
22
|
/**
|
|
19
23
|
* 受け入れられた興行オファー
|
|
20
24
|
*/
|
|
21
25
|
eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[]): void;
|
|
22
|
-
export {};
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -17,23 +17,25 @@ function validateMovieTicket(
|
|
|
17
17
|
* 決済方法区分
|
|
18
18
|
*/
|
|
19
19
|
paymentMethodType, transaction,
|
|
20
|
+
// authorizePaymentActions: IAuthorizePaymentAction[],
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* 決済承認で受け付けたmovieTickets
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
authorizedMovieTickets,
|
|
24
25
|
/**
|
|
25
26
|
* 受け入れられた興行オファー
|
|
26
27
|
*/
|
|
27
28
|
eventReservationAcceptedOffers) {
|
|
28
|
-
const authorizeMovieTicketActions = authorizePaymentActions.filter(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
29
|
+
// const authorizeMovieTicketActions = authorizePaymentActions.filter(
|
|
30
|
+
// (a) => {
|
|
31
|
+
// const resultAsInvoice = (Array.isArray(a.result))
|
|
32
|
+
// ? a.result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
33
|
+
// : undefined;
|
|
34
|
+
// return resultAsInvoice?.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
35
|
+
// // 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
36
|
+
// && resultAsInvoice.paymentMethodAsObject?.typeOf === paymentMethodType;
|
|
37
|
+
// }
|
|
38
|
+
// );
|
|
37
39
|
// const seatReservationAuthorizeActions = (<IAuthorizeSeatReservationOffer[]>authorizeActions).filter(
|
|
38
40
|
// (a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation
|
|
39
41
|
// );
|
|
@@ -44,10 +46,10 @@ eventReservationAcceptedOffers) {
|
|
|
44
46
|
acceptedOffers: eventReservationAcceptedOffers
|
|
45
47
|
});
|
|
46
48
|
debug(requiredMovieTickets.length, 'movie tickets required', 'transaction:', transaction.id);
|
|
47
|
-
const authorizedMovieTickets = [];
|
|
48
|
-
authorizeMovieTicketActions.forEach((a) => {
|
|
49
|
-
|
|
50
|
-
});
|
|
49
|
+
// const authorizedMovieTickets: IMovieTicket4validate[] = [];
|
|
50
|
+
// authorizeMovieTicketActions.forEach((a) => {
|
|
51
|
+
// authorizedMovieTickets.push(...(Array.isArray(a.object.movieTickets)) ? a.object.movieTickets : []);
|
|
52
|
+
// });
|
|
51
53
|
debug(authorizedMovieTickets.length, 'movie tickets authorized', 'transaction:', transaction.id);
|
|
52
54
|
// 合計枚数OK?
|
|
53
55
|
if (requiredMovieTickets.length !== authorizedMovieTickets.length) {
|
|
@@ -24,7 +24,22 @@ function validateTransaction(transaction, authorizePaymentActions, authorizeEven
|
|
|
24
24
|
if (Array.isArray(movieTicketPaymentMethodTypes) && movieTicketPaymentMethodTypes.length > 0) {
|
|
25
25
|
movieTicketPaymentMethodTypes.forEach((paymentMethodType) => {
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
const authorizeMovieTicketActions = authorizePaymentActions.filter((a) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const resultAsInvoice = (Array.isArray(a.result))
|
|
30
|
+
? a.result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
|
|
31
|
+
: undefined;
|
|
32
|
+
return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
33
|
+
// 決済方法区分は必ず存在するはず(2023-08-15~)
|
|
34
|
+
&& ((_a = resultAsInvoice.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.typeOf) === paymentMethodType;
|
|
35
|
+
});
|
|
36
|
+
const authorizedMovieTickets = [];
|
|
37
|
+
authorizeMovieTicketActions.forEach((a) => {
|
|
38
|
+
authorizedMovieTickets.push(...(Array.isArray(a.object.movieTickets)) ? a.object.movieTickets : []);
|
|
39
|
+
});
|
|
40
|
+
debug(authorizedMovieTickets.length, 'movie tickets authorized', 'transaction:', transaction.id);
|
|
41
|
+
// validateMovieTicket(paymentMethodType, { id: transaction.id }, authorizePaymentActions, eventReservationAcceptedOffers);
|
|
42
|
+
(0, validateMovieTicket_1.validateMovieTicket)(paymentMethodType, { id: transaction.id }, authorizedMovieTickets, eventReservationAcceptedOffers);
|
|
28
43
|
}
|
|
29
44
|
catch (error) {
|
|
30
45
|
// 検証結果をlog(2022-06-04~)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
|
+
import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
3
|
+
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
|
+
export declare function validateOrder(params: {
|
|
5
|
+
orderNumber: string;
|
|
6
|
+
project: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
}): (repos: {
|
|
10
|
+
acceptedOffer: AcceptedOfferRepo;
|
|
11
|
+
assetTransaction: AssetTransactionRepo;
|
|
12
|
+
order: OrderRepo;
|
|
13
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as createDebug from 'debug';
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.validateOrder = void 0;
|
|
14
|
+
const factory = require("../../factory");
|
|
15
|
+
const factory_1 = require("../offer/event/factory");
|
|
16
|
+
const validateMovieTicket_1 = require("../transaction/placeOrderInProgress/validation/validateMovieTicket");
|
|
17
|
+
// const debug = createDebug('chevre-domain:service:validation');
|
|
18
|
+
// tslint:disable-next-line:max-func-body-length
|
|
19
|
+
function validateOrder(params) {
|
|
20
|
+
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const order = yield repos.order.findByOrderNumber({
|
|
23
|
+
orderNumber: params.orderNumber,
|
|
24
|
+
project: { id: params.project.id },
|
|
25
|
+
inclusion: [],
|
|
26
|
+
exclusion: []
|
|
27
|
+
});
|
|
28
|
+
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
29
|
+
orderNumber: { $eq: params.orderNumber },
|
|
30
|
+
project: { id: { $eq: params.project.id } }
|
|
31
|
+
});
|
|
32
|
+
let payTransactions = [];
|
|
33
|
+
if (order.paymentMethods.length > 0) {
|
|
34
|
+
payTransactions = yield repos.assetTransaction.search({
|
|
35
|
+
project: { id: { $eq: order.project.id } },
|
|
36
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
37
|
+
transactionNumber: { $in: order.paymentMethods.map(({ paymentMethodId }) => paymentMethodId) }
|
|
38
|
+
}, [], []);
|
|
39
|
+
}
|
|
40
|
+
// 型検証
|
|
41
|
+
if (typeof order.confirmationNumber !== 'string' || order.confirmationNumber.length === 0) {
|
|
42
|
+
throw new Error(`invalid confirmationNumber [${typeof order.confirmationNumber}]`);
|
|
43
|
+
}
|
|
44
|
+
if (!Array.isArray(order.orderedItem)) {
|
|
45
|
+
throw new Error(`invalid orderedItem [${typeof order.orderedItem}]`);
|
|
46
|
+
}
|
|
47
|
+
if (!Array.isArray(order.paymentMethods)) {
|
|
48
|
+
throw new Error(`invalid paymentMethods [${typeof order.paymentMethods}]`);
|
|
49
|
+
}
|
|
50
|
+
if (!(order.orderDate instanceof Date)) {
|
|
51
|
+
throw new Error(`invalid orderDate [${typeof order.orderDate}]`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof order.price !== 'number') {
|
|
54
|
+
throw new Error(`invalid price [${typeof order.price}]`);
|
|
55
|
+
}
|
|
56
|
+
if (typeof order.orderStatus !== 'string') {
|
|
57
|
+
throw new Error(`invalid orderStatus [${typeof order.orderStatus}]`);
|
|
58
|
+
}
|
|
59
|
+
acceptedOffers.forEach(({ itemOffered, priceSpecification, serialNumber }) => {
|
|
60
|
+
const { typeOf } = itemOffered;
|
|
61
|
+
if (typeof typeOf !== 'string') {
|
|
62
|
+
throw new Error(`invalid acceptedOffer.itemOffered.typeOf [${typeof typeOf}]`);
|
|
63
|
+
}
|
|
64
|
+
if (priceSpecification !== undefined) {
|
|
65
|
+
if (!Array.isArray(priceSpecification.priceComponent)) {
|
|
66
|
+
// tslint:disable-next-line:max-line-length
|
|
67
|
+
throw new Error(`invalid acceptedOffer.priceSpecification.priceComponent [${typeof priceSpecification.priceComponent}]`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (typeof serialNumber !== 'string' || serialNumber.length === 0) {
|
|
71
|
+
throw new Error(`invalid acceptedOffer.serialNumber [${typeof serialNumber}]`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
let reservationForIds = [];
|
|
75
|
+
let itemOfferedTypeOfs = [];
|
|
76
|
+
acceptedOffers.forEach(({ itemOffered }) => {
|
|
77
|
+
itemOfferedTypeOfs.push(itemOffered.typeOf);
|
|
78
|
+
if (itemOffered.typeOf === factory.reservationType.BusReservation
|
|
79
|
+
|| itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
80
|
+
reservationForIds.push(itemOffered.reservationFor.id);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
reservationForIds = [...new Set(reservationForIds)];
|
|
84
|
+
itemOfferedTypeOfs = [...new Set(itemOfferedTypeOfs)];
|
|
85
|
+
// orderedItem検証
|
|
86
|
+
if (order.orderedItem.length !== reservationForIds.length) {
|
|
87
|
+
throw new Error(`invalid orderedItem.length:${order.orderedItem.length} [expected:${reservationForIds.length}]`);
|
|
88
|
+
}
|
|
89
|
+
// itemOffered.typeOf検証
|
|
90
|
+
if (itemOfferedTypeOfs.length !== 1) {
|
|
91
|
+
throw new Error(`itemOfferedTypeOfs.length must be 1 [${itemOfferedTypeOfs.length}]`);
|
|
92
|
+
}
|
|
93
|
+
// price検証
|
|
94
|
+
let priceExpected = 0;
|
|
95
|
+
const itemOfferedTypeOf = itemOfferedTypeOfs[0];
|
|
96
|
+
switch (itemOfferedTypeOf) {
|
|
97
|
+
case factory.reservationType.BusReservation:
|
|
98
|
+
case factory.reservationType.EventReservation:
|
|
99
|
+
const reservationAcceptedOffers = acceptedOffers;
|
|
100
|
+
const coaTicketInfoExists = reservationAcceptedOffers[0].itemOffered.reservedTicket.coaTicketInfo !== undefined;
|
|
101
|
+
if (coaTicketInfoExists) {
|
|
102
|
+
// 実際の発生金額を算出
|
|
103
|
+
priceExpected = reservationAcceptedOffers.reduce((a, { itemOffered }) => {
|
|
104
|
+
const coaTicketInfo = itemOffered.reservedTicket.coaTicketInfo;
|
|
105
|
+
if (coaTicketInfo === undefined) {
|
|
106
|
+
throw new Error(`itemOffered.reservedTicket.coaTicketInfo not found`);
|
|
107
|
+
}
|
|
108
|
+
if (typeof coaTicketInfo.salesTicketSalePrice !== 'number'
|
|
109
|
+
|| typeof coaTicketInfo.addGlasses !== 'number'
|
|
110
|
+
|| typeof coaTicketInfo.spseatAdd1 !== 'number'
|
|
111
|
+
|| typeof coaTicketInfo.spseatAdd2 !== 'number') {
|
|
112
|
+
throw new Error(`invalid itemOffered.reservedTicket.coaTicketInfo`);
|
|
113
|
+
}
|
|
114
|
+
return a + [
|
|
115
|
+
coaTicketInfo.salesTicketSalePrice,
|
|
116
|
+
coaTicketInfo.addGlasses,
|
|
117
|
+
coaTicketInfo.spseatAdd1,
|
|
118
|
+
coaTicketInfo.spseatAdd2
|
|
119
|
+
].reduce((a2, b2) => a2 + b2, 0);
|
|
120
|
+
}, 0);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
priceExpected = (0, factory_1.acceptedOffers2amount)({
|
|
124
|
+
acceptedOffers: reservationAcceptedOffers
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case factory.permit.PermitType.Permit:
|
|
129
|
+
break;
|
|
130
|
+
case factory.actionType.MoneyTransfer:
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
throw new Error(`invalid itemOfferedTypeOf [${itemOfferedTypeOf}]`);
|
|
134
|
+
}
|
|
135
|
+
if (order.price !== priceExpected) {
|
|
136
|
+
throw new Error(`order.price should be ${priceExpected} [actual: ${order.price}]`);
|
|
137
|
+
}
|
|
138
|
+
// MovieTicket検証
|
|
139
|
+
if (payTransactions.length !== order.paymentMethods.length) {
|
|
140
|
+
throw new Error(`payTransactions.length should be ${order.paymentMethods.length} [actual: ${payTransactions.length}]`);
|
|
141
|
+
}
|
|
142
|
+
order.paymentMethods
|
|
143
|
+
.filter(({ issuedThrough }) => issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket)
|
|
144
|
+
.forEach(({ paymentMethod }) => {
|
|
145
|
+
if (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier) !== 'string') {
|
|
146
|
+
throw new Error(`invalid order.paymentMethods.paymentMethod.identifier [${paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier}]`);
|
|
147
|
+
}
|
|
148
|
+
const authorizedMovieTickets = [];
|
|
149
|
+
payTransactions.filter(({ object }) => object.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
150
|
+
&& object.paymentMethod.identifier === paymentMethod.identifier)
|
|
151
|
+
.forEach((a) => {
|
|
152
|
+
authorizedMovieTickets.push(...(Array.isArray(a.object.paymentMethod.movieTickets)) ? a.object.paymentMethod.movieTickets : []);
|
|
153
|
+
});
|
|
154
|
+
(0, validateMovieTicket_1.validateMovieTicket)(paymentMethod.identifier, { id: 'xxxx' }, authorizedMovieTickets, acceptedOffers);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
exports.validateOrder = validateOrder;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from './factory';
|
|
2
2
|
export declare const TRIGGER_WEBHOOK_MAX_RETRY_COUNT: number;
|
|
3
3
|
export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
4
|
+
export declare const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS: number;
|
|
4
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
5
6
|
export declare const MAX_NUM_CREDIT_CARD_PAYMENT_METHOD: number;
|
|
6
7
|
/**
|
|
@@ -26,7 +27,6 @@ export type ISettings = factory.project.ISettings & {
|
|
|
26
27
|
onResourceUpdated: {
|
|
27
28
|
informResource?: factory.project.IInformParams[];
|
|
28
29
|
};
|
|
29
|
-
maximumReservationGracePeriodInDays: number;
|
|
30
30
|
userPoolIdOld: string;
|
|
31
31
|
userPoolIdNew: string;
|
|
32
32
|
useAggregateEntranceGateProjects: string[];
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -25,7 +25,7 @@ exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = (typeof process.env.TRIGGER_WEBHOOK_MA
|
|
|
25
25
|
exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = (typeof process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS === 'string')
|
|
26
26
|
? Number(process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS)
|
|
27
27
|
: 0;
|
|
28
|
-
|
|
28
|
+
exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = (typeof process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS === 'string')
|
|
29
29
|
? Number(process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS)
|
|
30
30
|
// tslint:disable-next-line:no-magic-numbers
|
|
31
31
|
: 93;
|
|
@@ -149,7 +149,7 @@ exports.settings = {
|
|
|
149
149
|
webhook: {
|
|
150
150
|
timeout: triggerWebhookTimeout
|
|
151
151
|
},
|
|
152
|
-
maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS,
|
|
152
|
+
// maximumReservationGracePeriodInDays: MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS,
|
|
153
153
|
userPoolIdOld: String(process.env.USERPOOL_ID_OLD),
|
|
154
154
|
userPoolIdNew: String(process.env.USERPOOL_ID_NEW),
|
|
155
155
|
// ...(typeof MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'number')
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.361.0",
|
|
14
14
|
"@cinerino/sdk": "5.13.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.
|
|
113
|
+
"version": "21.26.0-alpha.0"
|
|
114
114
|
}
|