@chevre/domain 21.2.0-alpha.31 → 21.2.0-alpha.33
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/searchAbortedTasks.ts +11 -5
- package/example/src/chevre/transaction/startExportTasks.ts +2 -1
- package/lib/chevre/repo/assetTransaction.d.ts +7 -0
- package/lib/chevre/repo/assetTransaction.js +40 -0
- package/lib/chevre/repo/transaction.d.ts +7 -0
- package/lib/chevre/repo/transaction.js +40 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- package/package.json +1 -1
|
@@ -9,18 +9,24 @@ async function main() {
|
|
|
9
9
|
|
|
10
10
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
11
11
|
|
|
12
|
-
const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.
|
|
12
|
+
const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.ConfirmPayTransaction>[]>await taskRepo.search({
|
|
13
13
|
// limit: 100,
|
|
14
14
|
// page: 1,
|
|
15
|
-
name:
|
|
15
|
+
name: {
|
|
16
|
+
$in: [chevre.factory.taskName.ConfirmPayTransaction]
|
|
17
|
+
// $nin: [
|
|
18
|
+
// chevre.factory.taskName.ImportEventsFromCOA,
|
|
19
|
+
// chevre.factory.taskName.ImportEventCapacitiesFromCOA
|
|
20
|
+
// ]
|
|
21
|
+
},
|
|
16
22
|
statuses: [chevre.factory.taskStatus.Aborted],
|
|
17
|
-
runsFrom: moment('2023-
|
|
23
|
+
runsFrom: moment('2023-05-02T22:00:00Z')
|
|
18
24
|
.toDate(),
|
|
19
25
|
sort: { runsAt: chevre.factory.sortType.Ascending }
|
|
20
26
|
});
|
|
21
|
-
console.log(tasks.map((task) => `${task.project.id},${task.id},${moment(task.runsAt)
|
|
27
|
+
console.log(tasks.map((task) => `${task.project.id},${task.id},${task.name},${moment(task.runsAt)
|
|
22
28
|
.tz('Asia/Tokyo')
|
|
23
|
-
.format('YYYY-MM-DDTHH:mm:ssZ')},"${task.data.object[0]
|
|
29
|
+
.format('YYYY-MM-DDTHH:mm:ssZ')},"${task.data.object[0]?.transactionNumber}"`)
|
|
24
30
|
.join('\n'));
|
|
25
31
|
console.log(tasks.length);
|
|
26
32
|
}
|
|
@@ -9,7 +9,8 @@ async function main() {
|
|
|
9
9
|
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
10
|
const result = await transactionRepo.startExportTasks({
|
|
11
11
|
typeOf: { $in: [chevre.factory.transactionType.PlaceOrder] },
|
|
12
|
-
status: chevre.factory.transactionStatusType.Confirmed
|
|
12
|
+
status: chevre.factory.transactionStatusType.Confirmed,
|
|
13
|
+
tasksExportAction: { agent: { name: 'xxx' } }
|
|
13
14
|
});
|
|
14
15
|
console.log(result);
|
|
15
16
|
}
|
|
@@ -111,6 +111,13 @@ export declare class MongoRepository {
|
|
|
111
111
|
reexportTasks(params: {
|
|
112
112
|
intervalInMinutes: number;
|
|
113
113
|
}): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
116
|
+
*/
|
|
117
|
+
exportTasks(params: {
|
|
118
|
+
now: Date;
|
|
119
|
+
delayInSeconds: number;
|
|
120
|
+
}): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction, "typeOf" | "id" | "status">[]>;
|
|
114
121
|
/**
|
|
115
122
|
* set task status exported by transaction id
|
|
116
123
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -436,6 +436,46 @@ class MongoRepository {
|
|
|
436
436
|
// .exec();
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
441
|
+
*/
|
|
442
|
+
exportTasks(params) {
|
|
443
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
444
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
445
|
+
status: {
|
|
446
|
+
$in: [
|
|
447
|
+
factory.transactionStatusType.Canceled,
|
|
448
|
+
factory.transactionStatusType.Confirmed,
|
|
449
|
+
factory.transactionStatusType.Expired
|
|
450
|
+
]
|
|
451
|
+
},
|
|
452
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
453
|
+
endDate: {
|
|
454
|
+
$exists: true,
|
|
455
|
+
$lt: moment(params.now)
|
|
456
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
457
|
+
.toDate()
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
.select({
|
|
461
|
+
_id: 1,
|
|
462
|
+
typeOf: 1,
|
|
463
|
+
status: 1
|
|
464
|
+
})
|
|
465
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
466
|
+
.exec();
|
|
467
|
+
if (delayedTransactions.length > 0) {
|
|
468
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
469
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
470
|
+
id: delayedTransaction.id,
|
|
471
|
+
typeOf: delayedTransaction.typeOf,
|
|
472
|
+
status: delayedTransaction.status
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return delayedTransactions;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
439
479
|
/**
|
|
440
480
|
* set task status exported by transaction id
|
|
441
481
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -127,6 +127,13 @@ export declare class MongoRepository {
|
|
|
127
127
|
reexportTasks(params: {
|
|
128
128
|
intervalInMinutes: number;
|
|
129
129
|
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
132
|
+
*/
|
|
133
|
+
exportTasks(params: {
|
|
134
|
+
now: Date;
|
|
135
|
+
delayInSeconds: number;
|
|
136
|
+
}): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "typeOf" | "id" | "status">[]>;
|
|
130
137
|
/**
|
|
131
138
|
* set task status exported by transaction id
|
|
132
139
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -547,6 +547,46 @@ class MongoRepository {
|
|
|
547
547
|
// .exec();
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
552
|
+
*/
|
|
553
|
+
exportTasks(params) {
|
|
554
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
556
|
+
status: {
|
|
557
|
+
$in: [
|
|
558
|
+
factory.transactionStatusType.Canceled,
|
|
559
|
+
factory.transactionStatusType.Confirmed,
|
|
560
|
+
factory.transactionStatusType.Expired
|
|
561
|
+
]
|
|
562
|
+
},
|
|
563
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
564
|
+
endDate: {
|
|
565
|
+
$exists: true,
|
|
566
|
+
$lt: moment(params.now)
|
|
567
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
568
|
+
.toDate()
|
|
569
|
+
}
|
|
570
|
+
})
|
|
571
|
+
.select({
|
|
572
|
+
_id: 1,
|
|
573
|
+
typeOf: 1,
|
|
574
|
+
status: 1
|
|
575
|
+
})
|
|
576
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
577
|
+
.exec();
|
|
578
|
+
if (delayedTransactions.length > 0) {
|
|
579
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
580
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
581
|
+
id: delayedTransaction.id,
|
|
582
|
+
typeOf: delayedTransaction.typeOf,
|
|
583
|
+
status: delayedTransaction.status
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return delayedTransactions;
|
|
588
|
+
});
|
|
589
|
+
}
|
|
550
590
|
/**
|
|
551
591
|
* set task status exported by transaction id
|
|
552
592
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -5,6 +5,7 @@ import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/o
|
|
|
5
5
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
6
6
|
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
8
|
+
import { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
8
9
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
9
10
|
interface IVoidTransactionRepos {
|
|
10
11
|
action: ActionRepo;
|
|
@@ -13,6 +14,7 @@ interface IVoidTransactionRepos {
|
|
|
13
14
|
offerRateLimit: OfferRateLimitRepo;
|
|
14
15
|
reservation: ReservationRepo;
|
|
15
16
|
task: TaskRepo;
|
|
17
|
+
transaction: TransactionRepo;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* イベントオファー承認取消(タスクから実行)
|
|
@@ -26,8 +26,13 @@ exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
|
26
26
|
*/
|
|
27
27
|
function voidTransaction(params) {
|
|
28
28
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const transaction = yield repos.transaction.findById({
|
|
30
|
+
typeOf: params.purpose.typeOf,
|
|
31
|
+
id: params.purpose.id,
|
|
32
|
+
inclusion: ['_id', 'typeOf', 'status']
|
|
33
|
+
});
|
|
29
34
|
// 座席仮予約アクション検索
|
|
30
|
-
|
|
35
|
+
let authorizeActions = yield repos.action.searchByPurpose({
|
|
31
36
|
typeOf: factory.actionType.AuthorizeAction,
|
|
32
37
|
purpose: {
|
|
33
38
|
typeOf: params.purpose.typeOf,
|
|
@@ -36,6 +41,17 @@ function voidTransaction(params) {
|
|
|
36
41
|
})
|
|
37
42
|
.then((actions) => actions
|
|
38
43
|
.filter((a) => a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation));
|
|
44
|
+
switch (transaction.status) {
|
|
45
|
+
case factory.transactionStatusType.InProgress:
|
|
46
|
+
throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
47
|
+
// 確定取引に対応(2023-05-07~)
|
|
48
|
+
case factory.transactionStatusType.Confirmed:
|
|
49
|
+
// アクションステータスを検証する
|
|
50
|
+
authorizeActions = authorizeActions.filter((a) => a.actionStatus !== factory.actionStatusType.CompletedActionStatus);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
// no op
|
|
54
|
+
}
|
|
39
55
|
yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
40
56
|
yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
|
|
41
57
|
switch (action.instrument.identifier) {
|
|
@@ -17,6 +17,7 @@ const offer_1 = require("../../repo/rateLimit/offer");
|
|
|
17
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
18
|
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
|
+
const transaction_1 = require("../../repo/transaction");
|
|
20
21
|
const EventOfferService = require("../offer/event");
|
|
21
22
|
/**
|
|
22
23
|
* タスク実行関数
|
|
@@ -38,7 +39,8 @@ function call(data) {
|
|
|
38
39
|
stockHolder: stockHolderRepo,
|
|
39
40
|
offerRateLimit: offerRateLimitRepo,
|
|
40
41
|
reservation: reservationRepo,
|
|
41
|
-
task: taskRepo
|
|
42
|
+
task: taskRepo,
|
|
43
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
42
44
|
});
|
|
43
45
|
});
|
|
44
46
|
}
|
package/package.json
CHANGED