@chevre/domain 24.0.0-alpha.2 → 24.0.0-alpha.21

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 (177) hide show
  1. package/lib/chevre/repo/action/acceptCOAOffer.d.ts +23 -0
  2. package/lib/chevre/repo/action/acceptCOAOffer.js +64 -0
  3. package/lib/chevre/repo/action/acceptPay.d.ts +8 -0
  4. package/lib/chevre/repo/action/acceptPay.js +13 -0
  5. package/lib/chevre/repo/action/actionProcess.d.ts +115 -0
  6. package/lib/chevre/repo/action/actionProcess.js +293 -0
  7. package/lib/chevre/repo/action/authorizeOffer.d.ts +21 -0
  8. package/lib/chevre/repo/action/authorizeOffer.js +85 -0
  9. package/lib/chevre/repo/action/checkMovieTicket.d.ts +111 -0
  10. package/lib/chevre/repo/action/checkMovieTicket.js +200 -0
  11. package/lib/chevre/repo/action/checkThing.d.ts +8 -0
  12. package/lib/chevre/repo/action/checkThing.js +13 -0
  13. package/lib/chevre/repo/action.d.ts +9 -249
  14. package/lib/chevre/repo/action.js +308 -708
  15. package/lib/chevre/repo/aggregateAction.d.ts +102 -0
  16. package/lib/chevre/repo/aggregateAction.js +379 -0
  17. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  18. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  19. package/lib/chevre/repo/orderInTransaction.js +16 -2
  20. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  21. package/lib/chevre/repo/orderNumber.js +23 -28
  22. package/lib/chevre/repo/transaction/moneyTransfer.d.ts +61 -0
  23. package/lib/chevre/repo/transaction/moneyTransfer.js +379 -0
  24. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  25. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  26. package/lib/chevre/repo/transaction/returnOrder.d.ts +45 -0
  27. package/lib/chevre/repo/transaction/returnOrder.js +341 -0
  28. package/lib/chevre/repo/transaction.d.ts +1 -125
  29. package/lib/chevre/repo/transaction.js +726 -632
  30. package/lib/chevre/repository.d.ts +49 -0
  31. package/lib/chevre/repository.js +107 -2
  32. package/lib/chevre/service/aggregation/system.d.ts +10 -10
  33. package/lib/chevre/service/aggregation/system.js +9 -9
  34. package/lib/chevre/service/assetTransaction/pay/check.d.ts +5 -4
  35. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +5 -2
  36. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +3 -3
  37. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  38. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  39. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  40. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  41. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +55 -0
  42. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  43. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +3 -1
  44. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  45. package/lib/chevre/service/assetTransaction/pay/start.d.ts +2 -0
  46. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  47. package/lib/chevre/service/notification/triggerWebhook.d.ts +7 -6
  48. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  49. package/lib/chevre/service/offer/event/authorize.js +3 -3
  50. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  51. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  52. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  53. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  54. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  55. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  56. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +3 -3
  57. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  58. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +16 -5
  59. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +7 -7
  60. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +6 -4
  61. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  62. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +21 -13
  63. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +19 -10
  64. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +2 -2
  65. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  66. package/lib/chevre/service/offer/moneyTransfer/authorize.js +6 -3
  67. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  68. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  69. package/lib/chevre/service/offer/product.d.ts +3 -3
  70. package/lib/chevre/service/offer/product.js +4 -4
  71. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  72. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  73. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  74. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  75. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +16 -0
  76. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +97 -0
  77. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.d.ts +21 -0
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +86 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +22 -0
  80. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +112 -0
  81. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +22 -0
  82. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.js +74 -0
  83. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +25 -0
  84. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +111 -0
  85. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +16 -0
  86. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.js +74 -0
  87. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +8 -30
  88. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +37 -348
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +6 -7
  90. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +6 -5
  91. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +7 -6
  92. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  93. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  94. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  95. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -1
  96. package/lib/chevre/service/order/placeOrder.d.ts +13 -12
  97. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  98. package/lib/chevre/service/order/returnOrder.js +1 -1
  99. package/lib/chevre/service/order/sendOrder.d.ts +6 -6
  100. package/lib/chevre/service/order/sendOrder.js +10 -8
  101. package/lib/chevre/service/order.d.ts +3 -6
  102. package/lib/chevre/service/order.js +3 -9
  103. package/lib/chevre/service/payment/any/{fixOrderAsNeeded.d.ts → authorize/fixOrderAsNeeded.d.ts} +6 -6
  104. package/lib/chevre/service/payment/any/{fixOrderAsNeeded.js → authorize/fixOrderAsNeeded.js} +5 -8
  105. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  106. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  107. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  108. package/lib/chevre/service/payment/any/authorize.d.ts +92 -0
  109. package/lib/chevre/service/payment/any/authorize.js +225 -0
  110. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +43 -0
  111. package/lib/chevre/service/payment/any/findAcceptAction.js +94 -0
  112. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +41 -0
  113. package/lib/chevre/service/payment/any/findAuthorizeAction.js +83 -0
  114. package/lib/chevre/service/payment/any/findCheckAction.d.ts +45 -0
  115. package/lib/chevre/service/payment/any/findCheckAction.js +89 -0
  116. package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +28 -0
  117. package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +185 -0
  118. package/lib/chevre/service/payment/any/onPayActionCompleted.d.ts +7 -3
  119. package/lib/chevre/service/payment/any/onPayActionCompleted.js +3 -0
  120. package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +29 -0
  121. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +125 -0
  122. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  123. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +66 -0
  124. package/lib/chevre/service/payment/any/publishPaymentUrl.js +133 -0
  125. package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +31 -0
  126. package/lib/chevre/service/payment/any/voidPayTransaction.js +38 -0
  127. package/lib/chevre/service/payment/any.d.ts +8 -305
  128. package/lib/chevre/service/payment/any.js +17 -857
  129. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +2 -0
  130. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -3
  131. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
  132. package/lib/chevre/service/payment/movieTicket/validation.d.ts +11 -10
  133. package/lib/chevre/service/payment/movieTicket/validation.js +19 -15
  134. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  135. package/lib/chevre/service/report/telemetry.js +7 -12
  136. package/lib/chevre/service/task/acceptCOAOffer.js +11 -6
  137. package/lib/chevre/service/task/authorizePayment.js +6 -2
  138. package/lib/chevre/service/task/checkMovieTicket.js +3 -3
  139. package/lib/chevre/service/task/checkResource.js +2 -2
  140. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  141. package/lib/chevre/service/task/deleteTransaction.js +7 -1
  142. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  143. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  144. package/lib/chevre/service/task/payment/payByTask.d.ts +14 -12
  145. package/lib/chevre/service/task/placeOrder.js +6 -4
  146. package/lib/chevre/service/task/publishPaymentUrl.js +8 -4
  147. package/lib/chevre/service/task/returnOrder.js +4 -4
  148. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  149. package/lib/chevre/service/task/sendOrder.js +4 -4
  150. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  151. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  152. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  153. package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
  154. package/lib/chevre/service/transaction/deleteTransaction.d.ts +6 -0
  155. package/lib/chevre/service/transaction/deleteTransaction.js +56 -14
  156. package/lib/chevre/service/transaction/moneyTransfer.d.ts +5 -5
  157. package/lib/chevre/service/transaction/moneyTransfer.js +5 -5
  158. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  159. package/lib/chevre/service/transaction/placeOrder/confirm.js +10 -9
  160. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +7 -6
  161. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  162. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  163. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  164. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  165. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  166. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  167. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  168. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  169. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  170. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  171. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  172. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +1 -1
  173. package/lib/chevre/service/transaction/returnOrder.d.ts +16 -14
  174. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  175. package/lib/chevre/service/transaction.d.ts +9 -21
  176. package/lib/chevre/service/transaction.js +5 -111
  177. package/package.json +4 -8
@@ -36,7 +36,8 @@ const paymentService_1 = require("../../repo/paymentService");
36
36
  const potentialAction_1 = require("../../repo/potentialAction");
37
37
  const product_1 = require("../../repo/product");
38
38
  const task_1 = require("../../repo/task");
39
- const transaction_1 = require("../../repo/transaction");
39
+ // import { TransactionRepo } from '../../repo/transaction';
40
+ const returnOrder_1 = require("../../repo/transaction/returnOrder");
40
41
  const transactionNumber_1 = require("../../repo/transactionNumber");
41
42
  const RefundTransactionService = __importStar(require("../assetTransaction/refund"));
42
43
  /**
@@ -58,7 +59,7 @@ function call(params) {
58
59
  potentialAction: new potentialAction_1.PotentialActionRepo(connection),
59
60
  product: new product_1.ProductRepo(connection),
60
61
  task: new task_1.TaskRepo(connection),
61
- transaction: new transaction_1.TransactionRepo(connection),
62
+ returnOrder: new returnOrder_1.ReturnOrderRepo(connection),
62
63
  transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
63
64
  });
64
65
  };
@@ -104,7 +105,7 @@ function fixOrderAndTransaction(params) {
104
105
  }
105
106
  // const orderNumber = params.purpose.orderNumber;
106
107
  const orderNumber = orderByPaymentMethodId.orderNumber;
107
- const returnOrderTransaction = (await repos.transaction.projectFields({
108
+ const returnOrderTransaction = (await repos.returnOrder.findReturnOrderTransactions({
108
109
  limit: 1,
109
110
  page: 1,
110
111
  typeOf: factory.transactionType.ReturnOrder,
@@ -31,13 +31,13 @@ const order_1 = require("../../repo/order");
31
31
  const ownershipInfo_1 = require("../../repo/ownershipInfo");
32
32
  const setting_1 = require("../../repo/setting");
33
33
  const task_1 = require("../../repo/task");
34
- const transaction_1 = require("../../repo/transaction");
34
+ const placeOrder_1 = require("../../repo/transaction/placeOrder");
35
35
  const sendOrder_1 = require("../order/sendOrder");
36
36
  /**
37
37
  * タスク実行関数
38
38
  */
39
39
  function call(data) {
40
- return async ({ connection, settings }) => {
40
+ return async ({ connection }) => {
41
41
  await (0, sendOrder_1.sendOrder)({
42
42
  ...data,
43
43
  object: {
@@ -57,7 +57,7 @@ function call(data) {
57
57
  ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
58
58
  setting: new setting_1.SettingRepo(connection),
59
59
  task: new task_1.TaskRepo(connection),
60
- transaction: new transaction_1.TransactionRepo(connection)
61
- }, settings);
60
+ placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
61
+ });
62
62
  };
63
63
  }
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
4
  const action_1 = require("../../repo/action");
5
5
  const assetTransaction_1 = require("../../repo/assetTransaction");
6
- const transaction_1 = require("../../repo/transaction");
6
+ // import { TransactionRepo } from '../../repo/transaction';
7
+ const placeOrder_1 = require("../../repo/transaction/placeOrder");
7
8
  const voidTransaction_1 = require("../offer/moneyTransfer/voidTransaction");
8
9
  /**
9
10
  * タスク実行関数
@@ -12,11 +13,13 @@ function call(data) {
12
13
  return async ({ connection }) => {
13
14
  const actionRepo = new action_1.ActionRepo(connection);
14
15
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
15
- const transactionRepo = new transaction_1.TransactionRepo(connection);
16
+ const placeOrderRepo = new placeOrder_1.PlaceOrderRepo(connection);
17
+ // const transactionRepo = new TransactionRepo(connection);
16
18
  await (0, voidTransaction_1.voidTransaction)(data)({
17
19
  action: actionRepo,
18
20
  assetTransaction: assetTransactionRepo,
19
- transaction: transactionRepo
21
+ placeOrder: placeOrderRepo
22
+ // transaction: transactionRepo
20
23
  });
21
24
  };
22
25
  }
@@ -8,7 +8,8 @@ const paymentService_1 = require("../../repo/paymentService");
8
8
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
9
9
  const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
10
10
  const task_1 = require("../../repo/task");
11
- const transaction_1 = require("../../repo/transaction");
11
+ const placeOrder_1 = require("../../repo/transaction/placeOrder");
12
+ // import { TransactionRepo } from '../../repo/transaction';
12
13
  const any_1 = require("../payment/any");
13
14
  /**
14
15
  * タスク実行関数
@@ -27,7 +28,8 @@ function call(params) {
27
28
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
28
29
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
29
30
  task: new task_1.TaskRepo(connection),
30
- transaction: new transaction_1.TransactionRepo(connection)
31
+ placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
32
+ // transaction: new TransactionRepo(connection)
31
33
  }
32
34
  // settings
33
35
  );
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
4
  const action_1 = require("../../repo/action");
5
5
  const assetTransaction_1 = require("../../repo/assetTransaction");
6
- const transaction_1 = require("../../repo/transaction");
6
+ const placeOrder_1 = require("../../repo/transaction/placeOrder");
7
7
  const product_1 = require("../offer/product");
8
8
  /**
9
9
  * タスク実行関数
@@ -12,11 +12,11 @@ function call(data) {
12
12
  return async ({ connection }) => {
13
13
  const actionRepo = new action_1.ActionRepo(connection);
14
14
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
15
- const transactionRepo = new transaction_1.TransactionRepo(connection);
15
+ const placeOrderRepo = new placeOrder_1.PlaceOrderRepo(connection);
16
16
  await (0, product_1.voidTransaction)(data)({
17
17
  action: actionRepo,
18
18
  assetTransaction: assetTransactionRepo,
19
- transaction: transactionRepo
19
+ placeOrder: placeOrderRepo
20
20
  });
21
21
  };
22
22
  }
@@ -36,8 +36,8 @@ const reserveInterface_1 = require("../../repo/reserveInterface");
36
36
  const setting_1 = require("../../repo/setting");
37
37
  const stockHolder_1 = require("../../repo/stockHolder");
38
38
  const task_1 = require("../../repo/task");
39
- const transaction_1 = require("../../repo/transaction");
40
- // import { TransactionProcessRepo } from '../../repo/transactionProcess';
39
+ // import { TransactionRepo } from '../../repo/transaction';
40
+ const placeOrder_1 = require("../../repo/transaction/placeOrder");
41
41
  let coaAuthClientCreated = false;
42
42
  let coaAuthClient = new COA.auth.RefreshToken({
43
43
  endpoint: '', // 使用されないので空文字でok
@@ -87,7 +87,8 @@ function call(params) {
87
87
  reservation: new reservation_1.ReservationRepo(connection),
88
88
  setting: new setting_1.SettingRepo(connection),
89
89
  task: new task_1.TaskRepo(connection),
90
- transaction: new transaction_1.TransactionRepo(connection),
90
+ placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
91
+ // transaction: new TransactionRepo(connection),
91
92
  reserveService
92
93
  }, settings);
93
94
  }
@@ -12,6 +12,9 @@ import type { ReservationRepo } from '../../repo/reservation';
12
12
  import type { SettingRepo } from '../../repo/setting';
13
13
  import type { TaskRepo } from '../../repo/task';
14
14
  import type { TransactionRepo } from '../../repo/transaction';
15
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
16
+ import type { ReturnOrderRepo } from '../../repo/transaction/returnOrder';
17
+ import type { MoneyTransferRepo } from '../../repo/transaction/moneyTransfer';
15
18
  /**
16
19
  * 取引に関わるリソースを削除する
17
20
  * 冪等性を確保すること
@@ -30,4 +33,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
30
33
  setting: SettingRepo;
31
34
  task: TaskRepo;
32
35
  transaction: TransactionRepo;
36
+ placeOrder: PlaceOrderRepo;
37
+ returnOrder: ReturnOrderRepo;
38
+ moneyTransfer: MoneyTransferRepo;
33
39
  }) => Promise<void>;
@@ -50,15 +50,40 @@ function createDeleteTransactionTasksByAgentId(params) {
50
50
  // agentIdによる全取引についてDeleteTransactionタスクを作成する
51
51
  if (typeof agentIdSpecified === 'string' && agentIdSpecified.length > 0) {
52
52
  const transactionTypeOf = params.object.typeOf;
53
- const transactions = await repos.transaction.projectFields({
54
- project: { id: { $eq: params.object.project.id } },
55
- agent: {
56
- ids: [agentIdSpecified],
57
- typeOf: factory.personType.Person
58
- },
59
- typeOf: transactionTypeOf,
60
- inclusion: ['typeOf', 'startDate', 'endDate', 'object', 'project']
61
- });
53
+ let transactions;
54
+ if (transactionTypeOf === factory.transactionType.PlaceOrder) {
55
+ transactions = await repos.placeOrder.findPlaceOrderTransactions({
56
+ project: { id: { $eq: params.object.project.id } },
57
+ agent: {
58
+ ids: [agentIdSpecified],
59
+ typeOf: factory.personType.Person
60
+ },
61
+ typeOf: transactionTypeOf,
62
+ inclusion: ['typeOf', 'startDate', 'endDate', 'object', 'project']
63
+ });
64
+ }
65
+ else if (transactionTypeOf === factory.transactionType.ReturnOrder) {
66
+ transactions = await repos.returnOrder.findReturnOrderTransactions({
67
+ project: { id: { $eq: params.object.project.id } },
68
+ agent: {
69
+ ids: [agentIdSpecified],
70
+ typeOf: factory.personType.Person
71
+ },
72
+ typeOf: transactionTypeOf,
73
+ inclusion: ['typeOf', 'startDate', 'endDate', 'object', 'project']
74
+ });
75
+ }
76
+ else {
77
+ transactions = await repos.moneyTransfer.findMoneyTransferTransactions({
78
+ project: { id: { $eq: params.object.project.id } },
79
+ agent: {
80
+ ids: [agentIdSpecified],
81
+ typeOf: factory.personType.Person
82
+ },
83
+ typeOf: transactionTypeOf,
84
+ inclusion: ['typeOf', 'startDate', 'endDate', 'object', 'project']
85
+ });
86
+ }
62
87
  const deleteAt = new Date();
63
88
  let deleteTransactionTasks;
64
89
  switch (transactionTypeOf) {
@@ -166,11 +191,28 @@ function deleteTransactionById(params) {
166
191
  if (typeof deletingTransactionId !== 'string' || deletingTransactionId.length === 0) {
167
192
  throw new factory.errors.ArgumentNull('object.id');
168
193
  }
169
- const transaction = (await repos.transaction.projectFields({
170
- ids: [deletingTransactionId],
171
- typeOf: params.object.typeOf,
172
- inclusion: ['typeOf', 'project', 'status', 'result']
173
- })).shift();
194
+ let transaction;
195
+ if (params.object.typeOf === factory.transactionType.PlaceOrder) {
196
+ transaction = (await repos.placeOrder.findPlaceOrderTransactions({
197
+ ids: [deletingTransactionId],
198
+ typeOf: params.object.typeOf,
199
+ inclusion: ['typeOf', 'project', 'status', 'result']
200
+ })).shift();
201
+ }
202
+ else if (params.object.typeOf === factory.transactionType.ReturnOrder) {
203
+ transaction = (await repos.returnOrder.findReturnOrderTransactions({
204
+ ids: [deletingTransactionId],
205
+ typeOf: params.object.typeOf,
206
+ inclusion: ['typeOf', 'project', 'status', 'result']
207
+ })).shift();
208
+ }
209
+ else {
210
+ transaction = (await repos.moneyTransfer.findMoneyTransferTransactions({
211
+ ids: [deletingTransactionId],
212
+ typeOf: params.object.typeOf,
213
+ inclusion: ['typeOf', 'project', 'status', 'result']
214
+ })).shift();
215
+ }
174
216
  if (transaction === undefined) {
175
217
  // すでに削除済
176
218
  return;
@@ -9,7 +9,7 @@ import type { SellerRepo } from '../../repo/seller';
9
9
  import type { SettingRepo } from '../../repo/setting';
10
10
  import type { TaskRepo } from '../../repo/task';
11
11
  import type { TicketRepo } from '../../repo/ticket';
12
- import type { IStartedTransaction, TransactionRepo } from '../../repo/transaction';
12
+ import type { IStartedTransaction, MoneyTransferRepo } from '../../repo/transaction/moneyTransfer';
13
13
  import type { TransactionNumberRepo } from '../../repo/transactionNumber';
14
14
  import { moneyTransfer as MoneyTransferFactory } from '../../factory/transaction';
15
15
  export interface IStartOperationRepos {
@@ -21,7 +21,7 @@ export interface IStartOperationRepos {
21
21
  project: ProjectRepo;
22
22
  seller: SellerRepo;
23
23
  ticket: TicketRepo;
24
- transaction: TransactionRepo;
24
+ moneyTransfer: MoneyTransferRepo;
25
25
  transactionNumber: TransactionNumberRepo;
26
26
  assetTransaction: AssetTransactionRepo;
27
27
  }
@@ -29,11 +29,11 @@ export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
29
29
  export type ITaskAndTransactionOperation<T> = (repos: {
30
30
  setting: SettingRepo;
31
31
  task: TaskRepo;
32
- transaction: TransactionRepo;
32
+ moneyTransfer: MoneyTransferRepo;
33
33
  }) => Promise<T>;
34
34
  export type IConfirmOperation<T> = (repos: {
35
35
  action: ActionRepo;
36
- transaction: TransactionRepo;
36
+ moneyTransfer: MoneyTransferRepo;
37
37
  }) => Promise<T>;
38
38
  export type IStartParams = MoneyTransferFactory.IStartParams;
39
39
  /**
@@ -48,7 +48,7 @@ export type IAuthorizeOperation<T> = (repos: {
48
48
  product: ProductRepo;
49
49
  project: ProjectRepo;
50
50
  ticket: TicketRepo;
51
- transaction: TransactionRepo;
51
+ moneyTransfer: MoneyTransferRepo;
52
52
  assetTransaction: AssetTransactionRepo;
53
53
  }) => Promise<T>;
54
54
  /**
@@ -72,7 +72,7 @@ function start(params) {
72
72
  const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
73
73
  // 取引開始
74
74
  const startParams = (0, factory_2.createStartParams)(params, passport, seller, amount, fromLocation, toLocation, transactionNumber);
75
- const transaction = await repos.transaction.start(startParams);
75
+ const transaction = await repos.moneyTransfer.startMoneyTransfer(startParams);
76
76
  await authorizePaymentCard({
77
77
  transaction: {
78
78
  ...transaction,
@@ -202,7 +202,7 @@ function processAuthorizePaymentCard(params) {
202
202
  // jwt: JWTCredentials;
203
203
  // }
204
204
  ) => {
205
- const transaction = await repos.transaction.projectFieldsInProgressById({
205
+ const transaction = await repos.moneyTransfer.findMoneyTransferInProgressById({
206
206
  typeOf: factory.transactionType.MoneyTransfer,
207
207
  id: params.purpose.id
208
208
  }, ['agent', 'project', 'recipient', 'seller', 'typeOf', 'object']);
@@ -566,7 +566,7 @@ function validateToLocation(project, toLocationBeforeStart, issuedThrough) {
566
566
  function confirm(params) {
567
567
  return async (repos) => {
568
568
  const now = new Date();
569
- const transaction = await repos.transaction.projectFieldsById({
569
+ const transaction = await repos.moneyTransfer.findMoneyTransferById({
570
570
  typeOf: factory.transactionType.MoneyTransfer,
571
571
  id: params.id
572
572
  }, ['typeOf', 'status', 'project']);
@@ -591,7 +591,7 @@ function confirm(params) {
591
591
  // ポストアクションを作成
592
592
  const potentialActions = await (0, potentialActions_1.createPotentialActions)({ authorizeActions, transaction });
593
593
  // 取引確定
594
- await repos.transaction.confirm({
594
+ await repos.moneyTransfer.confirmMoneyTransfer({
595
595
  typeOf: factory.transactionType.MoneyTransfer,
596
596
  id: transaction.id,
597
597
  result: {},
@@ -625,7 +625,7 @@ function exportTasksById(params) {
625
625
  return async (repos
626
626
  // settings: Settings
627
627
  ) => {
628
- const transaction = await repos.transaction.projectFieldsById({
628
+ const transaction = await repos.moneyTransfer.findMoneyTransferById({
629
629
  typeOf: factory.transactionType.MoneyTransfer,
630
630
  id: params.id
631
631
  }, ['endDate', 'status', 'project', 'startDate', 'typeOf', 'object', 'potentialActions']);
@@ -8,7 +8,7 @@ import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
8
8
  import type { OrderNumberRepo } from '../../../repo/orderNumber';
9
9
  import type { ProjectRepo } from '../../../repo/project';
10
10
  import type { SettingRepo } from '../../../repo/setting';
11
- import type { TransactionRepo } from '../../../repo/transaction';
11
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
12
12
  import * as factory from '../../../factory';
13
13
  import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
14
14
  interface IConfirmOperationRepos {
@@ -18,7 +18,7 @@ interface IConfirmOperationRepos {
18
18
  emailMessage?: EmailMessageRepo;
19
19
  message: MessageRepo;
20
20
  project: ProjectRepo;
21
- transaction: TransactionRepo;
21
+ placeOrder: PlaceOrderRepo;
22
22
  orderInTransaction: OrderInTransactionRepo;
23
23
  orderNumber: OrderNumberRepo;
24
24
  confirmationNumber: ConfirmationNumberRepo;
@@ -40,19 +40,20 @@ const potentialActions_1 = require("./confirm/potentialActions");
40
40
  const publishCode_1 = require("./confirm/publishCode");
41
41
  const validation_1 = require("./confirm/validation");
42
42
  const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
43
- const publishOrderNumberIfNotExist_1 = require("./publishOrderNumberIfNotExist");
43
+ const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
44
44
  const debug = (0, debug_1.default)('chevre-domain:service:transaction');
45
+ /**
46
+ * 進行中でない取引を処理する
47
+ */
45
48
  function processTransactionNotInProgress(transaction) {
46
49
  return async (repos) => {
47
50
  if (transaction.status === factory.transactionStatusType.Confirmed) {
48
- // retrieve customer from orderInTransaction(2024-06-24~)
49
- // let resultCustomer: factory.order.ICustomer | undefined = createCustomer({ transaction });
50
51
  const resultCustomer = await repos.orderInTransaction.findCustomerByOrderNumber({
51
52
  orderNumber: { $eq: String(transaction.object.orderNumber) }
52
53
  });
53
- if (resultCustomer === undefined) {
54
- throw new factory.errors.Internal('resultCustomer undefined'); // impossible process
55
- }
54
+ // if (resultCustomer === undefined) {
55
+ // throw new factory.errors.Internal('resultCustomer undefined'); // impossible process
56
+ // }
56
57
  // すでに確定済の場合
57
58
  return {
58
59
  ...transaction.result,
@@ -80,7 +81,7 @@ function confirm(params, options) {
80
81
  status: { $in: [factory.transactionStatusType.Confirmed, factory.transactionStatusType.InProgress] },
81
82
  object: { orderDate: params.result.order.orderDate }
82
83
  })(repos);
83
- const transaction = await repos.transaction.projectFieldsById({ typeOf: factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
84
+ const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
84
85
  const confirmResult = await processTransactionNotInProgress(transaction)(repos);
85
86
  if (confirmResult !== undefined) {
86
87
  return confirmResult;
@@ -95,7 +96,7 @@ function confirm(params, options) {
95
96
  acceptPayActions = await searchAcceptPayActions(params)(repos);
96
97
  }
97
98
  // 注文番号を発行
98
- const orderNumber = await (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
99
+ const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
99
100
  project: { id: transaction.project.id },
100
101
  id: transaction.id,
101
102
  object: { orderDate: params.result.order.orderDate }
@@ -179,7 +180,7 @@ function confirm(params, options) {
179
180
  })(repos);
180
181
  // ステータス変更
181
182
  try {
182
- await repos.transaction.confirm({
183
+ await repos.placeOrder.confirmPlaceOrder({
183
184
  typeOf: transaction.typeOf,
184
185
  id: transaction.id,
185
186
  result: result,
@@ -1,15 +1,16 @@
1
1
  import type { SettingRepo } from '../../../repo/setting';
2
2
  import type { TaskRepo } from '../../../repo/task';
3
- import type { TransactionRepo } from '../../../repo/transaction';
4
- type ITaskAndTransactionOperation<T> = (repos: {
3
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
4
+ interface IExportTasksByIdRepos {
5
5
  setting: SettingRepo;
6
6
  task: TaskRepo;
7
- transaction: TransactionRepo;
8
- }) => Promise<T>;
7
+ placeOrder: PlaceOrderRepo;
8
+ }
9
+ type ITaskAndTransactionOperation<T> = (repos: IExportTasksByIdRepos) => Promise<T>;
9
10
  /**
10
11
  * 取引のタスクを出力します
11
12
  */
12
- export declare function exportTasksById(params: {
13
+ declare function exportTasksById(params: {
13
14
  id: string;
14
15
  /**
15
16
  * タスク実行日時バッファ
@@ -20,4 +21,4 @@ export declare function exportTasksById(params: {
20
21
  */
21
22
  optimizeRedundantTasks: boolean;
22
23
  }): ITaskAndTransactionOperation<void>;
23
- export {};
24
+ export { IExportTasksByIdRepos, exportTasksById };
@@ -38,7 +38,7 @@ function exportTasksById(params) {
38
38
  return async (repos
39
39
  // settings: Settings
40
40
  ) => {
41
- const transaction = await repos.transaction.projectFieldsById({
41
+ const transaction = await repos.placeOrder.findPlaceOrderById({
42
42
  typeOf: factory.transactionType.PlaceOrder,
43
43
  id: params.id
44
44
  }, ['endDate', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']);
@@ -1,10 +1,10 @@
1
1
  import type { OrderNumberRepo } from '../../../repo/orderNumber';
2
2
  import type { ProjectRepo } from '../../../repo/project';
3
- import type { TransactionRepo } from '../../../repo/transaction';
3
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
4
4
  /**
5
5
  * 未発行であれば、注文番号を発行して取引に保管する
6
6
  */
7
- declare function publishOrderNumberIfNotExist(params: {
7
+ declare function issueOrderNumberIfNotExist(params: {
8
8
  project: {
9
9
  id: string;
10
10
  };
@@ -17,7 +17,7 @@ declare function publishOrderNumberIfNotExist(params: {
17
17
  };
18
18
  }): (repos: {
19
19
  project: ProjectRepo;
20
- transaction: TransactionRepo;
20
+ placeOrder: PlaceOrderRepo;
21
21
  orderNumber: OrderNumberRepo;
22
22
  }) => Promise<string>;
23
- export { publishOrderNumberIfNotExist };
23
+ export { issueOrderNumberIfNotExist };
@@ -23,36 +23,44 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.publishOrderNumberIfNotExist = publishOrderNumberIfNotExist;
26
+ exports.issueOrderNumberIfNotExist = issueOrderNumberIfNotExist;
27
27
  const factory = __importStar(require("../../../factory"));
28
28
  /**
29
29
  * 未発行であれば、注文番号を発行して取引に保管する
30
30
  */
31
- function publishOrderNumberIfNotExist(params) {
31
+ function issueOrderNumberIfNotExist(params) {
32
32
  return async (repos) => {
33
- // 最適化(2023-02-03~)
34
- let orderNumber = await repos.transaction.findInProgressOrderNumberById({ id: params.id });
33
+ // 1. 最初のチェック
34
+ let orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.id });
35
35
  // すでに発行済であれば何もしない
36
36
  if (typeof orderNumber === 'string') {
37
37
  return orderNumber;
38
38
  }
39
- // 注文番号を発行
39
+ // 2. 発行準備
40
40
  const { alternateName } = await repos.project.findAlternateNameById({ id: params.project.id });
41
41
  if (typeof alternateName !== 'string') {
42
42
  throw new factory.errors.NotFound('project.alternateName');
43
43
  }
44
- orderNumber = await repos.orderNumber.publishByTimestamp({
44
+ // 3. 番号発行
45
+ const issuedOrderNumber = await repos.orderNumber.issueOrderNumber({
45
46
  project: { alternateName },
46
47
  orderDate: params.object.orderDate
47
48
  });
48
- // 取引に存在しなければ保管
49
- await repos.transaction.saveOrderNumberIfNotExist({ id: params.id, orderNumber });
50
- // 注文番号を取引から再取得
51
- // 最適化(2023-02-03~)
52
- orderNumber = await repos.transaction.findInProgressOrderNumberById({ id: params.id });
53
- // 万が一処理が想定通りでない場合orderNumberが存在しない
49
+ // 4. 保管を試みる
50
+ const { modifiedCount } = await repos.placeOrder.saveOrderNumberIfNotExist({
51
+ id: params.id,
52
+ orderNumber: issuedOrderNumber
53
+ });
54
+ // 5. 書き込めたなら、自分が発行した番号が「真実」
55
+ if (modifiedCount === 1) {
56
+ return issuedOrderNumber;
57
+ }
58
+ // 6. 競合が発生した場合(他者が先に書き込んだ場合)
59
+ // DBにある「正解」を再取得して返す
60
+ orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.id });
54
61
  if (typeof orderNumber !== 'string') {
55
- throw new factory.errors.Internal('transaction.object.orderNumber not found');
62
+ // ここを通るのは、他者が保存した直後に取引がキャンセル/削除された等の極めて稀なケース
63
+ throw new factory.errors.Internal('OrderNumber conflict: failed to retrieve existing number');
56
64
  }
57
65
  return orderNumber;
58
66
  };
@@ -1,5 +1,5 @@
1
1
  import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
2
- import type { TransactionRepo } from '../../../repo/transaction';
2
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
3
3
  import * as factory from '../../../factory';
4
4
  /**
5
5
  * 未発行であれば、注文の確認番号を発行して取引に保管する
@@ -16,7 +16,7 @@ declare function publishConfirmationNumberIfNotExist(params: {
16
16
  orderDate: Date;
17
17
  };
18
18
  }): (repos: {
19
- transaction: TransactionRepo;
19
+ placeOrder: PlaceOrderRepo;
20
20
  confirmationNumber: ConfirmationNumberRepo;
21
21
  }) => Promise<string>;
22
22
  export { publishConfirmationNumberIfNotExist };
@@ -30,7 +30,7 @@ const factory = __importStar(require("../../../factory"));
30
30
  */
31
31
  function publishConfirmationNumberIfNotExist(params) {
32
32
  return async (repos) => {
33
- let confirmationNumber = await repos.transaction.findInProgressConfirmationNumberById({
33
+ let confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
34
34
  id: params.id,
35
35
  status: { $in: params.status.$in }
36
36
  });
@@ -41,13 +41,13 @@ function publishConfirmationNumberIfNotExist(params) {
41
41
  // 確認番号を発行
42
42
  confirmationNumber = await repos.confirmationNumber.publish({ orderDate: params.object.orderDate });
43
43
  // 取引に存在しなければ保管
44
- await repos.transaction.saveConfirmationNumberIfNotExist({
44
+ await repos.placeOrder.saveConfirmationNumberIfNotExist({
45
45
  id: params.id,
46
46
  status: { $in: params.status.$in },
47
47
  confirmationNumber
48
48
  });
49
49
  // 確認番号を取引から再取得
50
- confirmationNumber = await repos.transaction.findInProgressConfirmationNumberById({
50
+ confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
51
51
  id: params.id,
52
52
  status: { $in: params.status.$in }
53
53
  });
@@ -4,7 +4,7 @@ import type { MemberProgramRepo } from '../../../repo/memberProgram';
4
4
  import type { PassportRepo } from '../../../repo/passport';
5
5
  import type { ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
6
6
  import type { SellerRepo } from '../../../repo/seller';
7
- import type { IStartedTransaction, TransactionRepo } from '../../../repo/transaction';
7
+ import type { IStartedPlaceOrder, PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
8
8
  import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
9
9
  interface IStartOperationRepos {
10
10
  issuer: IssuerRepo;
@@ -13,7 +13,7 @@ interface IStartOperationRepos {
13
13
  passport: PassportRepo;
14
14
  projectMakesOffer: ProjectMakesOfferRepo;
15
15
  seller: SellerRepo;
16
- transaction: TransactionRepo;
16
+ placeOrder: PlaceOrderRepo;
17
17
  }
18
18
  type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
19
19
  type IStartParams = PlaceOrderFactory.IStartParams;
@@ -23,5 +23,5 @@ interface IStartOptions {
23
23
  /**
24
24
  * 取引開始
25
25
  */
26
- declare function start(params: IStartParams, options: IStartOptions): IStartOperation<IStartedTransaction>;
26
+ declare function start(params: IStartParams, options: IStartOptions): IStartOperation<IStartedPlaceOrder>;
27
27
  export { start };
@@ -54,7 +54,7 @@ function start(params, options) {
54
54
  }
55
55
  catch (error) {
56
56
  // in case already locked
57
- const alreadyStartedTransaction = (await repos.transaction.projectFields({
57
+ const alreadyStartedTransaction = (await repos.placeOrder.findPlaceOrderTransactions({
58
58
  limit: 1, page: 1,
59
59
  typeOf: factory.transactionType.PlaceOrder,
60
60
  project: { id: { $eq: startParams.project.id } },
@@ -72,7 +72,7 @@ function start(params, options) {
72
72
  }
73
73
  }
74
74
  if (transaction === undefined) {
75
- transaction = await repos.transaction.start(startParams);
75
+ transaction = await repos.placeOrder.startPlaceOrder(startParams);
76
76
  }
77
77
  return transaction;
78
78
  };