@chevre/domain 21.8.0-alpha.3 → 21.8.0-alpha.30

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.
Files changed (80) hide show
  1. package/example/src/chevre/db/stats.ts +22 -0
  2. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  3. package/example/src/chevre/migrateAggregateOffers.ts +58 -0
  4. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  5. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  7. package/example/src/chevre/processPay.ts +3 -4
  8. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  9. package/example/src/chevre/searchTasks.ts +9 -9
  10. package/example/src/chevre/syncAggregateOffer.ts +25 -0
  11. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  12. package/lib/chevre/repo/assetTransaction.js +54 -2
  13. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +71 -0
  14. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +42 -0
  15. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  16. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  17. package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
  18. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  19. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  20. package/lib/chevre/repo/offer.d.ts +38 -8
  21. package/lib/chevre/repo/offer.js +208 -25
  22. package/lib/chevre/repo/order.d.ts +15 -0
  23. package/lib/chevre/repo/order.js +34 -1
  24. package/lib/chevre/repo/task.d.ts +7 -1
  25. package/lib/chevre/repo/task.js +111 -22
  26. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  27. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  28. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  29. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  30. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  31. package/lib/chevre/service/assetTransaction/reserve.js +105 -31
  32. package/lib/chevre/service/delivery.js +17 -0
  33. package/lib/chevre/service/offer/event/authorize.js +3 -0
  34. package/lib/chevre/service/offer/event/factory.js +8 -8
  35. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  36. package/lib/chevre/service/offer/event/voidTransaction.js +7 -2
  37. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  38. package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
  39. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  40. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  41. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  42. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  43. package/lib/chevre/service/order/onOrderStatusChanged.js +104 -81
  44. package/lib/chevre/service/order/payOrder.d.ts +2 -10
  45. package/lib/chevre/service/order/payOrder.js +4 -45
  46. package/lib/chevre/service/order/placeOrder.js +11 -13
  47. package/lib/chevre/service/order.d.ts +3 -1
  48. package/lib/chevre/service/order.js +6 -2
  49. package/lib/chevre/service/payment/any/factory.js +33 -8
  50. package/lib/chevre/service/payment/any.js +30 -21
  51. package/lib/chevre/service/payment/creditCard.js +12 -12
  52. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  53. package/lib/chevre/service/payment/movieTicket.js +10 -11
  54. package/lib/chevre/service/payment/paymentCard.js +9 -12
  55. package/lib/chevre/service/project.js +1 -1
  56. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  57. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -4
  58. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -5
  59. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  60. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -4
  61. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  62. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  63. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  64. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  65. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
  66. package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
  67. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  68. package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
  69. package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
  70. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  71. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  72. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  73. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  74. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  75. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  76. package/lib/chevre/settings.d.ts +2 -2
  77. package/lib/chevre/settings.js +3 -5
  78. package/package.json +3 -3
  79. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  80. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
@@ -0,0 +1,22 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ const KILO_BYTES = 1024;
5
+ async function main() {
6
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
7
+
8
+ const stats = await mongoose.connection.db.collection('tasks')
9
+ .stats({
10
+ scale: KILO_BYTES * KILO_BYTES
11
+ });
12
+ console.log('scaleFactor:', stats.scaleFactor);
13
+ console.log('avgObjSize:', stats.avgObjSize);
14
+ console.log('count:', stats.count);
15
+ console.log('size:', stats.size);
16
+ }
17
+
18
+ main()
19
+ .then(() => {
20
+ console.log('success!');
21
+ })
22
+ .catch(console.error);
@@ -16,6 +16,7 @@ async function main() {
16
16
 
17
17
  const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
18
18
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
19
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
19
20
  const masterService = new chevre.COA.service.Master(
20
21
  {
21
22
  endpoint: chevre.credentials.coa.endpoint,
@@ -27,7 +28,12 @@ async function main() {
27
28
  await chevre.service.offer.event.importFromCOA({
28
29
  project,
29
30
  theaterCode: '120'
30
- })({ categoryCode: categoryCodeRepo, offer: offerRepo, masterService });
31
+ })({
32
+ categoryCode: categoryCodeRepo,
33
+ offer: offerRepo,
34
+ task: taskRepo,
35
+ masterService
36
+ });
31
37
  console.log('imported');
32
38
  }
33
39
 
@@ -0,0 +1,58 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
13
+
14
+ const cursor = offerRepo.getCursor(
15
+ {
16
+ 'project.id': { $eq: project.id }
17
+ },
18
+ {
19
+ _id: 1,
20
+ identifier: 1,
21
+ project: 1
22
+ }
23
+ );
24
+ console.log('offers found');
25
+
26
+ let i = 0;
27
+ let updateCount = 0;
28
+ await cursor.eachAsync(async (doc) => {
29
+ i += 1;
30
+ const unitPriceOffer: Pick<
31
+ chevre.factory.unitPriceOffer.IUnitPriceOffer,
32
+ 'id' | 'identifier' | 'project'
33
+ > = doc.toObject();
34
+
35
+ const alreadyMigrated = false;
36
+ if (alreadyMigrated) {
37
+ console.log('already exist.', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
38
+ } else {
39
+ console.log('updating...', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
40
+ // await offerRepo.saveSyncTask({
41
+ // project: { id: unitPriceOffer.project.id },
42
+ // id: { $in: [String(unitPriceOffer.id)] },
43
+ // identifier: { $in: [] },
44
+ // isDeleted: false,
45
+ // typeOf: chevre.factory.offerType.Offer
46
+ // });
47
+ updateCount += 1;
48
+ console.log('updated.', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
49
+ }
50
+ });
51
+
52
+ console.log(i, 'offers checked');
53
+ console.log(updateCount, 'offers updated');
54
+ }
55
+
56
+ main()
57
+ .then()
58
+ .catch(console.error);
@@ -0,0 +1,81 @@
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
+ // const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const orderRepo = new chevre.repository.Order(mongoose.connection);
14
+
15
+ const cursor = orderRepo.getCursor(
16
+ {
17
+ // 'project.id': { $eq: project.id },
18
+ // orderNumber: { $eq: 'KNR1-3961294-9087043' },
19
+ orderDate: {
20
+ $gte: moment()
21
+ // tslint:disable-next-line:no-magic-numbers
22
+ .add(-12, 'months')
23
+ .toDate()
24
+ // $lte: moment()
25
+ // // tslint:disable-next-line:no-magic-numbers
26
+ // .add(-6, 'months')
27
+ // .toDate()
28
+ }
29
+ },
30
+ {
31
+ orderDate: 1,
32
+ orderNumber: 1,
33
+ project: 1,
34
+ paymentMethods: 1
35
+ }
36
+ );
37
+ console.log('orders found');
38
+
39
+ let i = 0;
40
+ let updateCount = 0;
41
+ await cursor.eachAsync(async (doc) => {
42
+ i += 1;
43
+ const order: Pick<
44
+ chevre.factory.order.IOrder,
45
+ 'orderDate' | 'orderNumber' | 'project' | 'paymentMethods'
46
+ > = doc.toObject();
47
+
48
+ const noPayment = order.paymentMethods.length === 0;
49
+ const alreadyMigrated = order.paymentMethods.every((invoice) => {
50
+ return typeof invoice.paymentMethod?.identifier === 'string'
51
+ && invoice.paymentMethod.identifier === invoice.typeOf;
52
+ });
53
+
54
+ if (noPayment) {
55
+ console.log('noPayment.', order.project.id, order.orderNumber, order.orderDate, i);
56
+ } else if (alreadyMigrated) {
57
+ console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
58
+ } else {
59
+ console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i);
60
+ for (const invoice of order.paymentMethods) {
61
+ await orderRepo.fixPaymentMethodIdentifier({
62
+ project: { id: order.project.id },
63
+ orderNumber: order.orderNumber,
64
+ invoice: {
65
+ paymentMethodId: invoice.paymentMethodId,
66
+ paymentMethod: { identifier: invoice.typeOf }
67
+ }
68
+ });
69
+ }
70
+ updateCount += 1;
71
+ console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i);
72
+ }
73
+ });
74
+
75
+ console.log(i, 'orders checked');
76
+ console.log(updateCount, 'orders updated');
77
+ }
78
+
79
+ main()
80
+ .then()
81
+ .catch(console.error);
@@ -0,0 +1,72 @@
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
+ // const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
14
+
15
+ const cursor = assetTransactionRepo.getCursor(
16
+ {
17
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
18
+ // 'object.paymentMethodId': { $exists: false },
19
+ // 'project.id': { $eq: project.id },
20
+ startDate: {
21
+ $gte: moment()
22
+ // tslint:disable-next-line:no-magic-numbers
23
+ .add(-12, 'months')
24
+ .toDate()
25
+ }
26
+ },
27
+ {
28
+ typeOf: 1,
29
+ project: 1,
30
+ object: 1,
31
+ transactionNumber: 1,
32
+ startDate: 1
33
+ }
34
+ );
35
+ console.log('transactions found');
36
+
37
+ let i = 0;
38
+ let updateCount = 0;
39
+ await cursor.eachAsync(async (doc) => {
40
+ i += 1;
41
+ const payTransaction: Pick<
42
+ chevre.factory.assetTransaction.pay.ITransaction,
43
+ 'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
44
+ > = doc.toObject();
45
+
46
+ const alreadyMigrated = typeof payTransaction.object.paymentMethodId === 'string'
47
+ && payTransaction.object.paymentMethodId === (<any>payTransaction.object.paymentMethod).paymentMethodId;
48
+
49
+ if (alreadyMigrated) {
50
+ console.log(
51
+ 'already exist.',
52
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
53
+ } else {
54
+ const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
55
+ console.log(
56
+ 'updating...',
57
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
58
+ paymentMethodIdentifier);
59
+ updateCount += 1;
60
+ console.log(
61
+ 'updated.',
62
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
63
+ }
64
+ });
65
+
66
+ console.log(i, 'transactions checked');
67
+ console.log(updateCount, 'transactions updated');
68
+ }
69
+
70
+ main()
71
+ .then()
72
+ .catch(console.error);
@@ -0,0 +1,78 @@
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
+ // const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
14
+
15
+ const cursor = assetTransactionRepo.getCursor(
16
+ {
17
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
18
+ // 'project.id': { $eq: project.id },
19
+ startDate: {
20
+ $gte: moment('2023-05-08T00:00:00Z')
21
+ // tslint:disable-next-line:no-magic-numbers
22
+ // .add(-12, 'months')
23
+ .toDate(),
24
+ $lte: moment('2023-08-30T21:00:00Z')
25
+ .toDate()
26
+ }
27
+ },
28
+ {
29
+ typeOf: 1,
30
+ project: 1,
31
+ object: 1,
32
+ transactionNumber: 1,
33
+ startDate: 1
34
+ }
35
+ );
36
+ console.log('transactions found');
37
+
38
+ let i = 0;
39
+ let updateCount = 0;
40
+ await cursor.eachAsync(async (doc) => {
41
+ i += 1;
42
+ const payTransaction: Pick<
43
+ chevre.factory.assetTransaction.pay.ITransaction,
44
+ 'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
45
+ > = doc.toObject();
46
+
47
+ const alreadyMigrated = payTransaction.object.paymentMethod.identifier
48
+ === (<any>payTransaction.object.paymentMethod).typeOf;
49
+
50
+ if (alreadyMigrated) {
51
+ console.log(
52
+ 'already exist.',
53
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate,
54
+ i, updateCount);
55
+ } else {
56
+ const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
57
+ console.log(
58
+ 'updating...',
59
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
60
+ paymentMethodIdentifier);
61
+ await assetTransactionRepo.migratePaymentMethodIdentifier({
62
+ transactionNumber: payTransaction.transactionNumber,
63
+ object: { paymentMethod: { identifier: paymentMethodIdentifier } }
64
+ });
65
+ updateCount += 1;
66
+ console.log(
67
+ 'updated.',
68
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
69
+ }
70
+ });
71
+
72
+ console.log(i, 'transactions checked');
73
+ console.log(updateCount, 'transactions updated');
74
+ }
75
+
76
+ main()
77
+ .then()
78
+ .catch(console.error);
@@ -43,14 +43,13 @@ async function main() {
43
43
  .toDate(),
44
44
  object: {
45
45
  typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
46
- id: '5f9a6986cc98a1eb13a90285',
46
+ id: 'xxx',
47
47
  paymentMethod: {
48
48
  amount: 1,
49
- // paymentMethodId?: string;
50
- typeOf: 'CreditCard',
49
+ identifier: 'CreditCard',
51
50
  method: '1',
52
51
  creditCard: {
53
- memberId: 'a7909268-a584-425e-8212-d7d10f344093',
52
+ memberId: 'xxx',
54
53
  cardSeq: 91
55
54
  // cardPass?: string;
56
55
  }
@@ -0,0 +1,56 @@
1
+ // tslint:disable:no-console
2
+ import * as jwt from 'jsonwebtoken';
3
+ import { chevre } from '../../../lib/index';
4
+
5
+ function getToken(params: {
6
+ expiresIn: number;
7
+ payload: chevre.factory.authorization.IOwnershipInfoAsObject;
8
+ }) {
9
+ return async (__: {}) => {
10
+ // const now = new Date();
11
+
12
+ // const data = authorization.object;
13
+
14
+ return new Promise<string>((resolve, reject) => {
15
+ // 所有権を暗号化する
16
+ jwt.sign(
17
+ params.payload,
18
+ chevre.credentials.jwt.secret,
19
+ // params.secret,
20
+ {
21
+ issuer: chevre.credentials.jwt.issuer,
22
+ // issuer: params.issuer,
23
+ expiresIn: params.expiresIn
24
+ },
25
+ (err, encoded) => {
26
+ if (err instanceof Error) {
27
+ reject(err);
28
+ } else {
29
+ if (typeof encoded !== 'string') {
30
+ reject(new chevre.factory.errors.ServiceUnavailable('authorization.object cannot be signed unexpectedly'));
31
+ } else {
32
+ resolve(encoded);
33
+ }
34
+ }
35
+ }
36
+ );
37
+ });
38
+ };
39
+ }
40
+
41
+ getToken({
42
+ expiresIn: 2678400,
43
+ payload: {
44
+ typeOf: 'OwnershipInfo',
45
+ id: '',
46
+ typeOfGood: {
47
+ typeOf: chevre.factory.permit.PermitType.Permit,
48
+ identifier: 'xxxxxxxxxxxx',
49
+ issuedThrough: { id: '64f193ad5e79fe8a06ca3156', typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
50
+ }
51
+ }
52
+ })({})
53
+ .then((token) => {
54
+ console.log('token:', token);
55
+ })
56
+ .catch(console.error);
@@ -10,18 +10,18 @@ async function main() {
10
10
 
11
11
  const taskRepo = new chevre.repository.Task(mongoose.connection);
12
12
 
13
- const tasks = await taskRepo.taskModel.find(
13
+ const tasks = await taskRepo.search(
14
14
  {
15
- 'project.id': { $eq: project.id },
16
- name: { $eq: chevre.factory.taskName.SendOrder },
17
- 'data.object.orderNumber': {
18
- $exists: true,
19
- $eq: 'xxx'
15
+ limit: 1,
16
+ project: { id: { $eq: project.id } },
17
+ name: { $in: [chevre.factory.taskName.SendOrder] },
18
+ data: {
19
+ object: {
20
+ orderNumber: { $eq: 'xxx' }
21
+ }
20
22
  }
21
23
  }
22
- )
23
- .limit(1)
24
- .exec();
24
+ );
25
25
  console.log('tasks found', tasks);
26
26
  console.log(tasks.length, 'tasks found');
27
27
  }
@@ -0,0 +1,25 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
13
+
14
+ const result = await offerRepo.sync2aggregateOffer({
15
+ project: { id: project.id },
16
+ identifier: { $in: ['COA-120-15'] },
17
+ isDeleted: false,
18
+ typeOf: chevre.factory.offerType.Offer
19
+ });
20
+ console.log(result);
21
+ }
22
+
23
+ main()
24
+ .then(console.log)
25
+ .catch(console.error);
@@ -78,7 +78,14 @@ export declare class MongoRepository {
78
78
  confirm<T extends factory.assetTransactionType>(params: {
79
79
  typeOf: T;
80
80
  id: string;
81
- object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'>;
81
+ object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'> & {
82
+ /**
83
+ * 決済取引における決済方法区分指定
84
+ */
85
+ paymentMethod?: {
86
+ identifier?: string;
87
+ };
88
+ };
82
89
  result: factory.assetTransaction.IResult<T>;
83
90
  potentialActions: factory.assetTransaction.IPotentialActions<T>;
84
91
  }): Promise<void>;
@@ -182,6 +189,14 @@ export declare class MongoRepository {
182
189
  id: string;
183
190
  update: any;
184
191
  }): Promise<factory.assetTransaction.ITransaction<T>>;
192
+ migratePaymentMethodIdentifier(params: {
193
+ transactionNumber: string;
194
+ object: {
195
+ paymentMethod: {
196
+ identifier: string;
197
+ };
198
+ };
199
+ }): Promise<any>;
185
200
  findByIdAndDelete(params: {
186
201
  id: string;
187
202
  }): Promise<void>;
@@ -344,14 +344,16 @@ class MongoRepository {
344
344
  * 取引を確定する
345
345
  */
346
346
  confirm(params) {
347
- var _a, _b;
347
+ var _a, _b, _c, _d;
348
348
  return __awaiter(this, void 0, void 0, function* () {
349
349
  const doc = yield this.transactionModel.findOneAndUpdate({
350
350
  _id: { $eq: params.id },
351
351
  typeOf: { $eq: params.typeOf },
352
352
  status: { $eq: factory.transactionStatusType.InProgress }
353
- }, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
353
+ }, Object.assign(Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
354
354
  ? { 'object.underName': params.object.underName }
355
+ : undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethod) === null || _d === void 0 ? void 0 : _d.identifier) === 'string')
356
+ ? { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }
355
357
  : undefined), {
356
358
  new: true,
357
359
  projection: { _id: 1 }
@@ -704,6 +706,55 @@ class MongoRepository {
704
706
  });
705
707
  });
706
708
  }
709
+ migratePaymentMethodIdentifier(params) {
710
+ return __awaiter(this, void 0, void 0, function* () {
711
+ return this.transactionModel.findOneAndUpdate({
712
+ typeOf: { $eq: factory.assetTransactionType.Pay },
713
+ transactionNumber: { $exists: true, $eq: params.transactionNumber }
714
+ }, { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }, {
715
+ new: true,
716
+ projection: { _id: 1 }
717
+ })
718
+ .exec()
719
+ .then((doc) => {
720
+ if (doc === null) {
721
+ throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
722
+ }
723
+ return doc.toObject();
724
+ });
725
+ });
726
+ }
727
+ // public async migratePaymentMethodIdentifierMany() {
728
+ // // return this.transactionModel.updateMany(
729
+ // // {
730
+ // // typeOf: { $eq: factory.assetTransactionType.Pay }
731
+ // // // 'object.paymentMethod.identifier': { $exists: false }
732
+ // // },
733
+ // // { $set: { 'object.paymentMethod.identifier': '$object.paymentMethod.typeOf' } }
734
+ // // )
735
+ // // .exec();
736
+ // return this.transactionModel.aggregate([
737
+ // {
738
+ // $match: {
739
+ // typeOf: { $eq: factory.assetTransactionType.Pay }
740
+ // }
741
+ // },
742
+ // {
743
+ // $project: {
744
+ // paymentMethodIdentifier: '$object.paymentMethod.typeOf'
745
+ // }
746
+ // },
747
+ // {
748
+ // $unset: ['object.paymentMethod.identifier']
749
+ // }
750
+ // // {
751
+ // // $set: {
752
+ // // 'object.paymentMethod.identifier': '$paymentMethodIdentifier'
753
+ // // }
754
+ // // }
755
+ // ])
756
+ // .exec();
757
+ // }
707
758
  findByIdAndDelete(params) {
708
759
  return __awaiter(this, void 0, void 0, function* () {
709
760
  yield this.transactionModel.findByIdAndDelete(params.id)
@@ -713,6 +764,7 @@ class MongoRepository {
713
764
  getCursor(conditions, projection) {
714
765
  return this.transactionModel.find(conditions, projection)
715
766
  .sort({ startDate: factory.sortType.Ascending })
767
+ // .sort({ startDate: factory.sortType.Descending })
716
768
  .cursor();
717
769
  }
718
770
  aggregateAssetTransaction(params) {
@@ -0,0 +1,71 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import { Schema } from 'mongoose';
26
+ declare const modelName = "AggregateOffer";
27
+ /**
28
+ * 集計オファースキーマ
29
+ */
30
+ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
31
+ collection: string;
32
+ id: true;
33
+ read: string;
34
+ writeConcern: import("mongodb").WriteConcern;
35
+ strict: true;
36
+ strictQuery: false;
37
+ timestamps: {
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ };
41
+ toJSON: {
42
+ getters: false;
43
+ virtuals: false;
44
+ minimize: false;
45
+ versionKey: false;
46
+ };
47
+ toObject: {
48
+ getters: false;
49
+ virtuals: true;
50
+ minimize: false;
51
+ versionKey: false;
52
+ };
53
+ }, {
54
+ offers: any[];
55
+ _id?: string | undefined;
56
+ typeOf?: string | undefined;
57
+ project?: any;
58
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
59
+ offers: any[];
60
+ _id?: string | undefined;
61
+ typeOf?: string | undefined;
62
+ project?: any;
63
+ }>> & Omit<import("mongoose").FlatRecord<{
64
+ offers: any[];
65
+ _id?: string | undefined;
66
+ typeOf?: string | undefined;
67
+ project?: any;
68
+ }> & Required<{
69
+ _id: string;
70
+ }>, never>>;
71
+ export { modelName, schema };