@chevre/domain 22.1.0-alpha.5 → 22.1.0-alpha.6

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.
@@ -0,0 +1,27 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { chevre } from '../../../../lib/index';
4
+
5
+ const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
11
+
12
+ const seatingTypes = await seatRepo.aggregateSeatingTypes({
13
+ project: { id: { $eq: project.id } },
14
+ containedInPlace: {
15
+ containedInPlace: {
16
+ // branchCode: { $eq: '110' },
17
+ // containedInPlace: { branchCode: { $eq: '118' } }
18
+ }
19
+ }
20
+ });
21
+ console.log(seatingTypes);
22
+ console.log(seatingTypes.length);
23
+ }
24
+
25
+ main()
26
+ .then(console.log)
27
+ .catch(console.error);
@@ -41,6 +41,28 @@ export declare class SeatRepo {
41
41
  };
42
42
  }, $unset: any): Promise<IUpdateSeatResult>;
43
43
  searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
44
+ /**
45
+ * 座席区分集計検索
46
+ */
47
+ aggregateSeatingTypes(params: {
48
+ project: {
49
+ id: {
50
+ $eq: string;
51
+ };
52
+ };
53
+ containedInPlace?: {
54
+ containedInPlace?: {
55
+ branchCode?: {
56
+ $eq?: string;
57
+ };
58
+ containedInPlace?: {
59
+ branchCode?: {
60
+ $eq?: string;
61
+ };
62
+ };
63
+ };
64
+ };
65
+ }): Promise<string[]>;
44
66
  deleteSeat(seat: {
45
67
  project: {
46
68
  id: string;
@@ -340,6 +340,44 @@ class SeatRepo {
340
340
  .exec();
341
341
  });
342
342
  }
343
+ /**
344
+ * 座席区分集計検索
345
+ */
346
+ aggregateSeatingTypes(params) {
347
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
350
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
351
+ if (typeof projectIdEq === 'string') {
352
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
353
+ }
354
+ const branchCodeEq = (_e = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
355
+ if (typeof branchCodeEq === 'string') {
356
+ matchStages.push({ $match: { branchCode: { $eq: branchCodeEq } } });
357
+ }
358
+ const containedInPlaceBranchCodeEq = (_j = (_h = (_g = (_f = params.containedInPlace) === null || _f === void 0 ? void 0 : _f.containedInPlace) === null || _g === void 0 ? void 0 : _g.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$eq;
359
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
360
+ matchStages.push({
361
+ $match: { 'containedInPlace.branchCode': { $exists: true, $eq: containedInPlaceBranchCodeEq } }
362
+ });
363
+ }
364
+ const aggregate = this.placeModel.aggregate([
365
+ ...matchStages,
366
+ { $unwind: { path: '$containsPlace', preserveNullAndEmptyArrays: false } },
367
+ { $unwind: { path: '$containsPlace.containsPlace', preserveNullAndEmptyArrays: false } },
368
+ { $unwind: { path: '$containsPlace.containsPlace.seatingType', preserveNullAndEmptyArrays: false } },
369
+ {
370
+ $group: {
371
+ _id: '$containsPlace.containsPlace.seatingType'
372
+ }
373
+ }
374
+ ]);
375
+ return aggregate
376
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
377
+ .exec()
378
+ .then((result) => result.map(({ _id }) => _id));
379
+ });
380
+ }
343
381
  deleteSeat(seat) {
344
382
  var _a;
345
383
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
13
+ const createDebug = require("debug");
13
14
  const moment = require("moment");
14
15
  const factory = require("../factory");
15
16
  const EventOfferService = require("./offer/event");
@@ -20,6 +21,7 @@ const MoneyTransferOfferService = require("./offer/moneyTransfer");
20
21
  exports.moneyTransfer = MoneyTransferOfferService;
21
22
  const ProductOfferService = require("./offer/product");
22
23
  exports.product = ProductOfferService;
24
+ const debug = createDebug('chevre-domain:service:offer');
23
25
  /**
24
26
  * 座席にオファー情報を付加する
25
27
  */
@@ -58,6 +60,7 @@ exports.addOffers2Seat = addOffers2Seat;
58
60
  */
59
61
  // tslint:disable-next-line:max-func-body-length
60
62
  function searchEventSeatOffersWithPaging(params) {
63
+ // tslint:disable-next-line:max-func-body-length
61
64
  return (repos) => __awaiter(this, void 0, void 0, function* () {
62
65
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
63
66
  let offers = [];
@@ -97,28 +100,29 @@ function searchEventSeatOffersWithPaging(params) {
97
100
  };
98
101
  })
99
102
  });
100
- // tslint:disable-next-line:no-suspicious-comment
101
- // TODO 必要な座席区分のみ検索?
102
- // const uniqueSeatingTypes: string[] = [...new Set(seats.reduce<string[]>(
103
- // (a, { seatingType }) => {
104
- // if (Array.isArray(seatingType)) {
105
- // return [...a, ...seatingType];
106
- // } else if (typeof seatingType === 'string') {
107
- // return [...a, seatingType];
108
- // } else {
109
- // return a;
110
- // }
111
- // },
112
- // []
113
- // ))];
114
- // 座席タイプ価格仕様を検索
115
- const priceSpecs = yield repos.priceSpecification.search({
103
+ // ルームに含まれる座席区分のみ加算料金を検索(2024-08-05~)
104
+ const uniqueSeatingTypes = yield repos.seat.aggregateSeatingTypes({
116
105
  project: { id: { $eq: event.project.id } },
117
- typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
118
- appliesToCategoryCode: {
119
- inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
106
+ containedInPlace: {
107
+ containedInPlace: {
108
+ branchCode: { $eq: roomBranchCode },
109
+ containedInPlace: { branchCode: { $eq: movieTheaterBranchCode } }
110
+ }
120
111
  }
121
112
  });
113
+ debug('searchEventSeatOffersWithPaging: uniqueSeatingTypes:', uniqueSeatingTypes, event.project.id, roomBranchCode, movieTheaterBranchCode);
114
+ // 座席タイプ価格仕様を検索
115
+ let priceSpecs = [];
116
+ if (Array.isArray(uniqueSeatingTypes) && uniqueSeatingTypes.length > 0) {
117
+ priceSpecs = yield repos.priceSpecification.search({
118
+ project: { id: { $eq: event.project.id } },
119
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
120
+ appliesToCategoryCode: {
121
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } },
122
+ codeValue: { $in: uniqueSeatingTypes } // ルームに含まれる座席区分のみ加算料金を検索(2024-08-05~)
123
+ }
124
+ });
125
+ }
122
126
  offers = seats.map((seat, index) => {
123
127
  return addOffers2Seat({
124
128
  seat,
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.1.0-alpha.5"
113
+ "version": "22.1.0-alpha.6"
114
114
  }