@chevre/domain 21.2.0-alpha.98 → 21.2.0-alpha.99

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.
@@ -63,8 +63,11 @@ async function main() {
63
63
  name: 'xx'
64
64
  }
65
65
  },
66
- true,
67
- false
66
+ {
67
+ useCheckMovieTicketBeforePay: true,
68
+ useCheckByIdentifierIfNotYet: true,
69
+ searchTrade4accountId: false
70
+ }
68
71
  )({
69
72
  accountingReport: accountingReportRepo,
70
73
  action: actionRepo,
@@ -0,0 +1,33 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
10
+
11
+ const actionRepo = new chevre.repository.Action(mongoose.connection);
12
+ const actions = await actionRepo.search(
13
+ {
14
+ typeOf: { $eq: chevre.factory.actionType.CheckAction },
15
+ // project: { id: { $eq: project.id } },
16
+ object: {
17
+ movieTickets: {
18
+ identifier: { $eq: '0947524082' },
19
+ serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
20
+ }
21
+ }
22
+ },
23
+ ['_id'],
24
+ []
25
+ );
26
+ console.log('actions:', actions);
27
+ }
28
+
29
+ main()
30
+ .then(() => {
31
+ console.log('success!');
32
+ })
33
+ .catch(console.error);
@@ -21,7 +21,7 @@ class MongoRepository {
21
21
  }
22
22
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
23
23
  static CREATE_MONGO_CONDITIONS(params) {
24
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57;
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65;
25
25
  const andConditions = [];
26
26
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
27
27
  // tslint:disable-next-line:no-single-line-block-comment
@@ -75,9 +75,27 @@ class MongoRepository {
75
75
  }
76
76
  });
77
77
  }
78
+ const objectMovieTicketsIdentifierEq = (_o = (_m = (_l = params.object) === null || _l === void 0 ? void 0 : _l.movieTickets) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$eq;
79
+ if (typeof objectMovieTicketsIdentifierEq === 'string') {
80
+ andConditions.push({
81
+ 'object.movieTickets.identifier': {
82
+ $exists: true,
83
+ $eq: objectMovieTicketsIdentifierEq
84
+ }
85
+ });
86
+ }
87
+ const objectMovieTicketsServiceOutputReservationForIdEq = (_t = (_s = (_r = (_q = (_p = params.object) === null || _p === void 0 ? void 0 : _p.movieTickets) === null || _q === void 0 ? void 0 : _q.serviceOutput) === null || _r === void 0 ? void 0 : _r.reservationFor) === null || _s === void 0 ? void 0 : _s.id) === null || _t === void 0 ? void 0 : _t.$eq;
88
+ if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
89
+ andConditions.push({
90
+ 'object.movieTickets.serviceOutput.reservationFor.id': {
91
+ $exists: true,
92
+ $eq: objectMovieTicketsServiceOutputReservationForIdEq
93
+ }
94
+ });
95
+ }
78
96
  // tslint:disable-next-line:no-single-line-block-comment
79
97
  /* istanbul ignore else */
80
- const objectPaymentMethodIdEq = (_m = (_l = params.object) === null || _l === void 0 ? void 0 : _l.paymentMethodId) === null || _m === void 0 ? void 0 : _m.$eq;
98
+ const objectPaymentMethodIdEq = (_v = (_u = params.object) === null || _u === void 0 ? void 0 : _u.paymentMethodId) === null || _v === void 0 ? void 0 : _v.$eq;
81
99
  if (typeof objectPaymentMethodIdEq === 'string') {
82
100
  andConditions.push({
83
101
  'object.paymentMethodId': {
@@ -86,7 +104,7 @@ class MongoRepository {
86
104
  }
87
105
  });
88
106
  }
89
- const objectObjectPaymentMethodIdEq = (_q = (_p = (_o = params.object) === null || _o === void 0 ? void 0 : _o.object) === null || _p === void 0 ? void 0 : _p.paymentMethodId) === null || _q === void 0 ? void 0 : _q.$eq;
107
+ const objectObjectPaymentMethodIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.object) === null || _x === void 0 ? void 0 : _x.paymentMethodId) === null || _y === void 0 ? void 0 : _y.$eq;
90
108
  if (typeof objectObjectPaymentMethodIdEq === 'string') {
91
109
  andConditions.push({
92
110
  'object.object.paymentMethodId': {
@@ -95,7 +113,7 @@ class MongoRepository {
95
113
  }
96
114
  });
97
115
  }
98
- const objectReservationForIdEq = (_t = (_s = (_r = params.object) === null || _r === void 0 ? void 0 : _r.reservationFor) === null || _s === void 0 ? void 0 : _s.id) === null || _t === void 0 ? void 0 : _t.$eq;
116
+ const objectReservationForIdEq = (_1 = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationFor) === null || _0 === void 0 ? void 0 : _0.id) === null || _1 === void 0 ? void 0 : _1.$eq;
99
117
  // tslint:disable-next-line:no-single-line-block-comment
100
118
  /* istanbul ignore else */
101
119
  if (typeof objectReservationForIdEq === 'string') {
@@ -106,7 +124,7 @@ class MongoRepository {
106
124
  }
107
125
  });
108
126
  }
109
- const objectReservationNumberEq = (_v = (_u = params.object) === null || _u === void 0 ? void 0 : _u.reservationNumber) === null || _v === void 0 ? void 0 : _v.$eq;
127
+ const objectReservationNumberEq = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.reservationNumber) === null || _3 === void 0 ? void 0 : _3.$eq;
110
128
  if (typeof objectReservationNumberEq === 'string') {
111
129
  andConditions.push({
112
130
  'object.reservationNumber': {
@@ -115,7 +133,7 @@ class MongoRepository {
115
133
  }
116
134
  });
117
135
  }
118
- const objectReservationNumberIn = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationNumber) === null || _x === void 0 ? void 0 : _x.$in;
136
+ const objectReservationNumberIn = (_5 = (_4 = params.object) === null || _4 === void 0 ? void 0 : _4.reservationNumber) === null || _5 === void 0 ? void 0 : _5.$in;
119
137
  if (Array.isArray(objectReservationNumberIn)) {
120
138
  andConditions.push({
121
139
  'object.reservationNumber': {
@@ -124,7 +142,7 @@ class MongoRepository {
124
142
  }
125
143
  });
126
144
  }
127
- const objectPaymentMethodAccountIdEq = (_0 = (_z = (_y = params.object) === null || _y === void 0 ? void 0 : _y.paymentMethod) === null || _z === void 0 ? void 0 : _z.accountId) === null || _0 === void 0 ? void 0 : _0.$eq;
145
+ const objectPaymentMethodAccountIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.paymentMethod) === null || _7 === void 0 ? void 0 : _7.accountId) === null || _8 === void 0 ? void 0 : _8.$eq;
128
146
  // tslint:disable-next-line:no-single-line-block-comment
129
147
  /* istanbul ignore else */
130
148
  if (typeof objectPaymentMethodAccountIdEq === 'string') {
@@ -135,7 +153,7 @@ class MongoRepository {
135
153
  }
136
154
  });
137
155
  }
138
- const objectPaymentMethodPaymentMethodIdEq = (_3 = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.paymentMethod) === null || _2 === void 0 ? void 0 : _2.paymentMethodId) === null || _3 === void 0 ? void 0 : _3.$eq;
156
+ const objectPaymentMethodPaymentMethodIdEq = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.paymentMethod) === null || _10 === void 0 ? void 0 : _10.paymentMethodId) === null || _11 === void 0 ? void 0 : _11.$eq;
139
157
  // tslint:disable-next-line:no-single-line-block-comment
140
158
  /* istanbul ignore else */
141
159
  if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
@@ -146,7 +164,7 @@ class MongoRepository {
146
164
  }
147
165
  });
148
166
  }
149
- const objectPaymentMethodPaymentMethodIdIn = (_6 = (_5 = (_4 = params.object) === null || _4 === void 0 ? void 0 : _4.paymentMethod) === null || _5 === void 0 ? void 0 : _5.paymentMethodId) === null || _6 === void 0 ? void 0 : _6.$in;
167
+ const objectPaymentMethodPaymentMethodIdIn = (_14 = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.paymentMethod) === null || _13 === void 0 ? void 0 : _13.paymentMethodId) === null || _14 === void 0 ? void 0 : _14.$in;
150
168
  if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
151
169
  andConditions.push({
152
170
  'object.paymentMethod.paymentMethodId': {
@@ -155,7 +173,7 @@ class MongoRepository {
155
173
  }
156
174
  });
157
175
  }
158
- const objectPaymentMethodTypeOfEq = (_9 = (_8 = (_7 = params.object) === null || _7 === void 0 ? void 0 : _7.paymentMethod) === null || _8 === void 0 ? void 0 : _8.typeOf) === null || _9 === void 0 ? void 0 : _9.$eq;
176
+ const objectPaymentMethodTypeOfEq = (_17 = (_16 = (_15 = params.object) === null || _15 === void 0 ? void 0 : _15.paymentMethod) === null || _16 === void 0 ? void 0 : _16.typeOf) === null || _17 === void 0 ? void 0 : _17.$eq;
159
177
  // tslint:disable-next-line:no-single-line-block-comment
160
178
  /* istanbul ignore else */
161
179
  if (typeof objectPaymentMethodTypeOfEq === 'string') {
@@ -166,7 +184,7 @@ class MongoRepository {
166
184
  }
167
185
  });
168
186
  }
169
- const objectTypeOfEq = (_11 = (_10 = params.object) === null || _10 === void 0 ? void 0 : _10.typeOf) === null || _11 === void 0 ? void 0 : _11.$eq;
187
+ const objectTypeOfEq = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.typeOf) === null || _19 === void 0 ? void 0 : _19.$eq;
170
188
  // tslint:disable-next-line:no-single-line-block-comment
171
189
  /* istanbul ignore else */
172
190
  if (typeof objectTypeOfEq === 'string') {
@@ -177,7 +195,7 @@ class MongoRepository {
177
195
  }
178
196
  });
179
197
  }
180
- const objectTypeOfIn = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.typeOf) === null || _13 === void 0 ? void 0 : _13.$in;
198
+ const objectTypeOfIn = (_21 = (_20 = params.object) === null || _20 === void 0 ? void 0 : _20.typeOf) === null || _21 === void 0 ? void 0 : _21.$in;
181
199
  if (Array.isArray(objectTypeOfIn)) {
182
200
  andConditions.push({
183
201
  'object.typeOf': {
@@ -186,7 +204,7 @@ class MongoRepository {
186
204
  }
187
205
  });
188
206
  }
189
- const objectIdEq = (_15 = (_14 = params.object) === null || _14 === void 0 ? void 0 : _14.id) === null || _15 === void 0 ? void 0 : _15.$eq;
207
+ const objectIdEq = (_23 = (_22 = params.object) === null || _22 === void 0 ? void 0 : _22.id) === null || _23 === void 0 ? void 0 : _23.$eq;
190
208
  // tslint:disable-next-line:no-single-line-block-comment
191
209
  /* istanbul ignore else */
192
210
  if (typeof objectIdEq === 'string') {
@@ -197,7 +215,7 @@ class MongoRepository {
197
215
  }
198
216
  });
199
217
  }
200
- const objectIdIn = (_17 = (_16 = params.object) === null || _16 === void 0 ? void 0 : _16.id) === null || _17 === void 0 ? void 0 : _17.$in;
218
+ const objectIdIn = (_25 = (_24 = params.object) === null || _24 === void 0 ? void 0 : _24.id) === null || _25 === void 0 ? void 0 : _25.$in;
201
219
  if (Array.isArray(objectIdIn)) {
202
220
  andConditions.push({
203
221
  'object.id': {
@@ -206,7 +224,7 @@ class MongoRepository {
206
224
  }
207
225
  });
208
226
  }
209
- const objectOrderNumberIn = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.orderNumber) === null || _19 === void 0 ? void 0 : _19.$in;
227
+ const objectOrderNumberIn = (_27 = (_26 = params.object) === null || _26 === void 0 ? void 0 : _26.orderNumber) === null || _27 === void 0 ? void 0 : _27.$in;
210
228
  if (Array.isArray(objectOrderNumberIn)) {
211
229
  andConditions.push({
212
230
  'object.orderNumber': {
@@ -215,7 +233,7 @@ class MongoRepository {
215
233
  }
216
234
  });
217
235
  }
218
- const objectEventIdIn = (_22 = (_21 = (_20 = params.object) === null || _20 === void 0 ? void 0 : _20.event) === null || _21 === void 0 ? void 0 : _21.id) === null || _22 === void 0 ? void 0 : _22.$in;
236
+ const objectEventIdIn = (_30 = (_29 = (_28 = params.object) === null || _28 === void 0 ? void 0 : _28.event) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$in;
219
237
  if (Array.isArray(objectEventIdIn)) {
220
238
  andConditions.push({
221
239
  'object.event.id': {
@@ -224,7 +242,7 @@ class MongoRepository {
224
242
  }
225
243
  });
226
244
  }
227
- const objectAcceptedOfferSeatNumberIn = (_29 = (_28 = (_27 = (_26 = (_25 = (_24 = (_23 = params.object) === null || _23 === void 0 ? void 0 : _23.acceptedOffer) === null || _24 === void 0 ? void 0 : _24.itemOffered) === null || _25 === void 0 ? void 0 : _25.serviceOutput) === null || _26 === void 0 ? void 0 : _26.reservedTicket) === null || _27 === void 0 ? void 0 : _27.ticketedSeat) === null || _28 === void 0 ? void 0 : _28.seatNumber) === null || _29 === void 0 ? void 0 : _29.$in;
245
+ const objectAcceptedOfferSeatNumberIn = (_37 = (_36 = (_35 = (_34 = (_33 = (_32 = (_31 = params.object) === null || _31 === void 0 ? void 0 : _31.acceptedOffer) === null || _32 === void 0 ? void 0 : _32.itemOffered) === null || _33 === void 0 ? void 0 : _33.serviceOutput) === null || _34 === void 0 ? void 0 : _34.reservedTicket) === null || _35 === void 0 ? void 0 : _35.ticketedSeat) === null || _36 === void 0 ? void 0 : _36.seatNumber) === null || _37 === void 0 ? void 0 : _37.$in;
228
246
  if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
229
247
  andConditions.push({
230
248
  'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
@@ -241,7 +259,7 @@ class MongoRepository {
241
259
  });
242
260
  }
243
261
  else {
244
- const typeOfEq = (_30 = params.typeOf) === null || _30 === void 0 ? void 0 : _30.$eq;
262
+ const typeOfEq = (_38 = params.typeOf) === null || _38 === void 0 ? void 0 : _38.$eq;
245
263
  // tslint:disable-next-line:no-single-line-block-comment
246
264
  /* istanbul ignore else */
247
265
  if (typeof typeOfEq === 'string') {
@@ -250,7 +268,7 @@ class MongoRepository {
250
268
  });
251
269
  }
252
270
  }
253
- const actionStatusIn = (_31 = params.actionStatus) === null || _31 === void 0 ? void 0 : _31.$in;
271
+ const actionStatusIn = (_39 = params.actionStatus) === null || _39 === void 0 ? void 0 : _39.$in;
254
272
  // tslint:disable-next-line:no-single-line-block-comment
255
273
  /* istanbul ignore else */
256
274
  if (Array.isArray(actionStatusIn)) {
@@ -281,7 +299,7 @@ class MongoRepository {
281
299
  startDate: { $lte: startDateLte }
282
300
  });
283
301
  }
284
- const fromLocationTypeOfIn = (_33 = (_32 = params.fromLocation) === null || _32 === void 0 ? void 0 : _32.typeOf) === null || _33 === void 0 ? void 0 : _33.$in;
302
+ const fromLocationTypeOfIn = (_41 = (_40 = params.fromLocation) === null || _40 === void 0 ? void 0 : _40.typeOf) === null || _41 === void 0 ? void 0 : _41.$in;
285
303
  if (Array.isArray(fromLocationTypeOfIn)) {
286
304
  andConditions.push({
287
305
  'fromLocation.typeOf': {
@@ -290,7 +308,7 @@ class MongoRepository {
290
308
  }
291
309
  });
292
310
  }
293
- const fromLocationAccountNumberIn = (_35 = (_34 = params.fromLocation) === null || _34 === void 0 ? void 0 : _34.accountNumber) === null || _35 === void 0 ? void 0 : _35.$in;
311
+ const fromLocationAccountNumberIn = (_43 = (_42 = params.fromLocation) === null || _42 === void 0 ? void 0 : _42.accountNumber) === null || _43 === void 0 ? void 0 : _43.$in;
294
312
  if (Array.isArray(fromLocationAccountNumberIn)) {
295
313
  andConditions.push({
296
314
  'fromLocation.accountNumber': {
@@ -299,7 +317,7 @@ class MongoRepository {
299
317
  }
300
318
  });
301
319
  }
302
- const fromLocationAccountTypeIn = (_37 = (_36 = params.fromLocation) === null || _36 === void 0 ? void 0 : _36.accountType) === null || _37 === void 0 ? void 0 : _37.$in;
320
+ const fromLocationAccountTypeIn = (_45 = (_44 = params.fromLocation) === null || _44 === void 0 ? void 0 : _44.accountType) === null || _45 === void 0 ? void 0 : _45.$in;
303
321
  if (Array.isArray(fromLocationAccountTypeIn)) {
304
322
  andConditions.push({
305
323
  'fromLocation.accountType': {
@@ -308,7 +326,7 @@ class MongoRepository {
308
326
  }
309
327
  });
310
328
  }
311
- const toLocationTypeOfIn = (_39 = (_38 = params.toLocation) === null || _38 === void 0 ? void 0 : _38.typeOf) === null || _39 === void 0 ? void 0 : _39.$in;
329
+ const toLocationTypeOfIn = (_47 = (_46 = params.toLocation) === null || _46 === void 0 ? void 0 : _46.typeOf) === null || _47 === void 0 ? void 0 : _47.$in;
312
330
  if (Array.isArray(toLocationTypeOfIn)) {
313
331
  andConditions.push({
314
332
  'toLocation.typeOf': {
@@ -317,7 +335,7 @@ class MongoRepository {
317
335
  }
318
336
  });
319
337
  }
320
- const toLocationAccountNumberIn = (_41 = (_40 = params.toLocation) === null || _40 === void 0 ? void 0 : _40.accountNumber) === null || _41 === void 0 ? void 0 : _41.$in;
338
+ const toLocationAccountNumberIn = (_49 = (_48 = params.toLocation) === null || _48 === void 0 ? void 0 : _48.accountNumber) === null || _49 === void 0 ? void 0 : _49.$in;
321
339
  if (Array.isArray(toLocationAccountNumberIn)) {
322
340
  andConditions.push({
323
341
  'toLocation.accountNumber': {
@@ -326,7 +344,7 @@ class MongoRepository {
326
344
  }
327
345
  });
328
346
  }
329
- const toLocationAccountTypeIn = (_43 = (_42 = params.toLocation) === null || _42 === void 0 ? void 0 : _42.accountType) === null || _43 === void 0 ? void 0 : _43.$in;
347
+ const toLocationAccountTypeIn = (_51 = (_50 = params.toLocation) === null || _50 === void 0 ? void 0 : _50.accountType) === null || _51 === void 0 ? void 0 : _51.$in;
330
348
  if (Array.isArray(toLocationAccountTypeIn)) {
331
349
  andConditions.push({
332
350
  'toLocation.accountType': {
@@ -335,7 +353,7 @@ class MongoRepository {
335
353
  }
336
354
  });
337
355
  }
338
- const purposeTypeOfIn = (_45 = (_44 = params.purpose) === null || _44 === void 0 ? void 0 : _44.typeOf) === null || _45 === void 0 ? void 0 : _45.$in;
356
+ const purposeTypeOfIn = (_53 = (_52 = params.purpose) === null || _52 === void 0 ? void 0 : _52.typeOf) === null || _53 === void 0 ? void 0 : _53.$in;
339
357
  if (Array.isArray(purposeTypeOfIn)) {
340
358
  andConditions.push({
341
359
  'purpose.typeOf': {
@@ -344,7 +362,7 @@ class MongoRepository {
344
362
  }
345
363
  });
346
364
  }
347
- const purposeIdIn = (_47 = (_46 = params.purpose) === null || _46 === void 0 ? void 0 : _46.id) === null || _47 === void 0 ? void 0 : _47.$in;
365
+ const purposeIdIn = (_55 = (_54 = params.purpose) === null || _54 === void 0 ? void 0 : _54.id) === null || _55 === void 0 ? void 0 : _55.$in;
348
366
  if (Array.isArray(purposeIdIn)) {
349
367
  andConditions.push({
350
368
  'purpose.id': {
@@ -353,7 +371,7 @@ class MongoRepository {
353
371
  }
354
372
  });
355
373
  }
356
- const purposeOrderNumberIn = (_49 = (_48 = params.purpose) === null || _48 === void 0 ? void 0 : _48.orderNumber) === null || _49 === void 0 ? void 0 : _49.$in;
374
+ const purposeOrderNumberIn = (_57 = (_56 = params.purpose) === null || _56 === void 0 ? void 0 : _56.orderNumber) === null || _57 === void 0 ? void 0 : _57.$in;
357
375
  if (Array.isArray(purposeOrderNumberIn)) {
358
376
  andConditions.push({
359
377
  'purpose.orderNumber': {
@@ -362,7 +380,7 @@ class MongoRepository {
362
380
  }
363
381
  });
364
382
  }
365
- const resultTypeOfIn = (_51 = (_50 = params.result) === null || _50 === void 0 ? void 0 : _50.typeOf) === null || _51 === void 0 ? void 0 : _51.$in;
383
+ const resultTypeOfIn = (_59 = (_58 = params.result) === null || _58 === void 0 ? void 0 : _58.typeOf) === null || _59 === void 0 ? void 0 : _59.$in;
366
384
  if (Array.isArray(resultTypeOfIn)) {
367
385
  andConditions.push({
368
386
  'result.typeOf': {
@@ -371,7 +389,7 @@ class MongoRepository {
371
389
  }
372
390
  });
373
391
  }
374
- const resultIdIn = (_53 = (_52 = params.result) === null || _52 === void 0 ? void 0 : _52.id) === null || _53 === void 0 ? void 0 : _53.$in;
392
+ const resultIdIn = (_61 = (_60 = params.result) === null || _60 === void 0 ? void 0 : _60.id) === null || _61 === void 0 ? void 0 : _61.$in;
375
393
  if (Array.isArray(resultIdIn)) {
376
394
  andConditions.push({
377
395
  'result.id': {
@@ -380,7 +398,7 @@ class MongoRepository {
380
398
  }
381
399
  });
382
400
  }
383
- const resultOrderNumberIn = (_55 = (_54 = params.result) === null || _54 === void 0 ? void 0 : _54.orderNumber) === null || _55 === void 0 ? void 0 : _55.$in;
401
+ const resultOrderNumberIn = (_63 = (_62 = params.result) === null || _62 === void 0 ? void 0 : _62.orderNumber) === null || _63 === void 0 ? void 0 : _63.$in;
384
402
  if (Array.isArray(resultOrderNumberIn)) {
385
403
  andConditions.push({
386
404
  'result.orderNumber': {
@@ -389,7 +407,7 @@ class MongoRepository {
389
407
  }
390
408
  });
391
409
  }
392
- const resultCodeIn = (_57 = (_56 = params.result) === null || _56 === void 0 ? void 0 : _56.code) === null || _57 === void 0 ? void 0 : _57.$in;
410
+ const resultCodeIn = (_65 = (_64 = params.result) === null || _64 === void 0 ? void 0 : _64.code) === null || _65 === void 0 ? void 0 : _65.$in;
393
411
  if (Array.isArray(resultCodeIn)) {
394
412
  andConditions.push({
395
413
  'result.code': {
@@ -117,6 +117,18 @@ schema.index({ 'object.id': 1, startDate: -1 }, {
117
117
  'object.id': { $exists: true }
118
118
  }
119
119
  });
120
+ schema.index({ 'object.movieTickets.identifier': 1, startDate: -1 }, {
121
+ name: 'searchByObjectMovieTicketsIdentifier',
122
+ partialFilterExpression: {
123
+ 'object.movieTickets.identifier': { $exists: true }
124
+ }
125
+ });
126
+ schema.index({ 'object.movieTickets.serviceOutput.reservationFor.id': 1, startDate: -1 }, {
127
+ name: 'searchByObjectMovieTicketsServiceOutputReservationForId',
128
+ partialFilterExpression: {
129
+ 'object.movieTickets.serviceOutput.reservationFor.id': { $exists: true }
130
+ }
131
+ });
120
132
  schema.index({ 'object.paymentMethod.accountId': 1, startDate: -1 }, {
121
133
  name: 'searchByObjectPaymentMethodAccountId',
122
134
  partialFilterExpression: {
@@ -96,7 +96,11 @@ export declare function check(params: factory.action.check.paymentMethod.movieTi
96
96
  /**
97
97
  * 取引開始
98
98
  */
99
- export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, useCheckMovieTicketBeforePay: boolean, searchTrade4accountId: boolean): IStartOperation<factory.assetTransaction.pay.ITransaction>;
99
+ export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, options: {
100
+ useCheckMovieTicketBeforePay: boolean;
101
+ useCheckByIdentifierIfNotYet: boolean;
102
+ searchTrade4accountId: boolean;
103
+ }): IStartOperation<factory.assetTransaction.pay.ITransaction>;
100
104
  /**
101
105
  * 取引確定
102
106
  */
@@ -106,7 +106,7 @@ exports.check = check;
106
106
  /**
107
107
  * 取引開始
108
108
  */
109
- function start(params, useCheckMovieTicketBeforePay, searchTrade4accountId) {
109
+ function start(params, options) {
110
110
  return (repos) => __awaiter(this, void 0, void 0, function* () {
111
111
  var _a, _b;
112
112
  // 金額をfix
@@ -138,11 +138,11 @@ function start(params, useCheckMovieTicketBeforePay, searchTrade4accountId) {
138
138
  break;
139
139
  case factory.service.paymentService.PaymentServiceType.CreditCard:
140
140
  transaction =
141
- yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), searchTrade4accountId)(repos);
141
+ yield processAuthorizeCreditCard(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.searchTrade4accountId)(repos);
142
142
  break;
143
143
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
144
144
  transaction =
145
- yield processAuthorizeMovieTicket(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), useCheckMovieTicketBeforePay)(repos);
145
+ yield processAuthorizeMovieTicket(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.useCheckMovieTicketBeforePay, options.useCheckByIdentifierIfNotYet)(repos);
146
146
  break;
147
147
  default:
148
148
  throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
@@ -271,9 +271,9 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId, searc
271
271
  })(repos);
272
272
  });
273
273
  }
274
- function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay) {
274
+ function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
275
275
  return (repos) => __awaiter(this, void 0, void 0, function* () {
276
- const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay)(repos);
276
+ const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
277
277
  return saveAuthorizeResult({
278
278
  id: transaction.id,
279
279
  update: {
@@ -108,11 +108,14 @@ declare function authorize(params: {
108
108
  purpose: factory.action.authorize.paymentMethod.any.IPurpose;
109
109
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
110
110
  location?: factory.action.trade.pay.ILocation;
111
- /**
112
- * アクション失敗時に即時に決済取引を中止するかどうか
113
- */
114
- useCancelPayTransactionOnFailed: boolean;
115
- useCheckMovieTicketBeforePay: boolean;
116
- useSearchTrade4accountId: boolean;
111
+ options: {
112
+ /**
113
+ * アクション失敗時に即時に決済取引を中止するかどうか
114
+ */
115
+ useCancelPayTransactionOnFailed: boolean;
116
+ useCheckMovieTicketBeforePay: boolean;
117
+ useCheckByIdentifierIfNotYet: boolean;
118
+ useSearchTrade4accountId: boolean;
119
+ };
117
120
  }): IAuthorizeOperation<IAuthorizePaymentAction>;
118
121
  export { onPaymentStatusChanged, authorize, invalidatePaymentUrl, voidPayTransaction, person2username, processVoidPayTransaction, publishPaymentUrl };
@@ -314,7 +314,11 @@ function authorize(params) {
314
314
  transactionNumber: transactionNumber,
315
315
  location: params.location
316
316
  });
317
- payTransaction = yield PayTransactionService.start(startParams, params.useCheckMovieTicketBeforePay, params.useSearchTrade4accountId)(repos);
317
+ payTransaction = yield PayTransactionService.start(startParams, {
318
+ useCheckMovieTicketBeforePay: params.options.useCheckMovieTicketBeforePay,
319
+ useCheckByIdentifierIfNotYet: params.options.useCheckByIdentifierIfNotYet,
320
+ searchTrade4accountId: params.options.useSearchTrade4accountId
321
+ })(repos);
318
322
  }
319
323
  catch (error) {
320
324
  try {
@@ -325,7 +329,7 @@ function authorize(params) {
325
329
  // no op
326
330
  }
327
331
  // 即時に決済取引を中止するか?(2023-02-03~)
328
- if (params.useCancelPayTransactionOnFailed) {
332
+ if (params.options.useCancelPayTransactionOnFailed) {
329
333
  // abortエラーの場合は状態不明なので即時中止しない(2023-06-01~)
330
334
  // {
331
335
  // "type": "aborted",
@@ -6,16 +6,17 @@ interface ICheckResult {
6
6
  purchaseNumberAuthIn: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthIn;
7
7
  purchaseNumberAuthResult: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult;
8
8
  }
9
- /**
10
- * MovieTicket認証
11
- */
12
- declare function checkByIdentifier(params: {
9
+ interface ICheckByIdentifierParams {
13
10
  movieTickets: factory.action.check.paymentMethod.movieTicket.IMovieTicket[];
14
11
  seller: factory.seller.ISeller;
15
12
  screeningEvent: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
16
13
  paymentServiceId: string;
17
- }): (repos: {
14
+ }
15
+ /**
16
+ * MovieTicket認証
17
+ */
18
+ declare function checkByIdentifier(params: ICheckByIdentifierParams): (repos: {
18
19
  product: ProductRepo;
19
20
  project: ProjectRepo;
20
21
  }) => Promise<ICheckResult>;
21
- export { ICheckResult, checkByIdentifier };
22
+ export { ICheckByIdentifierParams, ICheckResult, checkByIdentifier };
@@ -1,12 +1,11 @@
1
- /**
2
- * 決済取引サービス
3
- */
4
1
  import * as factory from '../../../factory';
2
+ import { MongoRepository as ActionRepo } from '../../../repo/action';
5
3
  import { MongoRepository as EventRepo } from '../../../repo/event';
6
4
  import { MongoRepository as ProductRepo } from '../../../repo/product';
7
5
  import { MongoRepository as ProjectRepo } from '../../../repo/project';
8
6
  import { MongoRepository as SellerRepo } from '../../../repo/seller';
9
- export declare function validateMovieTicket(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean): (repos: {
7
+ export declare function validateMovieTicket(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
8
+ action: ActionRepo;
10
9
  event: EventRepo;
11
10
  product: ProductRepo;
12
11
  project: ProjectRepo;
@@ -10,12 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.validateMovieTicket = void 0;
13
- /**
14
- * 決済取引サービス
15
- */
13
+ const createDebug = require("debug");
16
14
  const factory = require("../../../factory");
17
15
  const checkByIdentifier_1 = require("./checkByIdentifier");
18
- function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBeforePay) {
16
+ const debug = createDebug('chevre-domain:service:payment');
17
+ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
19
18
  // tslint:disable-next-line:max-func-body-length
20
19
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
20
  var _a, _b, _c, _d;
@@ -33,6 +32,7 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
33
32
  if (movieTicketIdentifiers.length !== 1) {
34
33
  throw new factory.errors.Argument('movieTickets', 'Number of movie ticket identifiers must be 1');
35
34
  }
35
+ const movieTicketIdentifier = movieTicketIdentifiers[0];
36
36
  // ムビチケ系統の決済方法タイプは動的
37
37
  const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.typeOf;
38
38
  if (typeof paymentMethodType !== 'string') {
@@ -56,11 +56,13 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
56
56
  if (!useCheckMovieTicketBeforePay) {
57
57
  return { accountsReceivablesByServiceType: [] };
58
58
  }
59
- const checkResult = yield (0, checkByIdentifier_1.checkByIdentifier)({
59
+ const checkResult = yield checkByIdentifierIfNotYet({
60
+ movieTicketIdentifier,
60
61
  movieTickets: movieTickets,
61
62
  seller: seller,
62
63
  screeningEvent: screeningEvent,
63
- paymentServiceId
64
+ paymentServiceId,
65
+ useCheckByIdentifierIfNotYet
64
66
  })(repos);
65
67
  const accountsReceivablesByServiceType = [];
66
68
  // 券種ごとに枚数が足りているか
@@ -89,3 +91,35 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
89
91
  });
90
92
  }
91
93
  exports.validateMovieTicket = validateMovieTicket;
94
+ function checkByIdentifierIfNotYet(params) {
95
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
96
+ var _a;
97
+ let checkResult;
98
+ if (params.useCheckByIdentifierIfNotYet === true) {
99
+ // すでにCheckActionが存在すれば認証しない(2023-06-06~)
100
+ debug('searching alreadyCheckedActions...movieTicketIdentifier:', params.movieTicketIdentifier, 'screeningEvent.id:', params.screeningEvent.id, new Date());
101
+ const alreadyCheckedAction = yield repos.action.search({
102
+ limit: 1,
103
+ page: 1,
104
+ typeOf: { $eq: factory.actionType.CheckAction },
105
+ actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
106
+ object: {
107
+ typeOf: { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket },
108
+ movieTickets: {
109
+ identifier: { $eq: params.movieTicketIdentifier },
110
+ serviceOutput: {
111
+ reservationFor: { id: { $eq: params.screeningEvent.id } }
112
+ }
113
+ }
114
+ }
115
+ }, ['result'], []);
116
+ checkResult = (_a = alreadyCheckedAction.shift()) === null || _a === void 0 ? void 0 : _a.result;
117
+ debug('checkResult found', checkResult, 'movieTicketIdentifier:', params.movieTicketIdentifier, 'screeningEvent.id:', params.screeningEvent.id, new Date());
118
+ }
119
+ if (checkResult === undefined) {
120
+ debug('checkByIdentifier processing because movieTickets not checked yet...', checkResult);
121
+ checkResult = yield (0, checkByIdentifier_1.checkByIdentifier)(params)(repos);
122
+ }
123
+ return checkResult;
124
+ });
125
+ }
@@ -49,7 +49,7 @@ interface IAuthorizeResult {
49
49
  * MovieTicket承認
50
50
  * オーソリサービスが存在するわけではないので、実質着券する
51
51
  */
52
- declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean): (repos: {
52
+ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
53
53
  action: ActionRepo;
54
54
  accountingReport: AccountingReportRepo;
55
55
  event: EventRepo;
@@ -102,7 +102,7 @@ exports.checkMovieTicket = checkMovieTicket;
102
102
  * MovieTicket承認
103
103
  * オーソリサービスが存在するわけではないので、実質着券する
104
104
  */
105
- function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay) {
105
+ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
106
106
  return (repos) => __awaiter(this, void 0, void 0, function* () {
107
107
  var _a, _b;
108
108
  let accountId;
@@ -110,7 +110,7 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
110
110
  let accountsReceivablesByServiceType = [];
111
111
  try {
112
112
  // MovieTicket決済の場合、認証
113
- const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckMovieTicketBeforePay)(repos);
113
+ const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
114
114
  accountsReceivablesByServiceType = validateMovieTicketResult.accountsReceivablesByServiceType;
115
115
  const paymentMethod = transaction.object.paymentMethod;
116
116
  const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
@@ -338,9 +338,12 @@ function processAuthorizeCreditCard(params) {
338
338
  },
339
339
  purpose: params.purpose,
340
340
  paymentServiceType: factory.service.paymentService.PaymentServiceType.CreditCard,
341
- useCancelPayTransactionOnFailed: false,
342
- useCheckMovieTicketBeforePay: false,
343
- useSearchTrade4accountId: false
341
+ options: {
342
+ useCancelPayTransactionOnFailed: false,
343
+ useCheckMovieTicketBeforePay: false,
344
+ useCheckByIdentifierIfNotYet: false,
345
+ useSearchTrade4accountId: false
346
+ }
344
347
  })(repos);
345
348
  });
346
349
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.27",
12
+ "@chevre/factory": "4.313.0-alpha.28",
13
13
  "@cinerino/sdk": "3.157.0-alpha.8",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.98"
120
+ "version": "21.2.0-alpha.99"
121
121
  }
@@ -1,30 +0,0 @@
1
- // tslint:disable:no-implicit-dependencies no-console
2
- import { chevre } from '../../../lib/index';
3
-
4
- import * as mongoose from 'mongoose';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
10
-
11
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
12
- const assetTransactions = await assetTransactionRepo.search(
13
- {
14
- typeOf: chevre.factory.assetTransactionType.Reserve,
15
- project: { id: { $eq: project.id } },
16
- object: {
17
- reservations: { reservedTicket: { ticketedSeat: { seatNumber: { $eq: 'A-03' } } } }
18
- }
19
- },
20
- ['_id', 'transactionNumber'],
21
- []
22
- );
23
- console.log('assetTransactions:', assetTransactions);
24
- }
25
-
26
- main()
27
- .then(() => {
28
- console.log('success!');
29
- })
30
- .catch(console.error);