@chevre/domain 23.2.0-alpha.2 → 23.2.0-alpha.20

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 (67) hide show
  1. package/example/src/chevre/actions/checkAuthorizePaymentActions.ts +55 -0
  2. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  3. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  4. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  5. package/example/src/chevre/place/adminEntranceGates.ts +68 -0
  6. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  7. package/example/src/chevre/place/findRooms.ts +24 -0
  8. package/example/src/chevre/place/findSections.ts +28 -0
  9. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  10. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  11. package/example/src/chevre/place/upsertSeatsByBranchCode.ts +72 -0
  12. package/example/src/chevre/reIndex.ts +1 -1
  13. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  14. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  15. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  16. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  17. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  18. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  19. package/lib/chevre/repo/acceptedPaymentMethod.js +14 -10
  20. package/lib/chevre/repo/aggregateOrder.js +0 -93
  21. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  22. package/lib/chevre/repo/aggregateReservation.js +0 -2
  23. package/lib/chevre/repo/creativeWork.js +9 -5
  24. package/lib/chevre/repo/eventSeries.js +16 -12
  25. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  26. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  27. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  28. package/lib/chevre/repo/place/entranceGate.d.ts +58 -0
  29. package/lib/chevre/repo/place/entranceGate.js +159 -0
  30. package/lib/chevre/repo/place/movieTheater.d.ts +5 -2
  31. package/lib/chevre/repo/place/movieTheater.js +3 -1
  32. package/lib/chevre/repo/place/screeningRoom.d.ts +38 -31
  33. package/lib/chevre/repo/place/screeningRoom.js +166 -135
  34. package/lib/chevre/repo/place/seat.d.ts +47 -45
  35. package/lib/chevre/repo/place/seat.js +175 -45
  36. package/lib/chevre/repo/place/section.d.ts +36 -30
  37. package/lib/chevre/repo/place/section.js +214 -130
  38. package/lib/chevre/repository.d.ts +8 -0
  39. package/lib/chevre/repository.js +16 -0
  40. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +6 -1
  41. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +26 -4
  42. package/lib/chevre/service/assetTransaction/pay.d.ts +3 -0
  43. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  44. package/lib/chevre/service/event/processUpdateMovieTheater.js +1 -1
  45. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  46. package/lib/chevre/service/event/saveScreeningEvents.js +1 -1
  47. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  48. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  49. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  50. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  51. package/lib/chevre/service/payment/any/factory.d.ts +5 -0
  52. package/lib/chevre/service/payment/any/factory.js +11 -2
  53. package/lib/chevre/service/payment/any.d.ts +8 -0
  54. package/lib/chevre/service/payment/any.js +3 -2
  55. package/lib/chevre/service/task/authorizePayment.js +3 -1
  56. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  57. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +2 -2
  58. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  59. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  60. package/lib/chevre/service/task/publishPaymentUrl.js +3 -1
  61. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  62. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +2 -2
  63. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +3 -1
  64. package/lib/chevre/service/transaction/placeOrder/confirm.js +3 -1
  65. package/package.json +3 -2
  66. package/lib/chevre/service/eventOld.d.ts +0 -60
  67. package/lib/chevre/service/eventOld.js +0 -864
@@ -23,20 +23,112 @@ class SectionRepo {
23
23
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
24
24
  }
25
25
  // tslint:disable-next-line:max-func-body-length
26
- createScreeningRoomSection(screeningRoomSection) {
26
+ static CREATE_SECTION_MONGO_CONDITIONS(searchConditions) {
27
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
28
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
29
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
30
+ if (typeof projectIdEq === 'string') {
31
+ matchStages.push({
32
+ $match: { 'project.id': { $eq: projectIdEq } }
33
+ });
34
+ }
35
+ const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
36
+ if (typeof parentOrganizationIdEq === 'string') {
37
+ matchStages.push({
38
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
39
+ });
40
+ }
41
+ // 施設ID
42
+ const movieTheaterIdEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
43
+ if (typeof movieTheaterIdEq === 'string') {
44
+ matchStages.push({
45
+ $match: {
46
+ 'containedInPlace.id': { $exists: true, $eq: movieTheaterIdEq }
47
+ }
48
+ });
49
+ }
50
+ // 施設コード
51
+ const movieTheaterBranchCodeEq = (_k = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.containedInPlace) === null || _j === void 0 ? void 0 : _j.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
52
+ if (typeof movieTheaterBranchCodeEq === 'string') {
53
+ matchStages.push({
54
+ $match: {
55
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterBranchCodeEq }
56
+ }
57
+ });
58
+ }
59
+ // ルームコード
60
+ const containedInPlaceBranchCodeEq = (_m = (_l = searchConditions.containedInPlace) === null || _l === void 0 ? void 0 : _l.branchCode) === null || _m === void 0 ? void 0 : _m.$eq;
61
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
62
+ matchStages.push({
63
+ $match: {
64
+ branchCode: { $eq: containedInPlaceBranchCodeEq }
65
+ }
66
+ });
67
+ }
68
+ // セクションコード
69
+ const sectionBranchCodeEq = (_o = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _o === void 0 ? void 0 : _o.$eq;
70
+ if (typeof sectionBranchCodeEq === 'string') {
71
+ matchStages.push({
72
+ $match: {
73
+ 'containsPlace.branchCode': {
74
+ $exists: true,
75
+ $eq: sectionBranchCodeEq
76
+ }
77
+ }
78
+ });
79
+ }
80
+ const nameCodeRegex = (_p = searchConditions.name) === null || _p === void 0 ? void 0 : _p.$regex;
81
+ if (typeof nameCodeRegex === 'string') {
82
+ matchStages.push({
83
+ $match: {
84
+ $or: [
85
+ {
86
+ 'containsPlace.name.ja': {
87
+ $exists: true,
88
+ $regex: new RegExp(nameCodeRegex)
89
+ }
90
+ },
91
+ {
92
+ 'containsPlace.name.en': {
93
+ $exists: true,
94
+ $regex: new RegExp(nameCodeRegex)
95
+ }
96
+ }
97
+ ]
98
+ }
99
+ });
100
+ }
101
+ const branchCodeRegex = (_q = searchConditions.branchCode) === null || _q === void 0 ? void 0 : _q.$regex;
102
+ if (typeof branchCodeRegex === 'string') {
103
+ matchStages.push({
104
+ $match: {
105
+ 'containsPlace.branchCode': {
106
+ $exists: true,
107
+ $regex: new RegExp(branchCodeRegex)
108
+ }
109
+ }
110
+ });
111
+ }
112
+ const additionalPropertyElemMatch = (_r = searchConditions.additionalProperty) === null || _r === void 0 ? void 0 : _r.$elemMatch;
113
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
114
+ matchStages.push({
115
+ $match: {
116
+ 'containsPlace.additionalProperty': {
117
+ $exists: true,
118
+ $elemMatch: additionalPropertyElemMatch
119
+ }
120
+ }
121
+ });
122
+ }
123
+ return matchStages;
124
+ }
125
+ // tslint:disable-next-line:max-func-body-length
126
+ createSection(screeningRoomSection, options) {
27
127
  return __awaiter(this, void 0, void 0, function* () {
28
- var _a;
29
- const screeningRoom = screeningRoomSection.containedInPlace;
30
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
31
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
32
- }
33
- const movieTheater = screeningRoom.containedInPlace;
34
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
35
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
36
- }
128
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
37
129
  // 施設存在確認
38
- const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoomSection.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
39
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
130
+ const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
131
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
40
132
  : undefined), { _id: 1 })
41
133
  .lean()
42
134
  .exec();
@@ -46,13 +138,13 @@ class SectionRepo {
46
138
  // セクションコードが存在しなければ追加する
47
139
  const doc = yield this.placeModel.findOneAndUpdate({
48
140
  typeOf: { $eq: factory.placeType.ScreeningRoom },
49
- 'project.id': { $eq: screeningRoomSection.project.id },
50
- 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
51
- branchCode: { $eq: screeningRoom.branchCode },
141
+ 'project.id': { $eq: project.id },
142
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
143
+ branchCode: { $eq: roomCode },
52
144
  'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
53
145
  }, {
54
146
  $push: {
55
- containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
147
+ containsPlace: Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
56
148
  ? { additionalProperty: screeningRoomSection.additionalProperty }
57
149
  : undefined)
58
150
  }
@@ -68,21 +160,16 @@ class SectionRepo {
68
160
  return doc.toObject();
69
161
  });
70
162
  }
163
+ /**
164
+ * セクションの名称と追加特性を編集する
165
+ */
71
166
  // tslint:disable-next-line:max-func-body-length
72
- updateScreeningRoomSection(screeningRoomSection, $unset) {
167
+ updateSectionByBranchCode(screeningRoomSection, $unset, options) {
73
168
  return __awaiter(this, void 0, void 0, function* () {
74
- var _a;
75
- const screeningRoom = screeningRoomSection.containedInPlace;
76
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
77
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
78
- }
79
- const movieTheater = screeningRoom.containedInPlace;
80
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
81
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
82
- }
83
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
84
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
85
- : undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
169
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
170
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
171
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
172
+ : undefined), Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
86
173
  ? {
87
174
  'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
88
175
  }
@@ -90,13 +177,40 @@ class SectionRepo {
90
177
  ? {
91
178
  'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
92
179
  }
93
- : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
180
+ : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
181
+ new: true,
182
+ arrayFilters: [
183
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
184
+ ],
185
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
186
+ })
187
+ .exec();
188
+ if (doc === null) {
189
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
190
+ }
191
+ return doc.toObject();
192
+ });
193
+ }
194
+ /**
195
+ * セクションの座席を上書きする
196
+ */
197
+ // tslint:disable-next-line:max-func-body-length
198
+ overwriteSeats(screeningRoomSection, options) {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
201
+ const { containsPlace } = screeningRoomSection;
202
+ if (!Array.isArray(containsPlace)) {
203
+ throw new factory.errors.ArgumentNull('containsPlace');
204
+ }
205
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
206
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
207
+ : undefined), Object.assign({}, (containsPlace.length > 0)
94
208
  ? {
95
- 'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
209
+ 'containsPlace.$[screeningRoomSection].containsPlace': containsPlace.map((p) => {
96
210
  return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
97
211
  })
98
212
  }
99
- : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
213
+ : undefined), {
100
214
  new: true,
101
215
  arrayFilters: [
102
216
  { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
@@ -110,106 +224,76 @@ class SectionRepo {
110
224
  return doc.toObject();
111
225
  });
112
226
  }
113
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
114
- searchScreeningRoomSections(searchConditions) {
227
+ // tslint:disable-next-line:max-func-body-length
228
+ migrateSectionIdentifier(screeningRoomSection) {
115
229
  return __awaiter(this, void 0, void 0, function* () {
116
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
117
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
118
- const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
119
- if (typeof projectIdEq === 'string') {
120
- matchStages.push({
121
- $match: { 'project.id': { $eq: projectIdEq } }
122
- });
123
- }
124
- const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
125
- if (typeof parentOrganizationIdEq === 'string') {
126
- matchStages.push({
127
- $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
128
- });
129
- }
130
- // 施設コード
131
- const movieTheaterBranchCodeEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
132
- if (typeof movieTheaterBranchCodeEq === 'string') {
133
- matchStages.push({
134
- $match: {
135
- 'containedInPlace.branchCode': {
136
- $exists: true,
137
- $eq: movieTheaterBranchCodeEq
138
- }
139
- }
140
- });
141
- }
142
- // ルームコード
143
- const containedInPlaceBranchCodeEq = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$eq;
144
- if (typeof containedInPlaceBranchCodeEq === 'string') {
145
- matchStages.push({
146
- $match: {
147
- branchCode: {
148
- $eq: containedInPlaceBranchCodeEq
149
- }
150
- }
151
- });
152
- }
153
- // セクションコード
154
- const sectionBranchCodeEq = (_k = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
155
- if (typeof sectionBranchCodeEq === 'string') {
156
- matchStages.push({
157
- $match: {
158
- 'containsPlace.branchCode': {
159
- $exists: true,
160
- $eq: sectionBranchCodeEq
161
- }
162
- }
163
- });
230
+ const screeningRoom = screeningRoomSection.containedInPlace;
231
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
232
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
164
233
  }
165
- const nameCodeRegex = (_l = searchConditions.name) === null || _l === void 0 ? void 0 : _l.$regex;
166
- if (typeof nameCodeRegex === 'string') {
167
- matchStages.push({
168
- $match: {
169
- $or: [
170
- {
171
- 'containsPlace.name.ja': {
172
- $exists: true,
173
- $regex: new RegExp(nameCodeRegex)
174
- }
175
- },
176
- {
177
- 'containsPlace.name.en': {
178
- $exists: true,
179
- $regex: new RegExp(nameCodeRegex)
180
- }
181
- }
182
- ]
183
- }
184
- });
234
+ const movieTheater = screeningRoom.containedInPlace;
235
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
236
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
185
237
  }
186
- const branchCodeRegex = (_m = searchConditions.branchCode) === null || _m === void 0 ? void 0 : _m.$regex;
187
- if (typeof branchCodeRegex === 'string') {
188
- matchStages.push({
189
- $match: {
190
- 'containsPlace.branchCode': {
191
- $exists: true,
192
- $regex: new RegExp(branchCodeRegex)
193
- }
194
- }
195
- });
238
+ const doc = yield this.placeModel.findOneAndUpdate({
239
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
240
+ 'project.id': { $eq: screeningRoomSection.project.id },
241
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
242
+ branchCode: { $eq: screeningRoom.branchCode },
243
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
244
+ }, {
245
+ 'containsPlace.$[screeningRoomSection].identifier': screeningRoomSection.identifier
246
+ }, {
247
+ new: true,
248
+ arrayFilters: [
249
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
250
+ ],
251
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
252
+ })
253
+ .exec();
254
+ if (doc === null) {
255
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
196
256
  }
197
- const additionalPropertyElemMatch = (_o = searchConditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
198
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
199
- matchStages.push({
200
- $match: {
201
- 'containsPlace.additionalProperty': {
202
- $exists: true,
203
- $elemMatch: additionalPropertyElemMatch
204
- }
257
+ return doc.toObject();
258
+ });
259
+ }
260
+ /**
261
+ * 最小限のprojectionでセクション検索を再定義
262
+ * 2026-01-08~
263
+ */
264
+ findSections(params) {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const aggregate = this.placeModel.aggregate([
267
+ { $unwind: '$containsPlace' },
268
+ ...SectionRepo.CREATE_SECTION_MONGO_CONDITIONS(params),
269
+ {
270
+ $project: {
271
+ _id: 0,
272
+ branchCode: '$containsPlace.branchCode',
273
+ name: '$containsPlace.name',
274
+ additionalProperty: '$containsPlace.additionalProperty'
205
275
  }
206
- });
276
+ }
277
+ ]);
278
+ const { limit, page } = params;
279
+ if (typeof limit === 'number' && limit > 0) {
280
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
281
+ aggregate.skip(limit * (pageMustBePositive - 1))
282
+ .limit(limit);
207
283
  }
284
+ return aggregate
285
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
286
+ .exec();
287
+ });
288
+ }
289
+ searchScreeningRoomSections(searchConditions) {
290
+ return __awaiter(this, void 0, void 0, function* () {
291
+ var _a, _b;
208
292
  const aggregate = this.placeModel.aggregate([
209
293
  { $unwind: '$containsPlace' },
210
- ...matchStages,
294
+ ...SectionRepo.CREATE_SECTION_MONGO_CONDITIONS(searchConditions),
211
295
  {
212
- $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
296
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', identifier: '$containsPlace.identifier', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_a = searchConditions.$projection) === null || _a === void 0 ? void 0 : _a.containedInPlace) === 1)
213
297
  ? {
214
298
  containedInPlace: {
215
299
  typeOf: '$typeOf',
@@ -223,7 +307,7 @@ class SectionRepo {
223
307
  }
224
308
  }
225
309
  }
226
- : undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
310
+ : undefined), (((_b = searchConditions.$projection) === null || _b === void 0 ? void 0 : _b.seatCount) === 1)
227
311
  ? {
228
312
  seatCount: {
229
313
  $cond: {
@@ -295,14 +379,14 @@ class SectionRepo {
295
379
  .exec();
296
380
  });
297
381
  }
298
- deleteScreeningRoomSection(screeningRoomSection) {
382
+ deleteSectionByBranchCode(screeningRoomSection, options) {
299
383
  return __awaiter(this, void 0, void 0, function* () {
300
- var _a;
301
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': {
384
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
385
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
302
386
  $exists: true,
303
- $eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
304
- }, branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
305
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
387
+ $eq: movieTheaterCode
388
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
389
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
306
390
  : undefined), {
307
391
  $pull: {
308
392
  containsPlace: {
@@ -51,6 +51,7 @@ import type { PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
51
51
  import type { PendingReservationRepo } from './repo/pendingReservation';
52
52
  import type { PermitRepo } from './repo/permit';
53
53
  import type { BusStopRepo } from './repo/place/busStop';
54
+ import type { EntranceGateRepo } from './repo/place/entranceGate';
54
55
  import type { HasPOSRepo } from './repo/place/hasPOS';
55
56
  import type { MovieTheaterRepo } from './repo/place/movieTheater';
56
57
  import type { ScreeningRoomRepo } from './repo/place/screeningRoom';
@@ -316,6 +317,13 @@ export declare namespace place {
316
317
  namespace BusStop {
317
318
  function createInstance(...params: ConstructorParameters<typeof BusStopRepo>): Promise<BusStopRepo>;
318
319
  }
320
+ type EntranceGate = EntranceGateRepo;
321
+ /**
322
+ * 施設の入場ゲートリポジトリ
323
+ */
324
+ namespace EntranceGate {
325
+ function createInstance(...params: ConstructorParameters<typeof EntranceGateRepo>): Promise<EntranceGateRepo>;
326
+ }
319
327
  type HasPOS = HasPOSRepo;
320
328
  /**
321
329
  * 施設PointOfSalesリポジトリ
@@ -721,6 +721,22 @@ var place;
721
721
  }
722
722
  BusStop.createInstance = createInstance;
723
723
  })(BusStop = place.BusStop || (place.BusStop = {}));
724
+ /**
725
+ * 施設の入場ゲートリポジトリ
726
+ */
727
+ let EntranceGate;
728
+ (function (EntranceGate) {
729
+ let repo;
730
+ function createInstance(...params) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ if (repo === undefined) {
733
+ repo = (yield Promise.resolve().then(() => require('./repo/place/entranceGate'))).EntranceGateRepo;
734
+ }
735
+ return new repo(...params);
736
+ });
737
+ }
738
+ EntranceGate.createInstance = createInstance;
739
+ })(EntranceGate = place.EntranceGate || (place.EntranceGate = {}));
724
740
  /**
725
741
  * 施設PointOfSalesリポジトリ
726
742
  */
@@ -1,16 +1,21 @@
1
1
  import * as factory from '../../../factory';
2
+ import type { AcceptedPaymentMethodRepo } from '../../../repo/acceptedPaymentMethod';
2
3
  import type { EventRepo } from '../../../repo/event';
3
4
  import type { EventSeriesRepo } from '../../../repo/eventSeries';
4
5
  /**
5
6
  * 必要あらば関連リソースの対応決済方法を検証する
6
7
  */
7
- export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> | {
8
+ export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> & {
9
+ instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
10
+ } | {
8
11
  object: factory.action.accept.pay.IPayObject & {
9
12
  paymentMethod: factory.action.accept.pay.IPaymentMethod & {
10
13
  movieTickets: never;
11
14
  };
12
15
  };
16
+ instrument: factory.action.accept.pay.IInstrument[];
13
17
  }): (repos: {
18
+ acceptedPaymentMethod: AcceptedPaymentMethodRepo;
14
19
  event: EventRepo;
15
20
  eventSeries: EventSeriesRepo;
16
21
  }) => Promise<void>;
@@ -19,14 +19,18 @@ const debug = createDebug('chevre-domain:service:assetTransaction:pay');
19
19
  /**
20
20
  * 必要あらば関連リソースの対応決済方法を検証する
21
21
  */
22
+ // tslint:disable-next-line:max-func-body-length
22
23
  function validateAcceptedPaymentMethodIfNeeded(params) {
24
+ // tslint:disable-next-line:max-func-body-length
23
25
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
26
  var _a, _b;
27
+ const now = new Date();
25
28
  /**
26
29
  * 検証対象のイベントIDリスト
27
30
  */
28
31
  let checkingEventIds;
29
32
  const paymentServiceType = params.object.typeOf;
33
+ const paymentServiceId = params.object.id;
30
34
  // CreditCard or MovieTicket?
31
35
  if (paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
32
36
  // クレジットカードIF決済の場合、objectに注文アイテム指定があればそちらで検証する
@@ -77,10 +81,28 @@ function validateAcceptedPaymentMethodIfNeeded(params) {
77
81
  }
78
82
  if (((_b = eventSeries.offers) === null || _b === void 0 ? void 0 : _b.typeOf) === factory.offerType.AggregateOffer) {
79
83
  // 対応決済方法オファーIDの指定が必要
80
- throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferId');
81
- // if (paymentAccepted !== true) {
82
- // throw new factory.errors.Argument('recipient', `payment not accepted [${paymentMethodType}]`);
83
- // }
84
+ const acceptedPaymentMethodOfferIds = [];
85
+ params.instrument.forEach((instrument) => {
86
+ if (instrument.typeOf === factory.offerType.Offer) {
87
+ acceptedPaymentMethodOfferIds.push(instrument.id);
88
+ }
89
+ });
90
+ if (acceptedPaymentMethodOfferIds.length === 0) {
91
+ throw new factory.errors.ArgumentNull('acceptedPaymentMethodOfferIds');
92
+ }
93
+ // 全施設コンテンツについて有効な対応決済方法オファーの存在を検証
94
+ const validAcceptedPaymentMethodOffer = (yield repos.acceptedPaymentMethod.findAcceptedPaymentMethods({
95
+ limit: 1,
96
+ page: 1,
97
+ id: { $in: acceptedPaymentMethodOfferIds }, // 指定されたIDで
98
+ itemOffered: { id: { $eq: eventSeriesId } }, // リソースに対して
99
+ acceptedPaymentMethod: { id: { $eq: paymentServiceId } }, // 決済方法を許可
100
+ validFrom: { $lte: now }, // 現在有効
101
+ validThrough: { $gte: now } // 現在有効
102
+ }, ['identifier'])).shift();
103
+ if (validAcceptedPaymentMethodOffer === undefined) {
104
+ throw new factory.errors.NotFound(factory.offerType.Offer, `payment not accepted. eventSeriesId: ${eventSeriesId}`);
105
+ }
84
106
  }
85
107
  else {
86
108
  // 集約オファーでなければ検証の必要なし
@@ -5,6 +5,7 @@ import * as GMO from '@motionpicture/gmo-service';
5
5
  import * as factory from '../../factory';
6
6
  import { Settings } from '../../settings';
7
7
  import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
8
+ import type { AcceptedPaymentMethodRepo } from '../../repo/acceptedPaymentMethod';
8
9
  import type { AccountingReportRepo } from '../../repo/accountingReport';
9
10
  import type { ActionRepo } from '../../repo/action';
10
11
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
@@ -21,6 +22,7 @@ import type { TaskRepo } from '../../repo/task';
21
22
  import * as CreditCardPayment from '../payment/creditCard';
22
23
  import * as MovieTicketPayment from '../payment/movieTicket';
23
24
  export interface IStartOperationRepos {
25
+ acceptedPaymentMethod: AcceptedPaymentMethodRepo;
24
26
  accountingReport: AccountingReportRepo;
25
27
  action: ActionRepo;
26
28
  credentials: CredentialsRepo;
@@ -62,6 +64,7 @@ export type ICheckOperation<T> = (repos: {
62
64
  paymentServiceProvider: PaymentServiceProviderRepo;
63
65
  }, settings: Settings) => Promise<T>;
64
66
  export type IPublishPaymentUrlOperation<T> = (repos: {
67
+ acceptedPaymentMethod: AcceptedPaymentMethodRepo;
65
68
  action: ActionRepo;
66
69
  event: EventRepo;
67
70
  eventSeries: EventSeriesRepo;
@@ -19,6 +19,6 @@ declare function processUpdateMovieTheater(params: IImportFromCOAParams): (repos
19
19
  id: string;
20
20
  };
21
21
  movieTheater: IMovieTheater;
22
- screeningRooms: Omit<factory.place.screeningRoom.IPlace, "containsPlace" | "parentOrganization">[];
22
+ screeningRooms: Pick<factory.place.screeningRoom.IPlace, "additionalProperty" | "address" | "branchCode" | "name" | "openSeatingAllowed">[];
23
23
  }>;
24
24
  export { processUpdateMovieTheater };
@@ -65,7 +65,7 @@ function processUpdateMovieTheater(params) {
65
65
  if (movieTheater === undefined) {
66
66
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
67
67
  }
68
- screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
68
+ screeningRooms = yield repos.screeningRoom.findRooms({
69
69
  project: { id: { $eq: params.project.id } },
70
70
  containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
71
71
  });
@@ -7,7 +7,7 @@ import * as factory from '../../factory';
7
7
  type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | 'branchCode' | 'name' | 'kanaName'>;
8
8
  declare function saveScreeningEvents(params: {
9
9
  movieTheater: IMovieTheater;
10
- screeningRooms: Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'maximumAttendeeCapacity'>[];
10
+ screeningRooms: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'name' | 'maximumAttendeeCapacity'>[];
11
11
  screeningEventSerieses?: factory.eventSeries.IEvent[];
12
12
  project: {
13
13
  id: string;
@@ -266,7 +266,7 @@ function createScreeningEventFromCOA(params) {
266
266
  name: params.superEvent.name,
267
267
  eventStatus: factory.eventStatusType.EventScheduled,
268
268
  location: {
269
- typeOf: params.screenRoom.typeOf,
269
+ typeOf: factory.placeType.ScreeningRoom,
270
270
  branchCode: params.screenRoom.branchCode,
271
271
  name: params.screenRoom.name
272
272
  },
@@ -127,7 +127,7 @@ function searchTicketOffersByItemOffered(params) {
127
127
  function searchEventTicketOffersByEvent(params) {
128
128
  // tslint:disable-next-line:max-func-body-length
129
129
  return (repos) => __awaiter(this, void 0, void 0, function* () {
130
- var _a;
130
+ var _a, _b;
131
131
  const event = params.event;
132
132
  let soundFormatTypes = [];
133
133
  let videoFormatTypes = [];
@@ -137,13 +137,16 @@ function searchEventTicketOffersByEvent(params) {
137
137
  page: 1,
138
138
  id: { $eq: event.superEvent.id }
139
139
  // typeOf: factory.eventType.ScreeningEventSeries
140
- }, ['soundFormat', 'videoFormat']);
140
+ },
141
+ // ['soundFormat', 'videoFormat', 'subEvent']
142
+ ['soundFormat', 'subEvent']);
141
143
  const superEvent = superEvents.shift();
142
144
  if (superEvent === undefined) {
143
145
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
144
146
  }
145
147
  soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
146
- videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
148
+ // videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
149
+ videoFormatTypes = (Array.isArray((_a = superEvent.subEvent) === null || _a === void 0 ? void 0 : _a.videoFormat)) ? superEvent.subEvent.videoFormat : [];
147
150
  }
148
151
  const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
149
152
  // 上映方式がなければMovieTicket除外(2023-02-21~)
@@ -151,7 +154,7 @@ function searchEventTicketOffersByEvent(params) {
151
154
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
152
155
  const eventOffers = event.offers;
153
156
  const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
154
- itemOffered: { id: String((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) },
157
+ itemOffered: { id: String((_b = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _b === void 0 ? void 0 : _b.id) },
155
158
  // ids: params.ids,
156
159
  store: params.store,
157
160
  limit: params.limit,