@chevre/domain 21.5.0-alpha.3 → 21.5.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ class MongoRepository {
24
24
  }
25
25
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
26
26
  static CREATE_MONGO_CONDITIONS(params) {
27
- 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;
27
+ 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;
28
28
  const andConditions = [
29
29
  {
30
30
  typeOf: params.typeOf
@@ -176,7 +176,11 @@ class MongoRepository {
176
176
  case factory.assetTransactionType.CancelReservation:
177
177
  break;
178
178
  case factory.assetTransactionType.Reserve:
179
- const objectReservationForIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationFor) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
179
+ const objectProviderIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.provider) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
180
+ if (typeof objectProviderIdEq === 'string') {
181
+ andConditions.push({ 'object.provider.id': { $exists: true, $eq: objectProviderIdEq } });
182
+ }
183
+ 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;
180
184
  if (typeof objectReservationForIdEq === 'string') {
181
185
  andConditions.push({
182
186
  'object.reservationFor.id': {
@@ -185,7 +189,7 @@ class MongoRepository {
185
189
  }
186
190
  });
187
191
  }
188
- const objectReservationNumberIn = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationNumber) === null || _0 === void 0 ? void 0 : _0.$in;
192
+ const objectReservationNumberIn = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.reservationNumber) === null || _3 === void 0 ? void 0 : _3.$in;
189
193
  if (Array.isArray(objectReservationNumberIn)) {
190
194
  andConditions.push({
191
195
  'object.reservationNumber': {
@@ -194,7 +198,7 @@ class MongoRepository {
194
198
  }
195
199
  });
196
200
  }
197
- const objectReservationNumberEq = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.reservationNumber) === null || _2 === void 0 ? void 0 : _2.$eq;
201
+ const objectReservationNumberEq = (_5 = (_4 = params.object) === null || _4 === void 0 ? void 0 : _4.reservationNumber) === null || _5 === void 0 ? void 0 : _5.$eq;
198
202
  if (typeof objectReservationNumberEq === 'string') {
199
203
  andConditions.push({
200
204
  'object.reservationNumber': {
@@ -203,7 +207,7 @@ class MongoRepository {
203
207
  }
204
208
  });
205
209
  }
206
- const objectSubReservationIdIn = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservations) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$in;
210
+ const objectSubReservationIdIn = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.reservations) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$in;
207
211
  if (Array.isArray(objectSubReservationIdIn)) {
208
212
  andConditions.push({
209
213
  'object.subReservation.id': {
@@ -238,7 +242,7 @@ class MongoRepository {
238
242
  }
239
243
  }
240
244
  }
241
- const objectUnderNameIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.underName) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$eq;
245
+ const objectUnderNameIdEq = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.underName) === null || _10 === void 0 ? void 0 : _10.id) === null || _11 === void 0 ? void 0 : _11.$eq;
242
246
  if (typeof objectUnderNameIdEq === 'string') {
243
247
  andConditions.push({
244
248
  'object.underName.id': {
@@ -247,7 +251,7 @@ class MongoRepository {
247
251
  }
248
252
  });
249
253
  }
250
- const objectSubReservationSeatNumberEq = (_13 = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.reservations) === null || _10 === void 0 ? void 0 : _10.reservedTicket) === null || _11 === void 0 ? void 0 : _11.ticketedSeat) === null || _12 === void 0 ? void 0 : _12.seatNumber) === null || _13 === void 0 ? void 0 : _13.$eq;
254
+ const objectSubReservationSeatNumberEq = (_16 = (_15 = (_14 = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.reservations) === null || _13 === void 0 ? void 0 : _13.reservedTicket) === null || _14 === void 0 ? void 0 : _14.ticketedSeat) === null || _15 === void 0 ? void 0 : _15.seatNumber) === null || _16 === void 0 ? void 0 : _16.$eq;
251
255
  if (typeof objectSubReservationSeatNumberEq === 'string') {
252
256
  andConditions.push({
253
257
  'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
@@ -258,7 +262,7 @@ class MongoRepository {
258
262
  }
259
263
  break;
260
264
  case factory.assetTransactionType.RegisterService:
261
- const objectItemOfferedServiceOutputIdentifierEq = (_17 = (_16 = (_15 = (_14 = params.object) === null || _14 === void 0 ? void 0 : _14.itemOffered) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.identifier) === null || _17 === void 0 ? void 0 : _17.$eq;
265
+ const objectItemOfferedServiceOutputIdentifierEq = (_20 = (_19 = (_18 = (_17 = params.object) === null || _17 === void 0 ? void 0 : _17.itemOffered) === null || _18 === void 0 ? void 0 : _18.serviceOutput) === null || _19 === void 0 ? void 0 : _19.identifier) === null || _20 === void 0 ? void 0 : _20.$eq;
262
266
  if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
263
267
  andConditions.push({
264
268
  'object.itemOffered.serviceOutput.identifier': {
@@ -267,7 +271,7 @@ class MongoRepository {
267
271
  }
268
272
  });
269
273
  }
270
- const objectItemOfferedServiceOutputIdentifierIn = (_21 = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
274
+ const objectItemOfferedServiceOutputIdentifierIn = (_24 = (_23 = (_22 = (_21 = params.object) === null || _21 === void 0 ? void 0 : _21.itemOffered) === null || _22 === void 0 ? void 0 : _22.serviceOutput) === null || _23 === void 0 ? void 0 : _23.identifier) === null || _24 === void 0 ? void 0 : _24.$in;
271
275
  if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
272
276
  andConditions.push({
273
277
  'object.itemOffered.serviceOutput.identifier': {
@@ -99,6 +99,12 @@ schema.index({ 'object.paymentMethodId': 1, startDate: -1 }, {
99
99
  'object.paymentMethodId': { $exists: true }
100
100
  }
101
101
  });
102
+ schema.index({ 'object.provider.id': 1, startDate: -1 }, {
103
+ name: 'searchByObjectProviderId',
104
+ partialFilterExpression: {
105
+ 'object.provider.id': { $exists: true }
106
+ }
107
+ });
102
108
  schema.index({ 'object.subReservation.id': 1, startDate: -1 }, {
103
109
  name: 'searchByObjectSubReservationsId',
104
110
  partialFilterExpression: {
@@ -18,15 +18,23 @@ export type ITransactionOperation<T> = (repos: {
18
18
  /**
19
19
  * 取引開始
20
20
  */
21
- export declare function start(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
21
+ export declare function start(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {
22
+ seller: {
23
+ id?: string;
24
+ };
25
+ }): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
22
26
  /**
23
27
  * 取引確定
24
28
  */
25
29
  export declare function confirm(params: factory.assetTransaction.cancelReservation.IConfirmParams): ITransactionOperation<void>;
26
30
  /**
27
- * 取引開始
31
+ * 取引開始&確定
28
32
  */
29
- export declare function startAndConfirm(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {}): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
33
+ export declare function startAndConfirm(params: factory.assetTransaction.cancelReservation.IStartParamsWithoutDetail & {
34
+ seller: {
35
+ id?: string;
36
+ };
37
+ }): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
30
38
  /**
31
39
  * 取引タスク出力
32
40
  */
@@ -18,16 +18,17 @@ const factory = require("../../factory");
18
18
  const factory_1 = require("./cancelReservation/factory");
19
19
  function validateStartParams(params) {
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
- var _a, _b;
21
+ var _a, _b, _c, _d;
22
22
  let reserveTransaction;
23
23
  let reservations;
24
+ const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
24
25
  // 予約番号で取引存在確認
25
- if (typeof ((_a = params.object.reservation) === null || _a === void 0 ? void 0 : _a.reservationNumber) === 'string') {
26
+ if (typeof ((_b = params.object.reservation) === null || _b === void 0 ? void 0 : _b.reservationNumber) === 'string') {
26
27
  const transactions = yield repos.assetTransaction.search({
27
28
  limit: 1,
28
29
  page: 1,
29
30
  typeOf: factory.assetTransactionType.Reserve,
30
- object: { reservationNumber: { $eq: params.object.reservation.reservationNumber } }
31
+ object: Object.assign({ reservationNumber: { $eq: params.object.reservation.reservationNumber } }, (typeof sellerId === 'string') ? { provider: { id: { $eq: sellerId } } } : undefined)
31
32
  });
32
33
  reserveTransaction = transactions.shift();
33
34
  // ここでReservationConfirmedでない予約をスルーしても、
@@ -48,15 +49,21 @@ function validateStartParams(params) {
48
49
  // 取引指定が確認できなければ、予約指定を確認
49
50
  if (reserveTransaction === undefined) {
50
51
  // 予約存在確認
51
- if (typeof ((_b = params.object.reservation) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
52
+ if (typeof ((_c = params.object.reservation) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
52
53
  const reservation = yield repos.reservation.findById({
53
54
  id: params.object.reservation.id
54
55
  });
55
- reservations = [reservation];
56
+ // 販売者検証(2023-08-01~)
57
+ if (typeof sellerId === 'string') {
58
+ if (((_d = reservation.provider) === null || _d === void 0 ? void 0 : _d.id) !== sellerId) {
59
+ throw new factory.errors.NotFound(factory.reservationType.EventReservation);
60
+ }
61
+ }
56
62
  // 予約ステータス確認
57
63
  if (reservation.reservationStatus !== factory.reservationStatusType.ReservationConfirmed) {
58
64
  throw new factory.errors.Argument('object.reservation.id', `Reservation ${reservation.id} not confirmed`);
59
65
  }
66
+ reservations = [reservation];
60
67
  }
61
68
  }
62
69
  if (reserveTransaction === undefined && reservations === undefined) {
@@ -125,7 +132,7 @@ function confirm(params) {
125
132
  }
126
133
  exports.confirm = confirm;
127
134
  /**
128
- * 取引開始
135
+ * 取引開始&確定
129
136
  */
130
137
  function startAndConfirm(params) {
131
138
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -117,7 +117,8 @@ function processCancelReservation4chevre(params) {
117
117
  },
118
118
  expires: moment()
119
119
  .add(1, 'minutes')
120
- .toDate()
120
+ .toDate(),
121
+ seller: {} // 販売者条件必要なし
121
122
  })(repos);
122
123
  });
123
124
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.320.0",
12
+ "@chevre/factory": "4.321.0",
13
13
  "@cinerino/sdk": "3.162.0-alpha.7",
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.5.0-alpha.3"
120
+ "version": "21.5.0-alpha.4"
121
121
  }