@chevre/domain 20.2.0-alpha.30 → 20.2.0-alpha.32
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 +7 -7
- package/example/src/chevre/searchEventTicketOffers.ts +2 -3
- package/example/src/chevre/searchEvents.ts +0 -1
- package/example/src/chevre/searchOffersByCatalog.ts +26 -0
- package/example/src/chevre/updateTransaction.ts +38 -0
- package/lib/chevre/repo/mongoose/model/offer.js +2 -1
- package/lib/chevre/repo/offer.d.ts +4 -0
- package/lib/chevre/repo/offer.js +39 -13
- package/lib/chevre/repo/transaction.d.ts +10 -5
- package/lib/chevre/repo/transaction.js +24 -29
- package/lib/chevre/service/assetTransaction/reserve.js +44 -33
- package/lib/chevre/service/offer/event/authorize.js +8 -4
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +8 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +19 -6
- package/lib/chevre/service/offer/factory.js +10 -3
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
- package/lib/chevre/service/transaction/returnOrder.js +3 -3
- package/package.json +2 -2
|
@@ -23,31 +23,31 @@ async function main() {
|
|
|
23
23
|
})
|
|
24
24
|
.exec();
|
|
25
25
|
|
|
26
|
-
await chevre.service.aggregation.system.
|
|
26
|
+
await chevre.service.aggregation.system.aggregatePayTransaction({
|
|
27
27
|
aggregationDays: AGGREGATE_DAYS,
|
|
28
28
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
29
29
|
})({
|
|
30
30
|
agregation: aggregationRepo,
|
|
31
|
-
|
|
31
|
+
assetTransaction: assetTransactionRepo
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
await chevre.service.aggregation.system.
|
|
34
|
+
await chevre.service.aggregation.system.aggregateEvent({
|
|
35
35
|
aggregationDays: AGGREGATE_DAYS,
|
|
36
36
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
37
37
|
})({
|
|
38
38
|
agregation: aggregationRepo,
|
|
39
|
-
|
|
39
|
+
event: eventRepo
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
await chevre.service.aggregation.system.
|
|
42
|
+
await chevre.service.aggregation.system.aggregateTask({
|
|
43
43
|
aggregationDays: AGGREGATE_DAYS,
|
|
44
44
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
45
45
|
})({
|
|
46
46
|
agregation: aggregationRepo,
|
|
47
|
-
|
|
47
|
+
task: taskRepo
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
await chevre.service.aggregation.system.
|
|
50
|
+
await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
51
51
|
aggregationDays: AGGREGATE_DAYS,
|
|
52
52
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
53
53
|
})({
|
|
@@ -21,7 +21,7 @@ async function main() {
|
|
|
21
21
|
const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
|
|
22
22
|
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
|
|
25
25
|
event: { id: 'al9ew43f5' },
|
|
26
26
|
onlyValid: true
|
|
27
27
|
// ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
|
|
@@ -33,8 +33,7 @@ async function main() {
|
|
|
33
33
|
priceSpecification: priceSpecificationRepo,
|
|
34
34
|
product: productRepo
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
console.log(offers.length);
|
|
36
|
+
console.log(ticketOffers.length);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
main()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as redis from 'redis';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
+
|
|
10
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const offers = await offerRepo.findOffersByOfferCatalogId({
|
|
13
|
+
ids: ['al96nqj7z', 'xxx', '1001'],
|
|
14
|
+
// ids: ['xx', 'xxx'],
|
|
15
|
+
offerCatalog: {
|
|
16
|
+
id: '0001'
|
|
17
|
+
// id: 'xxx'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
console.log(offers.map((o) => o.id));
|
|
21
|
+
console.log(offers.length);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
main()
|
|
25
|
+
.then(console.log)
|
|
26
|
+
.catch(console.error);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
+
|
|
10
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
11
|
+
const transactionId = '63ce4d501c45c2000bdb2f9d';
|
|
12
|
+
let update = {
|
|
13
|
+
$set: { 'object.modifiedTime': new Date() }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let now = moment();
|
|
17
|
+
await transactionRepo.findByIdAndUpdate({
|
|
18
|
+
id: transactionId,
|
|
19
|
+
update
|
|
20
|
+
});
|
|
21
|
+
console.log(moment()
|
|
22
|
+
.diff(now));
|
|
23
|
+
|
|
24
|
+
update = {
|
|
25
|
+
$set: { 'object.modifiedTime': new Date() }
|
|
26
|
+
};
|
|
27
|
+
now = moment();
|
|
28
|
+
// await transactionRepo.updateById({
|
|
29
|
+
// id: transactionId,
|
|
30
|
+
// update
|
|
31
|
+
// });
|
|
32
|
+
console.log(moment()
|
|
33
|
+
.diff(now));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then()
|
|
38
|
+
.catch(console.error);
|
|
@@ -41,7 +41,8 @@ const schema = new mongoose.Schema({
|
|
|
41
41
|
eligibleRegion: mongoose.SchemaTypes.Mixed,
|
|
42
42
|
eligibleSeatingType: mongoose.SchemaTypes.Mixed,
|
|
43
43
|
eligibleSubReservation: mongoose.SchemaTypes.Mixed,
|
|
44
|
-
//
|
|
44
|
+
// settings追加(2023-01-26~)
|
|
45
|
+
settings: mongoose.SchemaTypes.Mixed,
|
|
45
46
|
validFrom: Date,
|
|
46
47
|
validThrough: Date,
|
|
47
48
|
validRateLimit: mongoose.SchemaTypes.Mixed
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -302,21 +302,47 @@ class MongoRepository {
|
|
|
302
302
|
*/
|
|
303
303
|
findOffersByOfferCatalogId(params) {
|
|
304
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
305
|
+
// aggregateで再実装(2023-01-26~)
|
|
306
|
+
const matchStages = [{ $match: { _id: { $eq: params.offerCatalog.id } } }];
|
|
307
|
+
if (Array.isArray(params.ids)) {
|
|
308
|
+
matchStages.push({
|
|
309
|
+
$match: { 'itemListElement.id': { $exists: true, $in: params.ids } }
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const aggregate = this.offerCatalogModel.aggregate([
|
|
313
|
+
{ $unwind: '$itemListElement' },
|
|
314
|
+
...matchStages,
|
|
315
|
+
{
|
|
316
|
+
$project: {
|
|
317
|
+
_id: 0,
|
|
318
|
+
id: '$itemListElement.id'
|
|
319
|
+
}
|
|
314
320
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const sortedOfferIds = (Array.isArray(
|
|
318
|
-
?
|
|
321
|
+
]);
|
|
322
|
+
const itemListElements = yield aggregate.exec();
|
|
323
|
+
const sortedOfferIds = (Array.isArray(itemListElements))
|
|
324
|
+
? itemListElements.map((element) => element.id)
|
|
319
325
|
: [];
|
|
326
|
+
// const offerCatalog = await this.offerCatalogModel.findById(
|
|
327
|
+
// params.offerCatalog.id,
|
|
328
|
+
// {
|
|
329
|
+
// itemListElement: 1
|
|
330
|
+
// }
|
|
331
|
+
// )
|
|
332
|
+
// .exec()
|
|
333
|
+
// .then((doc) => {
|
|
334
|
+
// if (doc === null) {
|
|
335
|
+
// throw new factory.errors.NotFound(this.offerCatalogModel.modelName);
|
|
336
|
+
// }
|
|
337
|
+
// return <Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>doc.toObject();
|
|
338
|
+
// });
|
|
339
|
+
// let sortedOfferIds: string[] = (Array.isArray(offerCatalog.itemListElement))
|
|
340
|
+
// ? offerCatalog.itemListElement.map((element) => element.id)
|
|
341
|
+
// : [];
|
|
342
|
+
// const filteredIds = params.ids;
|
|
343
|
+
// if (Array.isArray(filteredIds)) {
|
|
344
|
+
// sortedOfferIds = sortedOfferIds.filter((id) => filteredIds.includes(id));
|
|
345
|
+
// }
|
|
320
346
|
let offers = [];
|
|
321
347
|
if (sortedOfferIds.length > 0) {
|
|
322
348
|
offers = yield this.search({ id: { $in: sortedOfferIds } });
|
|
@@ -89,7 +89,7 @@ export declare class MongoRepository {
|
|
|
89
89
|
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
90
90
|
result: factory.transaction.IResult<T>;
|
|
91
91
|
potentialActions: factory.transaction.IPotentialActions<T>;
|
|
92
|
-
}): Promise<
|
|
92
|
+
}): Promise<void>;
|
|
93
93
|
/**
|
|
94
94
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
95
95
|
*/
|
|
@@ -128,7 +128,7 @@ export declare class MongoRepository {
|
|
|
128
128
|
cancel<T extends factory.transactionType>(params: {
|
|
129
129
|
typeOf: T;
|
|
130
130
|
id: string;
|
|
131
|
-
}): Promise<
|
|
131
|
+
}): Promise<void>;
|
|
132
132
|
count<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T>): Promise<number>;
|
|
133
133
|
/**
|
|
134
134
|
* 取引を検索する
|
|
@@ -137,10 +137,15 @@ export declare class MongoRepository {
|
|
|
137
137
|
/**
|
|
138
138
|
* 特定の取引を更新する(汎用)
|
|
139
139
|
*/
|
|
140
|
-
findByIdAndUpdate
|
|
140
|
+
findByIdAndUpdate(params: {
|
|
141
141
|
id: string;
|
|
142
|
-
update:
|
|
143
|
-
|
|
142
|
+
update: {
|
|
143
|
+
$set?: any;
|
|
144
|
+
$unset?: any;
|
|
145
|
+
$pull?: any;
|
|
146
|
+
$push?: any;
|
|
147
|
+
};
|
|
148
|
+
}): Promise<void>;
|
|
144
149
|
saveOrderNumberIfNotExist(params: {
|
|
145
150
|
id: string;
|
|
146
151
|
orderNumber: string;
|
|
@@ -313,6 +313,8 @@ class MongoRepository {
|
|
|
313
313
|
status: factory.transactionStatusType.InProgress
|
|
314
314
|
}, {
|
|
315
315
|
$set: Object.assign(Object.assign({ 'agent.id': params.agent.id }, (typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined), (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { 'object.customer': params.object.customer } : undefined)
|
|
316
|
+
}, {
|
|
317
|
+
projection: { _id: 1 }
|
|
316
318
|
})
|
|
317
319
|
.exec();
|
|
318
320
|
if (doc === null) {
|
|
@@ -333,6 +335,8 @@ class MongoRepository {
|
|
|
333
335
|
$set: {
|
|
334
336
|
expires: params.expires
|
|
335
337
|
}
|
|
338
|
+
}, {
|
|
339
|
+
projection: { _id: 1 }
|
|
336
340
|
})
|
|
337
341
|
.exec();
|
|
338
342
|
if (doc === null) {
|
|
@@ -353,6 +357,8 @@ class MongoRepository {
|
|
|
353
357
|
status: factory.transactionStatusType.InProgress
|
|
354
358
|
}, {
|
|
355
359
|
$set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
|
|
360
|
+
}, {
|
|
361
|
+
projection: { _id: 1 }
|
|
356
362
|
})
|
|
357
363
|
.exec();
|
|
358
364
|
if (doc === null) {
|
|
@@ -375,7 +381,10 @@ class MongoRepository {
|
|
|
375
381
|
'object.authorizeActions': params.authorizeActions,
|
|
376
382
|
result: params.result,
|
|
377
383
|
potentialActions: params.potentialActions // resultを更新
|
|
378
|
-
}, {
|
|
384
|
+
}, {
|
|
385
|
+
new: true,
|
|
386
|
+
projection: { _id: 1 }
|
|
387
|
+
})
|
|
379
388
|
.exec();
|
|
380
389
|
// NotFoundであれば取引状態確認
|
|
381
390
|
if (doc === null) {
|
|
@@ -384,7 +393,7 @@ class MongoRepository {
|
|
|
384
393
|
/* istanbul ignore next */
|
|
385
394
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
386
395
|
// すでに確定済の場合
|
|
387
|
-
return
|
|
396
|
+
return;
|
|
388
397
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
389
398
|
/* istanbul ignore next */
|
|
390
399
|
}
|
|
@@ -402,7 +411,7 @@ class MongoRepository {
|
|
|
402
411
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
403
412
|
}
|
|
404
413
|
}
|
|
405
|
-
return doc.toObject();
|
|
414
|
+
// return doc.toObject();
|
|
406
415
|
});
|
|
407
416
|
}
|
|
408
417
|
/**
|
|
@@ -485,7 +494,10 @@ class MongoRepository {
|
|
|
485
494
|
}, {
|
|
486
495
|
status: factory.transactionStatusType.Canceled,
|
|
487
496
|
endDate: endDate
|
|
488
|
-
}, {
|
|
497
|
+
}, {
|
|
498
|
+
new: true,
|
|
499
|
+
projection: { _id: 1 }
|
|
500
|
+
})
|
|
489
501
|
.exec();
|
|
490
502
|
// NotFoundであれば取引状態確認
|
|
491
503
|
if (doc === null) {
|
|
@@ -494,7 +506,7 @@ class MongoRepository {
|
|
|
494
506
|
/* istanbul ignore next */
|
|
495
507
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
496
508
|
// すでに中止済の場合
|
|
497
|
-
return
|
|
509
|
+
return;
|
|
498
510
|
}
|
|
499
511
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
500
512
|
throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
|
|
@@ -506,7 +518,7 @@ class MongoRepository {
|
|
|
506
518
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
507
519
|
}
|
|
508
520
|
}
|
|
509
|
-
return doc.toObject();
|
|
521
|
+
// return doc.toObject();
|
|
510
522
|
});
|
|
511
523
|
}
|
|
512
524
|
count(params) {
|
|
@@ -542,43 +554,26 @@ class MongoRepository {
|
|
|
542
554
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
543
555
|
});
|
|
544
556
|
}
|
|
545
|
-
// public stream<T extends factory.transactionType>(
|
|
546
|
-
// params: factory.transaction.ISearchConditions<T>
|
|
547
|
-
// ): QueryCursor<Document> {
|
|
548
|
-
// const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
549
|
-
// const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
550
|
-
// .select({ __v: 0, createdAt: 0, updatedAt: 0 });
|
|
551
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
552
|
-
// /* istanbul ignore else */
|
|
553
|
-
// if (params.limit !== undefined && params.page !== undefined) {
|
|
554
|
-
// query.limit(params.limit)
|
|
555
|
-
// .skip(params.limit * (params.page - 1));
|
|
556
|
-
// }
|
|
557
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
558
|
-
// /* istanbul ignore else */
|
|
559
|
-
// if (params.sort !== undefined) {
|
|
560
|
-
// query.sort(params.sort);
|
|
561
|
-
// }
|
|
562
|
-
// return query.cursor();
|
|
563
|
-
// }
|
|
564
557
|
/**
|
|
565
558
|
* 特定の取引を更新する(汎用)
|
|
566
559
|
*/
|
|
567
560
|
findByIdAndUpdate(params) {
|
|
568
561
|
return __awaiter(this, void 0, void 0, function* () {
|
|
569
|
-
|
|
562
|
+
yield this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, {
|
|
563
|
+
// new: true,
|
|
564
|
+
projection: { _id: 1 }
|
|
565
|
+
})
|
|
570
566
|
.exec()
|
|
571
567
|
.then((doc) => {
|
|
572
568
|
if (doc === null) {
|
|
573
569
|
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
574
570
|
}
|
|
575
|
-
return doc.toObject();
|
|
576
571
|
});
|
|
577
572
|
});
|
|
578
573
|
}
|
|
579
574
|
saveOrderNumberIfNotExist(params) {
|
|
580
575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
581
|
-
yield this.transactionModel.
|
|
576
|
+
yield this.transactionModel.updateOne({
|
|
582
577
|
_id: params.id,
|
|
583
578
|
'object.orderNumber': { $exists: false }
|
|
584
579
|
}, { 'object.orderNumber': params.orderNumber })
|
|
@@ -587,7 +582,7 @@ class MongoRepository {
|
|
|
587
582
|
}
|
|
588
583
|
saveConfirmationNumberIfNotExist(params) {
|
|
589
584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
590
|
-
yield this.transactionModel.
|
|
585
|
+
yield this.transactionModel.updateOne({
|
|
591
586
|
_id: params.id,
|
|
592
587
|
'object.confirmationNumber': { $exists: false }
|
|
593
588
|
}, { 'object.confirmationNumber': params.confirmationNumber })
|
|
@@ -64,7 +64,7 @@ exports.start = start;
|
|
|
64
64
|
function addReservations(params) {
|
|
65
65
|
// tslint:disable-next-line:max-func-body-length
|
|
66
66
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
var _a
|
|
67
|
+
var _a;
|
|
68
68
|
const now = new Date();
|
|
69
69
|
let transaction = yield repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
|
|
70
70
|
// イベント存在確認
|
|
@@ -88,26 +88,33 @@ function addReservations(params) {
|
|
|
88
88
|
if (event.typeOf === factory.eventType.ScreeningEvent || event.typeOf === factory.eventType.Event) {
|
|
89
89
|
validateEvent({ now, event });
|
|
90
90
|
}
|
|
91
|
+
// 受け入れたオファーIDだけ取得する(2023-01-26~)
|
|
92
|
+
const acceptedOfferIds = [...new Set(acceptedOffers.map((o) => String(o.id)))];
|
|
91
93
|
// イベントオファー検索
|
|
92
|
-
const ticketOffers = yield OfferService.event.searchEventTicketOffers({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
94
|
+
const { ticketOffers, unitPriceOffers } = yield OfferService.event.searchEventTicketOffers({
|
|
95
|
+
ids: acceptedOfferIds,
|
|
96
|
+
event: { id: event.id }
|
|
97
|
+
})(repos);
|
|
98
|
+
// 冗長なfindOffersByOfferCatalogId処理を削除(2023-01-26~)
|
|
99
|
+
const availableOffers = unitPriceOffers;
|
|
100
|
+
// let availableOffers: factory.unitPriceOffer.IUnitPriceOffer[] = [];
|
|
101
|
+
// // 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
102
|
+
// const eventOffers = <factory.event.screeningEvent.IOffer | undefined>event.offers;
|
|
103
|
+
// if (typeof eventOffers?.itemOffered?.id === 'string') {
|
|
104
|
+
// const eventService = <factory.product.IProduct>await repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
105
|
+
// if (typeof eventService.hasOfferCatalog?.id === 'string') {
|
|
106
|
+
// availableOffers = await repos.offer.findOffersByOfferCatalogId({
|
|
107
|
+
// offerCatalog: { id: eventService.hasOfferCatalog.id }
|
|
108
|
+
// });
|
|
109
|
+
// }
|
|
110
|
+
// } else {
|
|
111
|
+
// throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
112
|
+
// }
|
|
107
113
|
const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event: { id: event.id } })(repos);
|
|
108
114
|
// 仮予約作成
|
|
109
115
|
const { acceptedOffers4transactionObject, objectSubReservations } = yield createAcceptedOffers4transactionObject({
|
|
110
|
-
acceptedOffers,
|
|
116
|
+
acceptedOffers,
|
|
117
|
+
ticketOffers,
|
|
111
118
|
availableOffers, now,
|
|
112
119
|
event, availableSeatOffers,
|
|
113
120
|
transaction,
|
|
@@ -221,10 +228,10 @@ function createAcceptedOffers4transactionObject(params) {
|
|
|
221
228
|
return { acceptedOffers4transactionObject, objectSubReservations };
|
|
222
229
|
});
|
|
223
230
|
}
|
|
224
|
-
// tslint:disable-next-line:max-func-body-length
|
|
225
231
|
function createReservations4transactionObject(params) {
|
|
232
|
+
// tslint:disable-next-line:max-func-body-length
|
|
226
233
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
227
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
234
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
228
235
|
// 予約番号
|
|
229
236
|
const reservationNumber = params.transaction.object.reservationNumber;
|
|
230
237
|
if (typeof reservationNumber !== 'string') {
|
|
@@ -264,18 +271,22 @@ function createReservations4transactionObject(params) {
|
|
|
264
271
|
const additionalProperty = (0, factory_1.createAdditionalProperty)({ acceptedOffer });
|
|
265
272
|
// 座席指定であれば、座席タイプチャージを検索する
|
|
266
273
|
const seatPriceComponent = [];
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (Array.isArray(
|
|
278
|
-
|
|
274
|
+
// 区分加算料金を適用しないオプションを追加(2023-01-26~)
|
|
275
|
+
const ignoreCategoryCodeChargeSpec = ((_c = ticketType.settings) === null || _c === void 0 ? void 0 : _c.ignoreCategoryCodeChargeSpec) === true;
|
|
276
|
+
if (!ignoreCategoryCodeChargeSpec) {
|
|
277
|
+
const seatSection = (_d = reservedTicket.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatSection;
|
|
278
|
+
const seatNumber = (_e = reservedTicket.ticketedSeat) === null || _e === void 0 ? void 0 : _e.seatNumber;
|
|
279
|
+
if (typeof seatSection === 'string' && typeof seatNumber === 'string') {
|
|
280
|
+
const offersOnSeat = (_f = params.availableSeatOffers.find((o) => {
|
|
281
|
+
var _a;
|
|
282
|
+
return o.branchCode === seatNumber && ((_a = o.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode) === seatSection;
|
|
283
|
+
})) === null || _f === void 0 ? void 0 : _f.offers;
|
|
284
|
+
if (Array.isArray(offersOnSeat)) {
|
|
285
|
+
const availableSeatOffer = offersOnSeat[0];
|
|
286
|
+
const seatPriceSpecs = (_g = availableSeatOffer === null || availableSeatOffer === void 0 ? void 0 : availableSeatOffer.priceSpecification) === null || _g === void 0 ? void 0 : _g.priceComponent;
|
|
287
|
+
if (Array.isArray(seatPriceSpecs)) {
|
|
288
|
+
seatPriceComponent.push(...seatPriceSpecs);
|
|
289
|
+
}
|
|
279
290
|
}
|
|
280
291
|
}
|
|
281
292
|
}
|
|
@@ -286,7 +297,7 @@ function createReservations4transactionObject(params) {
|
|
|
286
297
|
if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
|
|
287
298
|
acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
|
|
288
299
|
}
|
|
289
|
-
const subReservation = (
|
|
300
|
+
const subReservation = (_j = (_h = acceptedOffer.itemOffered) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.subReservation;
|
|
290
301
|
const reservationId = `${reservationNumber}-${reservationIndex}`;
|
|
291
302
|
reservations.push((0, factory_1.createReservation)({
|
|
292
303
|
project: params.transaction.project,
|
|
@@ -305,7 +316,7 @@ function createReservations4transactionObject(params) {
|
|
|
305
316
|
subReservation: subReservation,
|
|
306
317
|
programMembershipUsed,
|
|
307
318
|
availableOffer: ticketType,
|
|
308
|
-
appliesToMovieTicket: (
|
|
319
|
+
appliesToMovieTicket: (_k = acceptedOffer.priceSpecification) === null || _k === void 0 ? void 0 : _k.appliesToMovieTicket,
|
|
309
320
|
validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
|
|
310
321
|
}));
|
|
311
322
|
}
|
|
@@ -278,18 +278,23 @@ function validateEvent(params) {
|
|
|
278
278
|
*/
|
|
279
279
|
function validateAcceptedOffers(params) {
|
|
280
280
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
281
|
+
const acceptedOffersWithoutDetail = params.object.acceptedOffer;
|
|
282
|
+
const offerIds = (Array.isArray(acceptedOffersWithoutDetail))
|
|
283
|
+
? [...new Set(acceptedOffersWithoutDetail.map((o) => o.id))]
|
|
284
|
+
: [];
|
|
281
285
|
// 利用可能なチケットオファーを検索
|
|
282
|
-
const
|
|
286
|
+
const { ticketOffers } = yield (0, searchEventTicketOffers_1.searchEventTicketOffers)({
|
|
287
|
+
// 受け入れたオファーIDだけ取得する(2023-01-26~)
|
|
288
|
+
ids: offerIds,
|
|
283
289
|
event: { id: params.event.id },
|
|
284
290
|
seller: params.seller,
|
|
285
291
|
store: params.store
|
|
286
292
|
})(repos);
|
|
287
|
-
const acceptedOffersWithoutDetail = params.object.acceptedOffer;
|
|
288
293
|
// 利用可能なチケットオファーであれば受け入れる
|
|
289
294
|
const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
|
|
290
295
|
? yield Promise.all(acceptedOffersWithoutDetail.map((offerWithoutDetail) => __awaiter(this, void 0, void 0, function* () {
|
|
291
296
|
return acceptedOfferWithoutDetail2acceptedOffer({
|
|
292
|
-
availableTicketOffers,
|
|
297
|
+
availableTicketOffers: ticketOffers,
|
|
293
298
|
offerWithoutDetail,
|
|
294
299
|
event: params.event,
|
|
295
300
|
transaction: params.transaction,
|
|
@@ -298,7 +303,6 @@ function validateAcceptedOffers(params) {
|
|
|
298
303
|
})))
|
|
299
304
|
: [];
|
|
300
305
|
// オファーIDごとにオファー適用条件を確認
|
|
301
|
-
const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
|
|
302
306
|
offerIds.forEach((offerId) => {
|
|
303
307
|
var _a;
|
|
304
308
|
const acceptedOffersByOfferId = acceptedOffers.filter((o) => o.id === offerId);
|
|
@@ -17,6 +17,10 @@ declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTic
|
|
|
17
17
|
* 興行オファー検索
|
|
18
18
|
*/
|
|
19
19
|
declare function searchEventTicketOffers(params: {
|
|
20
|
+
/**
|
|
21
|
+
* 指定したIDのオファーだけ取得する場合
|
|
22
|
+
*/
|
|
23
|
+
ids?: string[];
|
|
20
24
|
/**
|
|
21
25
|
* どのイベントに対して
|
|
22
26
|
*/
|
|
@@ -72,5 +76,8 @@ declare function searchEventTicketOffers(params: {
|
|
|
72
76
|
*/
|
|
73
77
|
kbnEisyahousiki: string;
|
|
74
78
|
};
|
|
75
|
-
}): ISearchEventTicketOffersOperation<
|
|
79
|
+
}): ISearchEventTicketOffersOperation<{
|
|
80
|
+
ticketOffers: factory.product.ITicketOffer[];
|
|
81
|
+
unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
82
|
+
}>;
|
|
76
83
|
export { searchEventTicketOffers };
|
|
@@ -30,6 +30,7 @@ function searchTransportationEventTicketOffers(params) {
|
|
|
30
30
|
const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
31
31
|
if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
32
32
|
availableOffers = yield repos.offer.findOffersByOfferCatalogId({
|
|
33
|
+
ids: params.ids,
|
|
33
34
|
offerCatalog: { id: transportation.hasOfferCatalog.id }
|
|
34
35
|
});
|
|
35
36
|
}
|
|
@@ -116,7 +117,10 @@ function searchTransportationEventTicketOffers(params) {
|
|
|
116
117
|
}
|
|
117
118
|
offer.addOn = offerAddOn;
|
|
118
119
|
}
|
|
119
|
-
return
|
|
120
|
+
return {
|
|
121
|
+
ticketOffers: offers4event,
|
|
122
|
+
unitPriceOffers: availableOffers
|
|
123
|
+
};
|
|
120
124
|
});
|
|
121
125
|
}
|
|
122
126
|
/**
|
|
@@ -140,6 +144,7 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
140
144
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
141
145
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
142
146
|
availableOffers = yield repos.offer.findOffersByOfferCatalogId({
|
|
147
|
+
ids: params.ids,
|
|
143
148
|
offerCatalog: { id: eventService.hasOfferCatalog.id }
|
|
144
149
|
});
|
|
145
150
|
}
|
|
@@ -226,7 +231,10 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
226
231
|
}
|
|
227
232
|
offer.addOn = offerAddOn;
|
|
228
233
|
}
|
|
229
|
-
return
|
|
234
|
+
return {
|
|
235
|
+
ticketOffers: offers4event,
|
|
236
|
+
unitPriceOffers: availableOffers
|
|
237
|
+
};
|
|
230
238
|
});
|
|
231
239
|
}
|
|
232
240
|
function getUnacceptedPaymentMethodByEvent(params) {
|
|
@@ -342,8 +350,8 @@ function searchAddOns(params) {
|
|
|
342
350
|
/**
|
|
343
351
|
* 興行オファー検索
|
|
344
352
|
*/
|
|
345
|
-
// tslint:disable-next-line:max-func-body-length
|
|
346
353
|
function searchEventTicketOffers(params) {
|
|
354
|
+
// tslint:disable-next-line:max-func-body-length
|
|
347
355
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
348
356
|
var _a;
|
|
349
357
|
const now = moment();
|
|
@@ -354,6 +362,7 @@ function searchEventTicketOffers(params) {
|
|
|
354
362
|
id: params.event.id
|
|
355
363
|
});
|
|
356
364
|
let offers;
|
|
365
|
+
let unitPriceOffers;
|
|
357
366
|
const eventOffers = event.offers;
|
|
358
367
|
if (eventOffers === undefined) {
|
|
359
368
|
throw new factory.errors.NotFound('EventOffers', 'Event offers undefined');
|
|
@@ -367,10 +376,14 @@ function searchEventTicketOffers(params) {
|
|
|
367
376
|
default:
|
|
368
377
|
// Chevreで券種オファーを検索
|
|
369
378
|
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
370
|
-
|
|
379
|
+
const searchOffersResult = yield searchScreeningEventTicketOffers({ ids: params.ids, event })(repos);
|
|
380
|
+
offers = searchOffersResult.ticketOffers;
|
|
381
|
+
unitPriceOffers = searchOffersResult.unitPriceOffers;
|
|
371
382
|
}
|
|
372
383
|
else if (event.typeOf === factory.eventType.Event) {
|
|
373
|
-
|
|
384
|
+
const searchOffersResult = yield searchTransportationEventTicketOffers({ ids: params.ids, event })(repos);
|
|
385
|
+
offers = searchOffersResult.ticketOffers;
|
|
386
|
+
unitPriceOffers = searchOffersResult.unitPriceOffers;
|
|
374
387
|
}
|
|
375
388
|
else {
|
|
376
389
|
throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
|
|
@@ -426,7 +439,7 @@ function searchEventTicketOffers(params) {
|
|
|
426
439
|
}
|
|
427
440
|
}
|
|
428
441
|
}
|
|
429
|
-
return offers;
|
|
442
|
+
return { ticketOffers: offers, unitPriceOffers };
|
|
430
443
|
});
|
|
431
444
|
}
|
|
432
445
|
exports.searchEventTicketOffers = searchEventTicketOffers;
|
|
@@ -22,13 +22,20 @@ function mvtkChargePriceSpec2component(params) {
|
|
|
22
22
|
return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
|
|
23
23
|
}
|
|
24
24
|
function createCompoundPriceSpec4event(params) {
|
|
25
|
+
var _a;
|
|
25
26
|
// priceSpecificationはマスタ管理の仕様上必ず存在するはず
|
|
26
27
|
if (params.offer.priceSpecification === undefined) {
|
|
27
28
|
throw new factory.errors.NotFound(`priceSpecification of the offer: ${params.offer.id}`);
|
|
28
29
|
}
|
|
29
30
|
const unitPriceSpec = Object.assign(Object.assign({}, params.offer.priceSpecification), { name: params.offer.name });
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
let videoFormatChargeSpecComponents = [];
|
|
32
|
+
let soundFormatChargeSpecComponents = [];
|
|
33
|
+
// 区分加算料金を適用しないオプションを追加(2023-01-26~)
|
|
34
|
+
const ignoreCategoryCodeChargeSpec = ((_a = params.offer.settings) === null || _a === void 0 ? void 0 : _a.ignoreCategoryCodeChargeSpec) === true;
|
|
35
|
+
if (!ignoreCategoryCodeChargeSpec) {
|
|
36
|
+
videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
|
|
37
|
+
soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
|
|
38
|
+
}
|
|
32
39
|
const mvtkPriceComponents = [];
|
|
33
40
|
// 複数決済カード対応(2022-07-11~)
|
|
34
41
|
if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
|
|
@@ -62,7 +69,7 @@ function createCompoundPriceSpec4event(params) {
|
|
|
62
69
|
priceComponent
|
|
63
70
|
};
|
|
64
71
|
// 不要な属性を除外(2022-11-07~)
|
|
65
|
-
const
|
|
72
|
+
const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
|
|
66
73
|
return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
|
|
67
74
|
}
|
|
68
75
|
exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
|
|
@@ -189,7 +189,7 @@ function publishPaymentUrl(params) {
|
|
|
189
189
|
};
|
|
190
190
|
yield repos.transaction.findByIdAndUpdate({
|
|
191
191
|
id: transaction.id,
|
|
192
|
-
update: { 'object.paymentMethods': paymentMethodByPaymentUrl }
|
|
192
|
+
update: { $set: { 'object.paymentMethods': paymentMethodByPaymentUrl } }
|
|
193
193
|
});
|
|
194
194
|
return result;
|
|
195
195
|
});
|
|
@@ -68,13 +68,13 @@ exports.start = start;
|
|
|
68
68
|
*/
|
|
69
69
|
function confirm(params) {
|
|
70
70
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
var _a
|
|
71
|
+
var _a;
|
|
72
72
|
// 確認番号を事前発行
|
|
73
73
|
yield publishConfirmationNumberIfNotExist({
|
|
74
74
|
id: params.id,
|
|
75
75
|
object: { orderDate: params.result.order.orderDate }
|
|
76
76
|
})(repos);
|
|
77
|
-
|
|
77
|
+
const transaction = yield repos.transaction.findById({
|
|
78
78
|
typeOf: factory.transactionType.PlaceOrder,
|
|
79
79
|
id: params.id
|
|
80
80
|
});
|
|
@@ -121,7 +121,7 @@ function confirm(params) {
|
|
|
121
121
|
});
|
|
122
122
|
// ステータス変更
|
|
123
123
|
try {
|
|
124
|
-
|
|
124
|
+
yield repos.transaction.confirm({
|
|
125
125
|
typeOf: transaction.typeOf,
|
|
126
126
|
id: transaction.id,
|
|
127
127
|
authorizeActions: transaction.object.authorizeActions,
|
|
@@ -140,10 +140,10 @@ function confirm(params) {
|
|
|
140
140
|
throw error;
|
|
141
141
|
}
|
|
142
142
|
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
143
|
-
if (typeof
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
return
|
|
143
|
+
// if (typeof transaction.result?.order.typeOf !== 'string') {
|
|
144
|
+
// throw new factory.errors.ServiceUnavailable('transaction.result not found');
|
|
145
|
+
// }
|
|
146
|
+
return result;
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
exports.confirm = confirm;
|
|
@@ -306,7 +306,7 @@ function validateAppliedReturnPolicy(params) {
|
|
|
306
306
|
function confirm(params) {
|
|
307
307
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
308
308
|
var _a;
|
|
309
|
-
|
|
309
|
+
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
|
|
310
310
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
311
311
|
// すでに確定済の場合
|
|
312
312
|
return transaction.result;
|
|
@@ -356,14 +356,14 @@ function confirm(params) {
|
|
|
356
356
|
// useConfirmRefund: params.useConfirmRefund
|
|
357
357
|
});
|
|
358
358
|
// ステータス変更
|
|
359
|
-
|
|
359
|
+
yield repos.transaction.confirm({
|
|
360
360
|
typeOf: transaction.typeOf,
|
|
361
361
|
id: transaction.id,
|
|
362
362
|
authorizeActions: [],
|
|
363
363
|
result: result,
|
|
364
364
|
potentialActions: potentialActions
|
|
365
365
|
});
|
|
366
|
-
return
|
|
366
|
+
return result;
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
exports.confirm = confirm;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.284.0-alpha.0",
|
|
13
13
|
"@cinerino/sdk": "3.136.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.2.0-alpha.
|
|
123
|
+
"version": "20.2.0-alpha.32"
|
|
124
124
|
}
|