@chevre/domain 24.1.0-alpha.8 → 25.0.0-alpha.0

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 (223) hide show
  1. package/lib/chevre/emailMessageBuilder.d.ts +1 -1
  2. package/lib/chevre/emailMessageBuilder.js +4 -12
  3. package/lib/chevre/factory/transaction/placeOrder.d.ts +2 -10
  4. package/lib/chevre/factory/transaction/placeOrder.js +1 -0
  5. package/lib/chevre/index.d.ts +1 -2
  6. package/lib/chevre/index.js +1 -3
  7. package/lib/chevre/repo/acceptedOffer.d.ts +25 -27
  8. package/lib/chevre/repo/acceptedOffer.js +102 -67
  9. package/lib/chevre/repo/acceptedOfferInReserve.d.ts +34 -0
  10. package/lib/chevre/repo/acceptedOfferInReserve.js +86 -0
  11. package/lib/chevre/repo/accountingReport.js +2 -30
  12. package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
  13. package/lib/chevre/repo/assetTransaction/reserve.d.ts +1 -2
  14. package/lib/chevre/repo/assetTransaction/reserve.js +4 -50
  15. package/lib/chevre/repo/event.js +12 -8
  16. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +9 -0
  17. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.js +76 -0
  18. package/lib/chevre/repo/factory/reservation/createMongoConditions.d.ts +1 -1
  19. package/lib/chevre/repo/factory/reservation/createMongoConditions.js +171 -363
  20. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +42 -42
  21. package/lib/chevre/repo/mongoose/schemas/order.js +134 -131
  22. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -2
  23. package/lib/chevre/repo/mongoose/schemas/reservation.js +6 -57
  24. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +84 -0
  25. package/lib/chevre/repo/mongoose/schemas/setting.js +2 -1
  26. package/lib/chevre/repo/order.d.ts +1 -82
  27. package/lib/chevre/repo/order.js +11 -372
  28. package/lib/chevre/repo/orderInTransaction.d.ts +58 -7
  29. package/lib/chevre/repo/orderInTransaction.js +58 -4
  30. package/lib/chevre/repo/place/hasPOS.js +2 -1
  31. package/lib/chevre/repo/reservation.d.ts +20 -9
  32. package/lib/chevre/repo/reservation.js +16 -12
  33. package/lib/chevre/repo/role.d.ts +1 -15
  34. package/lib/chevre/repo/role.js +7 -14
  35. package/lib/chevre/repo/setting/integration.d.ts +27 -0
  36. package/lib/chevre/repo/setting/integration.js +102 -0
  37. package/lib/chevre/repo/transaction/placeOrder.d.ts +8 -3
  38. package/lib/chevre/repo/transaction/placeOrder.js +5 -1
  39. package/lib/chevre/repo/transaction.d.ts +6 -6
  40. package/lib/chevre/repo/transaction.js +0 -776
  41. package/lib/chevre/repository.d.ts +5 -0
  42. package/lib/chevre/repository.js +11 -0
  43. package/lib/chevre/service/aggregation/event/aggregateOffers.js +6 -1
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +0 -1
  45. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +14 -11
  46. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  47. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +1 -1
  48. package/lib/chevre/service/assetTransaction/pay/check.d.ts +1 -1
  49. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  51. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +1 -1
  52. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +1 -1
  53. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  54. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
  55. package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +1 -1
  56. package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +1 -1
  57. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +2 -2
  58. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +1 -8
  59. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +20 -32
  60. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.d.ts +1 -1
  61. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +1 -1
  62. package/lib/chevre/service/delivery/factory.d.ts +6 -1
  63. package/lib/chevre/service/delivery/factory.js +1 -1
  64. package/lib/chevre/service/delivery/reservation/factory.d.ts +1 -3
  65. package/lib/chevre/service/delivery/reservation/factory.js +0 -17
  66. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +2 -4
  67. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +3 -3
  68. package/lib/chevre/service/notification/notifyByEmail.d.ts +3 -3
  69. package/lib/chevre/service/notification/notifyByEmail.js +7 -12
  70. package/lib/chevre/service/notification/sendEmailMessage.d.ts +2 -3
  71. package/lib/chevre/service/notification/sendEmailMessage.js +5 -4
  72. package/lib/chevre/service/offer/any.d.ts +7 -2
  73. package/lib/chevre/service/offer/event/authorize/factory.d.ts +6 -3
  74. package/lib/chevre/service/offer/event/authorize/factory.js +17 -18
  75. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  76. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  77. package/lib/chevre/service/offer/event/authorize.js +55 -107
  78. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +1 -1
  79. package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
  80. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
  81. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -3
  82. package/lib/chevre/service/order/deleteOrder.d.ts +1 -1
  83. package/lib/chevre/service/order/deleteOrder.js +19 -46
  84. package/lib/chevre/service/order/{findPlaceOrderTransaction.d.ts → findConfirmedPlaceOrder.d.ts} +1 -1
  85. package/lib/chevre/service/order/{findPlaceOrderTransaction.js → findConfirmedPlaceOrder.js} +12 -7
  86. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +2 -2
  87. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +1 -1
  88. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +1 -1
  89. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +1 -1
  90. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +11 -18
  91. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +1 -1
  92. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +1 -1
  93. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +0 -1
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +6 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +0 -1
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +1 -1
  97. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -1
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +0 -1
  101. package/lib/chevre/service/order/onOrderUpdated.js +0 -1
  102. package/lib/chevre/service/order/payOrder.d.ts +1 -1
  103. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +1 -1
  104. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +19 -7
  105. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
  106. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +0 -5
  107. package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
  108. package/lib/chevre/service/order/placeOrder/factory.js +33 -22
  109. package/lib/chevre/service/order/placeOrder.d.ts +3 -2
  110. package/lib/chevre/service/order/placeOrder.js +0 -9
  111. package/lib/chevre/service/order/returnOrder.js +0 -1
  112. package/lib/chevre/service/order/sendOrder.js +1 -7
  113. package/lib/chevre/service/payment/any/authorize.d.ts +1 -1
  114. package/lib/chevre/service/payment/any/factory.js +7 -6
  115. package/lib/chevre/service/payment/any/person2username.js +0 -1
  116. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +1 -1
  117. package/lib/chevre/service/payment/creditCard/authorize.d.ts +1 -1
  118. package/lib/chevre/service/payment/creditCard/authorize.js +4 -3
  119. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +1 -1
  120. package/lib/chevre/service/payment/creditCard/payCreditCard.js +1 -1
  121. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +1 -1
  122. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +1 -1
  123. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  124. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +1 -1
  125. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +1 -1
  126. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  127. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +8 -1
  128. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
  129. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -1
  130. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +1 -1
  131. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +1 -1
  132. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
  133. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
  134. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +1 -1
  135. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +1 -1
  136. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +2 -2
  137. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +1 -1
  138. package/lib/chevre/service/reserve/confirmReservation.js +7 -7
  139. package/lib/chevre/service/reserve/factory.js +2 -1
  140. package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
  141. package/lib/chevre/service/reserve/findByCode.js +1 -1
  142. package/lib/chevre/service/reserve/findReservations.d.ts +14 -6
  143. package/lib/chevre/service/reserve/findReservations.js +26 -36
  144. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +0 -1
  145. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +0 -1
  146. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +4 -3
  147. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -10
  148. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +0 -1
  149. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +0 -1
  150. package/lib/chevre/service/reserve/searchByOrder.js +7 -3
  151. package/lib/chevre/service/task/acceptCOAOffer.js +6 -3
  152. package/lib/chevre/service/task/authorizePayment.js +4 -2
  153. package/lib/chevre/service/task/cancelPendingReservation.js +4 -2
  154. package/lib/chevre/service/task/checkMovieTicket.js +4 -2
  155. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
  156. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -3
  157. package/lib/chevre/service/task/createAccountingReport.js +0 -4
  158. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +4 -2
  159. package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
  160. package/lib/chevre/service/task/importOffersFromCOA.js +4 -2
  161. package/lib/chevre/service/task/invalidatePaymentUrl.js +3 -1
  162. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +3 -1
  163. package/lib/chevre/service/task/onOrderPaymentCompleted.js +3 -1
  164. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
  165. package/lib/chevre/service/task/pay.js +4 -2
  166. package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +1 -1
  167. package/lib/chevre/service/task/payment/payByTask.d.ts +1 -1
  168. package/lib/chevre/service/task/payment/payByTask.js +6 -7
  169. package/lib/chevre/service/task/payment/refundByTask.d.ts +1 -1
  170. package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +1 -1
  171. package/lib/chevre/service/task/placeOrder.js +3 -1
  172. package/lib/chevre/service/task/publishPaymentUrl.js +3 -1
  173. package/lib/chevre/service/task/refund.js +4 -2
  174. package/lib/chevre/service/task/returnReserveTransaction.js +4 -2
  175. package/lib/chevre/service/task/sendEmailMessage.js +5 -3
  176. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  177. package/lib/chevre/service/task/voidPayment.js +4 -2
  178. package/lib/chevre/service/task/voidReserveTransaction.js +4 -2
  179. package/lib/chevre/service/task.d.ts +0 -7
  180. package/lib/chevre/service/transaction/deleteTransaction.js +13 -7
  181. package/lib/chevre/service/transaction/placeOrder/confirm/factory/result.d.ts +0 -1
  182. package/lib/chevre/service/transaction/placeOrder/confirm/factory/result.js +7 -17
  183. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +7 -1
  184. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +0 -1
  185. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +7 -1
  186. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -1
  187. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
  188. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
  189. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +5 -4
  190. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +5 -4
  191. package/lib/chevre/service/transaction/placeOrder/confirm.js +55 -58
  192. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +0 -1
  193. package/lib/chevre/service/transaction/placeOrder/start/factory.d.ts +11 -2
  194. package/lib/chevre/service/transaction/placeOrder/start/factory.js +12 -10
  195. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +1 -2
  196. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +5 -16
  197. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -4
  198. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  199. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +0 -1
  200. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -2
  201. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +0 -1
  202. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
  203. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +0 -1
  204. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.d.ts +1 -1
  205. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
  206. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +0 -1
  207. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -4
  208. package/lib/chevre/service/transaction/returnOrder.js +1 -1
  209. package/lib/chevre/service/transaction.js +3 -5
  210. package/lib/chevre/service/validation/validateOrder.js +4 -79
  211. package/lib/chevre/settings.d.ts +0 -55
  212. package/lib/chevre/settings.js +1 -29
  213. package/lib/chevre/taskSettings.d.ts +0 -22
  214. package/lib/chevre/taskSettings.js +1 -7
  215. package/package.json +2 -2
  216. package/lib/chevre/credentials/customSearch.d.ts +0 -13
  217. package/lib/chevre/credentials/customSearch.js +0 -16
  218. package/lib/chevre/credentials/lineNotify.d.ts +0 -17
  219. package/lib/chevre/credentials/lineNotify.js +0 -20
  220. package/lib/chevre/credentials/sendGrid.d.ts +0 -24
  221. package/lib/chevre/credentials/sendGrid.js +0 -18
  222. package/lib/chevre/credentials.d.ts +0 -20
  223. package/lib/chevre/credentials.js +0 -42
@@ -9,10 +9,6 @@ const transaction_1 = require("../eventEmitter/transaction");
9
9
  const factory_1 = require("../factory");
10
10
  const settings_1 = require("../settings");
11
11
  const transaction_2 = require("./mongoose/schemas/transaction");
12
- // type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
13
- // export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
14
- // type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
15
- // export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
16
12
  /**
17
13
  * 取引リポジトリ
18
14
  */
@@ -21,547 +17,6 @@ class TransactionRepo {
21
17
  constructor(connection) {
22
18
  this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
23
19
  }
24
- // public static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType.MoneyTransfer>) {
25
- // if (params.typeOf !== factory.transactionType.MoneyTransfer) {
26
- // throw new factory.errors.Argument('typeOf', `must be ${factory.transactionType.MoneyTransfer}`);
27
- // }
28
- // const andConditions: FilterQuery<factory.assetTransaction.ITransaction<factory.assetTransactionType>>[] = [];
29
- // const projectIdEq = params.project?.id?.$eq;
30
- // if (typeof projectIdEq === 'string') {
31
- // andConditions.push({ 'project.id': { $eq: projectIdEq } });
32
- // }
33
- // if (typeof params.typeOf === 'string') {
34
- // andConditions.push({ typeOf: { $eq: params.typeOf } });
35
- // }
36
- // if (params.startFrom !== undefined) {
37
- // andConditions.push({
38
- // startDate: { $gte: params.startFrom }
39
- // });
40
- // }
41
- // if (params.startThrough !== undefined) {
42
- // andConditions.push({
43
- // startDate: { $lte: params.startThrough }
44
- // });
45
- // }
46
- // if (params.endFrom !== undefined) {
47
- // andConditions.push({
48
- // endDate: {
49
- // $exists: true,
50
- // $gte: params.endFrom
51
- // }
52
- // });
53
- // }
54
- // if (params.endThrough !== undefined) {
55
- // andConditions.push({
56
- // endDate: {
57
- // $exists: true,
58
- // $lt: params.endThrough
59
- // }
60
- // });
61
- // }
62
- // if (Array.isArray(params.ids)) {
63
- // andConditions.push({
64
- // _id: { $in: params.ids }
65
- // });
66
- // }
67
- // if (Array.isArray(params.statuses)) {
68
- // andConditions.push({ status: { $in: params.statuses } });
69
- // }
70
- // const statusIn = params.status?.$in;
71
- // if (Array.isArray(statusIn)) {
72
- // andConditions.push({ status: { $in: statusIn } });
73
- // }
74
- // if (params.agent !== undefined) {
75
- // if (params.agent.typeOf !== undefined) {
76
- // andConditions.push({
77
- // 'agent.typeOf': {
78
- // $exists: true,
79
- // $eq: params.agent.typeOf
80
- // }
81
- // });
82
- // }
83
- // if (Array.isArray(params.agent.ids)) {
84
- // andConditions.push({
85
- // 'agent.id': {
86
- // $exists: true,
87
- // $in: params.agent.ids
88
- // }
89
- // });
90
- // }
91
- // if (Array.isArray(params.agent.identifiers)) {
92
- // andConditions.push({
93
- // 'agent.identifier': {
94
- // $exists: true,
95
- // $in: params.agent.identifiers
96
- // }
97
- // });
98
- // }
99
- // }
100
- // const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
101
- // if (Array.isArray(tasksExportActionStatusIn)) {
102
- // andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
103
- // }
104
- // const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
105
- // if (typeof tasksExportActionStatusEq === 'string') {
106
- // andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
107
- // }
108
- // switch (params.typeOf) {
109
- // case factory.transactionType.PlaceOrder as any:
110
- // throw new factory.errors.NotImplemented(`use PlaceOrderRepo`);
111
- // // const sellerIdIn = params.seller?.ids;
112
- // // if (Array.isArray(sellerIdIn)) {
113
- // // andConditions.push({ 'seller.id': { $exists: true, $in: sellerIdIn } });
114
- // // }
115
- // // const resultOrderNumberIn = params.result?.order?.orderNumbers;
116
- // // if (Array.isArray(resultOrderNumberIn)) {
117
- // // andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
118
- // // }
119
- // // const resultOrderConfirmationNumberEq = params.result?.order?.confirmationNumber?.$eq;
120
- // // if (typeof resultOrderConfirmationNumberEq === 'string') {
121
- // // andConditions.push({
122
- // // 'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
123
- // // });
124
- // // }
125
- // // const objectOrderNumberEq = params.object?.orderNumber?.$eq;
126
- // // if (typeof objectOrderNumberEq === 'string') {
127
- // // andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
128
- // // }
129
- // // break;
130
- // case factory.transactionType.ReturnOrder as any:
131
- // throw new factory.errors.NotImplemented(`use ReturnOrderRepo`);
132
- // // if (params.object !== undefined) {
133
- // // if (params.object.order !== undefined) {
134
- // // if (Array.isArray(params.object.order.orderNumbers)) {
135
- // // andConditions.push({
136
- // // 'object.order.orderNumber': {
137
- // // $exists: true,
138
- // // $in: params.object.order.orderNumbers
139
- // // }
140
- // // });
141
- // // }
142
- // // }
143
- // // }
144
- // // break;
145
- // default:
146
- // }
147
- // return andConditions;
148
- // }
149
- // /**
150
- // * 取引を開始する
151
- // */
152
- // // public async startNoPlaceOrder<
153
- // public async startMoneyTransfer(
154
- // params: factory.transaction.IStartParams<factory.transactionType.MoneyTransfer>
155
- // ): Promise<IStartedTransaction> {
156
- // const status = factory.transactionStatusType.InProgress;
157
- // const tasksExportAction: factory.transaction.ITasksExportAction = { actionStatus: factory.actionStatusType.PotentialActionStatus };
158
- // // const tasksExportationStatus = factory.transactionTasksExportationStatus.Unexported; // discontinue(2024-06-20~)
159
- // const startDate: Date = new Date();
160
- // // let expires: Date;
161
- // const { typeOf } = params;
162
- // // if (typeOf === factory.transactionType.ReturnOrder) {
163
- // // // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
164
- // // if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
165
- // // expires = moment(startDate)
166
- // // .add(params.expiresInSeconds, 'seconds')
167
- // // .toDate();
168
- // // } else {
169
- // // throw new factory.errors.ArgumentNull('expiresInSeconds');
170
- // // }
171
- // // } else {
172
- // // expires = params.expires;
173
- // // }
174
- // const expires = params.expires;
175
- // let creatingTransaction: factory.transaction.IAttributes<factory.transactionType.MoneyTransfer>;
176
- // if (typeOf === factory.transactionType.MoneyTransfer) {
177
- // const { agent, project, object, seller, recipient } = params;
178
- // creatingTransaction = {
179
- // status, startDate, expires, typeOf, tasksExportAction,
180
- // agent, project, seller, object, recipient
181
- // };
182
- // // } else if (typeOf === factory.transactionType.ReturnOrder) {
183
- // // const { agent, project, object, seller } = params;
184
- // // creatingTransaction = {
185
- // // status, startDate, expires, typeOf, tasksExportAction,
186
- // // agent, project, seller, object
187
- // // };
188
- // } else {
189
- // throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
190
- // }
191
- // // reimplemnt with insertMany(2024-05-30~)
192
- // const result = await this.transactionModel.insertMany(
193
- // creatingTransaction,
194
- // { rawResult: true }
195
- // );
196
- // const id = result.insertedIds?.[0]?.toHexString();
197
- // if (typeof id !== 'string') {
198
- // throw new factory.errors.Internal('transaction not saved');
199
- // }
200
- // // 取引開始時にも取引イベントエミッター連携(2024-03-21~)
201
- // transactionEventEmitter.emitTransactionStatusChanged({ id, typeOf, status });
202
- // return { expires, id, startDate, status }; // minimize response(2024-05-30~)
203
- // }
204
- // /**
205
- // * 特定取引検索
206
- // */
207
- // public async findMoneyTransferById(
208
- // params: { typeOf: factory.transactionType.MoneyTransfer; id: string },
209
- // inclusion: IKeyOfProjection[] // make required(2024-05-31~)
210
- // ): Promise<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> {
211
- // let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
212
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
213
- // positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection>key));
214
- // } else {
215
- // throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
216
- // }
217
- // const projection: ProjectionType<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
218
- // _id: 0,
219
- // id: { $toString: '$_id' },
220
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
221
- // };
222
- // // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
223
- // // if (Array.isArray(inclusion) && inclusion.length > 0) {
224
- // // inclusion.forEach((field) => {
225
- // // projection[field] = 1;
226
- // // });
227
- // // } else {
228
- // // projection = {
229
- // // __v: 0,
230
- // // createdAt: 0,
231
- // // updatedAt: 0
232
- // // };
233
- // // }
234
- // const doc = await this.transactionModel.findOne(
235
- // {
236
- // _id: { $eq: params.id },
237
- // typeOf: { $eq: params.typeOf }
238
- // },
239
- // projection
240
- // )
241
- // .lean<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>>() // 2024-08-26~
242
- // .exec();
243
- // if (doc === null) {
244
- // throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} not found`);
245
- // }
246
- // return doc;
247
- // }
248
- // /**
249
- // * 進行中の取引を取得する
250
- // */
251
- // public async findMoneyTransferInProgressById(
252
- // params: {
253
- // typeOf: factory.transactionType.MoneyTransfer;
254
- // id: string;
255
- // },
256
- // inclusion: IKeyOfProjection[] // make required(2024-05-29~)
257
- // ): Promise<IMoneyTransferTransactionInProgress> {
258
- // let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
259
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
260
- // positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection>key));
261
- // } else {
262
- // throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
263
- // }
264
- // const projection: ProjectionType<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
265
- // _id: 0,
266
- // id: { $toString: '$_id' },
267
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
268
- // };
269
- // const filter: FilterQuery<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
270
- // _id: { $eq: params.id },
271
- // typeOf: { $eq: params.typeOf },
272
- // status: { $eq: factory.transactionStatusType.InProgress },
273
- // // expiresを条件に追加(2023-05-12~),
274
- // expires: { $gt: new Date() }
275
- // };
276
- // const doc = await this.transactionModel.findOne(filter, projection)
277
- // .lean<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>>() // 2024-08-26~
278
- // .exec();
279
- // if (doc === null) {
280
- // throw new factory.errors.NotFound(
281
- // this.transactionModel.modelName,
282
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
283
- // );
284
- // }
285
- // return doc;
286
- // }
287
- // /**
288
- // * 進行中の取引を取得する
289
- // */
290
- // public async projectFieldsInProgressById<T extends factory.transactionType.MoneyTransfer>(
291
- // params: {
292
- // typeOf: T;
293
- // id: string;
294
- // },
295
- // inclusion: IKeyOfProjection<T>[] // make required(2024-05-29~)
296
- // ): Promise<ITransactionInProgress<T>> {
297
- // let positiveProjectionFields: (IKeyOfProjection<factory.transactionType.MoneyTransfer>
298
- // | IKeyOfProjection<factory.transactionType.PlaceOrder>
299
- // | IKeyOfProjection<factory.transactionType.ReturnOrder>
300
- // )[] = AVAILABLE_PROJECT_FIELDS;
301
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
302
- // positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection<T>>key));
303
- // } else {
304
- // throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
305
- // }
306
- // const projection: ProjectionType<factory.transaction.ITransaction<T>> = {
307
- // _id: 0,
308
- // id: { $toString: '$_id' },
309
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
310
- // };
311
- // const filter: FilterQuery<factory.transaction.ITransaction<T>> = {
312
- // _id: { $eq: params.id },
313
- // typeOf: { $eq: params.typeOf },
314
- // status: { $eq: factory.transactionStatusType.InProgress },
315
- // // expiresを条件に追加(2023-05-12~),
316
- // expires: { $gt: new Date() }
317
- // };
318
- // const doc = await this.transactionModel.findOne(filter, projection)
319
- // .lean<factory.transaction.ITransaction<T>>() // 2024-08-26~
320
- // .exec();
321
- // if (doc === null) {
322
- // throw new factory.errors.NotFound(
323
- // this.transactionModel.modelName,
324
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
325
- // );
326
- // }
327
- // return doc;
328
- // }
329
- // /**
330
- // * 進行中取引に保管された採用済決済方法を検索する
331
- // */
332
- // public async findInProgressPaymentMethodId(params: {
333
- // id: string;
334
- // }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined> {
335
- // const doc = await this.transactionModel.findOne(
336
- // {
337
- // _id: { $eq: params.id },
338
- // typeOf: { $eq: factory.transactionType.PlaceOrder },
339
- // status: { $eq: factory.transactionStatusType.InProgress }
340
- // },
341
- // { 'object.paymentMethods': 1 }
342
- // )
343
- // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>() // 2024-08-26~
344
- // .exec();
345
- // if (doc === null) {
346
- // throw new factory.errors.NotFound(
347
- // this.transactionModel.modelName,
348
- // `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
349
- // );
350
- // }
351
- // return doc.object.paymentMethods;
352
- // }
353
- // /**
354
- // * 取引の注文番号を検索する
355
- // */
356
- // public async findInProgressOrderNumberById(params: {
357
- // id: string;
358
- // }): Promise<string | undefined> {
359
- // const doc = await this.transactionModel.findOne(
360
- // {
361
- // _id: { $eq: params.id },
362
- // typeOf: { $eq: factory.transactionType.PlaceOrder },
363
- // status: { $eq: factory.transactionStatusType.InProgress }
364
- // },
365
- // { 'object.orderNumber': 1 }
366
- // )
367
- // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
368
- // .exec();
369
- // if (doc === null) {
370
- // throw new factory.errors.NotFound(
371
- // this.transactionModel.modelName,
372
- // `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
373
- // );
374
- // }
375
- // return doc.object.orderNumber;
376
- // }
377
- // /**
378
- // * 取引の確認番号を検索する
379
- // */
380
- // public async findInProgressConfirmationNumberById(params: {
381
- // id: string;
382
- // status: { $in: factory.transactionStatusType[] };
383
- // }): Promise<string | undefined> {
384
- // const doc = await this.transactionModel.findOne(
385
- // {
386
- // _id: { $eq: params.id },
387
- // typeOf: { $eq: factory.transactionType.PlaceOrder },
388
- // status: { $in: params.status.$in }
389
- // },
390
- // { 'object.confirmationNumber': 1 }
391
- // )
392
- // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
393
- // .exec();
394
- // if (doc === null) {
395
- // throw new factory.errors.NotFound(
396
- // this.transactionModel.modelName,
397
- // `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
398
- // );
399
- // }
400
- // return doc.object.confirmationNumber;
401
- // }
402
- // /**
403
- // * 取引進行者プロフィールを更新
404
- // */
405
- // public async updateAgent<T extends factory.transactionType>(params: {
406
- // typeOf: T;
407
- // id: string;
408
- // agent: Pick<factory.transaction.IAgent, 'id'>;
409
- // object?: {
410
- // customer?: factory.order.ICustomer;
411
- // };
412
- // }): Promise<void> {
413
- // const doc = await this.transactionModel.findOneAndUpdate(
414
- // {
415
- // _id: { $eq: params.id },
416
- // typeOf: { $eq: params.typeOf },
417
- // status: { $eq: factory.transactionStatusType.InProgress }
418
- // },
419
- // {
420
- // $set: {
421
- // 'agent.id': params.agent.id,
422
- // // ...(typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined,
423
- // ...(typeof params.object?.customer?.typeOf === 'string') ? { 'object.customer': params.object.customer } : undefined
424
- // }
425
- // },
426
- // {
427
- // projection: { _id: 1 }
428
- // }
429
- // )
430
- // .lean<{ _id: ObjectId }>()
431
- // .exec();
432
- // if (doc === null) {
433
- // throw new factory.errors.NotFound(
434
- // this.transactionModel.modelName,
435
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
436
- // );
437
- // }
438
- // }
439
- // /**
440
- // * 取引期限変更
441
- // */
442
- // public async updateExpires<T extends factory.transactionType>(params: {
443
- // typeOf: T;
444
- // id: string;
445
- // expires: Date;
446
- // }): Promise<void> {
447
- // const doc = await this.transactionModel.findOneAndUpdate(
448
- // {
449
- // _id: { $eq: params.id },
450
- // typeOf: { $eq: params.typeOf },
451
- // status: { $eq: factory.transactionStatusType.InProgress }
452
- // },
453
- // {
454
- // $set: {
455
- // expires: params.expires
456
- // }
457
- // },
458
- // {
459
- // projection: { _id: 1 }
460
- // }
461
- // )
462
- // .lean<{ _id: ObjectId }>()
463
- // .exec();
464
- // if (doc === null) {
465
- // throw new factory.errors.NotFound(
466
- // this.transactionModel.modelName,
467
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
468
- // );
469
- // }
470
- // }
471
- // /**
472
- // * 取引オブジェクトを更新
473
- // * 注文名称など
474
- // */
475
- // public async updateObject<T extends factory.transactionType>(params: {
476
- // typeOf: T;
477
- // id: string;
478
- // object?: {
479
- // name?: string;
480
- // };
481
- // }): Promise<void> {
482
- // const doc = await this.transactionModel.findOneAndUpdate(
483
- // {
484
- // _id: { $eq: params.id },
485
- // typeOf: { $eq: params.typeOf },
486
- // status: { $eq: factory.transactionStatusType.InProgress }
487
- // },
488
- // {
489
- // $set: {
490
- // ...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
491
- // }
492
- // },
493
- // {
494
- // projection: { _id: 1 }
495
- // }
496
- // )
497
- // .lean<{ _id: ObjectId }>()
498
- // .exec();
499
- // if (doc === null) {
500
- // throw new factory.errors.NotFound(
501
- // this.transactionModel.modelName,
502
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
503
- // );
504
- // }
505
- // }
506
- // /**
507
- // * 取引を確定する
508
- // */
509
- // // public async confirmNoPlaceOrder<
510
- // public async confirmMoneyTransfer(params: {
511
- // typeOf: factory.transactionType.MoneyTransfer;
512
- // id: string;
513
- // result: factory.transaction.IResult<factory.transactionType.MoneyTransfer>;
514
- // potentialActions: factory.transaction.IPotentialActions<factory.transactionType.MoneyTransfer>;
515
- // }): Promise<void> {
516
- // const endDate = new Date();
517
- // const doc = await this.transactionModel.findOneAndUpdate(
518
- // {
519
- // _id: { $eq: params.id },
520
- // typeOf: { $eq: params.typeOf },
521
- // status: { $eq: factory.transactionStatusType.InProgress },
522
- // expires: { $gt: endDate } // add expires(2025-02-27~)
523
- // },
524
- // {
525
- // status: factory.transactionStatusType.Confirmed, // ステータス変更
526
- // endDate,
527
- // // 'object.authorizeActions': params.authorizeActions,
528
- // result: params.result, // resultを更新
529
- // potentialActions: params.potentialActions // resultを更新
530
- // },
531
- // {
532
- // new: true,
533
- // projection: { _id: 1 }
534
- // }
535
- // )
536
- // .lean<{ _id: ObjectId }>()
537
- // .exec();
538
- // // NotFoundであれば取引状態確認
539
- // if (doc === null) {
540
- // const { expires, status } = <Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'expires' | 'status'>>
541
- // await this.findMoneyTransferById({ typeOf: params.typeOf, id: params.id }, ['expires', 'status']);
542
- // if (status === factory.transactionStatusType.Confirmed) {
543
- // // すでに確定済の場合スルー
544
- // } else if (status === factory.transactionStatusType.Expired) {
545
- // throw new factory.errors.Argument('Transaction id', 'Already expired');
546
- // } else if (status === factory.transactionStatusType.Canceled) {
547
- // throw new factory.errors.Argument('Transaction id', 'Already canceled');
548
- // } else {
549
- // if (moment(expires)
550
- // .isSameOrBefore(moment(endDate))) {
551
- // throw new factory.errors.Argument('Transaction id', 'potentially expired');
552
- // }
553
- // throw new factory.errors.NotFound(
554
- // this.transactionModel.modelName,
555
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
556
- // );
557
- // }
558
- // }
559
- // transactionEventEmitter.emitTransactionStatusChanged({
560
- // id: params.id,
561
- // typeOf: params.typeOf,
562
- // status: factory.transactionStatusType.Confirmed
563
- // });
564
- // }
565
20
  async countPotentiallyExportTasks(params) {
566
21
  const { endDate, limit } = params;
567
22
  const endDateLt = endDate?.$lt;
@@ -646,56 +101,6 @@ class TransactionRepo {
646
101
  .exec()
647
102
  .then((doc) => (doc === null) ? null : doc);
648
103
  }
649
- // discontinue(2025-03-10~)
650
- // public async reexportTasksByExportAction(params: {
651
- // intervalInMinutes: number;
652
- // limit: number;
653
- // }): Promise<void> {
654
- // const reexportingTransactions: Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'status' | 'typeOf'>[] =
655
- // await this.transactionModel.find(
656
- // {
657
- // 'tasksExportAction.actionStatus': {
658
- // $exists: true,
659
- // $eq: factory.actionStatusType.ActiveActionStatus
660
- // },
661
- // 'tasksExportAction.startDate': {
662
- // $exists: true,
663
- // $lt: moment()
664
- // .add(-params.intervalInMinutes, 'minutes')
665
- // .toDate()
666
- // }
667
- // },
668
- // { _id: 1, typeOf: 1, status: 1 }
669
- // )
670
- // .limit(params.limit)
671
- // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
672
- // .exec();
673
- // if (reexportingTransactions.length > 0) {
674
- // for (const reexportingTransaction of reexportingTransactions) {
675
- // await this.transactionModel.updateOne(
676
- // {
677
- // _id: { $eq: reexportingTransaction.id },
678
- // 'tasksExportAction.actionStatus': {
679
- // $exists: true,
680
- // $eq: factory.actionStatusType.ActiveActionStatus
681
- // }
682
- // },
683
- // {
684
- // tasksExportAction: {
685
- // actionStatus: factory.actionStatusType.PotentialActionStatus
686
- // }
687
- // // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
688
- // }
689
- // )
690
- // .exec();
691
- // transactionEventEmitter.emitTransactionStatusChanged({
692
- // id: reexportingTransaction.id,
693
- // typeOf: reexportingTransaction.typeOf,
694
- // status: reexportingTransaction.status
695
- // });
696
- // }
697
- // }
698
- // }
699
104
  /**
700
105
  * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
701
106
  * PotentialActionStatusに変更する
@@ -884,187 +289,6 @@ class TransactionRepo {
884
289
  }
885
290
  return expiringTransactions;
886
291
  }
887
- // /**
888
- // * 取引を中止する
889
- // */
890
- // public async cancelMoneyTransfer(params: {
891
- // typeOf: factory.transactionType.MoneyTransfer;
892
- // id: string;
893
- // }): Promise<void> {
894
- // const endDate = new Date();
895
- // // 進行中ステータスの取引を中止する
896
- // const doc = await this.transactionModel.findOneAndUpdate(
897
- // {
898
- // typeOf: params.typeOf,
899
- // _id: params.id,
900
- // status: factory.transactionStatusType.InProgress
901
- // },
902
- // {
903
- // status: factory.transactionStatusType.Canceled,
904
- // endDate: endDate
905
- // },
906
- // {
907
- // new: true,
908
- // projection: { _id: 1 }
909
- // }
910
- // )
911
- // .lean<{ _id: ObjectId }>()
912
- // .exec();
913
- // // NotFoundであれば取引状態確認
914
- // if (doc === null) {
915
- // const { status } = <Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'status'>>
916
- // await this.findMoneyTransferById(params, ['status']);
917
- // if (status === factory.transactionStatusType.Canceled) {
918
- // // すでに中止済の場合スルー
919
- // } else if (status === factory.transactionStatusType.Expired) {
920
- // throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
921
- // } else if (status === factory.transactionStatusType.Confirmed) {
922
- // throw new factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
923
- // } else {
924
- // throw new factory.errors.NotFound(
925
- // this.transactionModel.modelName,
926
- // `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
927
- // );
928
- // }
929
- // }
930
- // transactionEventEmitter.emitTransactionStatusChanged({
931
- // id: params.id,
932
- // typeOf: params.typeOf,
933
- // status: factory.transactionStatusType.Canceled
934
- // });
935
- // }
936
- // public async countMoneyTransfer<
937
- // // T extends factory.transactionType
938
- // T extends factory.transactionType.MoneyTransfer
939
- // >(params: factory.transaction.ISearchConditions<T>): Promise<{ count: number }> {
940
- // const { limit } = params;
941
- // const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
942
- // const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
943
- // if (typeof limit === 'number' && limit >= 0) {
944
- // query.limit(limit);
945
- // }
946
- // const count = await query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
947
- // .exec();
948
- // return { count };
949
- // }
950
- // /**
951
- // * 取引を検索する
952
- // */
953
- // public async findMoneyTransferTransactions<
954
- // // T extends factory.transactionType,
955
- // T extends factory.transactionType.MoneyTransfer,
956
- // F extends IKeyOfProjection
957
- // >(
958
- // params: factory.transaction.ISearchConditions<T> & {
959
- // inclusion: F[];
960
- // }
961
- // ): Promise<(Pick<factory.transaction.ITransaction<T>, F> & { id: string })[]> {
962
- // const { inclusion } = params;
963
- // const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
964
- // let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
965
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
966
- // positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<F>key));
967
- // }
968
- // const projection: ProjectionType<factory.transaction.ITransaction<T>> = {
969
- // _id: 0,
970
- // id: { $toString: '$_id' },
971
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
972
- // };
973
- // // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
974
- // // if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
975
- // // params.inclusion.forEach((field) => {
976
- // // projection[field] = 1;
977
- // // });
978
- // // } else {
979
- // // projection = {
980
- // // __v: 0,
981
- // // createdAt: 0,
982
- // // updatedAt: 0
983
- // // };
984
- // // }
985
- // const query = this.transactionModel.find(
986
- // (conditions.length > 0) ? { $and: conditions } : {}
987
- // )
988
- // .select(projection);
989
- // if (typeof params.limit === 'number' && params.limit > 0) {
990
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
991
- // query.limit(params.limit)
992
- // .skip(params.limit * (page - 1));
993
- // }
994
- // if (params.sort?.startDate !== undefined) {
995
- // query.sort({ startDate: params.sort.startDate });
996
- // }
997
- // // const explainResult = await (<any>query).explain();
998
- // // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
999
- // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
1000
- // .lean<(Pick<factory.transaction.ITransaction<T>, F> & { id: string })[]>()
1001
- // .exec();
1002
- // }
1003
- // /**
1004
- // * 特定の進行中取引を更新する(汎用)
1005
- // */
1006
- // public async findByIdAndUpdateInProgress(params: {
1007
- // id: string;
1008
- // update: {
1009
- // $set?: { 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl };
1010
- // // $unset?: any;
1011
- // // $pull?: any;
1012
- // // $push?: any;
1013
- // };
1014
- // }): Promise<void> {
1015
- // await this.transactionModel.findOneAndUpdate(
1016
- // {
1017
- // _id: { $eq: params.id },
1018
- // status: { $eq: factory.transactionStatusType.InProgress }
1019
- // },
1020
- // params.update,
1021
- // {
1022
- // // new: true,
1023
- // projection: { _id: 1 }
1024
- // }
1025
- // )
1026
- // .lean<{ _id: ObjectId }>()
1027
- // .exec()
1028
- // .then((doc) => {
1029
- // if (doc === null) {
1030
- // throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
1031
- // }
1032
- // });
1033
- // }
1034
- // /**
1035
- // * 進行中取引のobjectに注文番号を保管する
1036
- // */
1037
- // public async saveOrderNumberIfNotExist(params: {
1038
- // id: string;
1039
- // orderNumber: string;
1040
- // }): Promise<{ modifiedCount: number }> {
1041
- // const result = await this.transactionModel.updateOne(
1042
- // {
1043
- // _id: { $eq: params.id },
1044
- // status: { $eq: factory.transactionStatusType.InProgress },
1045
- // 'object.orderNumber': { $exists: false }
1046
- // },
1047
- // { $set: { 'object.orderNumber': params.orderNumber } }
1048
- // )
1049
- // .exec();
1050
- // return { modifiedCount: result.modifiedCount };
1051
- // }
1052
- // public async saveConfirmationNumberIfNotExist(params: {
1053
- // id: string;
1054
- // status: { $in: factory.transactionStatusType[] };
1055
- // confirmationNumber: string;
1056
- // }): Promise<void> {
1057
- // await this.transactionModel.updateOne(
1058
- // {
1059
- // _id: { $eq: params.id },
1060
- // // status: { $eq: factory.transactionStatusType.InProgress },
1061
- // status: { $in: params.status.$in },
1062
- // 'object.confirmationNumber': { $exists: false }
1063
- // },
1064
- // { $set: { 'object.confirmationNumber': params.confirmationNumber } }
1065
- // )
1066
- // .exec();
1067
- // }
1068
292
  async findByIdAndDelete(params) {
1069
293
  await this.transactionModel.findByIdAndDelete(params.id)
1070
294
  .exec();