@chevre/domain 20.2.0-alpha.34 → 20.2.0-alpha.35
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/aggregation/aggregateSystem.ts +8 -0
- package/lib/chevre/repo/action.d.ts +9 -0
- package/lib/chevre/repo/action.js +22 -0
- package/lib/chevre/repo/aggregation.d.ts +1 -0
- package/lib/chevre/repo/aggregation.js +1 -0
- package/lib/chevre/service/aggregation/system.d.ts +8 -1
- package/lib/chevre/service/aggregation/system.js +33 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
- package/lib/chevre/service/assetTransaction/reserve.d.ts +16 -1
- package/lib/chevre/service/assetTransaction/reserve.js +29 -19
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
- package/lib/chevre/service/offer/event/authorize.js +5 -78
- package/package.json +1 -1
|
@@ -95,6 +95,14 @@ async function main() {
|
|
|
95
95
|
agregation: aggregationRepo,
|
|
96
96
|
action: actionRepo
|
|
97
97
|
});
|
|
98
|
+
|
|
99
|
+
await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
|
|
100
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
101
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
102
|
+
})({
|
|
103
|
+
agregation: aggregationRepo,
|
|
104
|
+
action: actionRepo
|
|
105
|
+
});
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
main()
|
|
@@ -164,5 +164,14 @@ export declare class MongoRepository {
|
|
|
164
164
|
startThrough: Date;
|
|
165
165
|
typeOf: factory.actionType;
|
|
166
166
|
}): Promise<IAggregateAction>;
|
|
167
|
+
aggregateCheckMovieTicketAction(params: {
|
|
168
|
+
project?: {
|
|
169
|
+
id?: {
|
|
170
|
+
$ne?: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
startFrom: Date;
|
|
174
|
+
startThrough: Date;
|
|
175
|
+
}): Promise<IAggregateAction>;
|
|
167
176
|
private agggregateByStatus;
|
|
168
177
|
}
|
|
@@ -762,6 +762,28 @@ class MongoRepository {
|
|
|
762
762
|
return { statuses };
|
|
763
763
|
});
|
|
764
764
|
}
|
|
765
|
+
aggregateCheckMovieTicketAction(params) {
|
|
766
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
767
|
+
const statuses = yield Promise.all([
|
|
768
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
769
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
770
|
+
factory.actionStatusType.FailedActionStatus
|
|
771
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
772
|
+
var _a, _b;
|
|
773
|
+
const matchConditions = Object.assign({ startDate: {
|
|
774
|
+
$gte: params.startFrom,
|
|
775
|
+
$lte: params.startThrough
|
|
776
|
+
}, typeOf: { $eq: factory.actionType.CheckAction }, 'object.typeOf': {
|
|
777
|
+
$exists: true,
|
|
778
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
779
|
+
}, actionStatus: { $eq: actionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
780
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
781
|
+
: undefined);
|
|
782
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
783
|
+
})));
|
|
784
|
+
return { statuses };
|
|
785
|
+
});
|
|
786
|
+
}
|
|
765
787
|
// tslint:disable-next-line:max-func-body-length
|
|
766
788
|
agggregateByStatus(params) {
|
|
767
789
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -4,6 +4,7 @@ export declare enum AggregationType {
|
|
|
4
4
|
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
5
5
|
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
6
6
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
|
+
AggregateCheckMovieTicketAction = "AggregateCheckMovieTicketAction",
|
|
7
8
|
AggregateEvent = "AggregateEvent",
|
|
8
9
|
AggregatePay = "AggregatePay",
|
|
9
10
|
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
@@ -27,6 +27,7 @@ var AggregationType;
|
|
|
27
27
|
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
28
28
|
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
29
29
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
|
+
AggregationType["AggregateCheckMovieTicketAction"] = "AggregateCheckMovieTicketAction";
|
|
30
31
|
AggregationType["AggregateEvent"] = "AggregateEvent";
|
|
31
32
|
AggregationType["AggregatePay"] = "AggregatePay";
|
|
32
33
|
AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
|
|
@@ -59,6 +59,13 @@ declare function aggregateUseAction(params: {
|
|
|
59
59
|
agregation: AggregationRepo;
|
|
60
60
|
action: ActionRepo;
|
|
61
61
|
}) => Promise<void>;
|
|
62
|
+
declare function aggregateCheckMovieTicketAction(params: {
|
|
63
|
+
aggregationDays: number;
|
|
64
|
+
excludedProjectId?: string;
|
|
65
|
+
}): (repos: {
|
|
66
|
+
agregation: AggregationRepo;
|
|
67
|
+
action: ActionRepo;
|
|
68
|
+
}) => Promise<void>;
|
|
62
69
|
declare function aggregatePayTransaction(params: {
|
|
63
70
|
aggregationDays: number;
|
|
64
71
|
excludedProjectId?: string;
|
|
@@ -83,4 +90,4 @@ declare function aggregateTask(params: {
|
|
|
83
90
|
agregation: AggregationRepo;
|
|
84
91
|
task: TasKRepo;
|
|
85
92
|
}) => Promise<void>;
|
|
86
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateEvent, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
93
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregateEvent = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
const factory = require("../../factory");
|
|
@@ -242,6 +242,38 @@ function aggregateUseAction(params) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
exports.aggregateUseAction = aggregateUseAction;
|
|
245
|
+
function aggregateCheckMovieTicketAction(params) {
|
|
246
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
var _a;
|
|
248
|
+
const aggregateDate = new Date();
|
|
249
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
250
|
+
.toISOString();
|
|
251
|
+
let i = -1;
|
|
252
|
+
while (i < params.aggregationDays) {
|
|
253
|
+
i += 1;
|
|
254
|
+
const startFrom = moment()
|
|
255
|
+
.utc()
|
|
256
|
+
// .tz('Asia/Tokyo')
|
|
257
|
+
.add(-i, 'days')
|
|
258
|
+
.startOf('day')
|
|
259
|
+
.toDate();
|
|
260
|
+
const startThrough = moment()
|
|
261
|
+
.utc()
|
|
262
|
+
// .tz('Asia/Tokyo')
|
|
263
|
+
.add(-i, 'days')
|
|
264
|
+
.endOf('day')
|
|
265
|
+
.toDate();
|
|
266
|
+
const aggregateResult = yield repos.action.aggregateCheckMovieTicketAction({
|
|
267
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
268
|
+
startFrom,
|
|
269
|
+
startThrough
|
|
270
|
+
});
|
|
271
|
+
debug('aggregateCheckMovieTicketAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
272
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateCheckMovieTicketAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
exports.aggregateCheckMovieTicketAction = aggregateCheckMovieTicketAction;
|
|
245
277
|
function aggregatePayTransaction(params) {
|
|
246
278
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
247
279
|
var _a;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import { IMinimizedIndividualEvent } from '../../../factory/event';
|
|
3
|
+
declare function validateStartRequest(params: {
|
|
4
|
+
object: factory.assetTransaction.reserve.IObjectWithoutDetail;
|
|
5
|
+
event: IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>;
|
|
6
|
+
validateEventOfferPeriod?: boolean;
|
|
7
|
+
validateEvent?: boolean;
|
|
8
|
+
now: Date;
|
|
9
|
+
store?: {
|
|
10
|
+
/**
|
|
11
|
+
* 販売アプリケーションID
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
}): void;
|
|
16
|
+
export { validateStartRequest };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateStartRequest = void 0;
|
|
4
|
+
const moment = require("moment");
|
|
5
|
+
const factory = require("../../../factory");
|
|
6
|
+
function validateStartRequest(params) {
|
|
7
|
+
var _a;
|
|
8
|
+
const now = params.now;
|
|
9
|
+
const event = params.event;
|
|
10
|
+
if (params.validateEventOfferPeriod === true) {
|
|
11
|
+
if (typeof ((_a = params.store) === null || _a === void 0 ? void 0 : _a.id) !== 'string') {
|
|
12
|
+
throw new factory.errors.NotFound('store.id');
|
|
13
|
+
}
|
|
14
|
+
validateEventOfferPeriod({ event, now, availableAt: { id: params.store.id } });
|
|
15
|
+
}
|
|
16
|
+
if (params.validateEvent === true) {
|
|
17
|
+
validateEvent({ event, object: params.object });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.validateStartRequest = validateStartRequest;
|
|
21
|
+
/**
|
|
22
|
+
* イベントのオファー有効期間を検証する
|
|
23
|
+
*/
|
|
24
|
+
function validateEventOfferPeriod(params) {
|
|
25
|
+
const acceptedDate = moment(params.now);
|
|
26
|
+
const eventOffers = params.event.offers;
|
|
27
|
+
// アプリケーションごとの設定を参照する(2022-11-19~)
|
|
28
|
+
const makesOfferOnApplication = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.seller.makesOffer.find((offer) => {
|
|
29
|
+
return Array.isArray(offer.availableAtOrFrom) && offer.availableAtOrFrom[0].id === params.availableAt.id;
|
|
30
|
+
});
|
|
31
|
+
if (makesOfferOnApplication === undefined) {
|
|
32
|
+
throw new factory.errors.Argument('reservationFor.id', `seller makes no available offer at ${params.availableAt.id}`);
|
|
33
|
+
}
|
|
34
|
+
const validFrom = makesOfferOnApplication.validFrom;
|
|
35
|
+
const validThrough = makesOfferOnApplication.validThrough;
|
|
36
|
+
// const validFrom = eventOffers?.validFrom;
|
|
37
|
+
// const validThrough = eventOffers?.validThrough;
|
|
38
|
+
if (validFrom !== undefined && validFrom !== null) {
|
|
39
|
+
if (acceptedDate.isBefore(moment(validFrom))) {
|
|
40
|
+
throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid from ${validFrom}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (validThrough !== undefined && validThrough !== null) {
|
|
44
|
+
if (acceptedDate.isAfter(moment(validThrough))) {
|
|
45
|
+
throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid through ${validThrough}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* イベントの上限座席数を検証する
|
|
51
|
+
*/
|
|
52
|
+
function validateEvent(params) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
// const acceptedDate = moment(params.now);
|
|
55
|
+
const eventOffers = params.event.offers;
|
|
56
|
+
// const validFrom = eventOffers?.validFrom;
|
|
57
|
+
// const validThrough = eventOffers?.validThrough;
|
|
58
|
+
// if (validFrom !== undefined && validFrom !== null) {
|
|
59
|
+
// if (acceptedDate.isBefore(moment(validFrom))) {
|
|
60
|
+
// throw new factory.errors.Argument(
|
|
61
|
+
// 'reservationFor.id',
|
|
62
|
+
// `Offer of ${params.event.id} is valid from ${validFrom}`
|
|
63
|
+
// );
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// if (validThrough !== undefined && validThrough !== null) {
|
|
67
|
+
// if (acceptedDate.isAfter(moment(validThrough))) {
|
|
68
|
+
// throw new factory.errors.Argument(
|
|
69
|
+
// 'reservationFor.id',
|
|
70
|
+
// `Offer of ${params.event.id} is valid through ${validThrough}`
|
|
71
|
+
// );
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
// イベントのmaxValueを検証
|
|
75
|
+
const maxValue = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.eligibleQuantity) === null || _a === void 0 ? void 0 : _a.maxValue;
|
|
76
|
+
if (typeof maxValue === 'number') {
|
|
77
|
+
const numAcceptedOffers = (_b = params.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.length;
|
|
78
|
+
if (typeof numAcceptedOffers === 'number' && numAcceptedOffers > 0) {
|
|
79
|
+
if (numAcceptedOffers > maxValue) {
|
|
80
|
+
throw new factory.errors.Argument('reservationFor.id', `Maximum number of offers exceeded`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
3
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
|
-
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
4
|
+
import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../repo/event';
|
|
5
5
|
import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
|
|
6
6
|
import { MongoRepository as OfferRepo } from '../../repo/offer';
|
|
7
7
|
import { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
|
|
@@ -63,6 +63,10 @@ interface IConfirmRepo {
|
|
|
63
63
|
}
|
|
64
64
|
export declare type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
|
|
65
65
|
declare type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
|
|
66
|
+
/**
|
|
67
|
+
* 承認アクションを介した場合に検索済のイベント
|
|
68
|
+
*/
|
|
69
|
+
preSearchedEvent?: IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>;
|
|
66
70
|
/**
|
|
67
71
|
* 承認アクションを介した場合に検索済のオファーリスト
|
|
68
72
|
*/
|
|
@@ -71,9 +75,20 @@ declare type IStartParams = factory.assetTransaction.reserve.IStartParamsWithout
|
|
|
71
75
|
* 承認アクションを介した場合に検索済の単価オファーリスト
|
|
72
76
|
*/
|
|
73
77
|
preSearchedUnitPriceOffers?: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
78
|
+
/**
|
|
79
|
+
* 販売アプリケーション
|
|
80
|
+
*/
|
|
74
81
|
availableAtOrFrom?: {
|
|
75
82
|
id?: string;
|
|
76
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* イベントの販売期間を検証するかどうか
|
|
86
|
+
*/
|
|
87
|
+
validateEventOfferPeriod: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* イベントのオファー(最大予約座席数)を検証するかどうか
|
|
90
|
+
*/
|
|
91
|
+
validateEvent: boolean;
|
|
77
92
|
validateAppliesToMovieTicket: boolean;
|
|
78
93
|
};
|
|
79
94
|
/**
|
|
@@ -21,17 +21,39 @@ const cancelReservation_1 = require("../reserve/cancelReservation");
|
|
|
21
21
|
const confirmReservation_1 = require("../reserve/confirmReservation");
|
|
22
22
|
const settings_1 = require("../../settings");
|
|
23
23
|
const factory_1 = require("./reserve/factory");
|
|
24
|
+
const validateStartRequest_1 = require("./reserve/validateStartRequest");
|
|
24
25
|
/**
|
|
25
26
|
* 取引開始
|
|
26
27
|
*/
|
|
27
28
|
function start(params) {
|
|
28
29
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
var _a, _b;
|
|
30
|
+
var _a, _b, _c, _d, _e;
|
|
31
|
+
const now = new Date();
|
|
30
32
|
// 自動発行廃止(2022-05-17~)
|
|
31
33
|
const reservationNumber = params.transactionNumber;
|
|
32
34
|
if (typeof reservationNumber !== 'string' || reservationNumber.length === 0) {
|
|
33
35
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
34
36
|
}
|
|
37
|
+
// eventをfix
|
|
38
|
+
if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
|
|
39
|
+
throw new factory.errors.ArgumentNull('object.reservationFor.id');
|
|
40
|
+
}
|
|
41
|
+
let event;
|
|
42
|
+
if (typeof ((_b = params.preSearchedEvent) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') {
|
|
43
|
+
event = params.preSearchedEvent;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
event = yield repos.event.findMinimizedIndividualEventById({ id: params.object.reservationFor.id });
|
|
47
|
+
}
|
|
48
|
+
// validationを承認アクション開始前から移行(2023-01-27~)
|
|
49
|
+
(0, validateStartRequest_1.validateStartRequest)({
|
|
50
|
+
object: params.object,
|
|
51
|
+
event,
|
|
52
|
+
validateEventOfferPeriod: params.validateEventOfferPeriod,
|
|
53
|
+
validateEvent: params.validateEvent,
|
|
54
|
+
now,
|
|
55
|
+
store: { id: (_c = params.availableAtOrFrom) === null || _c === void 0 ? void 0 : _c.id }
|
|
56
|
+
});
|
|
35
57
|
const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { reservationNumber: reservationNumber }));
|
|
36
58
|
// 取引作成
|
|
37
59
|
let transaction;
|
|
@@ -47,13 +69,14 @@ function start(params) {
|
|
|
47
69
|
throw error;
|
|
48
70
|
}
|
|
49
71
|
// 指定があれば予約追加
|
|
50
|
-
if (typeof ((
|
|
72
|
+
if (typeof ((_d = params.object.reservationFor) === null || _d === void 0 ? void 0 : _d.id) === 'string') {
|
|
51
73
|
transaction = yield addReservations({
|
|
52
74
|
id: transaction.id,
|
|
53
75
|
object: params.object,
|
|
76
|
+
event,
|
|
54
77
|
preSearchedTicketOffers: params.preSearchedTicketOffers,
|
|
55
78
|
preSearchedUnitPriceOffers: params.preSearchedUnitPriceOffers,
|
|
56
|
-
availableAtOrFrom: { id: (
|
|
79
|
+
availableAtOrFrom: { id: (_e = params.availableAtOrFrom) === null || _e === void 0 ? void 0 : _e.id },
|
|
57
80
|
validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
|
|
58
81
|
})(repos);
|
|
59
82
|
}
|
|
@@ -67,24 +90,11 @@ exports.start = start;
|
|
|
67
90
|
function addReservations(params) {
|
|
68
91
|
// tslint:disable-next-line:max-func-body-length
|
|
69
92
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
var _a
|
|
93
|
+
var _a;
|
|
71
94
|
const now = new Date();
|
|
72
95
|
let transaction = yield repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
|
|
73
|
-
// イベント存在確認
|
|
74
|
-
if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
|
|
75
|
-
throw new factory.errors.ArgumentNull('object.reservationFor.id');
|
|
76
|
-
}
|
|
77
96
|
const acceptedOffers = (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer : [];
|
|
78
|
-
|
|
79
|
-
const event = yield repos.event.findMinimizedIndividualEventById({ id: params.object.reservationFor.id });
|
|
80
|
-
// const event = await repos.event.findById(
|
|
81
|
-
// { id: params.object.reservationFor.id },
|
|
82
|
-
// {
|
|
83
|
-
// // 予約データに不要な属性は取得しない
|
|
84
|
-
// aggregateReservation: 0, aggregateOffer: 0, attendeeCount: 0,
|
|
85
|
-
// checkInCount: 0, maximumAttendeeCapacity: 0, remainingAttendeeCapacity: 0
|
|
86
|
-
// }
|
|
87
|
-
// );
|
|
97
|
+
const event = params.event;
|
|
88
98
|
if (event.typeOf !== factory.eventType.ScreeningEvent && event.typeOf !== factory.eventType.Event) {
|
|
89
99
|
throw new factory.errors.Argument('object.reservationFor.id', `invalid event type ${event.typeOf}`);
|
|
90
100
|
}
|
|
@@ -106,7 +116,7 @@ function addReservations(params) {
|
|
|
106
116
|
ids: acceptedOfferIds,
|
|
107
117
|
event: { id: event.id },
|
|
108
118
|
// 対応アプリケーション条件追加(2023-01-27~)
|
|
109
|
-
store: { id: (
|
|
119
|
+
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
110
120
|
sort: false // ソート不要(2023-01-27~)
|
|
111
121
|
})(repos);
|
|
112
122
|
ticketOffers = searchEventTicketOffersResult.ticketOffers;
|
|
@@ -37,7 +37,7 @@ declare type IAuthorizeOfferAction = factory.action.authorize.offer.seatReservat
|
|
|
37
37
|
/**
|
|
38
38
|
* イベントオファー承認
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
declare function authorize(params: {
|
|
41
41
|
project: {
|
|
42
42
|
id: string;
|
|
43
43
|
typeOf: factory.organizationType.Project;
|
|
@@ -49,11 +49,8 @@ export declare function authorize(params: {
|
|
|
49
49
|
transaction: {
|
|
50
50
|
id: string;
|
|
51
51
|
};
|
|
52
|
-
validateEventOfferPeriod
|
|
53
|
-
validateEvent
|
|
54
|
-
/**
|
|
55
|
-
* どの店舗に対して
|
|
56
|
-
*/
|
|
52
|
+
validateEventOfferPeriod: boolean;
|
|
53
|
+
validateEvent: boolean;
|
|
57
54
|
store: {
|
|
58
55
|
/**
|
|
59
56
|
* 販売アプリケーションID
|
|
@@ -61,4 +58,4 @@ export declare function authorize(params: {
|
|
|
61
58
|
id: string;
|
|
62
59
|
};
|
|
63
60
|
}): IAuthorizeOperation<IAuthorizeOfferAction>;
|
|
64
|
-
export {};
|
|
61
|
+
export { authorize };
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.authorize = void 0;
|
|
13
|
-
const moment = require("moment");
|
|
14
13
|
const factory = require("../../../factory");
|
|
15
14
|
const ReserveTransactionService = require("../../assetTransaction/reserve");
|
|
16
15
|
const CodeService = require("../../code");
|
|
@@ -22,8 +21,7 @@ const factory_1 = require("./factory");
|
|
|
22
21
|
function authorize(params) {
|
|
23
22
|
// tslint:disable-next-line:max-func-body-length
|
|
24
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const
|
|
26
|
-
const { transaction, event, bookingServiceIdentifire } = yield validateCreateRequest(Object.assign(Object.assign({}, params), { now, store: params.store }))({ event: repos.event, transaction: repos.transaction });
|
|
24
|
+
const { transaction, event, bookingServiceIdentifire } = yield validateCreateRequest(params)({ event: repos.event, transaction: repos.transaction });
|
|
27
25
|
const { acceptedOffers, ticketOffers, unitPriceOffers } = yield validateAcceptedOffers({
|
|
28
26
|
object: params.object,
|
|
29
27
|
event,
|
|
@@ -66,7 +64,9 @@ function authorize(params) {
|
|
|
66
64
|
transaction,
|
|
67
65
|
availableAtOrFrom: { id: params.store.id },
|
|
68
66
|
ticketOffers,
|
|
69
|
-
unitPriceOffers
|
|
67
|
+
unitPriceOffers,
|
|
68
|
+
validateEvent: params.validateEvent === true,
|
|
69
|
+
validateEventOfferPeriod: params.validateEventOfferPeriod === true
|
|
70
70
|
})(repos);
|
|
71
71
|
// requestBody = processStartReserveResult.requestBody;
|
|
72
72
|
// responseBody = processStartReserveResult.responseBody;
|
|
@@ -116,7 +116,6 @@ exports.authorize = authorize;
|
|
|
116
116
|
function validateCreateRequest(params) {
|
|
117
117
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
118
118
|
var _a, _b;
|
|
119
|
-
const now = params.now;
|
|
120
119
|
const transaction = yield repos.transaction.findInProgressById({
|
|
121
120
|
typeOf: factory.transactionType.PlaceOrder,
|
|
122
121
|
id: params.transaction.id
|
|
@@ -137,14 +136,6 @@ function validateCreateRequest(params) {
|
|
|
137
136
|
offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
|
|
138
137
|
}
|
|
139
138
|
const bookingServiceIdentifire = offeredThrough.identifier;
|
|
140
|
-
if (bookingServiceIdentifire === factory.service.webAPI.Identifier.Chevre) {
|
|
141
|
-
if (params.validateEventOfferPeriod === true) {
|
|
142
|
-
validateEventOfferPeriod({ event, now, availableAt: { id: params.store.id } });
|
|
143
|
-
}
|
|
144
|
-
if (params.validateEvent === true) {
|
|
145
|
-
validateEvent({ event, object: params.object });
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
139
|
return { transaction, event, bookingServiceIdentifire };
|
|
149
140
|
});
|
|
150
141
|
}
|
|
@@ -171,7 +162,7 @@ function processStartReserve4chevre(params) {
|
|
|
171
162
|
// requestBody = startParams;
|
|
172
163
|
const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
|
|
173
164
|
// 予約取引開始
|
|
174
|
-
responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateAppliesToMovieTicket: true }))(repos);
|
|
165
|
+
responseBody = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true }))(repos);
|
|
175
166
|
// 予約取引からオファー情報を生成する
|
|
176
167
|
acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
|
|
177
168
|
responseBody: responseBody,
|
|
@@ -212,70 +203,6 @@ function validateObjectWithoutDetail(params) {
|
|
|
212
203
|
return objectWithoutDetail;
|
|
213
204
|
});
|
|
214
205
|
}
|
|
215
|
-
/**
|
|
216
|
-
* イベントのオファー有効期間を検証する
|
|
217
|
-
*/
|
|
218
|
-
function validateEventOfferPeriod(params) {
|
|
219
|
-
const acceptedDate = moment(params.now);
|
|
220
|
-
const eventOffers = params.event.offers;
|
|
221
|
-
// アプリケーションごとの設定を参照する(2022-11-19~)
|
|
222
|
-
const makesOfferOnApplication = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.seller.makesOffer.find((offer) => {
|
|
223
|
-
return Array.isArray(offer.availableAtOrFrom) && offer.availableAtOrFrom[0].id === params.availableAt.id;
|
|
224
|
-
});
|
|
225
|
-
if (makesOfferOnApplication === undefined) {
|
|
226
|
-
throw new factory.errors.Argument('reservationFor.id', `seller makes no available offer at ${params.availableAt.id}`);
|
|
227
|
-
}
|
|
228
|
-
const validFrom = makesOfferOnApplication.validFrom;
|
|
229
|
-
const validThrough = makesOfferOnApplication.validThrough;
|
|
230
|
-
// const validFrom = eventOffers?.validFrom;
|
|
231
|
-
// const validThrough = eventOffers?.validThrough;
|
|
232
|
-
if (validFrom !== undefined && validFrom !== null) {
|
|
233
|
-
if (acceptedDate.isBefore(moment(validFrom))) {
|
|
234
|
-
throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid from ${validFrom}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (validThrough !== undefined && validThrough !== null) {
|
|
238
|
-
if (acceptedDate.isAfter(moment(validThrough))) {
|
|
239
|
-
throw new factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid through ${validThrough}`);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* イベントの上限座席数を検証する
|
|
245
|
-
*/
|
|
246
|
-
function validateEvent(params) {
|
|
247
|
-
var _a, _b;
|
|
248
|
-
// const acceptedDate = moment(params.now);
|
|
249
|
-
const eventOffers = params.event.offers;
|
|
250
|
-
// const validFrom = eventOffers?.validFrom;
|
|
251
|
-
// const validThrough = eventOffers?.validThrough;
|
|
252
|
-
// if (validFrom !== undefined && validFrom !== null) {
|
|
253
|
-
// if (acceptedDate.isBefore(moment(validFrom))) {
|
|
254
|
-
// throw new factory.errors.Argument(
|
|
255
|
-
// 'reservationFor.id',
|
|
256
|
-
// `Offer of ${params.event.id} is valid from ${validFrom}`
|
|
257
|
-
// );
|
|
258
|
-
// }
|
|
259
|
-
// }
|
|
260
|
-
// if (validThrough !== undefined && validThrough !== null) {
|
|
261
|
-
// if (acceptedDate.isAfter(moment(validThrough))) {
|
|
262
|
-
// throw new factory.errors.Argument(
|
|
263
|
-
// 'reservationFor.id',
|
|
264
|
-
// `Offer of ${params.event.id} is valid through ${validThrough}`
|
|
265
|
-
// );
|
|
266
|
-
// }
|
|
267
|
-
// }
|
|
268
|
-
// イベントのmaxValueを検証
|
|
269
|
-
const maxValue = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.eligibleQuantity) === null || _a === void 0 ? void 0 : _a.maxValue;
|
|
270
|
-
if (typeof maxValue === 'number') {
|
|
271
|
-
const numAcceptedOffers = (_b = params.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.length;
|
|
272
|
-
if (typeof numAcceptedOffers === 'number' && numAcceptedOffers > 0) {
|
|
273
|
-
if (numAcceptedOffers > maxValue) {
|
|
274
|
-
throw new factory.errors.Argument('reservationFor.id', `Maximum number of offers exceeded`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
206
|
/**
|
|
280
207
|
* 受け入れらたオファーの内容を検証
|
|
281
208
|
*/
|
package/package.json
CHANGED