@chevre/domain 20.2.0-alpha.25 → 20.2.0-alpha.26
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/aggregation/aggregateSystem.ts +9 -3
- package/lib/chevre/repo/aggregation.d.ts +1 -0
- package/lib/chevre/repo/aggregation.js +1 -0
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.js +8 -2
- package/lib/chevre/service/aggregation/system.d.ts +8 -1
- package/lib/chevre/service/aggregation/system.js +49 -2
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ async function main() {
|
|
|
18
18
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
19
|
|
|
20
20
|
await aggregationRepo.aggregationModel.deleteMany({
|
|
21
|
-
typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
|
|
21
|
+
typeOf: { $in: ['AggregateOrder', 'AggregateReservation', 'AggregatePay', 'AggregateReserve'] }
|
|
22
22
|
})
|
|
23
23
|
.exec();
|
|
24
24
|
await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
@@ -29,8 +29,14 @@ async function main() {
|
|
|
29
29
|
assetTransaction: assetTransactionRepo
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
await chevre.service.aggregation.system.aggregatePayTransaction({
|
|
33
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
34
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
35
|
+
})({
|
|
36
|
+
agregation: aggregationRepo,
|
|
37
|
+
assetTransaction: assetTransactionRepo
|
|
38
|
+
});
|
|
39
|
+
// return;
|
|
34
40
|
await chevre.service.aggregation.system.aggregateTask({
|
|
35
41
|
aggregationDays: AGGREGATE_DAYS,
|
|
36
42
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
@@ -5,6 +5,7 @@ export declare enum AggregationType {
|
|
|
5
5
|
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
6
6
|
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
7
7
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
8
|
+
AggregatePay = "AggregatePay",
|
|
8
9
|
AggregateReserve = "AggregateReserve",
|
|
9
10
|
AggregateTask = "AggregateTask",
|
|
10
11
|
AggregateUseAction = "AggregateUseAction"
|
|
@@ -28,6 +28,7 @@ var AggregationType;
|
|
|
28
28
|
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
29
29
|
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
30
30
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
31
|
+
AggregationType["AggregatePay"] = "AggregatePay";
|
|
31
32
|
AggregationType["AggregateReserve"] = "AggregateReserve";
|
|
32
33
|
AggregationType["AggregateTask"] = "AggregateTask";
|
|
33
34
|
AggregationType["AggregateUseAction"] = "AggregateUseAction";
|
|
@@ -536,7 +536,7 @@ class MongoRepository {
|
|
|
536
536
|
.exec();
|
|
537
537
|
});
|
|
538
538
|
}
|
|
539
|
-
|
|
539
|
+
aggregateAssetTransaction(params) {
|
|
540
540
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541
541
|
const statuses = yield Promise.all([
|
|
542
542
|
factory.transactionStatusType.Confirmed,
|
|
@@ -567,7 +567,13 @@ class MongoRepository {
|
|
|
567
567
|
{
|
|
568
568
|
$project: {
|
|
569
569
|
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
570
|
-
graceTime: {
|
|
570
|
+
graceTime: {
|
|
571
|
+
$cond: {
|
|
572
|
+
if: { $eq: ['$typeOf', factory.assetTransactionType.Reserve] },
|
|
573
|
+
then: { $subtract: ['$object.reservationFor.startDate', '$startDate'] },
|
|
574
|
+
else: 0
|
|
575
|
+
}
|
|
576
|
+
},
|
|
571
577
|
status: '$status',
|
|
572
578
|
startDate: '$startDate',
|
|
573
579
|
endDate: '$endDate',
|
|
@@ -51,6 +51,13 @@ declare function aggregateUseAction(params: {
|
|
|
51
51
|
agregation: AggregationRepo;
|
|
52
52
|
action: ActionRepo;
|
|
53
53
|
}) => Promise<void>;
|
|
54
|
+
declare function aggregatePayTransaction(params: {
|
|
55
|
+
aggregationDays: number;
|
|
56
|
+
excludedProjectId?: string;
|
|
57
|
+
}): (repos: {
|
|
58
|
+
agregation: AggregationRepo;
|
|
59
|
+
assetTransaction: AssetTransactionRepo;
|
|
60
|
+
}) => Promise<void>;
|
|
54
61
|
/**
|
|
55
62
|
* 予約集計
|
|
56
63
|
*/
|
|
@@ -68,4 +75,4 @@ declare function aggregateTask(params: {
|
|
|
68
75
|
agregation: AggregationRepo;
|
|
69
76
|
task: TasKRepo;
|
|
70
77
|
}) => Promise<void>;
|
|
71
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
78
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregatePayTransaction, aggregatePlaceOrder, 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.aggregatePlaceOrder = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregatePayTransaction = 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");
|
|
@@ -28,11 +28,13 @@ function aggregatePlaceOrder(params) {
|
|
|
28
28
|
while (i < params.aggregationDays) {
|
|
29
29
|
i += 1;
|
|
30
30
|
const startFrom = moment()
|
|
31
|
+
.utc()
|
|
31
32
|
// .tz('Asia/Tokyo')
|
|
32
33
|
.add(-i, 'days')
|
|
33
34
|
.startOf('day')
|
|
34
35
|
.toDate();
|
|
35
36
|
const startThrough = moment()
|
|
37
|
+
.utc()
|
|
36
38
|
// .tz('Asia/Tokyo')
|
|
37
39
|
.add(-i, 'days')
|
|
38
40
|
.endOf('day')
|
|
@@ -79,11 +81,13 @@ function aggregateAuthorizeEventServiceOfferAction(params) {
|
|
|
79
81
|
while (i < params.aggregationDays) {
|
|
80
82
|
i += 1;
|
|
81
83
|
const startFrom = moment()
|
|
84
|
+
.utc()
|
|
82
85
|
// .tz('Asia/Tokyo')
|
|
83
86
|
.add(-i, 'days')
|
|
84
87
|
.startOf('day')
|
|
85
88
|
.toDate();
|
|
86
89
|
const startThrough = moment()
|
|
90
|
+
.utc()
|
|
87
91
|
// .tz('Asia/Tokyo')
|
|
88
92
|
.add(-i, 'days')
|
|
89
93
|
.endOf('day')
|
|
@@ -113,11 +117,13 @@ function aggregateAuthorizePaymentAction(params) {
|
|
|
113
117
|
while (i < params.aggregationDays) {
|
|
114
118
|
i += 1;
|
|
115
119
|
const startFrom = moment()
|
|
120
|
+
.utc()
|
|
116
121
|
// .tz('Asia/Tokyo')
|
|
117
122
|
.add(-i, 'days')
|
|
118
123
|
.startOf('day')
|
|
119
124
|
.toDate();
|
|
120
125
|
const startThrough = moment()
|
|
126
|
+
.utc()
|
|
121
127
|
// .tz('Asia/Tokyo')
|
|
122
128
|
.add(-i, 'days')
|
|
123
129
|
.endOf('day')
|
|
@@ -144,11 +150,13 @@ function aggregateAuthorizeOrderAction(params) {
|
|
|
144
150
|
while (i < params.aggregationDays) {
|
|
145
151
|
i += 1;
|
|
146
152
|
const startFrom = moment()
|
|
153
|
+
.utc()
|
|
147
154
|
// .tz('Asia/Tokyo')
|
|
148
155
|
.add(-i, 'days')
|
|
149
156
|
.startOf('day')
|
|
150
157
|
.toDate();
|
|
151
158
|
const startThrough = moment()
|
|
159
|
+
.utc()
|
|
152
160
|
// .tz('Asia/Tokyo')
|
|
153
161
|
.add(-i, 'days')
|
|
154
162
|
.endOf('day')
|
|
@@ -178,11 +186,13 @@ function aggregateUseAction(params) {
|
|
|
178
186
|
while (i < params.aggregationDays) {
|
|
179
187
|
i += 1;
|
|
180
188
|
const startFrom = moment()
|
|
189
|
+
.utc()
|
|
181
190
|
// .tz('Asia/Tokyo')
|
|
182
191
|
.add(-i, 'days')
|
|
183
192
|
.startOf('day')
|
|
184
193
|
.toDate();
|
|
185
194
|
const startThrough = moment()
|
|
195
|
+
.utc()
|
|
186
196
|
// .tz('Asia/Tokyo')
|
|
187
197
|
.add(-i, 'days')
|
|
188
198
|
.endOf('day')
|
|
@@ -199,6 +209,39 @@ function aggregateUseAction(params) {
|
|
|
199
209
|
});
|
|
200
210
|
}
|
|
201
211
|
exports.aggregateUseAction = aggregateUseAction;
|
|
212
|
+
function aggregatePayTransaction(params) {
|
|
213
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
var _a;
|
|
215
|
+
const aggregateDate = new Date();
|
|
216
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
217
|
+
.toISOString();
|
|
218
|
+
let i = -1;
|
|
219
|
+
while (i < params.aggregationDays) {
|
|
220
|
+
i += 1;
|
|
221
|
+
const startFrom = moment()
|
|
222
|
+
.utc()
|
|
223
|
+
// .tz('Asia/Tokyo')
|
|
224
|
+
.add(-i, 'days')
|
|
225
|
+
.startOf('day')
|
|
226
|
+
.toDate();
|
|
227
|
+
const startThrough = moment()
|
|
228
|
+
.utc()
|
|
229
|
+
// .tz('Asia/Tokyo')
|
|
230
|
+
.add(-i, 'days')
|
|
231
|
+
.endOf('day')
|
|
232
|
+
.toDate();
|
|
233
|
+
const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
|
|
234
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
235
|
+
startFrom,
|
|
236
|
+
startThrough,
|
|
237
|
+
typeOf: factory.assetTransactionType.Pay
|
|
238
|
+
});
|
|
239
|
+
debug('aggregatePayTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
|
|
240
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePay, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
exports.aggregatePayTransaction = aggregatePayTransaction;
|
|
202
245
|
/**
|
|
203
246
|
* 予約集計
|
|
204
247
|
*/
|
|
@@ -212,16 +255,18 @@ function aggregateReserveTransaction(params) {
|
|
|
212
255
|
while (i < params.aggregationDays) {
|
|
213
256
|
i += 1;
|
|
214
257
|
const startFrom = moment()
|
|
258
|
+
.utc()
|
|
215
259
|
// .tz('Asia/Tokyo')
|
|
216
260
|
.add(-i, 'days')
|
|
217
261
|
.startOf('day')
|
|
218
262
|
.toDate();
|
|
219
263
|
const startThrough = moment()
|
|
264
|
+
.utc()
|
|
220
265
|
// .tz('Asia/Tokyo')
|
|
221
266
|
.add(-i, 'days')
|
|
222
267
|
.endOf('day')
|
|
223
268
|
.toDate();
|
|
224
|
-
const aggregateResult = yield repos.assetTransaction.
|
|
269
|
+
const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
|
|
225
270
|
project: { id: { $ne: params.excludedProjectId } },
|
|
226
271
|
startFrom,
|
|
227
272
|
startThrough,
|
|
@@ -243,11 +288,13 @@ function aggregateTask(params) {
|
|
|
243
288
|
while (i < params.aggregationDays) {
|
|
244
289
|
i += 1;
|
|
245
290
|
const runsFrom = moment()
|
|
291
|
+
.utc()
|
|
246
292
|
// .tz('Asia/Tokyo')
|
|
247
293
|
.add(-i, 'days')
|
|
248
294
|
.startOf('day')
|
|
249
295
|
.toDate();
|
|
250
296
|
const runsThrough = moment()
|
|
297
|
+
.utc()
|
|
251
298
|
// .tz('Asia/Tokyo')
|
|
252
299
|
.add(-i, 'days')
|
|
253
300
|
.endOf('day')
|
package/package.json
CHANGED