@chevre/domain 20.2.0-alpha.2 → 20.2.0-alpha.20
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 +80 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +90 -0
- package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
- package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
- package/lib/chevre/repo/action.d.ts +58 -0
- package/lib/chevre/repo/action.js +187 -0
- package/lib/chevre/repo/aggregation.d.ts +29 -0
- package/lib/chevre/repo/aggregation.js +64 -0
- package/lib/chevre/repo/event.d.ts +0 -1
- package/lib/chevre/repo/event.js +124 -105
- 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 +2 -2
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/order.d.ts +9 -0
- package/lib/chevre/repo/order.js +49 -0
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +205 -52
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/reservation.js +64 -29
- package/lib/chevre/repo/transaction.d.ts +28 -0
- package/lib/chevre/repo/transaction.js +125 -0
- 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.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
- package/lib/chevre/service/aggregation/system.d.ts +73 -0
- package/lib/chevre/service/aggregation/system.js +251 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -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/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +29 -1
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +33 -51
- package/lib/chevre/service/delivery/factory.js +1 -0
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +21 -10
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.js +25 -5
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer.js +28 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/payment/any.d.ts +5 -0
- package/lib/chevre/service/reserve/useReservation.js +2 -1
- 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/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -2,6 +2,23 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { modelName } from './mongoose/model/transaction';
|
|
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
|
+
}
|
|
15
|
+
interface IStatus {
|
|
16
|
+
status: factory.transactionStatusType;
|
|
17
|
+
aggregation: IAggregationByStatus;
|
|
18
|
+
}
|
|
19
|
+
interface IAggregatePlaceOrder {
|
|
20
|
+
statuses: IStatus[];
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* 取引リポジトリ
|
|
7
24
|
*/
|
|
@@ -129,4 +146,15 @@ export declare class MongoRepository {
|
|
|
129
146
|
findByIdAndDelete(params: {
|
|
130
147
|
id: string;
|
|
131
148
|
}): Promise<void>;
|
|
149
|
+
aggregatePlaceOrder(params: {
|
|
150
|
+
project?: {
|
|
151
|
+
id?: {
|
|
152
|
+
$ne?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
startFrom: Date;
|
|
156
|
+
startThrough: Date;
|
|
157
|
+
typeOf: factory.transactionType;
|
|
158
|
+
}): Promise<IAggregatePlaceOrder>;
|
|
159
|
+
private agggregateByStatus;
|
|
132
160
|
}
|
|
@@ -600,5 +600,130 @@ class MongoRepository {
|
|
|
600
600
|
.exec();
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
|
+
aggregatePlaceOrder(params) {
|
|
604
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
const statuses = yield Promise.all([
|
|
606
|
+
factory.transactionStatusType.Canceled,
|
|
607
|
+
factory.transactionStatusType.Expired,
|
|
608
|
+
factory.transactionStatusType.Confirmed
|
|
609
|
+
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
610
|
+
var _a, _b;
|
|
611
|
+
const matchConditions = Object.assign({ startDate: {
|
|
612
|
+
$gte: params.startFrom,
|
|
613
|
+
$lte: params.startThrough
|
|
614
|
+
}, typeOf: { $eq: params.typeOf }, status: { $eq: transactionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
615
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
616
|
+
: undefined);
|
|
617
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
618
|
+
})));
|
|
619
|
+
return { statuses };
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
// tslint:disable-next-line:max-func-body-length
|
|
623
|
+
agggregateByStatus(params) {
|
|
624
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
625
|
+
const matchConditions = params.matchConditions;
|
|
626
|
+
const transactionStatus = params.status;
|
|
627
|
+
const aggregations = yield this.transactionModel.aggregate([
|
|
628
|
+
{
|
|
629
|
+
$match: matchConditions
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
$project: {
|
|
633
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
634
|
+
status: '$status',
|
|
635
|
+
startDate: '$startDate',
|
|
636
|
+
endDate: '$endDate',
|
|
637
|
+
typeOf: '$typeOf'
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
$group: {
|
|
642
|
+
_id: '$typeOf',
|
|
643
|
+
transactionCount: { $sum: 1 },
|
|
644
|
+
maxDuration: { $max: '$duration' },
|
|
645
|
+
minDuration: { $min: '$duration' },
|
|
646
|
+
avgDuration: { $avg: '$duration' }
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
$project: {
|
|
651
|
+
_id: 0,
|
|
652
|
+
transactionCount: '$transactionCount',
|
|
653
|
+
avgDuration: '$avgDuration',
|
|
654
|
+
maxDuration: '$maxDuration',
|
|
655
|
+
minDuration: '$minDuration'
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
])
|
|
659
|
+
.exec();
|
|
660
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
661
|
+
const percents = [50, 95, 99];
|
|
662
|
+
if (aggregations.length === 0) {
|
|
663
|
+
return {
|
|
664
|
+
status: transactionStatus,
|
|
665
|
+
aggregation: {
|
|
666
|
+
transactionCount: 0,
|
|
667
|
+
avgDuration: 0,
|
|
668
|
+
maxDuration: 0,
|
|
669
|
+
minDuration: 0,
|
|
670
|
+
percentilesDuration: percents.map((percent) => {
|
|
671
|
+
return {
|
|
672
|
+
name: String(percent),
|
|
673
|
+
value: 0
|
|
674
|
+
};
|
|
675
|
+
})
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
680
|
+
return {
|
|
681
|
+
percentile,
|
|
682
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
683
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
const aggregations2 = yield this.transactionModel.aggregate([
|
|
687
|
+
{
|
|
688
|
+
$match: matchConditions
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
$project: {
|
|
692
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
693
|
+
status: '$status',
|
|
694
|
+
startDate: '$startDate',
|
|
695
|
+
endDate: '$endDate',
|
|
696
|
+
typeOf: '$typeOf'
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{ $sort: { duration: 1 } },
|
|
700
|
+
{
|
|
701
|
+
$group: {
|
|
702
|
+
_id: '$typeOf',
|
|
703
|
+
durations: { $push: '$duration' }
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
$project: {
|
|
708
|
+
_id: 0,
|
|
709
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
710
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
711
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
712
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
713
|
+
return {
|
|
714
|
+
name: String(rank.percentile),
|
|
715
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
716
|
+
};
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
])
|
|
721
|
+
.exec();
|
|
722
|
+
return {
|
|
723
|
+
status: transactionStatus,
|
|
724
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
725
|
+
};
|
|
726
|
+
});
|
|
727
|
+
}
|
|
603
728
|
}
|
|
604
729
|
exports.MongoRepository = MongoRepository;
|
package/lib/chevre/repo/trip.js
CHANGED
|
@@ -32,18 +32,46 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
35
|
-
var _a, _b, _c;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f;
|
|
36
36
|
const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
|
|
37
37
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
38
|
if (typeof projectIdEq === 'string') {
|
|
39
|
-
andConditions.push({
|
|
40
|
-
'project.id': { $eq: projectIdEq }
|
|
41
|
-
});
|
|
39
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
42
40
|
}
|
|
43
41
|
const idIn = (_c = conditions.id) === null || _c === void 0 ? void 0 : _c.$in;
|
|
44
42
|
if (Array.isArray(idIn)) {
|
|
43
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
44
|
+
}
|
|
45
|
+
const identifierEq = (_d = conditions.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
46
|
+
if (typeof identifierEq === 'string') {
|
|
47
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
48
|
+
}
|
|
49
|
+
const nameRegex = (_e = conditions.name) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
50
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
51
|
+
andConditions.push({
|
|
52
|
+
$or: [
|
|
53
|
+
{
|
|
54
|
+
'name.ja': {
|
|
55
|
+
$exists: true,
|
|
56
|
+
$regex: new RegExp(nameRegex)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
'name.en': {
|
|
61
|
+
$exists: true,
|
|
62
|
+
$regex: new RegExp(nameRegex)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const additionalPropertyElemMatch = (_f = conditions.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
|
|
69
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
45
70
|
andConditions.push({
|
|
46
|
-
|
|
71
|
+
additionalProperty: {
|
|
72
|
+
$exists: true,
|
|
73
|
+
$elemMatch: additionalPropertyElemMatch
|
|
74
|
+
}
|
|
47
75
|
});
|
|
48
76
|
}
|
|
49
77
|
return andConditions;
|
|
@@ -119,28 +147,6 @@ class MongoRepository {
|
|
|
119
147
|
if (p.attributes.typeOf === factory.tripType.BusTrip) {
|
|
120
148
|
// 上書き禁止属性を除外
|
|
121
149
|
const _a = p.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
122
|
-
bulkWriteOps.push({
|
|
123
|
-
updateOne: {
|
|
124
|
-
filter: {
|
|
125
|
-
_id: p.id,
|
|
126
|
-
typeOf: p.attributes.typeOf
|
|
127
|
-
},
|
|
128
|
-
// upsertの場合、createがありうるので属性を除外しない
|
|
129
|
-
update: Object.assign({ $setOnInsert: {
|
|
130
|
-
typeOf: p.attributes.typeOf,
|
|
131
|
-
project: p.attributes.project,
|
|
132
|
-
identifier: p.attributes.identifier
|
|
133
|
-
// ...(typeof p.attributes.remainingAttendeeCapacity === 'number')
|
|
134
|
-
// ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
|
|
135
|
-
// : undefined
|
|
136
|
-
}, $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
|
|
137
|
-
upsert
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else if (p.attributes.typeOf === factory.tripType.BusTripSeries) {
|
|
142
|
-
// 上書き禁止属性を除外
|
|
143
|
-
const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
|
|
144
150
|
bulkWriteOps.push({
|
|
145
151
|
updateOne: {
|
|
146
152
|
filter: {
|
|
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
|
7
7
|
import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
|
|
8
8
|
import { MongoRepository as ActionRepo } from './repo/action';
|
|
9
9
|
import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
10
|
+
import { MongoRepository as AggregationRepo } from './repo/aggregation';
|
|
10
11
|
import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
|
|
11
12
|
import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
|
|
12
13
|
import { MongoRepository as CodeRepo } from './repo/code';
|
|
@@ -69,6 +70,8 @@ export declare class Action extends ActionRepo {
|
|
|
69
70
|
*/
|
|
70
71
|
export declare class AdditionalProperty extends AdditionalPropertyRepo {
|
|
71
72
|
}
|
|
73
|
+
export declare class Aggregation extends AggregationRepo {
|
|
74
|
+
}
|
|
72
75
|
export declare namespace action {
|
|
73
76
|
class RegisterServiceInProgress extends RegisterServiceActionInProgress {
|
|
74
77
|
}
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
3
|
+
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
|
|
|
11
11
|
const accountTransaction_1 = require("./repo/accountTransaction");
|
|
12
12
|
const action_1 = require("./repo/action");
|
|
13
13
|
const additionalProperty_1 = require("./repo/additionalProperty");
|
|
14
|
+
const aggregation_1 = require("./repo/aggregation");
|
|
14
15
|
const assetTransaction_1 = require("./repo/assetTransaction");
|
|
15
16
|
const categoryCode_1 = require("./repo/categoryCode");
|
|
16
17
|
const code_1 = require("./repo/code");
|
|
@@ -80,6 +81,9 @@ exports.Action = Action;
|
|
|
80
81
|
class AdditionalProperty extends additionalProperty_1.MongoRepository {
|
|
81
82
|
}
|
|
82
83
|
exports.AdditionalProperty = AdditionalProperty;
|
|
84
|
+
class Aggregation extends aggregation_1.MongoRepository {
|
|
85
|
+
}
|
|
86
|
+
exports.Aggregation = Aggregation;
|
|
83
87
|
var action;
|
|
84
88
|
(function (action) {
|
|
85
89
|
class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
|
|
@@ -26,5 +26,5 @@ export declare function aggregateScreeningEvent(params: {
|
|
|
26
26
|
id: string;
|
|
27
27
|
}): IAggregateScreeningEventOperation<void>;
|
|
28
28
|
export declare function aggregateByEvent(params: {
|
|
29
|
-
event: factory.event.screeningEvent.IEvent;
|
|
29
|
+
event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
|
|
30
30
|
}): IAggregateScreeningEventOperation<void>;
|
|
@@ -120,9 +120,16 @@ exports.aggregateByEvent = aggregateByEvent;
|
|
|
120
120
|
*/
|
|
121
121
|
function findLocation(params) {
|
|
122
122
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
var _a;
|
|
123
124
|
let movieTheater;
|
|
124
125
|
try {
|
|
125
|
-
|
|
126
|
+
if (params.event.typeOf === factory.eventType.ScreeningEvent) {
|
|
127
|
+
movieTheater = yield repos.place.findById({ id: params.event.superEvent.location.id });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
|
|
131
|
+
movieTheater = yield repos.place.findById({ id: movieTheaterId });
|
|
132
|
+
}
|
|
126
133
|
}
|
|
127
134
|
catch (error) {
|
|
128
135
|
let throwsError = true;
|
|
@@ -223,22 +230,29 @@ function aggregateReservationByOffer(params) {
|
|
|
223
230
|
let reservationCount4offer;
|
|
224
231
|
let attendeeCount4offer;
|
|
225
232
|
let checkInCount4offer;
|
|
233
|
+
let reservationType = factory.reservationType.EventReservation;
|
|
234
|
+
if (params.event.typeOf === factory.eventType.Event) {
|
|
235
|
+
reservationType = factory.reservationType.BusReservation;
|
|
236
|
+
}
|
|
226
237
|
reservationCount4offer = yield repos.reservation.count({
|
|
227
|
-
typeOf:
|
|
228
|
-
reservationFor: { ids: [params.event.id] },
|
|
238
|
+
typeOf: reservationType,
|
|
239
|
+
// reservationFor: { ids: [params.event.id] },
|
|
240
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
229
241
|
reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
230
242
|
reservedTicket: { ticketType: { ids: [params.offer.id] } }
|
|
231
243
|
});
|
|
232
244
|
attendeeCount4offer = yield repos.reservation.count({
|
|
233
|
-
typeOf:
|
|
234
|
-
reservationFor: { ids: [params.event.id] },
|
|
245
|
+
typeOf: reservationType,
|
|
246
|
+
// reservationFor: { ids: [params.event.id] },
|
|
247
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
235
248
|
reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
236
249
|
reservedTicket: { ticketType: { ids: [params.offer.id] } },
|
|
237
250
|
attended: true
|
|
238
251
|
});
|
|
239
252
|
checkInCount4offer = yield repos.reservation.count({
|
|
240
|
-
typeOf:
|
|
241
|
-
reservationFor: { ids: [params.event.id] },
|
|
253
|
+
typeOf: reservationType,
|
|
254
|
+
// reservationFor: { ids: [params.event.id] },
|
|
255
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
242
256
|
reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
243
257
|
reservedTicket: { ticketType: { ids: [params.offer.id] } },
|
|
244
258
|
checkedIn: true
|
|
@@ -390,9 +404,14 @@ function aggregateReservationByEvent(params) {
|
|
|
390
404
|
let attendeeCount;
|
|
391
405
|
let checkInCount;
|
|
392
406
|
let reservationCount;
|
|
407
|
+
let reservationType = factory.reservationType.EventReservation;
|
|
408
|
+
if (params.event.typeOf === factory.eventType.Event) {
|
|
409
|
+
reservationType = factory.reservationType.BusReservation;
|
|
410
|
+
}
|
|
393
411
|
reservationCount = yield repos.reservation.count({
|
|
394
|
-
typeOf:
|
|
395
|
-
reservationFor: { ids: [params.event.id] },
|
|
412
|
+
typeOf: reservationType,
|
|
413
|
+
// reservationFor: { ids: [params.event.id] },
|
|
414
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
396
415
|
reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
|
|
397
416
|
});
|
|
398
417
|
// maximumAttendeeCapacityを決定
|
|
@@ -421,14 +440,16 @@ function aggregateReservationByEvent(params) {
|
|
|
421
440
|
}
|
|
422
441
|
}
|
|
423
442
|
attendeeCount = yield repos.reservation.count({
|
|
424
|
-
typeOf:
|
|
425
|
-
reservationFor: { ids: [params.event.id] },
|
|
443
|
+
typeOf: reservationType,
|
|
444
|
+
// reservationFor: { ids: [params.event.id] },
|
|
445
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
426
446
|
// reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
427
447
|
attended: true
|
|
428
448
|
});
|
|
429
449
|
checkInCount = yield repos.reservation.count({
|
|
430
|
-
typeOf:
|
|
431
|
-
reservationFor: { ids: [params.event.id] },
|
|
450
|
+
typeOf: reservationType,
|
|
451
|
+
// reservationFor: { ids: [params.event.id] },
|
|
452
|
+
reservationFor: { id: { $eq: params.event.id } },
|
|
432
453
|
// reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
|
|
433
454
|
checkedIn: true
|
|
434
455
|
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
|
+
import { MongoRepository as AggregationRepo } from '../../repo/aggregation';
|
|
3
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
|
+
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
5
|
+
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
|
+
/**
|
|
7
|
+
* 注文取引集計
|
|
8
|
+
*/
|
|
9
|
+
declare function aggregatePlaceOrder(params: {
|
|
10
|
+
aggregationDays: number;
|
|
11
|
+
excludedProjectId?: string;
|
|
12
|
+
}): (repos: {
|
|
13
|
+
agregation: AggregationRepo;
|
|
14
|
+
transaction: TransactionRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* 興行オファー承認アクション集計
|
|
18
|
+
*/
|
|
19
|
+
declare function aggregateAuthorizeEventServiceOfferAction(params: {
|
|
20
|
+
aggregationDays: number;
|
|
21
|
+
excludedProjectId?: string;
|
|
22
|
+
}): (repos: {
|
|
23
|
+
agregation: AggregationRepo;
|
|
24
|
+
action: ActionRepo;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 決済承認アクション集計
|
|
28
|
+
*/
|
|
29
|
+
declare function aggregateAuthorizePaymentAction(params: {
|
|
30
|
+
aggregationDays: number;
|
|
31
|
+
excludedProjectId?: string;
|
|
32
|
+
}): (repos: {
|
|
33
|
+
agregation: AggregationRepo;
|
|
34
|
+
action: ActionRepo;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
declare function aggregateAuthorizeOrderAction(params: {
|
|
37
|
+
aggregationDays: number;
|
|
38
|
+
excludedProjectId?: string;
|
|
39
|
+
}): (repos: {
|
|
40
|
+
agregation: AggregationRepo;
|
|
41
|
+
action: ActionRepo;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* 使用アクション集計
|
|
45
|
+
*/
|
|
46
|
+
declare function aggregateUseAction(params: {
|
|
47
|
+
aggregationDays: number;
|
|
48
|
+
excludedProjectId?: string;
|
|
49
|
+
}): (repos: {
|
|
50
|
+
agregation: AggregationRepo;
|
|
51
|
+
action: ActionRepo;
|
|
52
|
+
}) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* 注文集計
|
|
55
|
+
*/
|
|
56
|
+
declare function aggregateOrder(params: {
|
|
57
|
+
aggregationDays: number;
|
|
58
|
+
excludedProjectId?: string;
|
|
59
|
+
}): (repos: {
|
|
60
|
+
agregation: AggregationRepo;
|
|
61
|
+
order: OrderRepo;
|
|
62
|
+
}) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* 予約集計
|
|
65
|
+
*/
|
|
66
|
+
declare function aggregateReservation(params: {
|
|
67
|
+
aggregationDays: number;
|
|
68
|
+
excludedProjectId?: string;
|
|
69
|
+
}): (repos: {
|
|
70
|
+
agregation: AggregationRepo;
|
|
71
|
+
reservation: ReservationRepo;
|
|
72
|
+
}) => Promise<void>;
|
|
73
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateOrder, aggregatePlaceOrder, aggregateReservation, aggregateUseAction };
|