@chevre/domain 21.20.0-alpha.19 → 21.20.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.
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
- type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
27
+ type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
28
28
  interface IAggregationByStatus {
29
29
  transactionCount: number;
30
30
  avgDuration: number;
@@ -44,10 +44,11 @@ function voidAcceptedOffer(params) {
44
44
  reservationNumbers = [...new Set(reservationNumbers)];
45
45
  debug('removing acceptedOffers from PlaceOrder...', orderNumber, reservationNumbers);
46
46
  if (reservationNumbers.length > 0) {
47
- yield repos.orderInTransaction.voidAcceptedOfferByReservationNumber({
47
+ const result = yield repos.orderInTransaction.voidAcceptedOfferByReservationNumber({
48
48
  orderNumber,
49
49
  acceptedOffers: { reservationNumber: { $in: reservationNumbers } }
50
50
  });
51
+ debug('acceptedOffers removed from PlaceOrder.', result);
51
52
  }
52
53
  });
53
54
  }
@@ -75,12 +75,14 @@ function authorize(params) {
75
75
  })(repos);
76
76
  acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
77
77
  // add orderInTransaction(2024-01-15~)
78
- if (params.options.useCreateOrderOnOfferAccepted) {
79
- yield (0, any_1.acceptOffer)({
80
- project: transaction.project,
81
- purpose: { id: transaction.id },
82
- acceptedOffers: acceptedOffers4result
83
- })(repos);
78
+ if (!noOfferSpecified) {
79
+ if (params.options.useCreateOrderOnOfferAccepted) {
80
+ yield (0, any_1.acceptOffer)({
81
+ project: transaction.project,
82
+ purpose: { id: transaction.id },
83
+ acceptedOffers: acceptedOffers4result
84
+ })(repos);
85
+ }
84
86
  }
85
87
  break;
86
88
  default:
@@ -1,6 +1,7 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { MongoRepository as ActionRepo } from '../../../repo/action';
3
3
  import type { MongoRepository as AssetTransactionRepo } from '../../../repo/assetTransaction';
4
+ import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
4
5
  import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
5
6
  import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
6
7
  import type { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
@@ -12,6 +13,7 @@ interface IVoidTransactionRepos {
12
13
  assetTransaction: AssetTransactionRepo;
13
14
  stockHolder: StockHolderRepo;
14
15
  offerRateLimit: OfferRateLimitRepo;
16
+ orderInTransaction: OrderInTransactionRepo;
15
17
  reservation: ReservationRepo;
16
18
  task: TaskRepo;
17
19
  transaction: TransactionRepo;
@@ -15,6 +15,7 @@ const http_status_1 = require("http-status");
15
15
  const credentials_1 = require("../../../credentials");
16
16
  const factory = require("../../../factory");
17
17
  const ReserveTransactionService = require("../../assetTransaction/reserve");
18
+ const any_1 = require("../any");
18
19
  const coaAuthClient = new COA.auth.RefreshToken({
19
20
  endpoint: credentials_1.credentials.coa.endpoint,
20
21
  refreshToken: credentials_1.credentials.coa.refreshToken
@@ -30,7 +31,7 @@ function voidTransaction(params) {
30
31
  const transaction = yield repos.transaction.findById({
31
32
  typeOf: params.purpose.typeOf,
32
33
  id: params.purpose.id,
33
- inclusion: ['_id', 'typeOf', 'status']
34
+ inclusion: ['_id', 'typeOf', 'status', 'object.orderNumber']
34
35
  });
35
36
  // 興行オファー承認アクション検索
36
37
  let authorizeActions = yield repos.action.searchByPurpose({
@@ -41,9 +42,6 @@ function voidTransaction(params) {
41
42
  },
42
43
  object: { typeOf: { $eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation } }
43
44
  });
44
- // .then((actions) => actions
45
- // .filter((a) => a.object.typeOf === factory.action.authorize.offer.eventService.ObjectType.SeatReservation)
46
- // );
47
45
  switch (transaction.status) {
48
46
  case factory.transactionStatusType.InProgress:
49
47
  throw new factory.errors.NotImplemented(`${transaction.status} not implemented`);
@@ -59,6 +57,15 @@ function voidTransaction(params) {
59
57
  default:
60
58
  // no op
61
59
  }
60
+ // add orderInTransaction(2024-01-15~)
61
+ // USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
62
+ const orderNumberByTransaction = transaction.object.orderNumber;
63
+ if (typeof orderNumberByTransaction === 'string') {
64
+ yield (0, any_1.voidAcceptedOffer)({
65
+ authorizeActions,
66
+ orderNumber: orderNumberByTransaction
67
+ })(repos);
68
+ }
62
69
  yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
63
70
  yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
64
71
  switch (action.instrument.identifier) {
@@ -13,6 +13,7 @@ exports.call = void 0;
13
13
  const factory = require("../../factory");
14
14
  const action_1 = require("../../repo/action");
15
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const orderInTransaction_1 = require("../../repo/orderInTransaction");
16
17
  const offer_1 = require("../../repo/rateLimit/offer");
17
18
  const reservation_1 = require("../../repo/reservation");
18
19
  const stockHolder_1 = require("../../repo/stockHolder");
@@ -27,19 +28,14 @@ function call(data) {
27
28
  if (settings.redisClient === undefined) {
28
29
  throw new factory.errors.Argument('settings', 'redisClient required');
29
30
  }
30
- const actionRepo = new action_1.MongoRepository(settings.connection);
31
- const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
32
- const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
33
- const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
34
- const reservationRepo = new reservation_1.MongoRepository(settings.connection);
35
- const taskRepo = new task_1.MongoRepository(settings.connection);
36
31
  yield EventOfferService.voidTransaction(data)({
37
- action: actionRepo,
38
- assetTransaction: assetTransactionRepo,
39
- stockHolder: stockHolderRepo,
40
- offerRateLimit: offerRateLimitRepo,
41
- reservation: reservationRepo,
42
- task: taskRepo,
32
+ action: new action_1.MongoRepository(settings.connection),
33
+ assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
34
+ stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
35
+ offerRateLimit: new offer_1.RedisRepository(settings.redisClient),
36
+ orderInTransaction: new orderInTransaction_1.MongoRepository(settings.connection),
37
+ reservation: new reservation_1.MongoRepository(settings.connection),
38
+ task: new task_1.MongoRepository(settings.connection),
43
39
  transaction: new transaction_1.MongoRepository(settings.connection)
44
40
  });
45
41
  });
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "21.20.0-alpha.19"
118
+ "version": "21.20.0-alpha.20"
119
119
  }