@chevre/domain 20.2.0-alpha.30 → 20.2.0-alpha.31
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 +7 -7
- package/example/src/chevre/searchEvents.ts +0 -1
- package/example/src/chevre/updateTransaction.ts +38 -0
- package/lib/chevre/repo/transaction.d.ts +10 -5
- package/lib/chevre/repo/transaction.js +24 -29
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
- package/lib/chevre/service/transaction/returnOrder.js +3 -3
- package/package.json +1 -1
|
@@ -23,31 +23,31 @@ async function main() {
|
|
|
23
23
|
})
|
|
24
24
|
.exec();
|
|
25
25
|
|
|
26
|
-
await chevre.service.aggregation.system.
|
|
26
|
+
await chevre.service.aggregation.system.aggregatePayTransaction({
|
|
27
27
|
aggregationDays: AGGREGATE_DAYS,
|
|
28
28
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
29
29
|
})({
|
|
30
30
|
agregation: aggregationRepo,
|
|
31
|
-
|
|
31
|
+
assetTransaction: assetTransactionRepo
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
await chevre.service.aggregation.system.
|
|
34
|
+
await chevre.service.aggregation.system.aggregateEvent({
|
|
35
35
|
aggregationDays: AGGREGATE_DAYS,
|
|
36
36
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
37
37
|
})({
|
|
38
38
|
agregation: aggregationRepo,
|
|
39
|
-
|
|
39
|
+
event: eventRepo
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
await chevre.service.aggregation.system.
|
|
42
|
+
await chevre.service.aggregation.system.aggregateTask({
|
|
43
43
|
aggregationDays: AGGREGATE_DAYS,
|
|
44
44
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
45
45
|
})({
|
|
46
46
|
agregation: aggregationRepo,
|
|
47
|
-
|
|
47
|
+
task: taskRepo
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
await chevre.service.aggregation.system.
|
|
50
|
+
await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
51
51
|
aggregationDays: AGGREGATE_DAYS,
|
|
52
52
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
53
53
|
})({
|
|
@@ -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
|
+
'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
|
+
'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);
|
|
@@ -89,7 +89,7 @@ export declare class MongoRepository {
|
|
|
89
89
|
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
90
90
|
result: factory.transaction.IResult<T>;
|
|
91
91
|
potentialActions: factory.transaction.IPotentialActions<T>;
|
|
92
|
-
}): Promise<
|
|
92
|
+
}): Promise<void>;
|
|
93
93
|
/**
|
|
94
94
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
95
95
|
*/
|
|
@@ -128,7 +128,7 @@ export declare class MongoRepository {
|
|
|
128
128
|
cancel<T extends factory.transactionType>(params: {
|
|
129
129
|
typeOf: T;
|
|
130
130
|
id: string;
|
|
131
|
-
}): Promise<
|
|
131
|
+
}): Promise<void>;
|
|
132
132
|
count<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T>): Promise<number>;
|
|
133
133
|
/**
|
|
134
134
|
* 取引を検索する
|
|
@@ -137,10 +137,15 @@ export declare class MongoRepository {
|
|
|
137
137
|
/**
|
|
138
138
|
* 特定の取引を更新する(汎用)
|
|
139
139
|
*/
|
|
140
|
-
findByIdAndUpdate
|
|
140
|
+
findByIdAndUpdate(params: {
|
|
141
141
|
id: string;
|
|
142
|
-
update:
|
|
143
|
-
|
|
142
|
+
update: {
|
|
143
|
+
$set?: any;
|
|
144
|
+
$unset?: any;
|
|
145
|
+
$pull?: any;
|
|
146
|
+
$push?: any;
|
|
147
|
+
};
|
|
148
|
+
}): Promise<void>;
|
|
144
149
|
saveOrderNumberIfNotExist(params: {
|
|
145
150
|
id: string;
|
|
146
151
|
orderNumber: string;
|
|
@@ -313,6 +313,8 @@ class MongoRepository {
|
|
|
313
313
|
status: factory.transactionStatusType.InProgress
|
|
314
314
|
}, {
|
|
315
315
|
$set: Object.assign(Object.assign({ 'agent.id': params.agent.id }, (typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined), (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { 'object.customer': params.object.customer } : undefined)
|
|
316
|
+
}, {
|
|
317
|
+
projection: { _id: 1 }
|
|
316
318
|
})
|
|
317
319
|
.exec();
|
|
318
320
|
if (doc === null) {
|
|
@@ -333,6 +335,8 @@ class MongoRepository {
|
|
|
333
335
|
$set: {
|
|
334
336
|
expires: params.expires
|
|
335
337
|
}
|
|
338
|
+
}, {
|
|
339
|
+
projection: { _id: 1 }
|
|
336
340
|
})
|
|
337
341
|
.exec();
|
|
338
342
|
if (doc === null) {
|
|
@@ -353,6 +357,8 @@ class MongoRepository {
|
|
|
353
357
|
status: factory.transactionStatusType.InProgress
|
|
354
358
|
}, {
|
|
355
359
|
$set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
|
|
360
|
+
}, {
|
|
361
|
+
projection: { _id: 1 }
|
|
356
362
|
})
|
|
357
363
|
.exec();
|
|
358
364
|
if (doc === null) {
|
|
@@ -375,7 +381,10 @@ class MongoRepository {
|
|
|
375
381
|
'object.authorizeActions': params.authorizeActions,
|
|
376
382
|
result: params.result,
|
|
377
383
|
potentialActions: params.potentialActions // resultを更新
|
|
378
|
-
}, {
|
|
384
|
+
}, {
|
|
385
|
+
new: true,
|
|
386
|
+
projection: { _id: 1 }
|
|
387
|
+
})
|
|
379
388
|
.exec();
|
|
380
389
|
// NotFoundであれば取引状態確認
|
|
381
390
|
if (doc === null) {
|
|
@@ -384,7 +393,7 @@ class MongoRepository {
|
|
|
384
393
|
/* istanbul ignore next */
|
|
385
394
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
386
395
|
// すでに確定済の場合
|
|
387
|
-
return
|
|
396
|
+
return;
|
|
388
397
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
389
398
|
/* istanbul ignore next */
|
|
390
399
|
}
|
|
@@ -402,7 +411,7 @@ class MongoRepository {
|
|
|
402
411
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
403
412
|
}
|
|
404
413
|
}
|
|
405
|
-
return doc.toObject();
|
|
414
|
+
// return doc.toObject();
|
|
406
415
|
});
|
|
407
416
|
}
|
|
408
417
|
/**
|
|
@@ -485,7 +494,10 @@ class MongoRepository {
|
|
|
485
494
|
}, {
|
|
486
495
|
status: factory.transactionStatusType.Canceled,
|
|
487
496
|
endDate: endDate
|
|
488
|
-
}, {
|
|
497
|
+
}, {
|
|
498
|
+
new: true,
|
|
499
|
+
projection: { _id: 1 }
|
|
500
|
+
})
|
|
489
501
|
.exec();
|
|
490
502
|
// NotFoundであれば取引状態確認
|
|
491
503
|
if (doc === null) {
|
|
@@ -494,7 +506,7 @@ class MongoRepository {
|
|
|
494
506
|
/* istanbul ignore next */
|
|
495
507
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
496
508
|
// すでに中止済の場合
|
|
497
|
-
return
|
|
509
|
+
return;
|
|
498
510
|
}
|
|
499
511
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
500
512
|
throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
|
|
@@ -506,7 +518,7 @@ class MongoRepository {
|
|
|
506
518
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
507
519
|
}
|
|
508
520
|
}
|
|
509
|
-
return doc.toObject();
|
|
521
|
+
// return doc.toObject();
|
|
510
522
|
});
|
|
511
523
|
}
|
|
512
524
|
count(params) {
|
|
@@ -542,43 +554,26 @@ class MongoRepository {
|
|
|
542
554
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
543
555
|
});
|
|
544
556
|
}
|
|
545
|
-
// public stream<T extends factory.transactionType>(
|
|
546
|
-
// params: factory.transaction.ISearchConditions<T>
|
|
547
|
-
// ): QueryCursor<Document> {
|
|
548
|
-
// const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
549
|
-
// const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
550
|
-
// .select({ __v: 0, createdAt: 0, updatedAt: 0 });
|
|
551
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
552
|
-
// /* istanbul ignore else */
|
|
553
|
-
// if (params.limit !== undefined && params.page !== undefined) {
|
|
554
|
-
// query.limit(params.limit)
|
|
555
|
-
// .skip(params.limit * (params.page - 1));
|
|
556
|
-
// }
|
|
557
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
558
|
-
// /* istanbul ignore else */
|
|
559
|
-
// if (params.sort !== undefined) {
|
|
560
|
-
// query.sort(params.sort);
|
|
561
|
-
// }
|
|
562
|
-
// return query.cursor();
|
|
563
|
-
// }
|
|
564
557
|
/**
|
|
565
558
|
* 特定の取引を更新する(汎用)
|
|
566
559
|
*/
|
|
567
560
|
findByIdAndUpdate(params) {
|
|
568
561
|
return __awaiter(this, void 0, void 0, function* () {
|
|
569
|
-
|
|
562
|
+
yield this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, {
|
|
563
|
+
// new: true,
|
|
564
|
+
projection: { _id: 1 }
|
|
565
|
+
})
|
|
570
566
|
.exec()
|
|
571
567
|
.then((doc) => {
|
|
572
568
|
if (doc === null) {
|
|
573
569
|
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
574
570
|
}
|
|
575
|
-
return doc.toObject();
|
|
576
571
|
});
|
|
577
572
|
});
|
|
578
573
|
}
|
|
579
574
|
saveOrderNumberIfNotExist(params) {
|
|
580
575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
581
|
-
yield this.transactionModel.
|
|
576
|
+
yield this.transactionModel.updateOne({
|
|
582
577
|
_id: params.id,
|
|
583
578
|
'object.orderNumber': { $exists: false }
|
|
584
579
|
}, { 'object.orderNumber': params.orderNumber })
|
|
@@ -587,7 +582,7 @@ class MongoRepository {
|
|
|
587
582
|
}
|
|
588
583
|
saveConfirmationNumberIfNotExist(params) {
|
|
589
584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
590
|
-
yield this.transactionModel.
|
|
585
|
+
yield this.transactionModel.updateOne({
|
|
591
586
|
_id: params.id,
|
|
592
587
|
'object.confirmationNumber': { $exists: false }
|
|
593
588
|
}, { 'object.confirmationNumber': params.confirmationNumber })
|
|
@@ -189,7 +189,7 @@ function publishPaymentUrl(params) {
|
|
|
189
189
|
};
|
|
190
190
|
yield repos.transaction.findByIdAndUpdate({
|
|
191
191
|
id: transaction.id,
|
|
192
|
-
update: { 'object.paymentMethods': paymentMethodByPaymentUrl }
|
|
192
|
+
update: { $set: { 'object.paymentMethods': paymentMethodByPaymentUrl } }
|
|
193
193
|
});
|
|
194
194
|
return result;
|
|
195
195
|
});
|
|
@@ -68,13 +68,13 @@ exports.start = start;
|
|
|
68
68
|
*/
|
|
69
69
|
function confirm(params) {
|
|
70
70
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
var _a
|
|
71
|
+
var _a;
|
|
72
72
|
// 確認番号を事前発行
|
|
73
73
|
yield publishConfirmationNumberIfNotExist({
|
|
74
74
|
id: params.id,
|
|
75
75
|
object: { orderDate: params.result.order.orderDate }
|
|
76
76
|
})(repos);
|
|
77
|
-
|
|
77
|
+
const transaction = yield repos.transaction.findById({
|
|
78
78
|
typeOf: factory.transactionType.PlaceOrder,
|
|
79
79
|
id: params.id
|
|
80
80
|
});
|
|
@@ -121,7 +121,7 @@ function confirm(params) {
|
|
|
121
121
|
});
|
|
122
122
|
// ステータス変更
|
|
123
123
|
try {
|
|
124
|
-
|
|
124
|
+
yield repos.transaction.confirm({
|
|
125
125
|
typeOf: transaction.typeOf,
|
|
126
126
|
id: transaction.id,
|
|
127
127
|
authorizeActions: transaction.object.authorizeActions,
|
|
@@ -140,10 +140,10 @@ function confirm(params) {
|
|
|
140
140
|
throw error;
|
|
141
141
|
}
|
|
142
142
|
// 万が一処理が想定通りでない場合orderNumberが存在しない
|
|
143
|
-
if (typeof
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
return
|
|
143
|
+
// if (typeof transaction.result?.order.typeOf !== 'string') {
|
|
144
|
+
// throw new factory.errors.ServiceUnavailable('transaction.result not found');
|
|
145
|
+
// }
|
|
146
|
+
return result;
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
exports.confirm = confirm;
|
|
@@ -306,7 +306,7 @@ function validateAppliedReturnPolicy(params) {
|
|
|
306
306
|
function confirm(params) {
|
|
307
307
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
308
308
|
var _a;
|
|
309
|
-
|
|
309
|
+
const transaction = yield repos.transaction.findById({ typeOf: factory.transactionType.ReturnOrder, id: params.id });
|
|
310
310
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
311
311
|
// すでに確定済の場合
|
|
312
312
|
return transaction.result;
|
|
@@ -356,14 +356,14 @@ function confirm(params) {
|
|
|
356
356
|
// useConfirmRefund: params.useConfirmRefund
|
|
357
357
|
});
|
|
358
358
|
// ステータス変更
|
|
359
|
-
|
|
359
|
+
yield repos.transaction.confirm({
|
|
360
360
|
typeOf: transaction.typeOf,
|
|
361
361
|
id: transaction.id,
|
|
362
362
|
authorizeActions: [],
|
|
363
363
|
result: result,
|
|
364
364
|
potentialActions: potentialActions
|
|
365
365
|
});
|
|
366
|
-
return
|
|
366
|
+
return result;
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
exports.confirm = confirm;
|
package/package.json
CHANGED