@chevre/domain 20.2.0-alpha.2 → 20.2.0-alpha.4
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/migrateEventOffersItemOfferedAvailableChannel.ts +89 -0
- package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
- package/lib/chevre/repo/place.js +30 -42
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +120 -4
- package/package.json +1 -1
- package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
14
|
+
|
|
15
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = eventRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
// 'project.id': { $eq: project.id },
|
|
20
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
22
|
+
startDate: {
|
|
23
|
+
$gte: moment()
|
|
24
|
+
.add(-1, 'month')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
// _id: { $eq: 'al6aff83w' }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
// _id: 1,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('events found');
|
|
34
|
+
|
|
35
|
+
let i = 0;
|
|
36
|
+
let updateCount = 0;
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
40
|
+
|
|
41
|
+
const eventOffers = <chevre.factory.event.screeningEvent.IOffer | undefined>event.offers;
|
|
42
|
+
if (eventOffers === undefined) {
|
|
43
|
+
throw new Error('event.offers undefined');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const availableChannel = eventOffers.itemOffered.availableChannel;
|
|
47
|
+
|
|
48
|
+
const alreadyMigrated = availableChannel?.typeOf === 'ServiceChannel';
|
|
49
|
+
|
|
50
|
+
if (alreadyMigrated) {
|
|
51
|
+
console.log(
|
|
52
|
+
'already exist...', event.project.id, event.id, event.startDate, availableChannel.serviceLocation.branchCode, i);
|
|
53
|
+
} else {
|
|
54
|
+
const newAvailableChannel: chevre.factory.reservation.IServiceChannel = {
|
|
55
|
+
typeOf: 'ServiceChannel',
|
|
56
|
+
serviceLocation: {
|
|
57
|
+
typeOf: event.location.typeOf,
|
|
58
|
+
branchCode: event.location.branchCode,
|
|
59
|
+
name: event.location.name,
|
|
60
|
+
containedInPlace: {
|
|
61
|
+
typeOf: event.superEvent.location.typeOf,
|
|
62
|
+
id: event.superEvent.location.id,
|
|
63
|
+
branchCode: event.superEvent.location.branchCode,
|
|
64
|
+
name: event.superEvent.location.name
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
console.log(
|
|
69
|
+
'updating seller...', event.project.id, event.id, event.startDate, newAvailableChannel.serviceLocation.branchCode, i);
|
|
70
|
+
await eventRepo.updatePartiallyById({
|
|
71
|
+
id: event.id,
|
|
72
|
+
attributes: <any>{
|
|
73
|
+
typeOf: event.typeOf,
|
|
74
|
+
'offers.itemOffered.availableChannel': newAvailableChannel
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
updateCount += 1;
|
|
78
|
+
console.log(
|
|
79
|
+
'updated...', event.project.id, event.id, event.startDate, i);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log(i, 'events checked');
|
|
84
|
+
console.log(updateCount, 'events updated');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main()
|
|
88
|
+
.then()
|
|
89
|
+
.catch(console.error);
|
|
@@ -5,11 +5,6 @@ import * as mongoose from 'mongoose';
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
6
|
|
|
7
7
|
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
const POS_CLIENT_ID = process.env.POS_CLIENT_ID;
|
|
10
|
-
if (typeof POS_CLIENT_ID !== 'string') {
|
|
11
|
-
throw new Error('set POS_CLIENT_ID');
|
|
12
|
-
}
|
|
13
8
|
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
14
9
|
|
|
15
10
|
// tslint:disable-next-line:max-func-body-length
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -38,9 +38,7 @@ class MongoRepository {
|
|
|
38
38
|
const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
|
|
39
39
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
40
|
if (typeof projectIdEq === 'string') {
|
|
41
|
-
andConditions.push({
|
|
42
|
-
'project.id': { $eq: projectIdEq }
|
|
43
|
-
});
|
|
41
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
44
42
|
}
|
|
45
43
|
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
46
44
|
if (typeof branchCodeEq === 'string') {
|
|
@@ -435,22 +433,17 @@ class MongoRepository {
|
|
|
435
433
|
}
|
|
436
434
|
// tslint:disable-next-line:max-func-body-length
|
|
437
435
|
searchScreeningRoomSections(searchConditions) {
|
|
438
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
436
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
439
437
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440
|
-
const matchStages = [];
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
'project.id': { $eq: searchConditions.project.id.$eq }
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
}
|
|
438
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
|
|
439
|
+
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
440
|
+
if (typeof projectIdEq === 'string') {
|
|
441
|
+
matchStages.push({
|
|
442
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
443
|
+
});
|
|
451
444
|
}
|
|
452
445
|
// 施設コード
|
|
453
|
-
const movieTheaterBranchCodeEq = (
|
|
446
|
+
const movieTheaterBranchCodeEq = (_e = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
454
447
|
if (typeof movieTheaterBranchCodeEq === 'string') {
|
|
455
448
|
matchStages.push({
|
|
456
449
|
$match: {
|
|
@@ -462,7 +455,7 @@ class MongoRepository {
|
|
|
462
455
|
});
|
|
463
456
|
}
|
|
464
457
|
// スクリーンコード
|
|
465
|
-
const containedInPlaceBranchCodeEq = (
|
|
458
|
+
const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
466
459
|
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
467
460
|
matchStages.push({
|
|
468
461
|
$match: {
|
|
@@ -474,7 +467,7 @@ class MongoRepository {
|
|
|
474
467
|
});
|
|
475
468
|
}
|
|
476
469
|
// セクションコード
|
|
477
|
-
const sectionBranchCodeEq = (
|
|
470
|
+
const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
478
471
|
if (typeof sectionBranchCodeEq === 'string') {
|
|
479
472
|
matchStages.push({
|
|
480
473
|
$match: {
|
|
@@ -485,7 +478,7 @@ class MongoRepository {
|
|
|
485
478
|
}
|
|
486
479
|
});
|
|
487
480
|
}
|
|
488
|
-
const nameCodeRegex = (
|
|
481
|
+
const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
489
482
|
if (typeof nameCodeRegex === 'string') {
|
|
490
483
|
matchStages.push({
|
|
491
484
|
$match: {
|
|
@@ -506,7 +499,7 @@ class MongoRepository {
|
|
|
506
499
|
}
|
|
507
500
|
});
|
|
508
501
|
}
|
|
509
|
-
const branchCodeRegex = (
|
|
502
|
+
const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
|
|
510
503
|
if (typeof branchCodeRegex === 'string') {
|
|
511
504
|
matchStages.push({
|
|
512
505
|
$match: {
|
|
@@ -517,7 +510,7 @@ class MongoRepository {
|
|
|
517
510
|
}
|
|
518
511
|
});
|
|
519
512
|
}
|
|
520
|
-
const additionalPropertyElemMatch = (
|
|
513
|
+
const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
521
514
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
522
515
|
matchStages.push({
|
|
523
516
|
$match: {
|
|
@@ -543,7 +536,7 @@ class MongoRepository {
|
|
|
543
536
|
branchCode: '$branchCode',
|
|
544
537
|
name: '$name'
|
|
545
538
|
}
|
|
546
|
-
}, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((
|
|
539
|
+
}, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
|
|
547
540
|
? {
|
|
548
541
|
seatCount: {
|
|
549
542
|
$cond: {
|
|
@@ -595,7 +588,7 @@ class MongoRepository {
|
|
|
595
588
|
searchScreeningRooms(searchConditions) {
|
|
596
589
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
597
590
|
return __awaiter(this, void 0, void 0, function* () {
|
|
598
|
-
const matchStages = [];
|
|
591
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
|
|
599
592
|
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
600
593
|
if (typeof projectIdEq === 'string') {
|
|
601
594
|
matchStages.push({
|
|
@@ -855,21 +848,16 @@ class MongoRepository {
|
|
|
855
848
|
}
|
|
856
849
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
857
850
|
searchSeats(params) {
|
|
858
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
851
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
859
852
|
return __awaiter(this, void 0, void 0, function* () {
|
|
860
|
-
const matchStages = [];
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
'project.id': { $eq: params.project.id.$eq }
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
}
|
|
853
|
+
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
|
|
854
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
855
|
+
if (typeof projectIdEq === 'string') {
|
|
856
|
+
matchStages.push({
|
|
857
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
858
|
+
});
|
|
871
859
|
}
|
|
872
|
-
const containedInPlaceBranchCodeEq = (
|
|
860
|
+
const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
873
861
|
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
874
862
|
matchStages.push({
|
|
875
863
|
$match: {
|
|
@@ -880,7 +868,7 @@ class MongoRepository {
|
|
|
880
868
|
}
|
|
881
869
|
});
|
|
882
870
|
}
|
|
883
|
-
const containedInPlaceBranchCodeIn = (
|
|
871
|
+
const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
|
|
884
872
|
if (Array.isArray(containedInPlaceBranchCodeIn)) {
|
|
885
873
|
matchStages.push({
|
|
886
874
|
$match: {
|
|
@@ -934,7 +922,7 @@ class MongoRepository {
|
|
|
934
922
|
});
|
|
935
923
|
}
|
|
936
924
|
}
|
|
937
|
-
const branchCodeIn = (
|
|
925
|
+
const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
|
|
938
926
|
if (Array.isArray(branchCodeIn)) {
|
|
939
927
|
matchStages.push({
|
|
940
928
|
$match: {
|
|
@@ -945,7 +933,7 @@ class MongoRepository {
|
|
|
945
933
|
}
|
|
946
934
|
});
|
|
947
935
|
}
|
|
948
|
-
const branchCodeRegex = (
|
|
936
|
+
const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
949
937
|
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
950
938
|
matchStages.push({
|
|
951
939
|
$match: {
|
|
@@ -956,7 +944,7 @@ class MongoRepository {
|
|
|
956
944
|
}
|
|
957
945
|
});
|
|
958
946
|
}
|
|
959
|
-
const nameRegex = (
|
|
947
|
+
const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
|
|
960
948
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
961
949
|
matchStages.push({
|
|
962
950
|
$match: {
|
|
@@ -977,7 +965,7 @@ class MongoRepository {
|
|
|
977
965
|
}
|
|
978
966
|
});
|
|
979
967
|
}
|
|
980
|
-
const seatingTypeEq = (
|
|
968
|
+
const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
981
969
|
if (typeof seatingTypeEq === 'string') {
|
|
982
970
|
matchStages.push({
|
|
983
971
|
$match: {
|
|
@@ -993,7 +981,7 @@ class MongoRepository {
|
|
|
993
981
|
&& params.$projection['containedInPlace.containedInPlace'] === 0) {
|
|
994
982
|
includeScreeningRooms = false;
|
|
995
983
|
}
|
|
996
|
-
const additionalPropertyElemMatch = (
|
|
984
|
+
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
997
985
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
998
986
|
matchStages.push({
|
|
999
987
|
$match: {
|
|
@@ -13,6 +13,116 @@ exports.searchEventTicketOffers = void 0;
|
|
|
13
13
|
const moment = require("moment-timezone");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
15
|
const factory_1 = require("../factory");
|
|
16
|
+
/**
|
|
17
|
+
* 旅客オファー検索
|
|
18
|
+
*/
|
|
19
|
+
function searchTransportationEventTicketOffers(params) {
|
|
20
|
+
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const screeningEvent = yield repos.event.findById({ id: params.eventId });
|
|
24
|
+
const soundFormatTypes = [];
|
|
25
|
+
const videoFormatTypes = [];
|
|
26
|
+
let availableOffers = [];
|
|
27
|
+
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
28
|
+
const eventOffers = screeningEvent.offers;
|
|
29
|
+
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
30
|
+
const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
31
|
+
if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
32
|
+
availableOffers = yield repos.offer.findOffersByOfferCatalogId({
|
|
33
|
+
offerCatalog: { id: transportation.hasOfferCatalog.id }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// hasOfferCatalog参照廃止(2022-09-02~)
|
|
39
|
+
throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
40
|
+
}
|
|
41
|
+
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
42
|
+
const screeningEventOfferSettings = screeningEvent.offers;
|
|
43
|
+
if (screeningEventOfferSettings === undefined) {
|
|
44
|
+
throw new factory.errors.NotFound('event.offers');
|
|
45
|
+
}
|
|
46
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
|
|
47
|
+
// 不許可決済方法があれば、該当オファーを除外
|
|
48
|
+
if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
|
|
49
|
+
availableOffers = availableOffers.filter((o) => {
|
|
50
|
+
var _a;
|
|
51
|
+
// 複数決済カード対応(2022-07-11~)
|
|
52
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
53
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
54
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
55
|
+
return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
|
|
65
|
+
availableOffers = availableOffers.filter((o) => {
|
|
66
|
+
var _a;
|
|
67
|
+
// 複数決済カード対応(2022-07-26~)
|
|
68
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
69
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
70
|
+
// 適用決済カード数が0であれば除外
|
|
71
|
+
if (priceSpecificationAppliesToMovieTicket.length === 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
// 上映方式がなければ除外(2022-11-03~)
|
|
75
|
+
if (videoFormatTypes.length === 0) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
79
|
+
// すべての上映方式について検証する(2022-10-29~)
|
|
80
|
+
return videoFormatTypes.every((videoFormat) => {
|
|
81
|
+
return movieTicketTypeChargeSpecs.some((s) => {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
|
|
84
|
+
&& ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
|
|
85
|
+
&& s.appliesToVideoFormat === videoFormat;
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
let offers4event = availableOffers.map((availableOffer) => {
|
|
96
|
+
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
97
|
+
eligibleQuantity: screeningEventOfferSettings.eligibleQuantity,
|
|
98
|
+
offer: availableOffer,
|
|
99
|
+
videoFormatChargeSpecifications,
|
|
100
|
+
soundFormatChargeSpecifications,
|
|
101
|
+
movieTicketTypeChargeSpecs,
|
|
102
|
+
videoFormatTypes
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
// レート制限を確認
|
|
106
|
+
offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return checkAvailability({ event: screeningEvent, offer })(repos);
|
|
108
|
+
})));
|
|
109
|
+
// アドオン設定があれば、プロダクトオファーを検索
|
|
110
|
+
for (const offer of offers4event) {
|
|
111
|
+
const offerAddOn = [];
|
|
112
|
+
if (Array.isArray(offer.addOn)) {
|
|
113
|
+
for (const addOn of offer.addOn) {
|
|
114
|
+
const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
|
|
115
|
+
if (typeof productId === 'string') {
|
|
116
|
+
const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
|
|
117
|
+
offerAddOn.push(...productOffers);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
offer.addOn = offerAddOn;
|
|
122
|
+
}
|
|
123
|
+
return offers4event;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
16
126
|
/**
|
|
17
127
|
* 興行オファー全検索
|
|
18
128
|
*/
|
|
@@ -243,9 +353,7 @@ function searchEventTicketOffers(params) {
|
|
|
243
353
|
var _a;
|
|
244
354
|
const now = moment();
|
|
245
355
|
let event;
|
|
246
|
-
event = yield repos.event.findById({
|
|
247
|
-
id: params.event.id
|
|
248
|
-
});
|
|
356
|
+
event = yield repos.event.findById({ id: params.event.id });
|
|
249
357
|
let offers;
|
|
250
358
|
const eventOffers = event.offers;
|
|
251
359
|
if (eventOffers === undefined) {
|
|
@@ -259,7 +367,15 @@ function searchEventTicketOffers(params) {
|
|
|
259
367
|
throw new factory.errors.NotImplemented(`booking service '${eventOffers.offeredThrough.identifier}' not implemented`);
|
|
260
368
|
default:
|
|
261
369
|
// Chevreで券種オファーを検索
|
|
262
|
-
|
|
370
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
371
|
+
offers = yield searchScreeningEventTicketOffers({ eventId: params.event.id })(repos);
|
|
372
|
+
}
|
|
373
|
+
else if (event.typeOf === factory.eventType.Event) {
|
|
374
|
+
offers = yield searchTransportationEventTicketOffers({ eventId: params.event.id })(repos);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
|
|
378
|
+
}
|
|
263
379
|
const specifiedStoreId = (_a = params.store) === null || _a === void 0 ? void 0 : _a.id;
|
|
264
380
|
if (typeof specifiedStoreId === 'string') {
|
|
265
381
|
// アプリケーションが利用可能なオファーに絞る
|
package/package.json
CHANGED
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_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);
|
|
13
|
-
|
|
14
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
22
|
-
startDate: {
|
|
23
|
-
$gte: moment()
|
|
24
|
-
.add(-1, 'month')
|
|
25
|
-
.toDate()
|
|
26
|
-
}
|
|
27
|
-
// _id: { $eq: 'al6aff83w' }
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
// _id: 1,
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
console.log('events found');
|
|
34
|
-
|
|
35
|
-
let i = 0;
|
|
36
|
-
let updateCount = 0;
|
|
37
|
-
await cursor.eachAsync(async (doc) => {
|
|
38
|
-
i += 1;
|
|
39
|
-
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
40
|
-
|
|
41
|
-
const locationProjectId = (<any>event.location).project?.id;
|
|
42
|
-
if (typeof locationProjectId !== 'string') {
|
|
43
|
-
console.log('already deleted', event.id, event.startDate, event.project.id, i);
|
|
44
|
-
} else {
|
|
45
|
-
updateCount += 1;
|
|
46
|
-
console.log('deleting project...', event.id, event.startDate, event.project.id, i);
|
|
47
|
-
await eventRepo.deleteUnnecessaryProjectAttributesById({ id: event.id });
|
|
48
|
-
console.log('project deleted', event.id, event.startDate, event.project.id, i);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
console.log(i, 'events checked');
|
|
52
|
-
console.log(updateCount, 'events updated');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
main()
|
|
56
|
-
.then()
|
|
57
|
-
.catch(console.error);
|