@chevre/domain 22.9.0-alpha.66 → 22.9.0-alpha.68

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,6 +9,7 @@ const PROJECT_ID = String(process.env.PROJECT_ID);
9
9
  const SCREEN_CODE = '130';
10
10
  const MOVIE_THEATER_CODE = '020';
11
11
  const AGGREGATE_PERIOD_IN_MONTHS = 6;
12
+ // tslint:disable-next-line:max-func-body-length
12
13
  async function main() {
13
14
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
15
 
@@ -42,14 +43,17 @@ async function main() {
42
43
  const orderDateLte: Date = moment()
43
44
  .toDate();
44
45
 
46
+ let maxSumGraceTime: number = 0;
45
47
  const seatsWithAggregateOrder: {
46
48
  branchCode: string;
47
49
  aggregateOrder: {
48
50
  orderCount: number;
49
51
  avgGraceTime?: number;
52
+ sumGraceTime: number;
50
53
  avgGraceTimeInHours?: number;
51
- sumGraceTimeInHours?: number;
54
+ sumGraceTimeInHours: number;
52
55
  };
56
+ score?: number;
53
57
  }[] = [];
54
58
  let i = 1;
55
59
  for (const { branchCode } of seats) {
@@ -72,6 +76,9 @@ async function main() {
72
76
  const diff = process.hrtime(startTime);
73
77
  console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
74
78
 
79
+ const sumGraceTime = (typeof aggregateResult.aggregation.sumGraceTime === 'number')
80
+ ? aggregateResult.aggregation.sumGraceTime
81
+ : 0;
75
82
  const avgGraceTimeInHours = (typeof aggregateResult.aggregation.sumGraceTime === 'number')
76
83
  ? Math.floor(
77
84
  moment.duration(Math.floor(aggregateResult.aggregation.sumGraceTime / aggregateResult.aggregation.orderCount), 'milliseconds')
@@ -82,18 +89,32 @@ async function main() {
82
89
  ? Math.floor(moment.duration(aggregateResult.aggregation.sumGraceTime, 'milliseconds')
83
90
  .asHours())
84
91
  : 0;
92
+ maxSumGraceTime = Math.max(sumGraceTime, maxSumGraceTime);
93
+
85
94
  seatsWithAggregateOrder.push({
86
95
  branchCode,
87
96
  aggregateOrder: {
88
97
  ...aggregateResult.aggregation,
89
98
  avgGraceTimeInHours,
90
- sumGraceTimeInHours
99
+ sumGraceTimeInHours,
100
+ sumGraceTime
91
101
  }
92
102
  });
93
103
  }
94
104
 
105
+ const seatsJson = seatsWithAggregateOrder.map((seat, key) => {
106
+ // tslint:disable-next-line:no-magic-numbers
107
+ const score = Math.floor(seat.aggregateOrder.sumGraceTime * 100 / maxSumGraceTime);
108
+ console.log('aggregateOrder:result', seat.branchCode, score, key);
109
+
110
+ return {
111
+ branchCode: seat.branchCode,
112
+ score
113
+ };
114
+ });
115
+
95
116
  // tslint:disable-next-line:non-literal-fs-path no-null-keyword
96
- fs.writeFileSync(`${__dirname}/seatsWithAggregateOrder.json`, JSON.stringify(seatsWithAggregateOrder, null, ' '));
117
+ fs.writeFileSync(`${__dirname}/seatsWithAggregateOrder.json`, JSON.stringify(seatsJson, null, ' '));
97
118
  }
98
119
 
99
120
  main()
@@ -14,22 +14,21 @@ async function main() {
14
14
  setInterval(
15
15
  async () => {
16
16
  const startTime = process.hrtime();
17
- const transaction = await transactionRepo.findExportableTransaction({
17
+ const result = await transactionRepo.reExportAction({
18
18
  // status: { $eq: params.status },
19
19
  // id: params.id,
20
- endDate: {
20
+ startDate: {
21
21
  $lt: moment()
22
22
  // tslint:disable-next-line:no-magic-numbers
23
23
  .add(-60, 'seconds')
24
24
  .toDate()
25
- },
26
- sort: { endDate: chevre.factory.sortType.Ascending }
25
+ }
27
26
  });
28
27
  const diff = process.hrtime(startTime);
29
28
  console.log(`took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
30
29
 
31
30
  // tslint:disable-next-line:no-null-keyword
32
- console.dir(transaction?.id, { depth: null });
31
+ console.dir(result, { depth: null });
33
32
  },
34
33
  // tslint:disable-next-line:no-magic-numbers
35
34
  1000
@@ -11,8 +11,8 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- await chevre.repository.Identity.createInstance(mongoose.connection);
15
- await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
14
+ await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
15
+ await chevre.repository.Transaction.createInstance(mongoose.connection);
16
16
  console.log('success!');
17
17
  }
18
18
 
@@ -90,19 +90,26 @@ export declare class AssetTransactionRepo {
90
90
  };
91
91
  };
92
92
  }): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
93
- reexportTasksByExportAction(params: {
94
- intervalInMinutes: number;
95
- limit: number;
96
- }): Promise<void>;
93
+ /**
94
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
95
+ * PotentialActionStatusに変更する
96
+ * 2025-03-10~
97
+ */
98
+ reExportAction(params: {
99
+ startDate: {
100
+ $lt: Date;
101
+ };
102
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
97
103
  /**
98
104
  * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
99
105
  */
100
- exportTasks(params: {
106
+ exportTasksMany(params: {
101
107
  now: Date;
102
108
  delayInSeconds: number;
103
109
  status: {
104
110
  $in: factory.transactionStatusType[];
105
111
  };
112
+ limit: number;
106
113
  }): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction, "id" | "typeOf" | "status">[]>;
107
114
  /**
108
115
  * set task status exported by transaction id
@@ -487,56 +487,94 @@ class AssetTransactionRepo {
487
487
  .then((doc) => (doc === null) ? null : doc.toObject());
488
488
  });
489
489
  }
490
- reexportTasksByExportAction(params) {
490
+ // discontinue(2025-03-10~)
491
+ // public async reexportTasksByExportAction(params: {
492
+ // intervalInMinutes: number;
493
+ // limit: number;
494
+ // }): Promise<void> {
495
+ // const reexportingTransactions: Pick<
496
+ // factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'status' | 'typeOf'
497
+ // >[] = await this.transactionModel.find(
498
+ // {
499
+ // 'tasksExportAction.actionStatus': {
500
+ // $exists: true,
501
+ // $eq: factory.actionStatusType.ActiveActionStatus
502
+ // },
503
+ // 'tasksExportAction.startDate': {
504
+ // $exists: true,
505
+ // $lt: moment()
506
+ // .add(-params.intervalInMinutes, 'minutes')
507
+ // .toDate()
508
+ // }
509
+ // },
510
+ // { _id: 1, typeOf: 1, status: 1 }
511
+ // )
512
+ // .limit(params.limit)
513
+ // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
514
+ // .exec();
515
+ // if (reexportingTransactions.length > 0) {
516
+ // for (const reexportingTransaction of reexportingTransactions) {
517
+ // await this.transactionModel.updateOne(
518
+ // {
519
+ // _id: { $eq: reexportingTransaction.id },
520
+ // 'tasksExportAction.actionStatus': {
521
+ // $exists: true,
522
+ // $eq: factory.actionStatusType.ActiveActionStatus
523
+ // }
524
+ // },
525
+ // {
526
+ // tasksExportAction: {
527
+ // actionStatus: factory.actionStatusType.PotentialActionStatus
528
+ // }
529
+ // // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
530
+ // }
531
+ // )
532
+ // .exec();
533
+ // assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
534
+ // id: reexportingTransaction.id,
535
+ // typeOf: reexportingTransaction.typeOf,
536
+ // status: reexportingTransaction.status
537
+ // });
538
+ // }
539
+ // }
540
+ // }
541
+ /**
542
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
543
+ * PotentialActionStatusに変更する
544
+ * 2025-03-10~
545
+ */
546
+ reExportAction(params) {
491
547
  return __awaiter(this, void 0, void 0, function* () {
492
- const reexportingTransactions = yield this.transactionModel.find({
548
+ const { startDate } = params;
549
+ if (!(startDate.$lt instanceof Date)) {
550
+ throw new factory.errors.Argument('startDate.$lt', 'must be Date');
551
+ }
552
+ return this.transactionModel.updateMany({
493
553
  'tasksExportAction.actionStatus': {
494
554
  $exists: true,
495
555
  $eq: factory.actionStatusType.ActiveActionStatus
496
556
  },
497
557
  'tasksExportAction.startDate': {
498
558
  $exists: true,
499
- $lt: moment()
500
- .add(-params.intervalInMinutes, 'minutes')
501
- .toDate()
559
+ $lt: startDate.$lt
502
560
  }
503
- }, { _id: 1, typeOf: 1, status: 1 })
504
- .limit(params.limit)
505
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
506
- .exec();
507
- if (reexportingTransactions.length > 0) {
508
- for (const reexportingTransaction of reexportingTransactions) {
509
- yield this.transactionModel.updateOne({
510
- _id: { $eq: reexportingTransaction.id },
511
- 'tasksExportAction.actionStatus': {
512
- $exists: true,
513
- $eq: factory.actionStatusType.ActiveActionStatus
514
- }
515
- }, {
516
- tasksExportAction: {
517
- actionStatus: factory.actionStatusType.PotentialActionStatus
518
- }
519
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
520
- })
521
- .exec();
522
- assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
523
- id: reexportingTransaction.id,
524
- typeOf: reexportingTransaction.typeOf,
525
- status: reexportingTransaction.status
526
- });
561
+ }, {
562
+ $set: {
563
+ tasksExportAction: {
564
+ actionStatus: factory.actionStatusType.PotentialActionStatus
565
+ }
527
566
  }
528
- }
567
+ })
568
+ .exec();
529
569
  });
530
570
  }
531
571
  /**
532
572
  * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
533
573
  */
534
- exportTasks(params) {
574
+ exportTasksMany(params) {
535
575
  return __awaiter(this, void 0, void 0, function* () {
536
576
  const delayedTransactions = yield this.transactionModel.find({
537
577
  status: { $in: params.status.$in },
538
- // remove dependency on tasksExportationStatus(2024-06-13~)
539
- // tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
540
578
  'tasksExportAction.actionStatus': {
541
579
  $exists: true,
542
580
  $eq: factory.actionStatusType.PotentialActionStatus
@@ -549,11 +587,14 @@ class AssetTransactionRepo {
549
587
  }
550
588
  })
551
589
  .select({
552
- _id: 1,
590
+ _id: 0,
591
+ id: { $toString: '$_id' },
553
592
  typeOf: 1,
554
593
  status: 1
555
594
  })
595
+ .limit(params.limit)
556
596
  .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
597
+ .lean()
557
598
  .exec();
558
599
  if (delayedTransactions.length > 0) {
559
600
  delayedTransactions.forEach((delayedTransaction) => {
@@ -256,6 +256,25 @@ const indexes = [
256
256
  { status: 1, expires: 1 },
257
257
  { name: 'makeExpired' }
258
258
  ],
259
+ [
260
+ { status: 1, 'tasksExportAction.actionStatus': 1, endDate: 1 },
261
+ {
262
+ name: 'exportTasksIfExists',
263
+ partialFilterExpression: {
264
+ 'tasksExportAction.actionStatus': { $exists: true },
265
+ endDate: { $exists: true }
266
+ }
267
+ }
268
+ ],
269
+ [
270
+ { 'tasksExportAction.actionStatus': 1, 'tasksExportAction.startDate': 1 },
271
+ {
272
+ name: 'reExportTasks',
273
+ partialFilterExpression: {
274
+ 'tasksExportAction.startDate': { $exists: true }
275
+ }
276
+ }
277
+ ],
259
278
  [
260
279
  { 'tasksExportAction.actionStatus': 1, startDate: -1 },
261
280
  {
@@ -203,6 +203,15 @@ const indexes = [
203
203
  }
204
204
  }
205
205
  ],
206
+ [
207
+ { 'tasksExportAction.actionStatus': 1, 'tasksExportAction.startDate': 1 },
208
+ {
209
+ name: 'reExportTasks',
210
+ partialFilterExpression: {
211
+ 'tasksExportAction.startDate': { $exists: true }
212
+ }
213
+ }
214
+ ],
206
215
  [
207
216
  { 'tasksExportAction.actionStatus': 1, startDate: -1 },
208
217
  {
@@ -140,19 +140,26 @@ export declare class TransactionRepo {
140
140
  startDate?: factory.sortType;
141
141
  };
142
142
  }): Promise<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'> | null>;
143
- reexportTasksByExportAction(params: {
144
- intervalInMinutes: number;
145
- limit: number;
146
- }): Promise<void>;
143
+ /**
144
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
145
+ * PotentialActionStatusに変更する
146
+ * 2025-03-10~
147
+ */
148
+ reExportAction(params: {
149
+ startDate: {
150
+ $lt: Date;
151
+ };
152
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
147
153
  /**
148
154
  * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
149
155
  */
150
- exportTasks(params: {
156
+ exportTasksMany(params: {
151
157
  now: Date;
152
158
  delayInSeconds: number;
153
159
  status: {
154
160
  $in: factory.transactionStatusType[];
155
161
  };
162
+ limit: number;
156
163
  }): Promise<Pick<import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
157
164
  /**
158
165
  * set task status exported by transaction id
@@ -649,56 +649,93 @@ class TransactionRepo {
649
649
  .then((doc) => (doc === null) ? null : doc);
650
650
  });
651
651
  }
652
- reexportTasksByExportAction(params) {
652
+ // discontinue(2025-03-10~)
653
+ // public async reexportTasksByExportAction(params: {
654
+ // intervalInMinutes: number;
655
+ // limit: number;
656
+ // }): Promise<void> {
657
+ // const reexportingTransactions: Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'status' | 'typeOf'>[] =
658
+ // await this.transactionModel.find(
659
+ // {
660
+ // 'tasksExportAction.actionStatus': {
661
+ // $exists: true,
662
+ // $eq: factory.actionStatusType.ActiveActionStatus
663
+ // },
664
+ // 'tasksExportAction.startDate': {
665
+ // $exists: true,
666
+ // $lt: moment()
667
+ // .add(-params.intervalInMinutes, 'minutes')
668
+ // .toDate()
669
+ // }
670
+ // },
671
+ // { _id: 1, typeOf: 1, status: 1 }
672
+ // )
673
+ // .limit(params.limit)
674
+ // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
675
+ // .exec();
676
+ // if (reexportingTransactions.length > 0) {
677
+ // for (const reexportingTransaction of reexportingTransactions) {
678
+ // await this.transactionModel.updateOne(
679
+ // {
680
+ // _id: { $eq: reexportingTransaction.id },
681
+ // 'tasksExportAction.actionStatus': {
682
+ // $exists: true,
683
+ // $eq: factory.actionStatusType.ActiveActionStatus
684
+ // }
685
+ // },
686
+ // {
687
+ // tasksExportAction: {
688
+ // actionStatus: factory.actionStatusType.PotentialActionStatus
689
+ // }
690
+ // // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
691
+ // }
692
+ // )
693
+ // .exec();
694
+ // transactionEventEmitter.emitTransactionStatusChanged({
695
+ // id: reexportingTransaction.id,
696
+ // typeOf: reexportingTransaction.typeOf,
697
+ // status: reexportingTransaction.status
698
+ // });
699
+ // }
700
+ // }
701
+ // }
702
+ /**
703
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
704
+ * PotentialActionStatusに変更する
705
+ * 2025-03-10~
706
+ */
707
+ reExportAction(params) {
653
708
  return __awaiter(this, void 0, void 0, function* () {
654
- const reexportingTransactions = yield this.transactionModel.find({
709
+ const { startDate } = params;
710
+ if (!(startDate.$lt instanceof Date)) {
711
+ throw new factory.errors.Argument('startDate.$lt', 'must be Date');
712
+ }
713
+ return this.transactionModel.updateMany({
655
714
  'tasksExportAction.actionStatus': {
656
715
  $exists: true,
657
716
  $eq: factory.actionStatusType.ActiveActionStatus
658
717
  },
659
718
  'tasksExportAction.startDate': {
660
719
  $exists: true,
661
- $lt: moment()
662
- .add(-params.intervalInMinutes, 'minutes')
663
- .toDate()
720
+ $lt: startDate.$lt
664
721
  }
665
- }, { _id: 1, typeOf: 1, status: 1 })
666
- .limit(params.limit)
667
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
668
- .exec();
669
- if (reexportingTransactions.length > 0) {
670
- for (const reexportingTransaction of reexportingTransactions) {
671
- yield this.transactionModel.updateOne({
672
- _id: { $eq: reexportingTransaction.id },
673
- 'tasksExportAction.actionStatus': {
674
- $exists: true,
675
- $eq: factory.actionStatusType.ActiveActionStatus
676
- }
677
- }, {
678
- tasksExportAction: {
679
- actionStatus: factory.actionStatusType.PotentialActionStatus
680
- }
681
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
682
- })
683
- .exec();
684
- transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
685
- id: reexportingTransaction.id,
686
- typeOf: reexportingTransaction.typeOf,
687
- status: reexportingTransaction.status
688
- });
722
+ }, {
723
+ $set: {
724
+ tasksExportAction: {
725
+ actionStatus: factory.actionStatusType.PotentialActionStatus
726
+ }
689
727
  }
690
- }
728
+ })
729
+ .exec();
691
730
  });
692
731
  }
693
732
  /**
694
733
  * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
695
734
  */
696
- exportTasks(params) {
735
+ exportTasksMany(params) {
697
736
  return __awaiter(this, void 0, void 0, function* () {
698
737
  const delayedTransactions = yield this.transactionModel.find({
699
738
  status: { $in: params.status.$in },
700
- // remove dependency on tasksExportationStatus(2024-06-17~)
701
- // tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
702
739
  'tasksExportAction.actionStatus': {
703
740
  $exists: true,
704
741
  $eq: factory.actionStatusType.PotentialActionStatus
@@ -711,12 +748,12 @@ class TransactionRepo {
711
748
  }
712
749
  })
713
750
  .select({
714
- // _id: 1,
715
751
  _id: 0,
716
752
  id: { $toString: '$_id' },
717
753
  typeOf: 1,
718
754
  status: 1
719
755
  })
756
+ .limit(params.limit)
720
757
  .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
721
758
  .lean()
722
759
  .exec();
@@ -30,6 +30,9 @@ interface IVoidTransactionRepos {
30
30
  * 取引中の承認アクション全てについて処理する or 特定の承認アクションについて処理する
31
31
  */
32
32
  declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidReserveTransaction> & {
33
+ project: {
34
+ id: string;
35
+ };
33
36
  sameAs?: {
34
37
  /**
35
38
  * 実行元タスクID
@@ -30,6 +30,9 @@ interface IVoidTransactionByActionIdRepos {
30
30
  * 特定の承認アクションについて処理する
31
31
  */
32
32
  declare function voidTransactionByActionId(params: factory.task.IData<factory.taskName.VoidReserveTransaction> & {
33
+ project: {
34
+ id: string;
35
+ };
33
36
  sameAs?: {
34
37
  /**
35
38
  * 実行元タスクID
@@ -1,11 +1,15 @@
1
1
  import type * as COA from '@motionpicture/coa-service';
2
2
  import type { ActionRepo } from '../../../repo/action';
3
3
  import type { EventRepo } from '../../../repo/event';
4
+ import type { OrderNumberRepo } from '../../../repo/orderNumber';
5
+ import type { ProjectRepo } from '../../../repo/project';
4
6
  import type { TransactionRepo } from '../../../repo/transaction';
5
7
  import * as factory from '../../../factory';
6
8
  interface IAcceptRepos {
7
9
  action: ActionRepo;
8
10
  event: EventRepo;
11
+ orderNumber: OrderNumberRepo;
12
+ project: ProjectRepo;
9
13
  transaction: TransactionRepo;
10
14
  reserveService: COA.service.Reserve;
11
15
  masterService: COA.service.Master;
@@ -13,6 +13,7 @@ exports.acceptOffer = acceptOffer;
13
13
  exports.reAcceptOffer = reAcceptOffer;
14
14
  const errorHandler_1 = require("../../../errorHandler");
15
15
  const factory = require("../../../factory");
16
+ const publishOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/publishOrderNumberIfNotExist");
16
17
  const authorize_1 = require("./acceptOffer/authorize");
17
18
  const factory_1 = require("./acceptOffer/factory");
18
19
  function findCOAInfo(params) {
@@ -47,6 +48,12 @@ function acceptOffer(params) {
47
48
  typeOf: factory.transactionType.PlaceOrder,
48
49
  id: params.purpose.id
49
50
  }, ['project', 'agent', 'typeOf']);
51
+ // publishOrderNumber(2025-03-11~)
52
+ yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
53
+ project: { id: transaction.project.id },
54
+ id: transaction.id,
55
+ object: { orderDate: new Date() }
56
+ })(repos);
50
57
  const coaInfo = yield findCOAInfo({ id: params.object.event.id, project: { id: transaction.project.id } })(repos);
51
58
  const updTmpReserveSeatArgs = (0, factory_1.createUpdTmpReserveSeatArgs)({ object: params.object, coaInfo });
52
59
  let updTmpReserveSeatResult;
@@ -128,6 +135,11 @@ function reAcceptOffer(params) {
128
135
  typeOf: factory.transactionType.PlaceOrder,
129
136
  id: params.purpose.id
130
137
  }, ['project', 'agent', 'typeOf']);
138
+ const orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: transaction.id });
139
+ if (typeof orderNumber !== 'string') {
140
+ // 事前に発行されているはず
141
+ throw new factory.errors.NotFound('transaction.object.orderNumber');
142
+ }
131
143
  const coaInfo = yield findCOAInfo({ id: params.object.event.id, project: { id: transaction.project.id } })(repos);
132
144
  // 承認アクション存在検証
133
145
  yield repos.action.findById({ id: params.potentialActions.id, typeOf: factory.actionType.AuthorizeAction }, ['id'], []);
@@ -3,8 +3,6 @@ import type { CategoryCodeRepo } from '../../../repo/categoryCode';
3
3
  import type { EventRepo } from '../../../repo/event';
4
4
  import type { OfferRepo } from '../../../repo/offer';
5
5
  import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
6
- import type { OrderNumberRepo } from '../../../repo/orderNumber';
7
- import type { ProjectRepo } from '../../../repo/project';
8
6
  import type { TransactionRepo } from '../../../repo/transaction';
9
7
  import { IRequestBody, IResponseBody } from './authorize/factory';
10
8
  import { IAcceptedOfferBeforeAuthorize4COA } from './authorize/validateAcceptedOffers';
@@ -17,8 +15,6 @@ export interface IAuthorizeRepos {
17
15
  event: EventRepo;
18
16
  offer: OfferRepo;
19
17
  orderInTransaction: OrderInTransactionRepo;
20
- orderNumber: OrderNumberRepo;
21
- project: ProjectRepo;
22
18
  transaction: TransactionRepo;
23
19
  }
24
20
  export type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.authorize = authorize;
13
13
  const moment = require("moment");
14
- const publishOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/publishOrderNumberIfNotExist");
14
+ // import { publishOrderNumberIfNotExist } from '../../transaction/placeOrder/publishOrderNumberIfNotExist';
15
15
  const any_1 = require("../any");
16
16
  const factory_1 = require("./authorize/factory");
17
17
  const validateAcceptedOffers_1 = require("./authorize/validateAcceptedOffers");
@@ -89,12 +89,17 @@ function authorize(params) {
89
89
  yield repos.action.giveUp({ typeOf: failedAction.typeOf, id: failedAction.id, error });
90
90
  throw error;
91
91
  }
92
- const now = new Date();
93
- const orderNumber = yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
94
- project: { id: transaction.project.id },
95
- id: transaction.id,
96
- object: { orderDate: now }
97
- })(repos);
92
+ // const now = new Date();
93
+ // const orderNumber = await publishOrderNumberIfNotExist({
94
+ // project: { id: transaction.project.id },
95
+ // id: transaction.id,
96
+ // object: { orderDate: now }
97
+ // })(repos);
98
+ const orderNumber = yield repos.transaction.findInProgressOrderNumberById({ id: params.transaction.id });
99
+ if (typeof orderNumber !== 'string') {
100
+ // 事前に発行されているはず
101
+ throw new factory.errors.NotFound('transaction.object.orderNumber');
102
+ }
98
103
  let result;
99
104
  // 承認アクションを開始
100
105
  const actionAttributes = (0, factory_1.createAuthorizeSeatReservationActionAttributes)({
@@ -8,7 +8,6 @@ declare function fixOrderAsNeeded(params: {
8
8
  id: string;
9
9
  };
10
10
  purpose: factory.action.authorize.paymentMethod.any.IPurpose;
11
- paymentServiceType: factory.service.paymentService.PaymentServiceType;
12
11
  }): (repos: {
13
12
  project: ProjectRepo;
14
13
  transaction: TransactionRepo;
@@ -27,6 +27,9 @@ import { person2username } from './any/person2username';
27
27
  * タスクから決済承認を取り消す
28
28
  */
29
29
  declare function voidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
30
+ project: {
31
+ id: string;
32
+ };
30
33
  sameAs?: {
31
34
  id: string;
32
35
  };
@@ -59,6 +62,9 @@ declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskNam
59
62
  * apiもしくはタスクから決済承認を取り消す
60
63
  */
61
64
  declare function processVoidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
65
+ project: {
66
+ id: string;
67
+ };
62
68
  sameAs?: {
63
69
  /**
64
70
  * 実行元タスクID
@@ -98,9 +104,11 @@ interface IPublishPaymentUrlRepos {
98
104
  action: ActionRepo;
99
105
  assetTransaction: AssetTransactionRepo;
100
106
  authorization: AuthorizationRepo;
107
+ orderNumber: OrderNumberRepo;
101
108
  paymentAccepted: SellerPaymentAcceptedRepo;
102
109
  paymentService: PaymentServiceRepo;
103
110
  paymentServiceProvider: PaymentServiceProviderRepo;
111
+ project: ProjectRepo;
104
112
  ticket: TicketRepo;
105
113
  transaction: TransactionRepo;
106
114
  transactionNumber: TransactionNumberRepo;
@@ -21,6 +21,7 @@ exports.publishPaymentUrl = publishPaymentUrl;
21
21
  const util = require("util");
22
22
  const factory = require("../../factory");
23
23
  const PayTransactionService = require("../assetTransaction/pay");
24
+ const publishOrderNumberIfNotExist_1 = require("../transaction/placeOrder/publishOrderNumberIfNotExist");
24
25
  const factory_1 = require("./any/factory");
25
26
  const fixOrderAsNeeded_1 = require("./any/fixOrderAsNeeded");
26
27
  const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./any/handlePrePublishedPaymentMethodIdOnAuthorizing");
@@ -326,6 +327,12 @@ function publishPaymentUrl(params) {
326
327
  }
327
328
  try {
328
329
  const transaction = yield repos.transaction.projectFieldsInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['expires', 'seller', 'project']);
330
+ // publishOrderNumber(2025-03-11~)
331
+ yield (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
332
+ project: { id: transaction.project.id },
333
+ id: transaction.id,
334
+ object: { orderDate: new Date() }
335
+ })(repos);
329
336
  // 取引番号生成
330
337
  let transactionNumber;
331
338
  // support ticketToken(2024-08-21~)
@@ -405,8 +412,8 @@ function authorize(params) {
405
412
  const transaction = yield repos.transaction.projectFieldsInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
406
413
  const { confirmationNumber, orderNumber } = yield (0, fixOrderAsNeeded_1.fixOrderAsNeeded)({
407
414
  project: { id: transaction.project.id },
408
- purpose,
409
- paymentServiceType
415
+ purpose
416
+ // paymentServiceType
410
417
  })(repos);
411
418
  // 取引番号生成
412
419
  let transactionNumber;
@@ -15,6 +15,8 @@ const factory = require("../../factory");
15
15
  const action_1 = require("../../repo/action");
16
16
  const credentials_1 = require("../../repo/credentials");
17
17
  const event_1 = require("../../repo/event");
18
+ const orderNumber_1 = require("../../repo/orderNumber");
19
+ const project_1 = require("../../repo/project");
18
20
  const reserveInterface_1 = require("../../repo/reserveInterface");
19
21
  const transaction_1 = require("../../repo/transaction");
20
22
  const transactionProcess_1 = require("../../repo/transactionProcess");
@@ -84,6 +86,8 @@ function call(params) {
84
86
  })({
85
87
  action: actionRepo,
86
88
  event: new event_1.EventRepo(connection),
89
+ orderNumber: new orderNumber_1.OrderNumberRepo(redisClient),
90
+ project: new project_1.ProjectRepo(connection),
87
91
  transaction: new transaction_1.TransactionRepo(connection),
88
92
  reserveService,
89
93
  masterService
@@ -100,6 +104,8 @@ function call(params) {
100
104
  })({
101
105
  action: actionRepo,
102
106
  event: new event_1.EventRepo(connection),
107
+ orderNumber: new orderNumber_1.OrderNumberRepo(redisClient),
108
+ project: new project_1.ProjectRepo(connection),
103
109
  transaction: new transaction_1.TransactionRepo(connection),
104
110
  reserveService,
105
111
  masterService
@@ -14,8 +14,10 @@ const factory = require("../../factory");
14
14
  const action_1 = require("../../repo/action");
15
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
16
  const authorization_1 = require("../../repo/authorization");
17
+ const orderNumber_1 = require("../../repo/orderNumber");
17
18
  const paymentService_1 = require("../../repo/paymentService");
18
19
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
20
+ const project_1 = require("../../repo/project");
19
21
  const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
20
22
  const ticket_1 = require("../../repo/ticket");
21
23
  const transaction_1 = require("../../repo/transaction");
@@ -41,9 +43,11 @@ function call(params) {
41
43
  action: actionRepo,
42
44
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
43
45
  authorization: new authorization_1.AuthorizationRepo(connection),
46
+ orderNumber: new orderNumber_1.OrderNumberRepo(redisClient),
44
47
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
45
48
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
46
49
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
50
+ project: new project_1.ProjectRepo(connection),
47
51
  ticket: new ticket_1.TicketRepo(connection),
48
52
  transaction: new transaction_1.TransactionRepo(connection),
49
53
  transactionNumber: new transactionNumber_1.TransactionNumberRepo(redisClient)
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = call;
13
+ const factory = require("../../factory");
13
14
  const accountingReport_1 = require("../../repo/accountingReport");
14
15
  const action_1 = require("../../repo/action");
15
16
  const assetTransaction_1 = require("../../repo/assetTransaction");
@@ -24,7 +25,7 @@ const any_1 = require("../payment/any");
24
25
  */
25
26
  function call(params) {
26
27
  return (_a) => __awaiter(this, [_a], void 0, function* ({ connection }) {
27
- yield (0, any_1.voidPayTransaction)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
28
+ yield (0, any_1.voidPayTransaction)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id, typeOf: factory.organizationType.Project }, sameAs: { id: params.id } }))({
28
29
  accountingReport: new accountingReport_1.AccountingReportRepo(connection),
29
30
  action: new action_1.ActionRepo(connection),
30
31
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
@@ -61,7 +61,7 @@ function call(params) {
61
61
  }, { timeout: settings.coa.timeout });
62
62
  const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
63
63
  try {
64
- yield (0, voidTransaction_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
64
+ yield (0, voidTransaction_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id, typeOf: factory.organizationType.Project }, sameAs: { id: params.id } }))({
65
65
  action: new action_1.ActionRepo(connection),
66
66
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
67
67
  stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
14
  "@chevre/factory": "4.393.0-alpha.36",
15
- "@cinerino/sdk": "10.21.0-alpha.23",
15
+ "@cinerino/sdk": "10.21.0-alpha.24",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.0",
@@ -112,5 +112,5 @@
112
112
  "postversion": "git push origin --tags",
113
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
114
114
  },
115
- "version": "22.9.0-alpha.66"
115
+ "version": "22.9.0-alpha.68"
116
116
  }