@chevre/domain 21.2.0-alpha.105 → 21.2.0-alpha.107

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.
@@ -22,6 +22,19 @@ async function main() {
22
22
 
23
23
  let result: { aggregationCount: number; aggregateDuration: string };
24
24
 
25
+ result = await chevre.service.aggregation.system.aggregateCancelReservationAction({
26
+ aggregateDurationUnit: 'hours',
27
+ // aggregateDurationUnit: 'days',
28
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
29
+ // aggregationCount: AGGREGATE_DAYS,
30
+ excludedProjectId: EXCLUDED_PROJECT_ID
31
+ })({
32
+ agregation: aggregationRepo,
33
+ action: actionRepo
34
+ });
35
+ console.log('aggregateCancelReservationAction processed.', result);
36
+ return;
37
+
25
38
  result = await chevre.service.aggregation.system.aggregateReserveAction({
26
39
  aggregateDurationUnit: 'hours',
27
40
  // aggregateDurationUnit: 'days',
@@ -180,6 +180,15 @@ export declare class MongoRepository {
180
180
  startThrough: Date;
181
181
  typeOf: factory.actionType;
182
182
  }): Promise<IAggregateAction>;
183
+ aggregateCancelReservationAction(params: {
184
+ project?: {
185
+ id?: {
186
+ $ne?: string;
187
+ };
188
+ };
189
+ startFrom: Date;
190
+ startThrough: Date;
191
+ }): Promise<IAggregateAction>;
183
192
  /**
184
193
  * アクションタイプによる汎用的な集計
185
194
  */
@@ -801,6 +801,32 @@ class MongoRepository {
801
801
  return { statuses };
802
802
  });
803
803
  }
804
+ aggregateCancelReservationAction(params) {
805
+ return __awaiter(this, void 0, void 0, function* () {
806
+ const statuses = yield Promise.all([
807
+ factory.actionStatusType.CompletedActionStatus,
808
+ factory.actionStatusType.CanceledActionStatus,
809
+ factory.actionStatusType.FailedActionStatus
810
+ ].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
811
+ var _a, _b;
812
+ const matchConditions = Object.assign({ startDate: {
813
+ $gte: params.startFrom,
814
+ $lte: params.startThrough
815
+ }, typeOf: { $eq: factory.actionType.CancelAction }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
816
+ $exists: true,
817
+ $in: [
818
+ factory.reservationType.BusReservation,
819
+ factory.reservationType.EventReservation,
820
+ factory.reservationType.ReservationPackage
821
+ ]
822
+ } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
823
+ ? { 'project.id': { $ne: params.project.id.$ne } }
824
+ : undefined);
825
+ return this.agggregateByStatus({ matchConditions, actionStatus });
826
+ })));
827
+ return { statuses };
828
+ });
829
+ }
804
830
  /**
805
831
  * アクションタイプによる汎用的な集計
806
832
  */
@@ -4,6 +4,7 @@ export declare enum AggregationType {
4
4
  AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
5
5
  AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
6
6
  AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
7
+ AggregateCancelReservationAction = "AggregateCancelReservationAction",
7
8
  AggregateCheckMovieTicketAction = "AggregateCheckMovieTicketAction",
8
9
  AggregateEvent = "AggregateEvent",
9
10
  AggregateOrderAction = "AggregateOrderAction",
@@ -27,6 +27,7 @@ var AggregationType;
27
27
  AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
28
28
  AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
29
29
  AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
30
+ AggregationType["AggregateCancelReservationAction"] = "AggregateCancelReservationAction";
30
31
  AggregationType["AggregateCheckMovieTicketAction"] = "AggregateCheckMovieTicketAction";
31
32
  AggregationType["AggregateEvent"] = "AggregateEvent";
32
33
  AggregationType["AggregateOrderAction"] = "AggregateOrderAction";
@@ -112,6 +112,20 @@ declare function aggregateOrderAction(params: {
112
112
  aggregationCount: number;
113
113
  aggregateDuration: string;
114
114
  }>;
115
+ /**
116
+ * 予約取消アクション集計
117
+ */
118
+ declare function aggregateCancelReservationAction(params: {
119
+ aggregateDurationUnit: AggregateDurationUnit;
120
+ aggregationCount: number;
121
+ excludedProjectId?: string;
122
+ }): (repos: {
123
+ agregation: AggregationRepo;
124
+ action: ActionRepo;
125
+ }) => Promise<{
126
+ aggregationCount: number;
127
+ aggregateDuration: string;
128
+ }>;
115
129
  declare function aggregateCheckMovieTicketAction(params: {
116
130
  aggregateDurationUnit: AggregateDurationUnit;
117
131
  aggregationCount: number;
@@ -170,4 +184,4 @@ declare function aggregateTask(params: {
170
184
  aggregationCount: number;
171
185
  aggregateDuration: string;
172
186
  }>;
173
- export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
187
+ export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCancelReservationAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregateReserveAction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregatePayMovieTicketAction = exports.aggregateOrderAction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
12
+ exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregateReserveAction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = exports.aggregatePayMovieTicketAction = exports.aggregateOrderAction = exports.aggregateEvent = exports.aggregateCheckMovieTicketAction = exports.aggregateCancelReservationAction = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
13
13
  const createDebug = require("debug");
14
14
  const moment = require("moment-timezone");
15
15
  const factory = require("../../factory");
@@ -322,6 +322,42 @@ function aggregateOrderAction(params) {
322
322
  });
323
323
  }
324
324
  exports.aggregateOrderAction = aggregateOrderAction;
325
+ /**
326
+ * 予約取消アクション集計
327
+ */
328
+ function aggregateCancelReservationAction(params) {
329
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
330
+ var _a;
331
+ const aggregateDate = new Date();
332
+ const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
333
+ .toISOString();
334
+ let i = -1;
335
+ while (i < params.aggregationCount) {
336
+ i += 1;
337
+ const startFrom = moment(aggregateDate)
338
+ .utc()
339
+ // .tz('Asia/Tokyo')
340
+ .add(-i, params.aggregateDurationUnit)
341
+ .startOf(params.aggregateDurationUnit)
342
+ .toDate();
343
+ const startThrough = moment(aggregateDate)
344
+ .utc()
345
+ // .tz('Asia/Tokyo')
346
+ .add(-i, params.aggregateDurationUnit)
347
+ .endOf(params.aggregateDurationUnit)
348
+ .toDate();
349
+ const aggregateResult = yield repos.action.aggregateCancelReservationAction({
350
+ project: { id: { $ne: params.excludedProjectId } },
351
+ startFrom,
352
+ startThrough
353
+ });
354
+ debug('aggregateCancelReservationAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
355
+ yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateCancelReservationAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
356
+ }
357
+ return { aggregationCount: i, aggregateDuration };
358
+ });
359
+ }
360
+ exports.aggregateCancelReservationAction = aggregateCancelReservationAction;
325
361
  function aggregateCheckMovieTicketAction(params) {
326
362
  return (repos) => __awaiter(this, void 0, void 0, function* () {
327
363
  var _a;
@@ -586,7 +586,10 @@ function createScreeningEventSeriesFromCOA(params) {
586
586
  endDate: endDate,
587
587
  startDate: startDate,
588
588
  coaInfo,
589
- offers: Object.assign({ project: { typeOf: params.project.typeOf, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
589
+ offers: Object.assign({
590
+ // 不要なので廃止(2023-06-09~)
591
+ // project: { typeOf: params.project.typeOf, id: params.project.id },
592
+ typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
590
593
  additionalProperty
591
594
  };
592
595
  }
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.30",
13
- "@cinerino/sdk": "3.157.0-alpha.9",
12
+ "@chevre/factory": "4.313.0-alpha.31",
13
+ "@cinerino/sdk": "3.157.0-alpha.11",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.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.105"
120
+ "version": "21.2.0-alpha.107"
121
121
  }
@@ -1,208 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- const PROJECT_ID = String(process.env.PROJECT_ID);
8
- const filterName: string = 'eventIdentifier';
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
-
14
- const eventRepo = new chevre.repository.Event(mongoose.connection);
15
-
16
- const result = await eventRepo.createManyIfNotExist<chevre.factory.eventType.ScreeningEvent>([
17
- {
18
- attributes: {
19
- additionalProperty: [{
20
- name: filterName,
21
- value: '20230201143000-03'
22
- }],
23
- project: {
24
- id: PROJECT_ID,
25
- typeOf: chevre.factory.organizationType.Project
26
- },
27
- typeOf: chevre.factory.eventType.ScreeningEvent,
28
- doorTime: moment('2023-02-01T05:00:00.000Z')
29
- .toDate(),
30
- startDate: moment('2023-02-01T05:00:00.000Z')
31
- .toDate(),
32
- endDate: moment('2023-02-01T06:00:00.000Z')
33
- .toDate(),
34
- // workPerformed: {
35
- // typeOf: chevre.factory.creativeWorkType.Movie,
36
- // identifier: '1622100',
37
- // id: '5bfb841d5a78d7948369980a',
38
- // name: {
39
- // en: 'Pet',
40
- // ja: 'ペット'
41
- // },
42
- // duration: 'PT2H3M'
43
- // },
44
- location: {
45
- typeOf: chevre.factory.placeType.ScreeningRoom,
46
- branchCode: '10',
47
- name: {
48
- ja: 'シネマ1',
49
- en: 'CINEMA1'
50
- },
51
- address: {
52
- ja: '7階',
53
- en: '7F'
54
- }
55
- },
56
- superEvent: {
57
- typeOf: chevre.factory.eventType.ScreeningEventSeries,
58
- project: {
59
- typeOf: chevre.factory.organizationType.Project,
60
- id: 'cinerino'
61
- },
62
- id: '7k9ayl8hc',
63
- videoFormat: [
64
- {
65
- typeOf: '2D',
66
- name: '2D'
67
- }
68
- ],
69
- soundFormat: [],
70
- workPerformed: {
71
- typeOf: chevre.factory.creativeWorkType.Movie,
72
- identifier: '1622100',
73
- id: '5bfb841d5a78d7948369980a',
74
- name: {
75
- en: 'Pet',
76
- ja: 'ペット'
77
- },
78
- duration: 'PT2H3M'
79
- },
80
- location: {
81
- typeOf: chevre.factory.placeType.MovieTheater,
82
- id: '5bfb841d5a78d7948369979a',
83
- branchCode: '118',
84
- name: {
85
- ja: 'シネモーション赤坂 ',
86
- en: 'CineMotion Akasaka'
87
- },
88
- kanaName: 'シネモーションアカサカ'
89
- },
90
- kanaName: 'ペットカナタイトル',
91
- name: {
92
- en: 'PetPetPetPet',
93
- ja: 'ペット'
94
- },
95
- additionalProperty: [
96
- {
97
- name: 'sortNumber',
98
- value: '99'
99
- }
100
- ],
101
- startDate: moment('2020-03-31T15:00:00.000Z')
102
- .toDate(),
103
- endDate: moment('2034-12-01T15:00:00.000Z')
104
- .toDate(),
105
- description: {
106
- en: 'english description',
107
- ja: 'ムビチケ検証用のイベントです。'
108
- },
109
- headline: {
110
- en: 'headlineheadlineheadlineheadlineheadlineheadlineheadline',
111
- ja: 'サブタイトルkanaName'
112
- },
113
- subtitleLanguage: {
114
- typeOf: 'Language',
115
- name: 'Japanese'
116
- }
117
- },
118
- name: {
119
- en: 'PetPetPetPet',
120
- ja: 'ペット'
121
- },
122
- eventStatus: chevre.factory.eventStatusType.EventScheduled,
123
- offers: {
124
- typeOf: chevre.factory.offerType.Offer,
125
- priceCurrency: chevre.factory.priceCurrency.JPY,
126
- availabilityEnds: moment('2023-02-01T01:20:00.000Z')
127
- .toDate(),
128
- availabilityStarts: moment('2023-01-30T15:00:00.000Z')
129
- .toDate(),
130
- eligibleQuantity: {
131
- typeOf: 'QuantitativeValue',
132
- unitCode: chevre.factory.unitCode.C62,
133
- maxValue: 6,
134
- value: 1
135
- },
136
- itemOffered: {
137
- id: '6308580bdef565000a9aa1fd',
138
- name: {
139
- ja: '通常興行カタログ'
140
- },
141
- serviceOutput: {
142
- typeOf: chevre.factory.reservationType.EventReservation,
143
- reservedTicket: {
144
- typeOf: 'Ticket',
145
- ticketedSeat: {
146
- typeOf: chevre.factory.placeType.Seat
147
- }
148
- }
149
- },
150
- typeOf: chevre.factory.product.ProductType.EventService,
151
- availableChannel: {
152
- typeOf: 'ServiceChannel',
153
- serviceLocation: {
154
- typeOf: chevre.factory.placeType.ScreeningRoom,
155
- branchCode: '10',
156
- name: {
157
- ja: 'シネマ1',
158
- en: 'CINEMA1'
159
- },
160
- containedInPlace: {
161
- typeOf: chevre.factory.placeType.MovieTheater,
162
- id: '5bfb841d5a78d7948369979a',
163
- branchCode: '118',
164
- name: {
165
- ja: 'シネモーション赤坂 ',
166
- en: 'CineMotion Akasaka'
167
- }
168
- }
169
- }
170
- },
171
- serviceType: {
172
- codeValue: '0001',
173
- id: '5e3361d01dc1ef1a20dd8737',
174
- inCodeSet: {
175
- typeOf: 'CategoryCodeSet',
176
- identifier: chevre.factory.categoryCode.CategorySetIdentifier.ServiceType
177
- },
178
- typeOf: 'CategoryCode'
179
- }
180
- },
181
- validFrom: moment('2023-01-29T15:00:00.000Z')
182
- .toDate(),
183
- validThrough: moment('2023-02-01T01:20:00.000Z')
184
- .toDate(),
185
- seller: {
186
- typeOf: chevre.factory.organizationType.Corporation,
187
- id: '59d20831e53ebc2b4e774466',
188
- name: {
189
- ja: 'シネモーション赤坂',
190
- en: 'CineMotion Akasaka'
191
- },
192
- makesOffer: []
193
- }
194
- }
195
- },
196
- filter: { name: filterName }
197
- }
198
- ]);
199
- console.log(result);
200
- console.log('upsertedIds:', (Array.isArray(result?.getUpsertedIds()))
201
- ? result?.getUpsertedIds()
202
- .map((u: any) => u._id)
203
- : []);
204
- }
205
-
206
- main()
207
- .then(console.log)
208
- .catch(console.error);