@chevre/domain 21.2.0-alpha.31 → 21.2.0-alpha.32

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.
@@ -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.Pay>[]>await taskRepo.search({
12
+ const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.ConfirmPayTransaction>[]>await taskRepo.search({
13
13
  // limit: 100,
14
14
  // page: 1,
15
- name: chevre.factory.taskName.Pay,
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-04-27T00:00:00Z')
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].paymentMethod.paymentMethodId}"`)
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
  }
@@ -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
- const authorizeActions = yield repos.action.searchByPurpose({
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
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.31"
120
+ "version": "21.2.0-alpha.32"
121
121
  }