@chevre/domain 20.2.0-alpha.8 → 20.2.0
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.
- package/example/src/chevre/aggregateEventReservation.ts +37 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
- package/example/src/chevre/attendIfNotAttended.ts +22 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
- package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
- package/example/src/chevre/migrateProjectSubscription.ts +51 -0
- package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
- package/example/src/chevre/processReserve.ts +2 -0
- package/example/src/chevre/searchEventIds.ts +24 -0
- package/example/src/chevre/searchEventTicketOffers.ts +5 -4
- package/example/src/chevre/searchEvents.ts +20 -41
- package/example/src/chevre/searchOffersByCatalog.ts +27 -0
- package/example/src/chevre/updateTransaction.ts +38 -0
- package/lib/chevre/factory/event.d.ts +2 -0
- package/lib/chevre/factory/event.js +2 -0
- package/lib/chevre/repo/action.d.ts +77 -1
- package/lib/chevre/repo/action.js +249 -6
- package/lib/chevre/repo/aggregation.d.ts +38 -0
- package/lib/chevre/repo/aggregation.js +68 -0
- package/lib/chevre/repo/assetTransaction.d.ts +32 -0
- package/lib/chevre/repo/assetTransaction.js +148 -0
- package/lib/chevre/repo/code.d.ts +13 -16
- package/lib/chevre/repo/code.js +33 -19
- package/lib/chevre/repo/creativeWork.js +13 -12
- package/lib/chevre/repo/event.d.ts +64 -17
- package/lib/chevre/repo/event.js +456 -156
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/event.js +4 -3
- package/lib/chevre/repo/mongoose/model/offer.js +2 -1
- package/lib/chevre/repo/mongoose/model/project.js +7 -1
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/offer.d.ts +10 -0
- package/lib/chevre/repo/offer.js +47 -16
- package/lib/chevre/repo/order.d.ts +6 -0
- package/lib/chevre/repo/order.js +53 -7
- package/lib/chevre/repo/place.d.ts +26 -1
- package/lib/chevre/repo/place.js +216 -12
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/project.d.ts +7 -1
- package/lib/chevre/repo/project.js +15 -6
- package/lib/chevre/repo/reservation.d.ts +7 -8
- package/lib/chevre/repo/reservation.js +181 -76
- package/lib/chevre/repo/task.d.ts +31 -4
- package/lib/chevre/repo/task.js +146 -33
- package/lib/chevre/repo/transaction.d.ts +57 -5
- package/lib/chevre/repo/transaction.js +228 -34
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -68
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
- package/lib/chevre/service/aggregation/system.d.ts +100 -0
- package/lib/chevre/service/aggregation/system.js +409 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
- package/lib/chevre/service/assetTransaction/pay.js +65 -32
- package/lib/chevre/service/assetTransaction/registerService.js +4 -1
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
- package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
- package/lib/chevre/service/assetTransaction/reserve.js +120 -94
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +2 -3
- package/lib/chevre/service/delivery/factory.d.ts +1 -1
- package/lib/chevre/service/delivery/product/factory.js +9 -3
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +35 -14
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
- package/lib/chevre/service/offer/event/authorize.js +33 -87
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.d.ts +3 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
- package/lib/chevre/service/offer/factory.js +10 -3
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
- package/lib/chevre/service/offer/product.d.ts +1 -0
- package/lib/chevre/service/offer/product.js +7 -2
- package/lib/chevre/service/offer.d.ts +13 -2
- package/lib/chevre/service/offer.js +68 -46
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/order/returnOrder.js +6 -4
- package/lib/chevre/service/order/sendOrder.js +4 -2
- package/lib/chevre/service/payment/any.d.ts +9 -0
- package/lib/chevre/service/payment/any.js +16 -1
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +8 -2
- package/lib/chevre/service/product.js +5 -3
- package/lib/chevre/service/report/telemetry.js +1 -1
- package/lib/chevre/service/reserve/checkInReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +7 -10
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
- package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
- package/lib/chevre/service/reserve/useReservation.js +58 -32
- package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
- package/lib/chevre/service/task/returnPayTransaction.js +10 -4
- package/lib/chevre/service/task.js +6 -9
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
- package/lib/chevre/service/transaction/placeOrder.js +5 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
- package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
- package/lib/chevre/service/transaction/returnOrder.js +8 -6
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +20 -12
- package/package.json +3 -3
- package/CHANGELOG.md +0 -2030
- package/example/.gitignore +0 -1
- package/example/src/chevre/.gitignore +0 -1
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
2
|
import * as mongoose from 'mongoose';
|
|
4
3
|
|
|
5
4
|
import { chevre } from '../../../lib/index';
|
|
@@ -11,47 +10,27 @@ async function main() {
|
|
|
11
10
|
|
|
12
11
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
availabilityStarts: {
|
|
32
|
-
$gte: moment('2022-11-15T15:00:00.000Z')
|
|
33
|
-
.toDate(),
|
|
34
|
-
$lte: moment('2022-11-15T15:00:00.000Z')
|
|
35
|
-
.toDate()
|
|
36
|
-
},
|
|
37
|
-
validFrom: {
|
|
38
|
-
$gte: moment('2022-11-15T15:00:00.000Z')
|
|
39
|
-
.toDate(),
|
|
40
|
-
$lte: moment('2022-11-15T15:00:00.000Z')
|
|
41
|
-
.toDate()
|
|
42
|
-
},
|
|
43
|
-
validThrough: {
|
|
44
|
-
$gte: moment('2022-11-18T02:20:00.000Z')
|
|
45
|
-
.toDate(),
|
|
46
|
-
$lte: moment('2022-11-18T02:20:00.000Z')
|
|
47
|
-
.toDate()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
13
|
+
const event = await eventRepo.findById(
|
|
14
|
+
{ id: 'al6aff83y' },
|
|
15
|
+
{
|
|
16
|
+
name: 1
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
console.log('event found', event);
|
|
20
|
+
|
|
21
|
+
const events = await eventRepo.search(
|
|
22
|
+
{
|
|
23
|
+
limit: 100,
|
|
24
|
+
page: 1,
|
|
25
|
+
sort: { startDate: 1 },
|
|
26
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
27
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
28
|
+
id: { $in: ['al6aff83y'] }
|
|
52
29
|
},
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
{
|
|
31
|
+
name: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
55
34
|
console.log(events);
|
|
56
35
|
console.log(events.length);
|
|
57
36
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as redis from 'redis';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
+
|
|
10
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const offers = await offerRepo.findOffersByOfferCatalogId({
|
|
13
|
+
ids: ['al96nqj7z', 'xxx', '1001'],
|
|
14
|
+
// ids: ['xx', 'xxx'],
|
|
15
|
+
offerCatalog: {
|
|
16
|
+
id: '0001'
|
|
17
|
+
// id: 'xxx'
|
|
18
|
+
},
|
|
19
|
+
sort: true
|
|
20
|
+
});
|
|
21
|
+
console.log(offers.map((o) => o.id));
|
|
22
|
+
console.log(offers.length);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
main()
|
|
26
|
+
.then(console.log)
|
|
27
|
+
.catch(console.error);
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
+
|
|
10
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
11
|
+
const transactionId = '63ce4d501c45c2000bdb2f9d';
|
|
12
|
+
let update = {
|
|
13
|
+
$set: { 'object.modifiedTime': new Date() }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let now = moment();
|
|
17
|
+
await transactionRepo.findByIdAndUpdate({
|
|
18
|
+
id: transactionId,
|
|
19
|
+
update
|
|
20
|
+
});
|
|
21
|
+
console.log(moment()
|
|
22
|
+
.diff(now));
|
|
23
|
+
|
|
24
|
+
update = {
|
|
25
|
+
$set: { 'object.modifiedTime': new Date() }
|
|
26
|
+
};
|
|
27
|
+
now = moment();
|
|
28
|
+
// await transactionRepo.updateById({
|
|
29
|
+
// id: transactionId,
|
|
30
|
+
// update
|
|
31
|
+
// });
|
|
32
|
+
console.log(moment()
|
|
33
|
+
.diff(now));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then()
|
|
38
|
+
.catch(console.error);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import * as factory from '../factory';
|
|
2
|
+
export declare type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
@@ -7,6 +7,23 @@ export interface IUseActionCountByOffer {
|
|
|
7
7
|
_id: string[];
|
|
8
8
|
useActionCount?: number;
|
|
9
9
|
}
|
|
10
|
+
interface IAggregationByStatus {
|
|
11
|
+
actionCount: number;
|
|
12
|
+
avgDuration: number;
|
|
13
|
+
maxDuration: number;
|
|
14
|
+
minDuration: number;
|
|
15
|
+
percentilesDuration: {
|
|
16
|
+
name: string;
|
|
17
|
+
value: number;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
interface IStatus {
|
|
21
|
+
status: factory.actionStatusType;
|
|
22
|
+
aggregation: IAggregationByStatus;
|
|
23
|
+
}
|
|
24
|
+
interface IAggregateAction {
|
|
25
|
+
statuses: IStatus[];
|
|
26
|
+
}
|
|
10
27
|
export { modelName };
|
|
11
28
|
/**
|
|
12
29
|
* アクションリポジトリ
|
|
@@ -18,7 +35,7 @@ export declare class MongoRepository {
|
|
|
18
35
|
/**
|
|
19
36
|
* アクション検索
|
|
20
37
|
*/
|
|
21
|
-
search<T extends factory.actionType>(params: factory.action.ISearchConditions,
|
|
38
|
+
search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<IAction<T>[]>;
|
|
22
39
|
/**
|
|
23
40
|
* アクション開始
|
|
24
41
|
*/
|
|
@@ -107,4 +124,63 @@ export declare class MongoRepository {
|
|
|
107
124
|
deleteEndDatePassedCertainPeriod(params: {
|
|
108
125
|
$lt: Date;
|
|
109
126
|
}): Promise<void>;
|
|
127
|
+
aggregateAuthorizeEventServiceOfferAction(params: {
|
|
128
|
+
project?: {
|
|
129
|
+
id?: {
|
|
130
|
+
$ne?: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
startFrom: Date;
|
|
134
|
+
startThrough: Date;
|
|
135
|
+
typeOf: factory.actionType;
|
|
136
|
+
}): Promise<IAggregateAction>;
|
|
137
|
+
aggregateAuthorizePaymentAction(params: {
|
|
138
|
+
project?: {
|
|
139
|
+
id?: {
|
|
140
|
+
$ne?: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
startFrom: Date;
|
|
144
|
+
startThrough: Date;
|
|
145
|
+
typeOf: factory.actionType;
|
|
146
|
+
}): Promise<IAggregateAction>;
|
|
147
|
+
aggregateAuthorizeOrderAction(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.actionType;
|
|
156
|
+
}): Promise<IAggregateAction>;
|
|
157
|
+
aggregateUseAction(params: {
|
|
158
|
+
project?: {
|
|
159
|
+
id?: {
|
|
160
|
+
$ne?: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
startFrom: Date;
|
|
164
|
+
startThrough: Date;
|
|
165
|
+
typeOf: factory.actionType;
|
|
166
|
+
}): Promise<IAggregateAction>;
|
|
167
|
+
aggregateCheckMovieTicketAction(params: {
|
|
168
|
+
project?: {
|
|
169
|
+
id?: {
|
|
170
|
+
$ne?: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
startFrom: Date;
|
|
174
|
+
startThrough: Date;
|
|
175
|
+
}): Promise<IAggregateAction>;
|
|
176
|
+
aggregatePayMovieTicketAction(params: {
|
|
177
|
+
project?: {
|
|
178
|
+
id?: {
|
|
179
|
+
$ne?: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
startFrom: Date;
|
|
183
|
+
startThrough: Date;
|
|
184
|
+
}): Promise<IAggregateAction>;
|
|
185
|
+
private agggregateByStatus;
|
|
110
186
|
}
|
|
@@ -386,16 +386,28 @@ class MongoRepository {
|
|
|
386
386
|
/**
|
|
387
387
|
* アクション検索
|
|
388
388
|
*/
|
|
389
|
-
search(params,
|
|
389
|
+
search(params, inclusion, exclusion) {
|
|
390
390
|
return __awaiter(this, void 0, void 0, function* () {
|
|
391
391
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
let projection = {};
|
|
393
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
394
|
+
inclusion.forEach((field) => {
|
|
395
|
+
projection[field] = 1;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
projection = {
|
|
395
400
|
__v: 0,
|
|
396
401
|
createdAt: 0,
|
|
397
402
|
updatedAt: 0
|
|
398
|
-
}
|
|
403
|
+
};
|
|
404
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
405
|
+
exclusion.forEach((field) => {
|
|
406
|
+
projection[field] = 0;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
399
411
|
if (typeof params.limit === 'number') {
|
|
400
412
|
const page = (typeof params.page === 'number') ? params.page : 1;
|
|
401
413
|
query.limit(params.limit)
|
|
@@ -507,7 +519,7 @@ class MongoRepository {
|
|
|
507
519
|
project: { id: { $eq: params.project.id } },
|
|
508
520
|
typeOf: { $eq: factory.actionType.PayAction },
|
|
509
521
|
object: { paymentMethod: { paymentMethodId: { $eq: params.paymentMethodId } } }
|
|
510
|
-
});
|
|
522
|
+
}, [], []);
|
|
511
523
|
return payActions.shift();
|
|
512
524
|
});
|
|
513
525
|
}
|
|
@@ -677,5 +689,236 @@ class MongoRepository {
|
|
|
677
689
|
.exec();
|
|
678
690
|
});
|
|
679
691
|
}
|
|
692
|
+
aggregateAuthorizeEventServiceOfferAction(params) {
|
|
693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
694
|
+
const statuses = yield Promise.all([
|
|
695
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
696
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
697
|
+
factory.actionStatusType.FailedActionStatus
|
|
698
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
699
|
+
var _a, _b;
|
|
700
|
+
const matchConditions = Object.assign({ startDate: {
|
|
701
|
+
$gte: params.startFrom,
|
|
702
|
+
$lte: params.startThrough
|
|
703
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
704
|
+
$exists: true,
|
|
705
|
+
$eq: factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation
|
|
706
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
707
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
708
|
+
: undefined);
|
|
709
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
710
|
+
})));
|
|
711
|
+
return { statuses };
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
aggregateAuthorizePaymentAction(params) {
|
|
715
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
716
|
+
const statuses = yield Promise.all([
|
|
717
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
718
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
719
|
+
factory.actionStatusType.FailedActionStatus
|
|
720
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
721
|
+
var _a, _b;
|
|
722
|
+
const matchConditions = Object.assign({ startDate: {
|
|
723
|
+
$gte: params.startFrom,
|
|
724
|
+
$lte: params.startThrough
|
|
725
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
726
|
+
$exists: true,
|
|
727
|
+
$eq: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
728
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
729
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
730
|
+
: undefined);
|
|
731
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
732
|
+
})));
|
|
733
|
+
return { statuses };
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
aggregateAuthorizeOrderAction(params) {
|
|
737
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
738
|
+
const statuses = yield Promise.all([
|
|
739
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
740
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
741
|
+
factory.actionStatusType.FailedActionStatus
|
|
742
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
743
|
+
var _a, _b;
|
|
744
|
+
const matchConditions = Object.assign({ startDate: {
|
|
745
|
+
$gte: params.startFrom,
|
|
746
|
+
$lte: params.startThrough
|
|
747
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
748
|
+
$exists: true,
|
|
749
|
+
$eq: factory.order.OrderType.Order
|
|
750
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
751
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
752
|
+
: undefined);
|
|
753
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
754
|
+
})));
|
|
755
|
+
return { statuses };
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
aggregateUseAction(params) {
|
|
759
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
760
|
+
const statuses = yield Promise.all([
|
|
761
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
762
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
763
|
+
factory.actionStatusType.FailedActionStatus
|
|
764
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
765
|
+
var _a, _b;
|
|
766
|
+
const matchConditions = Object.assign({ startDate: {
|
|
767
|
+
$gte: params.startFrom,
|
|
768
|
+
$lte: params.startThrough
|
|
769
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
770
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
771
|
+
: undefined);
|
|
772
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
773
|
+
})));
|
|
774
|
+
return { statuses };
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
aggregateCheckMovieTicketAction(params) {
|
|
778
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
779
|
+
const statuses = yield Promise.all([
|
|
780
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
781
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
782
|
+
factory.actionStatusType.FailedActionStatus
|
|
783
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
784
|
+
var _a, _b;
|
|
785
|
+
const matchConditions = Object.assign({ startDate: {
|
|
786
|
+
$gte: params.startFrom,
|
|
787
|
+
$lte: params.startThrough
|
|
788
|
+
}, typeOf: { $eq: factory.actionType.CheckAction }, 'object.typeOf': {
|
|
789
|
+
$exists: true,
|
|
790
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
791
|
+
}, actionStatus: { $eq: actionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
792
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
793
|
+
: undefined);
|
|
794
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
795
|
+
})));
|
|
796
|
+
return { statuses };
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
aggregatePayMovieTicketAction(params) {
|
|
800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
801
|
+
const statuses = yield Promise.all([
|
|
802
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
803
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
804
|
+
factory.actionStatusType.FailedActionStatus
|
|
805
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
806
|
+
var _a, _b;
|
|
807
|
+
const matchConditions = Object.assign({ startDate: {
|
|
808
|
+
$gte: params.startFrom,
|
|
809
|
+
$lte: params.startThrough
|
|
810
|
+
}, typeOf: { $eq: factory.actionType.PayAction }, 'object.typeOf': {
|
|
811
|
+
$exists: true,
|
|
812
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
813
|
+
}, actionStatus: { $eq: actionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
814
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
815
|
+
: undefined);
|
|
816
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
817
|
+
})));
|
|
818
|
+
return { statuses };
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
// tslint:disable-next-line:max-func-body-length
|
|
822
|
+
agggregateByStatus(params) {
|
|
823
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
824
|
+
const aggregations = yield this.actionModel.aggregate([
|
|
825
|
+
{ $match: params.matchConditions },
|
|
826
|
+
{
|
|
827
|
+
$project: {
|
|
828
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
829
|
+
actionStatus: '$actionStatus',
|
|
830
|
+
startDate: '$startDate',
|
|
831
|
+
endDate: '$endDate',
|
|
832
|
+
typeOf: '$typeOf'
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
$group: {
|
|
837
|
+
_id: '$typeOf',
|
|
838
|
+
actionCount: { $sum: 1 },
|
|
839
|
+
maxDuration: { $max: '$duration' },
|
|
840
|
+
minDuration: { $min: '$duration' },
|
|
841
|
+
avgDuration: { $avg: '$duration' }
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
$project: {
|
|
846
|
+
_id: 0,
|
|
847
|
+
actionCount: '$actionCount',
|
|
848
|
+
avgDuration: '$avgDuration',
|
|
849
|
+
maxDuration: '$maxDuration',
|
|
850
|
+
minDuration: '$minDuration'
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
])
|
|
854
|
+
.exec();
|
|
855
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
856
|
+
const percents = [50, 95, 99];
|
|
857
|
+
if (aggregations.length === 0) {
|
|
858
|
+
return {
|
|
859
|
+
status: params.actionStatus,
|
|
860
|
+
aggregation: {
|
|
861
|
+
actionCount: 0,
|
|
862
|
+
avgDuration: 0,
|
|
863
|
+
maxDuration: 0,
|
|
864
|
+
minDuration: 0,
|
|
865
|
+
percentilesDuration: percents.map((percent) => {
|
|
866
|
+
return {
|
|
867
|
+
name: String(percent),
|
|
868
|
+
value: 0
|
|
869
|
+
};
|
|
870
|
+
})
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
875
|
+
return {
|
|
876
|
+
percentile,
|
|
877
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
878
|
+
rank: Math.floor(aggregations[0].actionCount * percentile / 100)
|
|
879
|
+
};
|
|
880
|
+
});
|
|
881
|
+
const aggregations2 = yield this.actionModel.aggregate([
|
|
882
|
+
{
|
|
883
|
+
$match: params.matchConditions
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
$project: {
|
|
887
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
888
|
+
actionStatus: '$actionStatus',
|
|
889
|
+
startDate: '$startDate',
|
|
890
|
+
endDate: '$endDate',
|
|
891
|
+
typeOf: '$typeOf'
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
{ $sort: { duration: 1 } },
|
|
895
|
+
{
|
|
896
|
+
$group: {
|
|
897
|
+
_id: '$typeOf',
|
|
898
|
+
durations: { $push: '$duration' }
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
$project: {
|
|
903
|
+
_id: 0,
|
|
904
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
905
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
906
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
907
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
908
|
+
return {
|
|
909
|
+
name: String(rank.percentile),
|
|
910
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
911
|
+
};
|
|
912
|
+
})
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
])
|
|
916
|
+
.exec();
|
|
917
|
+
return {
|
|
918
|
+
status: params.actionStatus,
|
|
919
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
920
|
+
};
|
|
921
|
+
});
|
|
922
|
+
}
|
|
680
923
|
}
|
|
681
924
|
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Connection, Model } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
export declare enum AggregationType {
|
|
4
|
+
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
5
|
+
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
6
|
+
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
|
+
AggregateCheckMovieTicketAction = "AggregateCheckMovieTicketAction",
|
|
8
|
+
AggregateEvent = "AggregateEvent",
|
|
9
|
+
AggregatePay = "AggregatePay",
|
|
10
|
+
AggregatePayMovieTicketAction = "AggregatePayMovieTicketAction",
|
|
11
|
+
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
12
|
+
AggregateReserve = "AggregateReserve",
|
|
13
|
+
AggregateTask = "AggregateTask",
|
|
14
|
+
AggregateUseAction = "AggregateUseAction"
|
|
15
|
+
}
|
|
16
|
+
export interface IAggregationByClient {
|
|
17
|
+
clientId: string;
|
|
18
|
+
aggregation: any;
|
|
19
|
+
}
|
|
20
|
+
export interface IAggregation {
|
|
21
|
+
typeOf: AggregationType;
|
|
22
|
+
project: {
|
|
23
|
+
id: string;
|
|
24
|
+
typeOf: factory.organizationType.Project;
|
|
25
|
+
};
|
|
26
|
+
aggregateDate: Date;
|
|
27
|
+
aggregateDuration: string;
|
|
28
|
+
aggregateStart: Date;
|
|
29
|
+
aggregationByClient?: IAggregationByClient[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 集計リポジトリ
|
|
33
|
+
*/
|
|
34
|
+
export declare class MongoRepository {
|
|
35
|
+
readonly aggregationModel: typeof Model;
|
|
36
|
+
constructor(connection: Connection);
|
|
37
|
+
saveAggregation(params: IAggregation): Promise<any>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = exports.AggregationType = void 0;
|
|
24
|
+
const aggregation_1 = require("./mongoose/model/aggregation");
|
|
25
|
+
var AggregationType;
|
|
26
|
+
(function (AggregationType) {
|
|
27
|
+
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
28
|
+
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
29
|
+
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
|
+
AggregationType["AggregateCheckMovieTicketAction"] = "AggregateCheckMovieTicketAction";
|
|
31
|
+
AggregationType["AggregateEvent"] = "AggregateEvent";
|
|
32
|
+
AggregationType["AggregatePay"] = "AggregatePay";
|
|
33
|
+
AggregationType["AggregatePayMovieTicketAction"] = "AggregatePayMovieTicketAction";
|
|
34
|
+
AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
|
|
35
|
+
AggregationType["AggregateReserve"] = "AggregateReserve";
|
|
36
|
+
AggregationType["AggregateTask"] = "AggregateTask";
|
|
37
|
+
AggregationType["AggregateUseAction"] = "AggregateUseAction";
|
|
38
|
+
})(AggregationType = exports.AggregationType || (exports.AggregationType = {}));
|
|
39
|
+
/**
|
|
40
|
+
* 集計リポジトリ
|
|
41
|
+
*/
|
|
42
|
+
class MongoRepository {
|
|
43
|
+
constructor(connection) {
|
|
44
|
+
this.aggregationModel = connection.model(aggregation_1.modelName);
|
|
45
|
+
}
|
|
46
|
+
saveAggregation(params) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const { typeOf, project, aggregateDuration, aggregateStart } = params, setFields = __rest(params, ["typeOf", "project", "aggregateDuration", "aggregateStart"]);
|
|
49
|
+
const doc = yield this.aggregationModel.findOneAndUpdate({
|
|
50
|
+
typeOf: { $eq: params.typeOf },
|
|
51
|
+
'project.id': { $eq: params.project.id },
|
|
52
|
+
aggregateStart: { $eq: params.aggregateStart },
|
|
53
|
+
aggregateDuration: { $eq: params.aggregateDuration }
|
|
54
|
+
}, {
|
|
55
|
+
$setOnInsert: {
|
|
56
|
+
typeOf: params.typeOf,
|
|
57
|
+
project: params.project,
|
|
58
|
+
aggregateDuration: params.aggregateDuration,
|
|
59
|
+
aggregateStart: params.aggregateStart
|
|
60
|
+
},
|
|
61
|
+
$set: setFields
|
|
62
|
+
}, { upsert: true, new: true })
|
|
63
|
+
.exec();
|
|
64
|
+
return doc.toObject();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -2,6 +2,27 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import { modelName } from './mongoose/model/assetTransaction';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
export { modelName };
|
|
5
|
+
interface IAggregationByStatus {
|
|
6
|
+
transactionCount: number;
|
|
7
|
+
avgDuration: number;
|
|
8
|
+
maxDuration: number;
|
|
9
|
+
minDuration: number;
|
|
10
|
+
percentilesDuration: {
|
|
11
|
+
name: string;
|
|
12
|
+
value: number;
|
|
13
|
+
}[];
|
|
14
|
+
reservationCount: number;
|
|
15
|
+
avgGraceTime: number;
|
|
16
|
+
maxGraceTime: number;
|
|
17
|
+
minGraceTime: number;
|
|
18
|
+
}
|
|
19
|
+
interface IStatus {
|
|
20
|
+
status: factory.transactionStatusType;
|
|
21
|
+
aggregation: IAggregationByStatus;
|
|
22
|
+
}
|
|
23
|
+
export interface IAggregateReserve {
|
|
24
|
+
statuses: IStatus[];
|
|
25
|
+
}
|
|
5
26
|
/**
|
|
6
27
|
* 資産取引リポジトリ
|
|
7
28
|
*/
|
|
@@ -123,4 +144,15 @@ export declare class MongoRepository {
|
|
|
123
144
|
findByIdAndDelete(params: {
|
|
124
145
|
id: string;
|
|
125
146
|
}): Promise<void>;
|
|
147
|
+
aggregateAssetTransaction(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.assetTransactionType;
|
|
156
|
+
}): Promise<IAggregateReserve>;
|
|
157
|
+
private agggregateByStatus;
|
|
126
158
|
}
|