@chevre/domain 23.1.0-alpha.9 → 23.2.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.
Files changed (100) hide show
  1. package/example/src/chevre/{eventOffer/adminEventOffers.ts → acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts} +12 -11
  2. package/example/src/chevre/actions/checkAcceptPayActions.ts +60 -0
  3. package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +67 -0
  4. package/example/src/chevre/event/importEventSeriesFromCOAByTitle.ts +83 -0
  5. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +148 -0
  6. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +5 -5
  8. package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +46 -0
  9. package/example/src/chevre/place/checkSectionCount.ts +27 -0
  10. package/example/src/chevre/place/findSectionsByRoom.ts +50 -0
  11. package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
  12. package/example/src/chevre/reIndex.ts +0 -1
  13. package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
  14. package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
  15. package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
  16. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
  17. package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
  18. package/lib/chevre/repo/authorization.d.ts +3 -2
  19. package/lib/chevre/repo/authorization.js +13 -5
  20. package/lib/chevre/repo/event.d.ts +1 -35
  21. package/lib/chevre/repo/event.js +2 -102
  22. package/lib/chevre/repo/eventOffer.js +3 -3
  23. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +10 -0
  24. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +97 -0
  25. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +9 -0
  26. package/lib/chevre/repo/note.js +4 -2
  27. package/lib/chevre/repo/pendingReservation.js +28 -71
  28. package/lib/chevre/repo/place/seat.d.ts +24 -0
  29. package/lib/chevre/repo/place/seat.js +103 -21
  30. package/lib/chevre/repo/place/section.d.ts +20 -0
  31. package/lib/chevre/repo/place/section.js +47 -0
  32. package/lib/chevre/repo/ticket.d.ts +7 -1
  33. package/lib/chevre/repo/ticket.js +14 -1
  34. package/lib/chevre/repository.d.ts +5 -0
  35. package/lib/chevre/repository.js +15 -2
  36. package/lib/chevre/service/aggregation/event/importFromCOA.js +2 -2
  37. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  38. package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
  39. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
  40. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +94 -0
  41. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
  42. package/lib/chevre/service/assetTransaction/pay.js +6 -1
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +1 -2
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +7 -7
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +6 -2
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +0 -1
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +7 -51
  49. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +6 -8
  50. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +29 -1
  51. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +9 -9
  52. package/lib/chevre/service/event/factory.d.ts +22 -0
  53. package/lib/chevre/service/event/factory.js +2 -0
  54. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +24 -0
  55. package/lib/chevre/service/event/processUpdateMovieTheater.js +190 -0
  56. package/lib/chevre/service/event/saveScreeningEventSeries.d.ts +63 -0
  57. package/lib/chevre/service/event/saveScreeningEventSeries.js +277 -0
  58. package/lib/chevre/service/event/saveScreeningEvents.d.ts +46 -0
  59. package/lib/chevre/service/event/saveScreeningEvents.js +321 -0
  60. package/lib/chevre/service/event.d.ts +4 -34
  61. package/lib/chevre/service/event.js +12 -698
  62. package/lib/chevre/service/eventOld.d.ts +60 -0
  63. package/lib/chevre/service/eventOld.js +864 -0
  64. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -1
  65. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
  66. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
  67. package/lib/chevre/service/offer/event.d.ts +2 -1
  68. package/lib/chevre/service/offer/event.js +3 -1
  69. package/lib/chevre/service/offer.d.ts +31 -1
  70. package/lib/chevre/service/offer.js +104 -34
  71. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
  72. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
  73. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
  74. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
  75. package/lib/chevre/service/payment/any/factory.d.ts +20 -3
  76. package/lib/chevre/service/payment/any/factory.js +26 -6
  77. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
  78. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
  79. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
  80. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +8 -22
  81. package/lib/chevre/service/payment/any.d.ts +5 -1
  82. package/lib/chevre/service/payment/any.js +22 -13
  83. package/lib/chevre/service/payment/factory.js +0 -5
  84. package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
  85. package/lib/chevre/service/task/authorizePayment.js +2 -0
  86. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  87. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  88. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
  89. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
  90. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
  91. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
  92. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
  93. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
  94. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
  95. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
  96. package/package.json +3 -3
  97. package/example/src/chevre/checkReplaceActions.ts +0 -65
  98. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
  99. package/lib/chevre/service/code.d.ts +0 -8
  100. package/lib/chevre/service/code.js +0 -7
@@ -9,22 +9,23 @@ const project = { id: String(process.env.PROJECT_ID) };
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
12
+ const acceptedPaymentMethodRepo = await chevre.repository.AcceptedPaymentMethod.createInstance(mongoose.connection);
13
13
 
14
14
  const validFrom = moment()
15
15
  .toDate();
16
16
  const validThrough = moment(validFrom)
17
17
  .add(1, 'hour')
18
18
  .toDate();
19
- const eventOffer: chevre.factory.eventOffer.IEventOffer = {
19
+ const settingOffer: Omit<chevre.factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'id'> = {
20
20
  typeOf: chevre.factory.offerType.Offer,
21
- identifier: '20251113eventOffer',
21
+ identifier: '20251202acceptedPaymentMethod',
22
22
  itemOffered: {
23
- id: '69151228ad580da66c8b5068',
24
- typeOf: chevre.factory.eventType.ScreeningEvent
23
+ id: '7k9ayl8hc',
24
+ typeOf: chevre.factory.eventType.ScreeningEventSeries
25
25
  },
26
- availableAtOrFrom: {
27
- identifier: 'SmartTheaterTXN'
26
+ acceptedPaymentMethod: {
27
+ id: '5f9a52994f3709000abe6417',
28
+ typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
28
29
  },
29
30
  validFrom,
30
31
  validThrough,
@@ -35,10 +36,10 @@ async function main() {
35
36
  project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
36
37
  };
37
38
 
38
- let result = await eventOfferRepo.upsertEventOffersByIdentifier(
39
+ let result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
39
40
  [
40
41
  {
41
- $set: eventOffer,
42
+ $set: settingOffer,
42
43
  $unset: {}
43
44
  }
44
45
  ],
@@ -48,10 +49,10 @@ async function main() {
48
49
  );
49
50
  console.log(result);
50
51
 
51
- result = await eventOfferRepo.upsertEventOffersByIdentifier(
52
+ result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
52
53
  [
53
54
  {
54
- $set: eventOffer,
55
+ $set: settingOffer,
55
56
  $unset: {}
56
57
  }
57
58
  ],
@@ -0,0 +1,60 @@
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
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
12
+
13
+ const cursor = actionRepo.getCursor(
14
+ {
15
+ typeOf: { $eq: chevre.factory.actionType.AcceptAction },
16
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.assetTransactionType.Pay },
17
+ startDate: {
18
+ $gte: moment()
19
+ // tslint:disable-next-line:no-magic-numbers
20
+ .add(-3, 'days')
21
+ .toDate()
22
+ }
23
+ },
24
+ {
25
+ }
26
+ );
27
+ console.log('docs found');
28
+
29
+ let i = 0;
30
+ let ticketTokenCount = 0;
31
+ await cursor.eachAsync(async (doc) => {
32
+ i += 1;
33
+ const acceptAction = <chevre.factory.action.accept.pay.IAction>doc.toObject();
34
+
35
+ const ticketTokenByInstrument = acceptAction.instrument?.find((instrument) => instrument.typeOf === 'Ticket')?.ticketToken;
36
+ if (typeof ticketTokenByInstrument === 'string' && ticketTokenByInstrument !== '') {
37
+ console.log(
38
+ ticketTokenByInstrument,
39
+ ' ticket token exists.',
40
+ acceptAction.project.id, acceptAction.typeOf, acceptAction.object.typeOf,
41
+ acceptAction.startDate, acceptAction.identifier, i
42
+ );
43
+ ticketTokenCount += 1;
44
+ } else {
45
+ console.log(
46
+ ticketTokenByInstrument,
47
+ ' ticket token does not exists.',
48
+ acceptAction.project.id, acceptAction.typeOf, acceptAction.object.typeOf,
49
+ acceptAction.startDate, acceptAction.identifier, i
50
+ );
51
+ }
52
+ });
53
+
54
+ console.log(i, 'docs checked');
55
+ console.log(ticketTokenCount, 'ticketToken exist');
56
+ }
57
+
58
+ main()
59
+ .then()
60
+ .catch(console.error);
@@ -0,0 +1,67 @@
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
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
12
+
13
+ const cursor = assetTransactionRepo.getCursor(
14
+ {
15
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
16
+ startDate: {
17
+ $gte: moment()
18
+ // tslint:disable-next-line:no-magic-numbers
19
+ .add(-3, 'days')
20
+ .toDate()
21
+ },
22
+ 'object.typeOf': {
23
+ $exists: true,
24
+ $in: [
25
+ // chevre.factory.service.paymentService.PaymentServiceType.FaceToFace,
26
+ // chevre.factory.service.paymentService.PaymentServiceType.MovieTicket,
27
+ chevre.factory.service.paymentService.PaymentServiceType.CreditCard
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ }
33
+ );
34
+ console.log('docs found');
35
+
36
+ let i = 0;
37
+ let ticketTokenCount = 0;
38
+ await cursor.eachAsync(async (doc) => {
39
+ i += 1;
40
+ const payTransaction = <chevre.factory.assetTransaction.pay.ITransaction>doc.toObject();
41
+
42
+ const ticketTokenByInstrument = payTransaction.instrument?.find((instrument) => instrument.typeOf === 'Ticket')?.ticketToken;
43
+ if (typeof ticketTokenByInstrument === 'string' && ticketTokenByInstrument !== '') {
44
+ console.log(
45
+ ticketTokenByInstrument,
46
+ ' ticket token exists.',
47
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.object.typeOf,
48
+ payTransaction.startDate, payTransaction.transactionNumber, i
49
+ );
50
+ ticketTokenCount += 1;
51
+ } else {
52
+ console.log(
53
+ ticketTokenByInstrument,
54
+ ' ticket token does not exists.',
55
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.object.typeOf,
56
+ payTransaction.startDate, payTransaction.transactionNumber, i
57
+ );
58
+ }
59
+ });
60
+
61
+ console.log(i, 'docs checked');
62
+ console.log(ticketTokenCount, 'ticketToken exist');
63
+ }
64
+
65
+ main()
66
+ .then()
67
+ .catch(console.error);
@@ -0,0 +1,83 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ /**
9
+ * 指定する施設コード
10
+ */
11
+ const locationBranchCode = '120';
12
+ /**
13
+ * 指定するタイトルコード
14
+ */
15
+ const titleCode = '80001';
16
+ /**
17
+ * 指定するタイトル枝番
18
+ */
19
+ const titleBranchNum = '0';
20
+
21
+ async function main() {
22
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
23
+
24
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
25
+ const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
26
+ const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
27
+ const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
28
+
29
+ const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
30
+ endpoint: String(process.env.COA_ENDPOINT),
31
+ refreshToken: process.env.COA_REFRESH_TOKEN,
32
+ useFetch: true
33
+ });
34
+ const masterService = new (await chevre.loadCOA()).service.Master(
35
+ {
36
+ endpoint: String(process.env.COA_ENDPOINT),
37
+ auth: coaAuthClient
38
+ },
39
+ { timeout: 20000 }
40
+ );
41
+
42
+ const movieTheater = (await movieTheaterRepo.projectFields(
43
+ {
44
+ limit: 1,
45
+ page: 1,
46
+ project: { id: { $eq: project.id } },
47
+ branchCode: { $eq: locationBranchCode }
48
+ },
49
+ ['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
50
+ // []
51
+ )).shift();
52
+ if (movieTheater === undefined) {
53
+ throw new Error('movieTheater not found');
54
+ }
55
+ console.log('movieTheater:', movieTheater);
56
+
57
+ const result = await (await chevre.service.event.createService()).saveScreeningEventSeries(
58
+ {
59
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
60
+ seller: { id: movieTheater.parentOrganization.id },
61
+ movieTheater,
62
+ locationBranchCode,
63
+ saveScreeningEventSeries: true,
64
+ saveScreeningEventSeriesPeriodInMonth: 3
65
+ },
66
+ {
67
+ filterFilmsFromCOA: {
68
+ titleBranchNum,
69
+ titleCode
70
+ }
71
+ }
72
+ )({
73
+ categoryCode: categoryCodeRepo,
74
+ creativeWork: creativeWorkRepo,
75
+ eventSeries: eventSeriesRepo,
76
+ masterService
77
+ });
78
+ console.log('result:', result.savedEventsCount, result.screeningEventSerieses.length);
79
+ }
80
+
81
+ main()
82
+ .then(console.log)
83
+ .catch(console.error);
@@ -0,0 +1,148 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { createScreeningEventSeriesId } from '../../../../lib/chevre/service/event/saveScreeningEventSeries';
6
+ import { chevre } from '../../../../lib/index';
7
+
8
+ const project = { id: String(process.env.PROJECT_ID) };
9
+
10
+ /**
11
+ * 指定する施設コード
12
+ */
13
+ const locationBranchCode = '120';
14
+ /**
15
+ * 指定するルームコード
16
+ */
17
+ const roomCode = '30';
18
+ /**
19
+ * 指定するタイトルコード
20
+ */
21
+ const titleCode = '99100';
22
+ /**
23
+ * 指定するタイトル枝番
24
+ */
25
+ const titleBranchNum = '0';
26
+ /**
27
+ * 指定するスケジュールの開始日(日本時間)
28
+ */
29
+ const importDay = new Date();
30
+
31
+ // tslint:disable-next-line:max-func-body-length
32
+ async function main() {
33
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
34
+
35
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
36
+ const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
37
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
38
+ const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
39
+ const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
40
+ const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
41
+
42
+ const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
43
+ endpoint: String(process.env.COA_ENDPOINT),
44
+ refreshToken: process.env.COA_REFRESH_TOKEN,
45
+ useFetch: true
46
+ });
47
+ const masterService = new (await chevre.loadCOA()).service.Master(
48
+ {
49
+ endpoint: String(process.env.COA_ENDPOINT),
50
+ auth: coaAuthClient
51
+ },
52
+ { timeout: 20000 }
53
+ );
54
+
55
+ const movieTheater = (await movieTheaterRepo.projectFields(
56
+ {
57
+ limit: 1,
58
+ page: 1,
59
+ project: { id: { $eq: project.id } },
60
+ branchCode: { $eq: locationBranchCode }
61
+ },
62
+ ['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
63
+ // []
64
+ )).shift();
65
+ if (movieTheater === undefined) {
66
+ throw new Error('movieTheater not found');
67
+ }
68
+ console.log('movieTheater:', movieTheater);
69
+
70
+ const screeningRooms = await roomRepo.searchScreeningRooms({
71
+ project: { id: { $eq: project.id } },
72
+ containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
73
+ branchCode: { $eq: roomCode }
74
+ });
75
+ console.log(screeningRooms);
76
+
77
+ const eventSeriesId = createScreeningEventSeriesId({
78
+ theaterCode: locationBranchCode,
79
+ titleCode,
80
+ titleBranchNum
81
+ });
82
+ const eventSeries = (await eventSeriesRepo.projectEventSeriesFields(
83
+ {
84
+ id: { $eq: eventSeriesId },
85
+ project: { id: { $eq: project.id } }
86
+ },
87
+ [
88
+ 'project', 'typeOf', 'eventStatus', 'identifier',
89
+ 'name', 'kanaName', 'alternativeHeadline', 'location',
90
+ 'organizer', 'videoFormat', 'soundFormat', 'workPerformed',
91
+ 'duration', 'endDate', 'startDate', 'coaInfo',
92
+ 'offers', 'additionalProperty'
93
+ ]
94
+ )).shift();
95
+ if (eventSeries === undefined) {
96
+ throw new Error('eventSeries not found');
97
+ }
98
+ console.log(eventSeries);
99
+
100
+ const targetImportFrom = moment(importDay)
101
+ .tz('Asia/Tokyo')
102
+ .startOf('day');
103
+ const targetImportThrough = moment(importDay)
104
+ .tz('Asia/Tokyo')
105
+ .endOf('day');
106
+ const begin: string = moment(targetImportFrom)
107
+ .add(-1, 'day') // 深夜帯スケジュールが前日検索の結果に含まれるため
108
+ .tz('Asia/Tokyo')
109
+ .format('YYYYMMDD'); // COAは日本時間で判断
110
+ const end: string = moment(targetImportThrough)
111
+ // .add(-1, 'day')
112
+ .tz('Asia/Tokyo')
113
+ .format('YYYYMMDD'); // COAは日本時間で判断
114
+ console.log('importing screening events...', targetImportFrom, targetImportThrough, begin, end);
115
+
116
+ const result = await (await chevre.service.event.createService()).saveScreeningEvents(
117
+ {
118
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
119
+ seller: { id: movieTheater.parentOrganization.id },
120
+ movieTheater,
121
+ screeningRooms,
122
+ screeningEventSerieses: [eventSeries],
123
+ targetImportFrom: targetImportFrom.toDate(),
124
+ targetImportThrough: targetImportThrough.toDate(),
125
+ instrument: {
126
+ theaterCode: locationBranchCode,
127
+ begin, // debug(2024-04-24~)
128
+ end, // debug(2024-04-24~)
129
+ typeOf: 'WebAPI',
130
+ identifier: chevre.factory.service.webAPI.Identifier.COA
131
+ }
132
+ },
133
+ {
134
+ filterSchedulesFromCOA: { titleBranchNum, titleCode, roomCode }
135
+ }
136
+ )({
137
+ categoryCode: categoryCodeRepo,
138
+ creativeWork: creativeWorkRepo,
139
+ event: eventRepo,
140
+ eventSeries: eventSeriesRepo,
141
+ masterService
142
+ });
143
+ console.log('result:', result.length, 'events');
144
+ }
145
+
146
+ main()
147
+ .then(console.log)
148
+ .catch(console.error);
@@ -0,0 +1,93 @@
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 DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET = 'MovieTicket';
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
15
+
16
+ const cursor = eventSeriesRepo.getCursor(
17
+ {
18
+ 'project.id': { $eq: 'xxx' },
19
+ 'offers.unacceptedPaymentMethod': {
20
+ $exists: true,
21
+ $ne: DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
22
+ },
23
+ startDate: {
24
+ $lte: moment()
25
+ .add(-1, 'year')
26
+ .toDate()
27
+ }
28
+ // _id: { $eq: 'bliy11ffa' }
29
+ },
30
+ {
31
+ // _id: 1,
32
+ // offers: 1,
33
+ // startDate: 1,
34
+ // project: 1,
35
+ // typeOf: 1
36
+ }
37
+ );
38
+ console.log('docs found');
39
+
40
+ let i = 0;
41
+ let updateCount = 0;
42
+ await cursor.eachAsync(async (doc) => {
43
+ i += 1;
44
+ const eventSeries: Pick<
45
+ chevre.factory.eventSeries.IEvent,
46
+ 'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
47
+ > = doc.toObject();
48
+
49
+ console.log(
50
+ 'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
51
+ const unacceptedPaymentMethod = eventSeries.offers?.unacceptedPaymentMethod;
52
+ const alreadyMigrated = !Array.isArray(unacceptedPaymentMethod)
53
+ || (Array.isArray(unacceptedPaymentMethod)
54
+ && unacceptedPaymentMethod.every(
55
+ (paymentMethodType) => paymentMethodType === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
56
+ ));
57
+
58
+ if (alreadyMigrated) {
59
+ console.log(
60
+ 'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
61
+ } else {
62
+ if (Array.isArray(unacceptedPaymentMethod)) {
63
+ const newUnacceptedPaymentMethod = unacceptedPaymentMethod.filter(
64
+ (paymentMethod) => paymentMethod === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
65
+ );
66
+ console.log(
67
+ 'updating project...',
68
+ newUnacceptedPaymentMethod,
69
+ eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
70
+ await eventSeriesRepo.saveEventSeries({
71
+ id: eventSeries.id,
72
+ attributes: <any>{
73
+ ...{
74
+ typeOf: eventSeries.typeOf,
75
+ 'offers.unacceptedPaymentMethod': newUnacceptedPaymentMethod
76
+ }
77
+ }
78
+ });
79
+ updateCount += 1;
80
+ console.log(
81
+ 'updated.',
82
+ eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
83
+ }
84
+ }
85
+ });
86
+
87
+ console.log(i, 'docs checked');
88
+ console.log(updateCount, 'docs updated');
89
+ }
90
+
91
+ main()
92
+ .then()
93
+ .catch(console.error);
@@ -37,14 +37,14 @@ async function main() {
37
37
  id: project.id,
38
38
  typeOf: chevre.factory.organizationType.Project
39
39
  },
40
- locationBranchCode: '120',
41
- importFrom: moment()
40
+ locationBranchCode: '016',
41
+ importFrom: moment('2025-12-10T04:45:00.181Z')
42
42
  .toDate(),
43
- importThrough: moment()
44
- .add(1, 'day')
43
+ importThrough: moment('2025-12-11T04:45:00.181Z')
44
+ // .add(1, 'day')
45
45
  .toDate(),
46
46
  saveMovieTheater: false,
47
- saveScreeningEventSeries: false,
47
+ saveScreeningEventSeries: true,
48
48
  // saveScreeningEventSeries: true,
49
49
  saveScreeningEventSeriesPeriodInMonth: 3
50
50
  })({
@@ -0,0 +1,46 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const { PROJECT_ID } = process.env;
7
+ const formatter = new Intl.NumberFormat('ja-JP');
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ let startTime: [number, number] = process.hrtime();
12
+ let diff: [number, number] = process.hrtime(startTime);
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ setInterval(
16
+ async () => {
17
+ startTime = process.hrtime();
18
+ const result = await (await chevre.service.offer.createService()).findEventSeatOffersBySection({
19
+ limit: 100,
20
+ page: 10,
21
+ projectId: String(PROJECT_ID),
22
+ sellerId: '59d20831e53ebc2b4e774466',
23
+ eventId: '693622f7876e9977c32ae270',
24
+ /**
25
+ * セクションコード
26
+ */
27
+ sectionCode: 'Default'
28
+ })({
29
+ event: await chevre.repository.Event.createInstance(mongoose.connection),
30
+ seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
31
+ stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection })
32
+ });
33
+ diff = process.hrtime(startTime);
34
+ // tslint:disable-next-line:no-null-keyword
35
+ console.dir(result, { depth: null });
36
+ console.log(result.length, 'results found');
37
+ console.log('diff:', [diff[0], formatter.format(diff[1])]);
38
+ },
39
+ // tslint:disable-next-line:no-magic-numbers
40
+ 1000
41
+ );
42
+ }
43
+
44
+ main()
45
+ .then()
46
+ .catch(console.error);
@@ -0,0 +1,27 @@
1
+ // tslint:disable:no-console no-magic-numbers
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
11
+
12
+ const rooms = await roomRepo.searchScreeningRooms({
13
+ $projection: { sectionCount: 1 }
14
+ });
15
+ console.log('docs found');
16
+ console.log(rooms);
17
+
18
+ const mutipleSectionRooms = rooms.filter((room) => typeof room.sectionCount === 'number' && room.sectionCount > 1);
19
+ console.log(mutipleSectionRooms);
20
+
21
+ console.log(rooms.length, 'rooms');
22
+ console.log(mutipleSectionRooms.length, 'mutipleSectionRooms');
23
+ }
24
+
25
+ main()
26
+ .then()
27
+ .catch(console.error);
@@ -0,0 +1,50 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const PROJECT_ID = String(process.env.PROJECT_ID);
7
+ const SCREEN_CODE = '100';
8
+ const MOVIE_THEATER_CODE = '118';
9
+ const SELLER_ID = '59d20831e53ebc2b4e774466';
10
+
11
+ const formatter = new Intl.NumberFormat('ja-JP');
12
+
13
+ // tslint:disable-next-line:max-func-body-length
14
+ async function main() {
15
+ let startTime: [number, number] = process.hrtime();
16
+ let diff: [number, number] = process.hrtime(startTime);
17
+
18
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
19
+
20
+ const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
21
+
22
+ setInterval(
23
+ async () => {
24
+ startTime = process.hrtime();
25
+ const seats = await sectionRepo.findSectionsByRoom(
26
+ {
27
+ limit: 10,
28
+ page: 1,
29
+ projectId: PROJECT_ID,
30
+ sellerId: SELLER_ID,
31
+ movieTheaterCode: MOVIE_THEATER_CODE,
32
+ roomCode: SCREEN_CODE
33
+ }
34
+ );
35
+ diff = process.hrtime(startTime);
36
+ // tslint:disable-next-line:no-null-keyword
37
+ console.dir(seats, { depth: null });
38
+ console.log(seats.length, 'sections found');
39
+ console.log('diff:', [diff[0], formatter.format(diff[1])]);
40
+ },
41
+ // tslint:disable-next-line:no-magic-numbers
42
+ 1000
43
+ );
44
+ }
45
+
46
+ main()
47
+ .then(() => {
48
+ console.log('success!');
49
+ })
50
+ .catch(console.error);