@chevre/domain 23.2.0-alpha.61 → 23.2.0-alpha.62

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 (476) hide show
  1. package/lib/chevre/credentials/customSearch.js +2 -0
  2. package/lib/chevre/credentials/lineNotify.js +4 -0
  3. package/lib/chevre/credentials/sendGrid.js +2 -0
  4. package/lib/chevre/credentials.js +15 -30
  5. package/lib/chevre/emailMessageBuilder.js +225 -250
  6. package/lib/chevre/errorHandler.js +38 -54
  7. package/lib/chevre/factory/event.js +69 -42
  8. package/lib/chevre/factory/transactionNumber.js +2 -0
  9. package/lib/chevre/index.js +15 -30
  10. package/lib/chevre/repo/acceptedOffer.js +178 -197
  11. package/lib/chevre/repo/acceptedPaymentMethod.js +131 -143
  12. package/lib/chevre/repo/account.js +196 -223
  13. package/lib/chevre/repo/accountTitle.js +9 -21
  14. package/lib/chevre/repo/accountTransaction.js +189 -189
  15. package/lib/chevre/repo/accountingReport.js +88 -107
  16. package/lib/chevre/repo/action.js +853 -880
  17. package/lib/chevre/repo/additionalProperty.js +65 -91
  18. package/lib/chevre/repo/advanceBookingRequirement.js +69 -90
  19. package/lib/chevre/repo/aggregateOffer.js +394 -427
  20. package/lib/chevre/repo/aggregateOrder.js +50 -62
  21. package/lib/chevre/repo/aggregateReservation.js +76 -89
  22. package/lib/chevre/repo/aggregation.js +42 -63
  23. package/lib/chevre/repo/assetTransaction.js +696 -716
  24. package/lib/chevre/repo/authorization.js +115 -127
  25. package/lib/chevre/repo/categoryCode.js +115 -143
  26. package/lib/chevre/repo/comment.js +74 -82
  27. package/lib/chevre/repo/concurrentLock.js +17 -29
  28. package/lib/chevre/repo/confirmationNumber.js +20 -32
  29. package/lib/chevre/repo/creativeWork.js +154 -176
  30. package/lib/chevre/repo/credentials.js +40 -51
  31. package/lib/chevre/repo/customer.js +65 -88
  32. package/lib/chevre/repo/customerType.js +52 -61
  33. package/lib/chevre/repo/emailMessage.js +52 -80
  34. package/lib/chevre/repo/event.js +646 -669
  35. package/lib/chevre/repo/eventOffer.js +122 -125
  36. package/lib/chevre/repo/eventSellerMakesOffer.js +64 -76
  37. package/lib/chevre/repo/eventSeries.js +208 -231
  38. package/lib/chevre/repo/identity.js +94 -106
  39. package/lib/chevre/repo/identityProvider.js +72 -95
  40. package/lib/chevre/repo/issuer.js +102 -135
  41. package/lib/chevre/repo/member.js +238 -258
  42. package/lib/chevre/repo/memberProgram.js +157 -177
  43. package/lib/chevre/repo/merchantReturnPolicy.js +62 -93
  44. package/lib/chevre/repo/message.js +122 -135
  45. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +1 -1
  46. package/lib/chevre/repo/mongoose/schemas/account.js +1 -1
  47. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -1
  48. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +1 -1
  52. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -1
  53. package/lib/chevre/repo/mongoose/schemas/advanceBookingRequirement.js +1 -1
  54. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +1 -1
  55. package/lib/chevre/repo/mongoose/schemas/aggregateOrder.js +1 -1
  56. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
  57. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -1
  58. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -1
  59. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  60. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -1
  61. package/lib/chevre/repo/mongoose/schemas/civicStructure.js +1 -1
  62. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -1
  63. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -1
  64. package/lib/chevre/repo/mongoose/schemas/customerType.js +1 -1
  65. package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
  66. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +1 -1
  67. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +1 -1
  68. package/lib/chevre/repo/mongoose/schemas/identity.js +1 -1
  69. package/lib/chevre/repo/mongoose/schemas/identityProvider.js +1 -1
  70. package/lib/chevre/repo/mongoose/schemas/issuer.js +1 -1
  71. package/lib/chevre/repo/mongoose/schemas/member/global.js +1 -1
  72. package/lib/chevre/repo/mongoose/schemas/member.js +1 -1
  73. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -1
  74. package/lib/chevre/repo/mongoose/schemas/message.js +1 -1
  75. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +1 -1
  76. package/lib/chevre/repo/mongoose/schemas/note.js +1 -1
  77. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -1
  78. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
  79. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +1 -1
  80. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  81. package/lib/chevre/repo/mongoose/schemas/paymentService.js +1 -1
  82. package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.js +1 -1
  83. package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +1 -1
  84. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +1 -1
  85. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  86. package/lib/chevre/repo/mongoose/schemas/potentialAction.js +1 -1
  87. package/lib/chevre/repo/mongoose/schemas/product.js +1 -1
  88. package/lib/chevre/repo/mongoose/schemas/productModel.js +1 -1
  89. package/lib/chevre/repo/mongoose/schemas/productOffer.js +1 -1
  90. package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
  91. package/lib/chevre/repo/mongoose/schemas/reserveInterface.js +1 -1
  92. package/lib/chevre/repo/mongoose/schemas/role.js +1 -1
  93. package/lib/chevre/repo/mongoose/schemas/schedule.js +1 -1
  94. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -1
  95. package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +1 -1
  96. package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +1 -1
  97. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -1
  98. package/lib/chevre/repo/mongoose/schemas/task.js +1 -1
  99. package/lib/chevre/repo/mongoose/schemas/ticket.js +1 -1
  100. package/lib/chevre/repo/mongoose/schemas/transaction.js +1 -1
  101. package/lib/chevre/repo/mongoose/schemas/transactionNumber.js +1 -1
  102. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -1
  103. package/lib/chevre/repo/mongoose/schemas/webSite.js +1 -1
  104. package/lib/chevre/repo/movieTicketType.js +68 -89
  105. package/lib/chevre/repo/note.js +143 -146
  106. package/lib/chevre/repo/noteAboutOrder.js +112 -113
  107. package/lib/chevre/repo/offer/unitPriceInCatalog.js +331 -313
  108. package/lib/chevre/repo/offerCatalog.js +302 -333
  109. package/lib/chevre/repo/offerCatalogItem.js +289 -316
  110. package/lib/chevre/repo/offerItemCondition.js +60 -85
  111. package/lib/chevre/repo/order.js +563 -572
  112. package/lib/chevre/repo/orderInTransaction.js +113 -136
  113. package/lib/chevre/repo/orderNumber.js +99 -112
  114. package/lib/chevre/repo/ownershipInfo.js +213 -233
  115. package/lib/chevre/repo/passport.js +94 -102
  116. package/lib/chevre/repo/paymentMethod/creditCard.js +153 -169
  117. package/lib/chevre/repo/paymentService.js +180 -199
  118. package/lib/chevre/repo/paymentServiceChannel.js +76 -99
  119. package/lib/chevre/repo/paymentServiceProvider.js +186 -201
  120. package/lib/chevre/repo/pendingReservation.js +275 -305
  121. package/lib/chevre/repo/permit.js +47 -42
  122. package/lib/chevre/repo/person.js +227 -247
  123. package/lib/chevre/repo/place/busStop.js +77 -103
  124. package/lib/chevre/repo/place/entranceGate.js +123 -128
  125. package/lib/chevre/repo/place/hasPOS.js +108 -120
  126. package/lib/chevre/repo/place/movieTheater.js +187 -219
  127. package/lib/chevre/repo/place/screeningRoom.js +340 -324
  128. package/lib/chevre/repo/place/seat.js +539 -475
  129. package/lib/chevre/repo/place/section.js +329 -292
  130. package/lib/chevre/repo/potentialAction.js +67 -86
  131. package/lib/chevre/repo/priceSpecification.js +103 -141
  132. package/lib/chevre/repo/product.js +204 -238
  133. package/lib/chevre/repo/productHasOfferCatalog.js +39 -50
  134. package/lib/chevre/repo/productModel.js +94 -126
  135. package/lib/chevre/repo/productOffer.js +119 -118
  136. package/lib/chevre/repo/project.js +123 -141
  137. package/lib/chevre/repo/projectMakesOffer.js +96 -108
  138. package/lib/chevre/repo/rateLimit/offer.js +43 -56
  139. package/lib/chevre/repo/reservation.js +370 -345
  140. package/lib/chevre/repo/reserveInterface.js +31 -42
  141. package/lib/chevre/repo/role.js +94 -112
  142. package/lib/chevre/repo/schedule.js +25 -36
  143. package/lib/chevre/repo/seller.js +115 -145
  144. package/lib/chevre/repo/sellerMakesOffer.js +95 -110
  145. package/lib/chevre/repo/sellerPaymentAccepted.js +92 -109
  146. package/lib/chevre/repo/sellerReturnPolicy.js +74 -96
  147. package/lib/chevre/repo/service/availableHour.js +27 -38
  148. package/lib/chevre/repo/serviceOutput.js +55 -66
  149. package/lib/chevre/repo/serviceOutputIdentifier.js +46 -57
  150. package/lib/chevre/repo/setting/jwt.js +40 -50
  151. package/lib/chevre/repo/setting.js +48 -48
  152. package/lib/chevre/repo/stockHolder.js +179 -197
  153. package/lib/chevre/repo/task.js +615 -617
  154. package/lib/chevre/repo/telemetry.js +1 -0
  155. package/lib/chevre/repo/ticket.js +52 -65
  156. package/lib/chevre/repo/transaction.js +758 -795
  157. package/lib/chevre/repo/transactionNumber.js +67 -80
  158. package/lib/chevre/repo/transactionNumberCounter.js +69 -79
  159. package/lib/chevre/repo/transactionProcess.js +36 -47
  160. package/lib/chevre/repo/trip.js +145 -163
  161. package/lib/chevre/repo/webSite.js +90 -105
  162. package/lib/chevre/repository.js +455 -646
  163. package/lib/chevre/service/account.js +9 -18
  164. package/lib/chevre/service/accountTransaction/deposit.js +16 -17
  165. package/lib/chevre/service/accountTransaction/transfer.js +18 -19
  166. package/lib/chevre/service/accountTransaction/withdraw.js +16 -17
  167. package/lib/chevre/service/accountTransaction.js +4 -13
  168. package/lib/chevre/service/aggregation/event/aggregateOffers.js +63 -60
  169. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +52 -55
  170. package/lib/chevre/service/aggregation/event/findEventOffers.js +7 -17
  171. package/lib/chevre/service/aggregation/event/importFromCOA.js +4 -13
  172. package/lib/chevre/service/aggregation/project.js +10 -19
  173. package/lib/chevre/service/aggregation/system.js +182 -99
  174. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +31 -17
  175. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +17 -23
  176. package/lib/chevre/service/assetTransaction/cancelReservation/startAndConfirm.js +17 -15
  177. package/lib/chevre/service/assetTransaction/cancelReservation.js +7 -16
  178. package/lib/chevre/service/assetTransaction/cancelReservationCOA/factory.js +11 -4
  179. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +4 -13
  180. package/lib/chevre/service/assetTransaction/fixInformAction.js +6 -16
  181. package/lib/chevre/service/assetTransaction/moneyTransfer/potentialActions.js +13 -25
  182. package/lib/chevre/service/assetTransaction/moneyTransfer.js +101 -88
  183. package/lib/chevre/service/assetTransaction/pay/cancel.js +3 -12
  184. package/lib/chevre/service/assetTransaction/pay/check.js +4 -14
  185. package/lib/chevre/service/assetTransaction/pay/confirm.js +18 -21
  186. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +4 -13
  187. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +33 -32
  188. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +7 -17
  189. package/lib/chevre/service/assetTransaction/pay/start/account/validation.js +6 -16
  190. package/lib/chevre/service/assetTransaction/pay/start/factory.js +64 -36
  191. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.js +7 -17
  192. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +6 -16
  193. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +7 -17
  194. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +9 -15
  195. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +3 -12
  196. package/lib/chevre/service/assetTransaction/pay/start.js +29 -35
  197. package/lib/chevre/service/assetTransaction/refund/factory.js +36 -16
  198. package/lib/chevre/service/assetTransaction/refund/potentialActions.js +12 -21
  199. package/lib/chevre/service/assetTransaction/refund.js +35 -39
  200. package/lib/chevre/service/assetTransaction/registerService/factory.js +65 -28
  201. package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +50 -41
  202. package/lib/chevre/service/assetTransaction/registerService.js +45 -52
  203. package/lib/chevre/service/assetTransaction/reserve/cancel.js +5 -14
  204. package/lib/chevre/service/assetTransaction/reserve/confirm/factory.js +15 -3
  205. package/lib/chevre/service/assetTransaction/reserve/confirm.js +21 -26
  206. package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +3 -12
  207. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +99 -79
  208. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +17 -12
  209. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +108 -70
  210. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +69 -30
  211. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.js +29 -20
  212. package/lib/chevre/service/assetTransaction/reserve/start.js +91 -106
  213. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +5 -15
  214. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +41 -54
  215. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +42 -55
  216. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +7 -17
  217. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +15 -27
  218. package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +24 -24
  219. package/lib/chevre/service/assetTransaction/reserveCOA/factory.js +12 -4
  220. package/lib/chevre/service/assetTransaction/reserveCOA.js +4 -13
  221. package/lib/chevre/service/assetTransaction.js +17 -21
  222. package/lib/chevre/service/delivery/factory.js +3 -4
  223. package/lib/chevre/service/delivery/product/factory.js +16 -7
  224. package/lib/chevre/service/delivery/reservation/factory.js +14 -3
  225. package/lib/chevre/service/delivery.js +47 -49
  226. package/lib/chevre/service/event/processUpdateMovieTheater.js +21 -23
  227. package/lib/chevre/service/event/saveScreeningEventSeries.js +56 -37
  228. package/lib/chevre/service/event/saveScreeningEvents.js +14 -23
  229. package/lib/chevre/service/event.js +34 -27
  230. package/lib/chevre/service/iam.js +8 -17
  231. package/lib/chevre/service/moneyTransfer.js +128 -112
  232. package/lib/chevre/service/notification/factory.js +11 -8
  233. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +11 -15
  234. package/lib/chevre/service/notification/notifyByEmail.js +7 -17
  235. package/lib/chevre/service/notification/sendEmailMessage.js +23 -26
  236. package/lib/chevre/service/notification/triggerWebhook.js +58 -54
  237. package/lib/chevre/service/offer/any.js +6 -15
  238. package/lib/chevre/service/offer/event/authorize/factory.js +139 -61
  239. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +8 -18
  240. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +43 -27
  241. package/lib/chevre/service/offer/event/authorize.js +114 -68
  242. package/lib/chevre/service/offer/event/checkAvailability.js +5 -15
  243. package/lib/chevre/service/offer/event/importFromCOA/factory.js +9 -2
  244. package/lib/chevre/service/offer/event/importFromCOA.js +13 -19
  245. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +38 -39
  246. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +26 -38
  247. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +11 -22
  248. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +13 -24
  249. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +15 -22
  250. package/lib/chevre/service/offer/event/searchOffersByIds.js +24 -36
  251. package/lib/chevre/service/offer/event/searchPriceSpecs4event.js +5 -14
  252. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +4 -13
  253. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +6 -15
  254. package/lib/chevre/service/offer/event/voidTransaction.js +35 -39
  255. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +14 -20
  256. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +52 -40
  257. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +5 -1
  258. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +34 -37
  259. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +45 -22
  260. package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +67 -59
  261. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +16 -26
  262. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +8 -18
  263. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +42 -41
  264. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +22 -25
  265. package/lib/chevre/service/offer/factory.js +18 -7
  266. package/lib/chevre/service/offer/moneyTransfer/authorize.js +31 -36
  267. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +9 -18
  268. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +10 -19
  269. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +14 -24
  270. package/lib/chevre/service/offer/onEventChanged.js +69 -64
  271. package/lib/chevre/service/offer/product/factory.js +54 -29
  272. package/lib/chevre/service/offer/product/searchProductOffers.js +30 -23
  273. package/lib/chevre/service/offer/product.js +106 -80
  274. package/lib/chevre/service/offer.js +48 -44
  275. package/lib/chevre/service/order/confirmPayTransaction.js +28 -27
  276. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +54 -41
  277. package/lib/chevre/service/order/deleteOrder.js +28 -35
  278. package/lib/chevre/service/order/findPlaceOrderTransaction.js +3 -12
  279. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +64 -68
  280. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +1 -2
  281. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +3 -12
  282. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +11 -6
  283. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +5 -14
  284. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +22 -9
  285. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +5 -14
  286. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +23 -26
  287. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +13 -19
  288. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +5 -14
  289. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +24 -13
  290. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +23 -32
  291. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +8 -18
  292. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +10 -9
  293. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +23 -28
  294. package/lib/chevre/service/order/onOrderUpdated/factory.js +3 -5
  295. package/lib/chevre/service/order/onOrderUpdated.js +13 -15
  296. package/lib/chevre/service/order/payOrder.js +3 -12
  297. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +9 -19
  298. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +31 -15
  299. package/lib/chevre/service/order/placeOrder/factory.js +35 -22
  300. package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.js +3 -12
  301. package/lib/chevre/service/order/placeOrder.js +12 -22
  302. package/lib/chevre/service/order/placeOrderWithoutTransaction.js +10 -18
  303. package/lib/chevre/service/order/returnOrder.js +27 -29
  304. package/lib/chevre/service/order/sendOrder.js +37 -36
  305. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +19 -25
  306. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +24 -37
  307. package/lib/chevre/service/payment/any/factory.js +106 -49
  308. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -13
  309. package/lib/chevre/service/payment/any/onPayActionCompleted.js +13 -18
  310. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +34 -37
  311. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +18 -24
  312. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +16 -16
  313. package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +15 -20
  314. package/lib/chevre/service/payment/any/person2username.js +33 -45
  315. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +8 -18
  316. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +5 -15
  317. package/lib/chevre/service/payment/any.js +181 -137
  318. package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.js +2 -2
  319. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +44 -24
  320. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +6 -15
  321. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.js +5 -1
  322. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.js +10 -2
  323. package/lib/chevre/service/payment/creditCard/authorize.js +20 -22
  324. package/lib/chevre/service/payment/creditCard/factory.js +22 -4
  325. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +8 -18
  326. package/lib/chevre/service/payment/creditCard/payCreditCard.js +31 -36
  327. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +40 -49
  328. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +33 -45
  329. package/lib/chevre/service/payment/creditCard/voidTransaction.js +15 -25
  330. package/lib/chevre/service/payment/faceToFace.js +14 -23
  331. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +44 -25
  332. package/lib/chevre/service/payment/factory.js +50 -23
  333. package/lib/chevre/service/payment/movieTicket/authorize.js +35 -28
  334. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +22 -25
  335. package/lib/chevre/service/payment/movieTicket/factory.js +33 -10
  336. package/lib/chevre/service/payment/movieTicket/getCredentials.js +5 -15
  337. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +29 -40
  338. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +8 -18
  339. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +60 -59
  340. package/lib/chevre/service/payment/movieTicket/validation.js +41 -36
  341. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +8 -18
  342. package/lib/chevre/service/payment/paymentCard.js +87 -103
  343. package/lib/chevre/service/permit.js +36 -35
  344. package/lib/chevre/service/product.js +23 -27
  345. package/lib/chevre/service/project.js +22 -31
  346. package/lib/chevre/service/report/ownershipInfo.js +3 -4
  347. package/lib/chevre/service/report/telemetry.js +51 -55
  348. package/lib/chevre/service/reserve/cancelReservation.js +92 -90
  349. package/lib/chevre/service/reserve/checkInReservation.js +24 -29
  350. package/lib/chevre/service/reserve/confirmReservation.js +33 -38
  351. package/lib/chevre/service/reserve/factory.js +42 -20
  352. package/lib/chevre/service/reserve/findByCode.js +13 -18
  353. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +18 -24
  354. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +17 -24
  355. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +38 -29
  356. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +45 -35
  357. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +37 -32
  358. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +17 -23
  359. package/lib/chevre/service/reserve/searchByOrder.js +10 -19
  360. package/lib/chevre/service/reserve/useReservation.js +47 -32
  361. package/lib/chevre/service/reserve/verifyToken4reservation.js +7 -14
  362. package/lib/chevre/service/reserveCOA/cancelReservation.js +7 -16
  363. package/lib/chevre/service/reserveCOA/factory.js +5 -1
  364. package/lib/chevre/service/task/acceptCOAOffer.js +20 -24
  365. package/lib/chevre/service/task/aggregateOffers.js +3 -12
  366. package/lib/chevre/service/task/aggregateOnSystem.js +4 -14
  367. package/lib/chevre/service/task/aggregateScreeningEvent.js +3 -12
  368. package/lib/chevre/service/task/authorizePayment.js +9 -15
  369. package/lib/chevre/service/task/cancelMoneyTransfer.js +3 -12
  370. package/lib/chevre/service/task/cancelPendingReservation.js +10 -20
  371. package/lib/chevre/service/task/cancelReservation.js +3 -12
  372. package/lib/chevre/service/task/checkMovieTicket.js +16 -19
  373. package/lib/chevre/service/task/checkResource.js +7 -16
  374. package/lib/chevre/service/task/confirmMoneyTransfer.js +3 -12
  375. package/lib/chevre/service/task/confirmPayTransaction.js +6 -12
  376. package/lib/chevre/service/task/confirmRegisterService.js +3 -12
  377. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +24 -31
  378. package/lib/chevre/service/task/confirmReserveTransaction.js +48 -42
  379. package/lib/chevre/service/task/createAccountingReport.js +14 -20
  380. package/lib/chevre/service/task/deletePerson.js +48 -58
  381. package/lib/chevre/service/task/deleteTransaction.js +3 -12
  382. package/lib/chevre/service/task/givePointAward.js +3 -12
  383. package/lib/chevre/service/task/handleNotification.js +4 -14
  384. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +6 -16
  385. package/lib/chevre/service/task/importEventsFromCOA.js +6 -16
  386. package/lib/chevre/service/task/importOffersFromCOA.js +8 -18
  387. package/lib/chevre/service/task/invalidatePaymentUrl.js +6 -12
  388. package/lib/chevre/service/task/moneyTransfer.js +3 -12
  389. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +3 -12
  390. package/lib/chevre/service/task/onAuthorizationCreated.js +11 -18
  391. package/lib/chevre/service/task/onEventChanged.js +3 -12
  392. package/lib/chevre/service/task/onOrderPaymentCompleted.js +3 -12
  393. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +7 -16
  394. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +7 -16
  395. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +8 -17
  396. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +10 -19
  397. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +8 -17
  398. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +6 -15
  399. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +14 -23
  400. package/lib/chevre/service/task/onResourceDeleted.js +17 -26
  401. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +9 -21
  402. package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +3 -12
  403. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +11 -23
  404. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +13 -25
  405. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +9 -15
  406. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +21 -27
  407. package/lib/chevre/service/task/onResourceUpdated.js +113 -153
  408. package/lib/chevre/service/task/pay.js +8 -16
  409. package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.js +4 -14
  410. package/lib/chevre/service/task/payment/payByTask.js +49 -38
  411. package/lib/chevre/service/task/payment/refundByTask.js +7 -17
  412. package/lib/chevre/service/task/payment/voidPaymentByTask.js +6 -15
  413. package/lib/chevre/service/task/placeOrder.js +6 -12
  414. package/lib/chevre/service/task/publishPaymentUrl.js +9 -14
  415. package/lib/chevre/service/task/refund.js +8 -16
  416. package/lib/chevre/service/task/registerService.js +3 -12
  417. package/lib/chevre/service/task/reserve.js +3 -12
  418. package/lib/chevre/service/task/returnMoneyTransfer.js +3 -12
  419. package/lib/chevre/service/task/returnOrder.js +6 -12
  420. package/lib/chevre/service/task/returnPayTransaction.js +54 -48
  421. package/lib/chevre/service/task/returnPointAward.js +3 -12
  422. package/lib/chevre/service/task/returnReserveTransaction.js +29 -30
  423. package/lib/chevre/service/task/sendEmailMessage.js +6 -13
  424. package/lib/chevre/service/task/sendOrder.js +12 -15
  425. package/lib/chevre/service/task/syncResourcesFromCOA.js +39 -40
  426. package/lib/chevre/service/task/triggerWebhook.js +6 -12
  427. package/lib/chevre/service/task/useReservation.js +11 -14
  428. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +3 -12
  429. package/lib/chevre/service/task/voidPayTransaction.js +7 -12
  430. package/lib/chevre/service/task/voidPayment.js +3 -12
  431. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -12
  432. package/lib/chevre/service/task/voidReserveTransaction.js +10 -16
  433. package/lib/chevre/service/task.js +16 -22
  434. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +9 -20
  435. package/lib/chevre/service/taskHandler/onOperationFailed.js +20 -17
  436. package/lib/chevre/service/taskHandler.js +19 -21
  437. package/lib/chevre/service/transaction/deleteTransaction.js +104 -84
  438. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +15 -6
  439. package/lib/chevre/service/transaction/moneyTransfer/factory.js +13 -4
  440. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +12 -24
  441. package/lib/chevre/service/transaction/moneyTransfer.js +119 -96
  442. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +49 -51
  443. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +14 -25
  444. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +4 -14
  445. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +3 -4
  446. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.js +3 -4
  447. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -3
  448. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +30 -45
  449. package/lib/chevre/service/transaction/placeOrder/confirm.js +75 -55
  450. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +31 -13
  451. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +6 -15
  452. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +6 -15
  453. package/lib/chevre/service/transaction/placeOrder/publishOrderNumberIfNotExist.js +7 -16
  454. package/lib/chevre/service/transaction/placeOrder/start/factory.js +27 -7
  455. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +53 -59
  456. package/lib/chevre/service/transaction/placeOrder/start.js +14 -18
  457. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +13 -6
  458. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +176 -190
  459. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +77 -89
  460. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +40 -48
  461. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +52 -56
  462. package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.js +100 -102
  463. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +60 -80
  464. package/lib/chevre/service/transaction/returnOrder/preStart.js +42 -46
  465. package/lib/chevre/service/transaction/returnOrder.js +32 -36
  466. package/lib/chevre/service/transaction.js +75 -46
  467. package/lib/chevre/service/validation/validateEvent.js +2 -11
  468. package/lib/chevre/service/validation/validateOrder.js +7 -16
  469. package/lib/chevre/service.js +85 -128
  470. package/lib/chevre/settings/aggregation.js +4 -0
  471. package/lib/chevre/settings.js +7 -0
  472. package/package.json +6 -7
  473. package/example/src/chevre/addEventBySchedule.ts +0 -46
  474. package/example/src/idaas/auth0/adminApplications.ts +0 -183
  475. package/example/src/idaas/auth0/getToken.ts +0 -55
  476. package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +0 -84
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.OrderRepo = void 0;
13
4
  const factory = require("../factory");
@@ -28,16 +19,16 @@ const AVAILABLE_PROJECT_FIELDS = [
28
19
  * 注文リポジトリ
29
20
  */
30
21
  class OrderRepo {
22
+ orderModel;
31
23
  constructor(connection) {
32
24
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
33
25
  }
34
26
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
35
27
  static CREATE_MONGO_CONDITIONS(params) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
37
28
  const andConditions = [
38
29
  { typeOf: { $eq: factory.order.OrderType.Order } }
39
30
  ];
40
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
31
+ const projectIdEq = params.project?.id?.$eq;
41
32
  if (typeof projectIdEq === 'string') {
42
33
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
43
34
  }
@@ -65,15 +56,15 @@ class OrderRepo {
65
56
  });
66
57
  }
67
58
  }
68
- const providerIdEq = (_d = (_c = params.provider) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
59
+ const providerIdEq = params.provider?.id?.$eq;
69
60
  if (typeof providerIdEq === 'string') {
70
61
  andConditions.push({ 'seller.id': { $exists: true, $eq: providerIdEq } });
71
62
  }
72
- const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
63
+ const sellerIdEq = params.seller?.id?.$eq;
73
64
  if (typeof sellerIdEq === 'string') {
74
65
  andConditions.push({ 'seller.id': { $exists: true, $eq: sellerIdEq } });
75
66
  }
76
- const sellerIds = (_g = params.seller) === null || _g === void 0 ? void 0 : _g.ids;
67
+ const sellerIds = params.seller?.ids;
77
68
  if (Array.isArray(sellerIds)) {
78
69
  if (sellerIds.length === 1) {
79
70
  // use $eq(2025-04-01~)
@@ -83,7 +74,7 @@ class OrderRepo {
83
74
  andConditions.push({ 'seller.id': { $exists: true, $in: sellerIds } });
84
75
  }
85
76
  }
86
- const brokerIdEq = (_j = (_h = params.broker) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
77
+ const brokerIdEq = params.broker?.id?.$eq;
87
78
  if (typeof brokerIdEq === 'string') {
88
79
  andConditions.push({
89
80
  'broker.id': {
@@ -300,7 +291,7 @@ class OrderRepo {
300
291
  }
301
292
  }
302
293
  }
303
- const nameEq = (_k = params.name) === null || _k === void 0 ? void 0 : _k.$eq;
294
+ const nameEq = params.name?.$eq;
304
295
  if (typeof nameEq === 'string') {
305
296
  andConditions.push({
306
297
  name: {
@@ -309,7 +300,7 @@ class OrderRepo {
309
300
  }
310
301
  });
311
302
  }
312
- const nameRegex = (_l = params.name) === null || _l === void 0 ? void 0 : _l.$regex;
303
+ const nameRegex = params.name?.$regex;
313
304
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
314
305
  andConditions.push({
315
306
  name: {
@@ -345,19 +336,19 @@ class OrderRepo {
345
336
  andConditions.push({ confirmationNumber: { $exists: true, $in: params.confirmationNumbers } });
346
337
  }
347
338
  }
348
- const orderedItemSize = (_m = params.orderedItem) === null || _m === void 0 ? void 0 : _m.$size;
339
+ const orderedItemSize = params.orderedItem?.$size;
349
340
  if (typeof orderedItemSize === 'number') {
350
341
  andConditions.push({ orderedItem: { $size: orderedItemSize } });
351
342
  }
352
- const acceptedOffersSize = (_o = params.acceptedOffers) === null || _o === void 0 ? void 0 : _o.$size;
343
+ const acceptedOffersSize = params.acceptedOffers?.$size;
353
344
  if (typeof acceptedOffersSize === 'number') {
354
345
  andConditions.push({ acceptedOffers: { $size: acceptedOffersSize } });
355
346
  }
356
- const serialNumberEq = (_q = (_p = params.acceptedOffers) === null || _p === void 0 ? void 0 : _p.serialNumber) === null || _q === void 0 ? void 0 : _q.$eq;
347
+ const serialNumberEq = params.acceptedOffers?.serialNumber?.$eq;
357
348
  if (typeof serialNumberEq === 'string') {
358
349
  andConditions.push({ 'acceptedOffers.serialNumber': { $exists: true, $eq: serialNumberEq } });
359
350
  }
360
- const itemOfferedIdentifierIn = (_t = (_s = (_r = params.acceptedOffers) === null || _r === void 0 ? void 0 : _r.itemOffered) === null || _s === void 0 ? void 0 : _s.identifier) === null || _t === void 0 ? void 0 : _t.$in;
351
+ const itemOfferedIdentifierIn = params.acceptedOffers?.itemOffered?.identifier?.$in;
361
352
  if (Array.isArray(itemOfferedIdentifierIn)) {
362
353
  andConditions.push({
363
354
  'acceptedOffers.itemOffered.identifier': {
@@ -366,7 +357,7 @@ class OrderRepo {
366
357
  }
367
358
  });
368
359
  }
369
- const itemOfferedTypeOfIn = (_w = (_v = (_u = params.acceptedOffers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.typeOf) === null || _w === void 0 ? void 0 : _w.$in;
360
+ const itemOfferedTypeOfIn = params.acceptedOffers?.itemOffered?.typeOf?.$in;
370
361
  if (Array.isArray(itemOfferedTypeOfIn)) {
371
362
  andConditions.push({
372
363
  'acceptedOffers.itemOffered.typeOf': {
@@ -375,7 +366,7 @@ class OrderRepo {
375
366
  }
376
367
  });
377
368
  }
378
- const itemOfferedIssuedThroughTypeOfEq = (_0 = (_z = (_y = (_x = params.acceptedOffers) === null || _x === void 0 ? void 0 : _x.itemOffered) === null || _y === void 0 ? void 0 : _y.issuedThrough) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$eq;
369
+ const itemOfferedIssuedThroughTypeOfEq = params.acceptedOffers?.itemOffered?.issuedThrough?.typeOf?.$eq;
379
370
  if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
380
371
  andConditions.push({
381
372
  'acceptedOffers.itemOffered.issuedThrough.typeOf': {
@@ -384,7 +375,7 @@ class OrderRepo {
384
375
  }
385
376
  });
386
377
  }
387
- const itemOfferedIssuedThroughIdIn = (_4 = (_3 = (_2 = (_1 = params.acceptedOffers) === null || _1 === void 0 ? void 0 : _1.itemOffered) === null || _2 === void 0 ? void 0 : _2.issuedThrough) === null || _3 === void 0 ? void 0 : _3.id) === null || _4 === void 0 ? void 0 : _4.$in;
378
+ const itemOfferedIssuedThroughIdIn = params.acceptedOffers?.itemOffered?.issuedThrough?.id?.$in;
388
379
  if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
389
380
  andConditions.push({
390
381
  'acceptedOffers.itemOffered.issuedThrough.id': {
@@ -393,7 +384,7 @@ class OrderRepo {
393
384
  }
394
385
  });
395
386
  }
396
- const itemOfferedProgramMembershipUsedIdentifierEq = (_8 = (_7 = (_6 = (_5 = params.acceptedOffers) === null || _5 === void 0 ? void 0 : _5.itemOffered) === null || _6 === void 0 ? void 0 : _6.programMembershipUsed) === null || _7 === void 0 ? void 0 : _7.identifier) === null || _8 === void 0 ? void 0 : _8.$eq;
387
+ const itemOfferedProgramMembershipUsedIdentifierEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.identifier?.$eq;
397
388
  if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
398
389
  andConditions.push({
399
390
  'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
@@ -402,7 +393,7 @@ class OrderRepo {
402
393
  }
403
394
  });
404
395
  }
405
- const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_14 = (_13 = (_12 = (_11 = (_10 = (_9 = params.acceptedOffers) === null || _9 === void 0 ? void 0 : _9.itemOffered) === null || _10 === void 0 ? void 0 : _10.programMembershipUsed) === null || _11 === void 0 ? void 0 : _11.issuedThrough) === null || _12 === void 0 ? void 0 : _12.serviceType) === null || _13 === void 0 ? void 0 : _13.codeValue) === null || _14 === void 0 ? void 0 : _14.$eq;
396
+ const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
406
397
  if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
407
398
  andConditions.push({
408
399
  'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
@@ -411,7 +402,7 @@ class OrderRepo {
411
402
  }
412
403
  });
413
404
  }
414
- const itemOfferedReservedTicketIdentifierEq = (_18 = (_17 = (_16 = (_15 = params.acceptedOffers) === null || _15 === void 0 ? void 0 : _15.itemOffered) === null || _16 === void 0 ? void 0 : _16.reservedTicket) === null || _17 === void 0 ? void 0 : _17.identifier) === null || _18 === void 0 ? void 0 : _18.$eq;
405
+ const itemOfferedReservedTicketIdentifierEq = params.acceptedOffers?.itemOffered?.reservedTicket?.identifier?.$eq;
415
406
  if (typeof itemOfferedReservedTicketIdentifierEq === 'string') {
416
407
  andConditions.push({
417
408
  'acceptedOffers.itemOffered.reservedTicket.identifier': {
@@ -595,11 +586,11 @@ class OrderRepo {
595
586
  }
596
587
  }
597
588
  }
598
- const paymentMethodIdentifierIn = (_21 = (_20 = (_19 = params.paymentMethods) === null || _19 === void 0 ? void 0 : _19.paymentMethod) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
589
+ const paymentMethodIdentifierIn = params.paymentMethods?.paymentMethod?.identifier?.$in;
599
590
  if (Array.isArray(paymentMethodIdentifierIn)) {
600
591
  andConditions.push({ 'paymentMethods.paymentMethod.identifier': { $exists: true, $in: paymentMethodIdentifierIn } });
601
592
  }
602
- const paymentMethodsTypeOfIn = (_22 = params.paymentMethods) === null || _22 === void 0 ? void 0 : _22.typeOfs;
593
+ const paymentMethodsTypeOfIn = params.paymentMethods?.typeOfs;
603
594
  if (Array.isArray(paymentMethodsTypeOfIn)) {
604
595
  // paymentMethod.identifierで検索(2023-11-15~)
605
596
  // andConditions.push({ 'paymentMethods.typeOf': { $exists: true, $in: paymentMethodsTypeOfIn } });
@@ -629,7 +620,7 @@ class OrderRepo {
629
620
  });
630
621
  }
631
622
  }
632
- const paymentMethodAdditionalPropertyAll = (_24 = (_23 = params.paymentMethods) === null || _23 === void 0 ? void 0 : _23.additionalProperty) === null || _24 === void 0 ? void 0 : _24.$all;
623
+ const paymentMethodAdditionalPropertyAll = params.paymentMethods?.additionalProperty?.$all;
633
624
  if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
634
625
  andConditions.push({
635
626
  'paymentMethods.additionalProperty': {
@@ -638,7 +629,7 @@ class OrderRepo {
638
629
  }
639
630
  });
640
631
  }
641
- const paymentMethodAdditionalPropertyIn = (_26 = (_25 = params.paymentMethods) === null || _25 === void 0 ? void 0 : _25.additionalProperty) === null || _26 === void 0 ? void 0 : _26.$in;
632
+ const paymentMethodAdditionalPropertyIn = params.paymentMethods?.additionalProperty?.$in;
642
633
  if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
643
634
  andConditions.push({
644
635
  'paymentMethods.additionalProperty': {
@@ -696,622 +687,622 @@ class OrderRepo {
696
687
  /**
697
688
  * なければ作成する
698
689
  */
699
- createIfNotExist(order) {
700
- return __awaiter(this, void 0, void 0, function* () {
701
- try {
702
- // 存在しなければ上書き
703
- // updateOneに変更(2024-01-14~)
704
- // await this.orderModel.findOneAndUpdate(
705
- yield this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
706
- // new: true,
707
- upsert: true
708
- })
709
- .exec();
710
- }
711
- catch (error) {
712
- let throwsError = true;
713
- if (yield (0, errorHandler_1.isMongoError)(error)) {
714
- // すでにorderNumberが存在する場合ok
715
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
716
- throwsError = false;
717
- }
718
- }
719
- if (throwsError) {
720
- throw error;
690
+ async createIfNotExist(order) {
691
+ try {
692
+ // 存在しなければ上書き
693
+ // updateOneに変更(2024-01-14~)
694
+ // await this.orderModel.findOneAndUpdate(
695
+ await this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
696
+ // new: true,
697
+ upsert: true
698
+ })
699
+ .exec();
700
+ }
701
+ catch (error) {
702
+ let throwsError = true;
703
+ if (await (0, errorHandler_1.isMongoError)(error)) {
704
+ // すでにorderNumberが存在する場合ok
705
+ if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
706
+ throwsError = false;
721
707
  }
722
708
  }
723
- });
709
+ if (throwsError) {
710
+ throw error;
711
+ }
712
+ }
724
713
  }
725
714
  /**
726
715
  * 注文ステータスを変更する
727
716
  */
728
- changeStatus(params) {
729
- return __awaiter(this, void 0, void 0, function* () {
730
- const { orderNumber, previousOrderStatus, orderStatus } = params;
731
- const doc = yield this.orderModel.findOneAndUpdate({
732
- orderNumber: { $eq: orderNumber },
733
- orderStatus: { $eq: previousOrderStatus },
734
- 'project.id': { $eq: params.project.id },
735
- typeOf: { $eq: factory.order.OrderType.Order }
736
- }, {
737
- $set: {
738
- previousOrderStatus, // 追加(2023-08-31~)
739
- orderStatus
740
- }
741
- }, {
742
- new: true,
743
- // inclusion projection(2024-07-25~)
744
- projection: {
745
- _id: 0, // hide _id(2024-07-25~)
746
- id: { $toString: '$_id' },
747
- orderNumber: 1, broker: 1, confirmationNumber: 1, customer: 1, dateReturned: 1,
748
- name: 1, orderDate: 1, orderStatus: 1, orderedItem: 1, paymentMethods: 1,
749
- previousOrderStatus: 1, price: 1, priceCurrency: 1, project: 1, returner: 1, seller: 1, typeOf: 1
750
- }
751
- // projection: {
752
- // __v: 0,
753
- // createdAt: 0,
754
- // updatedAt: 0,
755
- // acceptedOffers: 0 // 除外(2023-12-08~)
756
- // }
757
- })
758
- .lean() // lean(2024-07-25~)
759
- .exec();
760
- // NotFoundであれば状態確認
761
- if (doc === null) {
762
- const order = yield this.projectFieldsByOrderNumber({
763
- orderNumber: params.orderNumber,
764
- project: { id: params.project.id },
765
- inclusion: [
766
- 'orderNumber', 'broker', 'confirmationNumber', 'customer', 'dateReturned',
767
- 'name', 'orderDate', 'orderStatus', 'orderedItem', 'paymentMethods',
768
- 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf'
769
- ] // inclusion projection(2024-07-25~)
770
- });
717
+ async changeStatus(params) {
718
+ const { orderNumber, previousOrderStatus, orderStatus } = params;
719
+ const doc = await this.orderModel.findOneAndUpdate({
720
+ orderNumber: { $eq: orderNumber },
721
+ orderStatus: { $eq: previousOrderStatus },
722
+ 'project.id': { $eq: params.project.id },
723
+ typeOf: { $eq: factory.order.OrderType.Order }
724
+ }, {
725
+ $set: {
726
+ previousOrderStatus, // 追加(2023-08-31~)
727
+ orderStatus
728
+ }
729
+ }, {
730
+ new: true,
731
+ // inclusion projection(2024-07-25~)
732
+ projection: {
733
+ _id: 0, // hide _id(2024-07-25~)
734
+ id: { $toString: '$_id' },
735
+ orderNumber: 1, broker: 1, confirmationNumber: 1, customer: 1, dateReturned: 1,
736
+ name: 1, orderDate: 1, orderStatus: 1, orderedItem: 1, paymentMethods: 1,
737
+ previousOrderStatus: 1, price: 1, priceCurrency: 1, project: 1, returner: 1, seller: 1, typeOf: 1
738
+ }
739
+ // projection: {
740
+ // __v: 0,
741
+ // createdAt: 0,
742
+ // updatedAt: 0,
743
+ // acceptedOffers: 0 // 除外(2023-12-08~)
744
+ // }
745
+ })
746
+ .lean() // lean(2024-07-25~)
747
+ .exec();
748
+ // NotFoundであれば状態確認
749
+ if (doc === null) {
750
+ const order = await this.projectFieldsByOrderNumber({
751
+ orderNumber: params.orderNumber,
752
+ project: { id: params.project.id },
753
+ inclusion: [
754
+ 'orderNumber', 'broker', 'confirmationNumber', 'customer', 'dateReturned',
755
+ 'name', 'orderDate', 'orderStatus', 'orderedItem', 'paymentMethods',
756
+ 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf'
757
+ ] // inclusion projection(2024-07-25~)
758
+ });
759
+ // tslint:disable-next-line:no-single-line-block-comment
760
+ /* istanbul ignore next */
761
+ if (order.orderStatus === params.orderStatus) {
762
+ // すでに変更済の場合
763
+ return order;
771
764
  // tslint:disable-next-line:no-single-line-block-comment
772
765
  /* istanbul ignore next */
773
- if (order.orderStatus === params.orderStatus) {
774
- // すでに変更済の場合
775
- return order;
776
- // tslint:disable-next-line:no-single-line-block-comment
777
- /* istanbul ignore next */
778
- }
779
- else {
780
- throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
781
- }
782
766
  }
783
- return doc;
784
- });
767
+ else {
768
+ throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
769
+ }
770
+ }
771
+ return doc;
785
772
  }
786
773
  /**
787
774
  * 注文を返品する
788
775
  */
789
- returnOrder(params) {
790
- return __awaiter(this, void 0, void 0, function* () {
791
- const { dateReturned, returner, orderNumber, project } = params;
792
- const doc = yield this.orderModel.findOneAndUpdate({
793
- orderNumber: { $eq: orderNumber },
794
- orderStatus: { $eq: factory.orderStatus.OrderDelivered },
795
- 'project.id': { $eq: project.id },
796
- typeOf: { $eq: factory.order.OrderType.Order }
797
- }, {
798
- $set: {
799
- previousOrderStatus: factory.orderStatus.OrderDelivered,
800
- orderStatus: factory.orderStatus.OrderReturned,
801
- dateReturned,
802
- returner
803
- }
804
- }, {
805
- new: true,
806
- projection: {
807
- _id: 0, // hide _id(2024-07-30~)
808
- id: { $toString: '$_id' },
809
- // _id: 1,
810
- project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
811
- customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
812
- // __v: 0,
813
- // createdAt: 0,
814
- // updatedAt: 0
815
- }
816
- })
817
- .lean() // lean(2024-07-30~)
818
- .exec();
819
- // NotFoundであれば状態確認
820
- if (doc === null) {
821
- const order = yield this.projectFieldsByOrderNumber({
822
- orderNumber: params.orderNumber,
823
- project: { id: params.project.id },
824
- inclusion: [
825
- 'project', 'typeOf', 'orderNumber', 'dateReturned',
826
- 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
827
- ]
828
- });
776
+ async returnOrder(params) {
777
+ const { dateReturned, returner, orderNumber, project } = params;
778
+ const doc = await this.orderModel.findOneAndUpdate({
779
+ orderNumber: { $eq: orderNumber },
780
+ orderStatus: { $eq: factory.orderStatus.OrderDelivered },
781
+ 'project.id': { $eq: project.id },
782
+ typeOf: { $eq: factory.order.OrderType.Order }
783
+ }, {
784
+ $set: {
785
+ previousOrderStatus: factory.orderStatus.OrderDelivered,
786
+ orderStatus: factory.orderStatus.OrderReturned,
787
+ dateReturned,
788
+ returner
789
+ }
790
+ }, {
791
+ new: true,
792
+ projection: {
793
+ _id: 0, // hide _id(2024-07-30~)
794
+ id: { $toString: '$_id' },
795
+ // _id: 1,
796
+ project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
797
+ customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
798
+ // __v: 0,
799
+ // createdAt: 0,
800
+ // updatedAt: 0
801
+ }
802
+ })
803
+ .lean() // lean(2024-07-30~)
804
+ .exec();
805
+ // NotFoundであれば状態確認
806
+ if (doc === null) {
807
+ const order = await this.projectFieldsByOrderNumber({
808
+ orderNumber: params.orderNumber,
809
+ project: { id: params.project.id },
810
+ inclusion: [
811
+ 'project', 'typeOf', 'orderNumber', 'dateReturned',
812
+ 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
813
+ ]
814
+ });
815
+ // tslint:disable-next-line:no-single-line-block-comment
816
+ /* istanbul ignore next */
817
+ if (order.orderStatus === factory.orderStatus.OrderReturned) {
818
+ // すでに変更済の場合
819
+ return order;
829
820
  // tslint:disable-next-line:no-single-line-block-comment
830
821
  /* istanbul ignore next */
831
- if (order.orderStatus === factory.orderStatus.OrderReturned) {
832
- // すでに変更済の場合
833
- return order;
834
- // tslint:disable-next-line:no-single-line-block-comment
835
- /* istanbul ignore next */
836
- }
837
- else {
838
- throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
839
- }
840
822
  }
841
- return doc;
842
- });
823
+ else {
824
+ throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
825
+ }
826
+ }
827
+ return doc;
843
828
  }
844
829
  /**
845
830
  * 変更可能な属性を更新する
846
831
  */
847
- updateChangeableAttributes(params) {
848
- return __awaiter(this, void 0, void 0, function* () {
849
- const updatedAt = new Date();
850
- const { orderNumber, project, name } = params;
851
- const doc = yield this.orderModel.findOneAndUpdate({
852
- orderNumber: { $eq: orderNumber },
853
- 'project.id': { $eq: project.id },
854
- typeOf: { $eq: factory.order.OrderType.Order }
855
- }, {
856
- $set: Object.assign({}, (typeof name === 'string') ? { name } : undefined)
857
- }, {
858
- new: false,
859
- projection: {
860
- _id: 1
861
- // updatedAt: 1 // discontinue(2024-06-17~)
862
- }
863
- })
864
- .lean() // lean(2024-07-30~)
865
- .exec();
866
- if (doc === null) {
867
- throw new factory.errors.NotFound(this.orderModel.modelName);
832
+ async updateChangeableAttributes(params) {
833
+ const updatedAt = new Date();
834
+ const { orderNumber, project, name } = params;
835
+ const doc = await this.orderModel.findOneAndUpdate({
836
+ orderNumber: { $eq: orderNumber },
837
+ 'project.id': { $eq: project.id },
838
+ typeOf: { $eq: factory.order.OrderType.Order }
839
+ }, {
840
+ $set: {
841
+ ...(typeof name === 'string') ? { name } : undefined
842
+ }
843
+ }, {
844
+ new: false,
845
+ projection: {
846
+ _id: 1
847
+ // updatedAt: 1 // discontinue(2024-06-17~)
868
848
  }
869
- return { updatedAt };
870
- });
849
+ })
850
+ .lean() // lean(2024-07-30~)
851
+ .exec();
852
+ if (doc === null) {
853
+ throw new factory.errors.NotFound(this.orderModel.modelName);
854
+ }
855
+ return { updatedAt };
871
856
  }
872
857
  /**
873
858
  * 注文後に決済方法区分を確定する
874
859
  */
875
- fixPaymentMethodIdentifier(params) {
876
- return __awaiter(this, void 0, void 0, function* () {
877
- const doc = yield this.orderModel.findOneAndUpdate({
878
- orderNumber: { $eq: params.orderNumber },
879
- 'project.id': { $eq: params.project.id },
880
- typeOf: { $eq: factory.order.OrderType.Order },
881
- 'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
882
- }, {
883
- $set: {
884
- 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
885
- // tslint:disable-next-line:no-suspicious-comment
886
- // TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
887
- 'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
888
- }
889
- }, {
890
- arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
891
- new: true,
892
- projection: {
893
- _id: 1
894
- }
895
- })
896
- .lean() // lean(2024-07-30~)
897
- .exec();
898
- if (doc === null) {
899
- throw new factory.errors.NotFound(this.orderModel.modelName);
860
+ async fixPaymentMethodIdentifier(params) {
861
+ const doc = await this.orderModel.findOneAndUpdate({
862
+ orderNumber: { $eq: params.orderNumber },
863
+ 'project.id': { $eq: params.project.id },
864
+ typeOf: { $eq: factory.order.OrderType.Order },
865
+ 'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
866
+ }, {
867
+ $set: {
868
+ 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
869
+ // tslint:disable-next-line:no-suspicious-comment
870
+ // TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
871
+ 'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
900
872
  }
901
- });
902
- }
903
- projectFieldsById(params) {
904
- return __awaiter(this, void 0, void 0, function* () {
905
- const projection = {
906
- // _id: 1
907
- _id: 0, // hide _id(2024-07-25~)
908
- id: { $toString: '$_id' }
909
- };
910
- if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
911
- params.inclusion.forEach((field) => {
912
- // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
913
- // projection[field] = 1;
914
- // }
915
- if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
916
- projection[field] = 1;
917
- }
918
- });
919
- }
920
- else {
921
- // discontinue(2024-07-25~)
922
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
923
- }
924
- const doc = yield this.orderModel.findOne({
925
- _id: { $eq: params.id },
926
- typeOf: { $eq: factory.order.OrderType.Order }
927
- }, projection)
928
- .lean() // lean(2024-07-25~)
929
- .exec();
930
- if (doc === null) {
931
- throw new factory.errors.NotFound(this.orderModel.modelName);
873
+ }, {
874
+ arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
875
+ new: true,
876
+ projection: {
877
+ _id: 1
932
878
  }
933
- return doc;
934
- });
879
+ })
880
+ .lean() // lean(2024-07-30~)
881
+ .exec();
882
+ if (doc === null) {
883
+ throw new factory.errors.NotFound(this.orderModel.modelName);
884
+ }
885
+ }
886
+ async projectFieldsById(params) {
887
+ const projection = {
888
+ // _id: 1
889
+ _id: 0, // hide _id(2024-07-25~)
890
+ id: { $toString: '$_id' }
891
+ };
892
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
893
+ params.inclusion.forEach((field) => {
894
+ // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
895
+ // projection[field] = 1;
896
+ // }
897
+ if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
898
+ projection[field] = 1;
899
+ }
900
+ });
901
+ }
902
+ else {
903
+ // discontinue(2024-07-25~)
904
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
905
+ }
906
+ const doc = await this.orderModel.findOne({
907
+ _id: { $eq: params.id },
908
+ typeOf: { $eq: factory.order.OrderType.Order }
909
+ }, projection)
910
+ .lean() // lean(2024-07-25~)
911
+ .exec();
912
+ if (doc === null) {
913
+ throw new factory.errors.NotFound(this.orderModel.modelName);
914
+ }
915
+ return doc;
935
916
  }
936
917
  /**
937
918
  * 注文番号から注文を取得する
938
919
  */
939
- projectFieldsByOrderNumber(
920
+ async projectFieldsByOrderNumber(
940
921
  // public async findByOrderNumber(
941
922
  params) {
942
- return __awaiter(this, void 0, void 0, function* () {
943
- const projection = {
944
- _id: 0, // hide _id(2024-07-25~)
945
- id: { $toString: '$_id' }
946
- };
947
- if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
948
- params.inclusion.forEach((field) => {
949
- // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
950
- // projection[field] = 1;
951
- // }
952
- if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
953
- projection[field] = 1;
954
- }
955
- });
956
- }
957
- else {
958
- // discontinue(2024-07-25~)
959
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
960
- }
961
- const doc = yield this.orderModel.findOne({
962
- orderNumber: { $eq: params.orderNumber },
963
- 'project.id': { $eq: params.project.id },
964
- typeOf: { $eq: factory.order.OrderType.Order }
965
- }, projection)
966
- .lean() // lean(2024-07-25~)
967
- .exec();
968
- if (doc === null) {
969
- throw new factory.errors.NotFound(this.orderModel.modelName);
970
- }
971
- return doc;
972
- });
923
+ const projection = {
924
+ _id: 0, // hide _id(2024-07-25~)
925
+ id: { $toString: '$_id' }
926
+ };
927
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
928
+ params.inclusion.forEach((field) => {
929
+ // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
930
+ // projection[field] = 1;
931
+ // }
932
+ if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
933
+ projection[field] = 1;
934
+ }
935
+ });
936
+ }
937
+ else {
938
+ // discontinue(2024-07-25~)
939
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
940
+ }
941
+ const doc = await this.orderModel.findOne({
942
+ orderNumber: { $eq: params.orderNumber },
943
+ 'project.id': { $eq: params.project.id },
944
+ typeOf: { $eq: factory.order.OrderType.Order }
945
+ }, projection)
946
+ .lean() // lean(2024-07-25~)
947
+ .exec();
948
+ if (doc === null) {
949
+ throw new factory.errors.NotFound(this.orderModel.modelName);
950
+ }
951
+ return doc;
973
952
  }
974
- findByOrderNumberAndReservationId(params) {
975
- return __awaiter(this, void 0, void 0, function* () {
976
- var _a;
977
- const projection = {
978
- orderStatus: 1,
979
- typeOf: 1,
980
- orderNumber: 1,
981
- _id: 0
982
- };
983
- const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, typeOf: { $eq: factory.order.OrderType.Order }, acceptedOffers: {
984
- $elemMatch: {
985
- 'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
986
- 'itemOffered.id': { $eq: params.reservationId }
987
- }
988
- } }, (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string')
953
+ async findByOrderNumberAndReservationId(params) {
954
+ const projection = {
955
+ orderStatus: 1,
956
+ typeOf: 1,
957
+ orderNumber: 1,
958
+ _id: 0
959
+ };
960
+ const doc = await this.orderModel.findOne({
961
+ orderNumber: { $eq: params.orderNumber },
962
+ 'project.id': { $eq: params.project.id },
963
+ typeOf: { $eq: factory.order.OrderType.Order },
964
+ acceptedOffers: {
965
+ $elemMatch: {
966
+ 'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
967
+ 'itemOffered.id': { $eq: params.reservationId }
968
+ }
969
+ },
970
+ ...(typeof params.seller?.id === 'string')
989
971
  ? { 'seller.id': { $exists: true, $eq: params.seller.id } }
990
- : undefined), projection)
991
- // projection的にleanで十分
992
- .lean()
993
- .exec();
994
- if (doc === null) {
995
- throw new factory.errors.NotFound(this.orderModel.modelName);
996
- }
997
- return doc;
998
- });
972
+ : undefined
973
+ }, projection)
974
+ // projection的にleanで十分
975
+ .lean()
976
+ .exec();
977
+ if (doc === null) {
978
+ throw new factory.errors.NotFound(this.orderModel.modelName);
979
+ }
980
+ return doc;
999
981
  }
1000
982
  /**
1001
983
  * 注文番号で削除する
1002
984
  */
1003
- deleteByOrderNumber(params) {
1004
- return __awaiter(this, void 0, void 0, function* () {
1005
- yield this.orderModel.deleteOne({
1006
- orderNumber: { $eq: params.orderNumber },
1007
- typeOf: { $eq: factory.order.OrderType.Order }
1008
- })
1009
- .exec();
1010
- });
985
+ async deleteByOrderNumber(params) {
986
+ await this.orderModel.deleteOne({
987
+ orderNumber: { $eq: params.orderNumber },
988
+ typeOf: { $eq: factory.order.OrderType.Order }
989
+ })
990
+ .exec();
1011
991
  }
1012
- count(params) {
1013
- return __awaiter(this, void 0, void 0, function* () {
1014
- const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1015
- return this.orderModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
1016
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1017
- .exec();
1018
- });
992
+ async count(params) {
993
+ const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
994
+ return this.orderModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
995
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
996
+ .exec();
1019
997
  }
1020
998
  /**
1021
999
  * 注文を検索する(inclusion projection)
1022
1000
  * redefine from search(2024-07-31~)
1023
1001
  */
1024
- projectFields(params, options) {
1025
- return __awaiter(this, void 0, void 0, function* () {
1026
- var _a;
1027
- const { inclusion } = options;
1028
- const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1029
- let projectStage = {};
1030
- const positiveProjectionFields = (Array.isArray(inclusion))
1031
- ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
1032
- : [];
1033
- if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
1034
- projectStage = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
1035
- }
1036
- else {
1037
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
1038
- }
1039
- const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
1040
- if (typeof params.limit === 'number' && params.limit > 0) {
1041
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1042
- query.limit(params.limit)
1043
- .skip(params.limit * (page - 1));
1044
- }
1045
- // tslint:disable-next-line:no-single-line-block-comment
1046
- /* istanbul ignore else */
1047
- if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) !== undefined) {
1048
- query.sort({ orderDate: params.sort.orderDate });
1049
- }
1050
- // const explainResult = await (<any>query).explain();
1051
- // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
1052
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1053
- .lean() // lean(2024-07-25~)
1054
- .exec();
1055
- });
1002
+ async projectFields(params, options) {
1003
+ const { inclusion } = options;
1004
+ const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1005
+ let projectStage = {};
1006
+ const positiveProjectionFields = (Array.isArray(inclusion))
1007
+ ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
1008
+ : [];
1009
+ if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
1010
+ projectStage = {
1011
+ _id: 0, // hide _id(2024-07-25~)
1012
+ id: { $toString: '$_id' },
1013
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
1014
+ };
1015
+ }
1016
+ else {
1017
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
1018
+ }
1019
+ const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
1020
+ if (typeof params.limit === 'number' && params.limit > 0) {
1021
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1022
+ query.limit(params.limit)
1023
+ .skip(params.limit * (page - 1));
1024
+ }
1025
+ // tslint:disable-next-line:no-single-line-block-comment
1026
+ /* istanbul ignore else */
1027
+ if (params.sort?.orderDate !== undefined) {
1028
+ query.sort({ orderDate: params.sort.orderDate });
1029
+ }
1030
+ // const explainResult = await (<any>query).explain();
1031
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
1032
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1033
+ .lean() // lean(2024-07-25~)
1034
+ .exec();
1056
1035
  }
1057
1036
  getCursor(conditions, projection) {
1058
1037
  return this.orderModel.find(conditions, projection)
1059
1038
  .sort({ orderDate: factory.sortType.Descending })
1060
1039
  .cursor();
1061
1040
  }
1062
- unsetUnnecessaryFields(params) {
1063
- return __awaiter(this, void 0, void 0, function* () {
1064
- return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1065
- .exec();
1066
- });
1041
+ async unsetUnnecessaryFields(params) {
1042
+ return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1043
+ .exec();
1067
1044
  }
1068
1045
  // tslint:disable-next-line:max-func-body-length
1069
- aggregateOrder(params) {
1070
- return __awaiter(this, void 0, void 0, function* () {
1071
- var _a, _b;
1072
- const matchConditions = Object.assign({ orderDate: {
1073
- $gte: params.orderDate.$gte,
1074
- $lte: params.orderDate.$lte
1075
- }, typeOf: { $eq: factory.order.OrderType.Order } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
1046
+ async aggregateOrder(params) {
1047
+ const matchConditions = {
1048
+ orderDate: {
1049
+ $gte: params.orderDate.$gte,
1050
+ $lte: params.orderDate.$lte
1051
+ },
1052
+ typeOf: { $eq: factory.order.OrderType.Order },
1053
+ ...(typeof params.project?.id?.$ne === 'string')
1076
1054
  ? { 'project.id': { $ne: params.project.id.$ne } }
1077
- : undefined);
1078
- const aggregations = yield this.orderModel.aggregate([
1079
- { $match: matchConditions },
1080
- {
1081
- $project: {
1082
- typeOf: '$typeOf',
1083
- price: '$price',
1084
- numAcceptedOffers: { $size: '$acceptedOffers' }
1085
- }
1086
- },
1087
- {
1088
- $group: {
1089
- _id: '$typeOf',
1090
- orderCount: { $sum: 1 },
1091
- totalNumAcceptedOffer: { $sum: '$numAcceptedOffers' },
1092
- maxNumAcceptedOffer: { $max: '$numAcceptedOffers' },
1093
- minNumAcceptedOffer: { $min: '$numAcceptedOffers' },
1094
- avgNumAcceptedOffer: { $avg: '$numAcceptedOffers' },
1095
- totalPrice: { $sum: '$price' },
1096
- maxPrice: { $max: '$price' },
1097
- minPrice: { $min: '$price' },
1098
- avgPrice: { $avg: '$price' }
1099
- }
1100
- },
1101
- {
1102
- $project: {
1103
- _id: 0,
1104
- orderCount: '$orderCount',
1105
- totalNumAcceptedOffer: '$totalNumAcceptedOffer',
1106
- maxNumAcceptedOffer: '$maxNumAcceptedOffer',
1107
- minNumAcceptedOffer: '$minNumAcceptedOffer',
1108
- avgNumAcceptedOffer: '$avgNumAcceptedOffer',
1109
- totalPrice: '$totalPrice',
1110
- maxPrice: '$maxPrice',
1111
- minPrice: '$minPrice',
1112
- avgPrice: '$avgPrice'
1113
- }
1055
+ : undefined
1056
+ };
1057
+ const aggregations = await this.orderModel.aggregate([
1058
+ { $match: matchConditions },
1059
+ {
1060
+ $project: {
1061
+ typeOf: '$typeOf',
1062
+ price: '$price',
1063
+ numAcceptedOffers: { $size: '$acceptedOffers' }
1064
+ }
1065
+ },
1066
+ {
1067
+ $group: {
1068
+ _id: '$typeOf',
1069
+ orderCount: { $sum: 1 },
1070
+ totalNumAcceptedOffer: { $sum: '$numAcceptedOffers' },
1071
+ maxNumAcceptedOffer: { $max: '$numAcceptedOffers' },
1072
+ minNumAcceptedOffer: { $min: '$numAcceptedOffers' },
1073
+ avgNumAcceptedOffer: { $avg: '$numAcceptedOffers' },
1074
+ totalPrice: { $sum: '$price' },
1075
+ maxPrice: { $max: '$price' },
1076
+ minPrice: { $min: '$price' },
1077
+ avgPrice: { $avg: '$price' }
1078
+ }
1079
+ },
1080
+ {
1081
+ $project: {
1082
+ _id: 0,
1083
+ orderCount: '$orderCount',
1084
+ totalNumAcceptedOffer: '$totalNumAcceptedOffer',
1085
+ maxNumAcceptedOffer: '$maxNumAcceptedOffer',
1086
+ minNumAcceptedOffer: '$minNumAcceptedOffer',
1087
+ avgNumAcceptedOffer: '$avgNumAcceptedOffer',
1088
+ totalPrice: '$totalPrice',
1089
+ maxPrice: '$maxPrice',
1090
+ minPrice: '$minPrice',
1091
+ avgPrice: '$avgPrice'
1114
1092
  }
1115
- ])
1116
- .exec();
1117
- if (aggregations.length === 0) {
1118
- return {
1119
- aggregation: {
1120
- orderCount: 0,
1121
- totalNumAcceptedOffer: 0,
1122
- maxNumAcceptedOffer: 0,
1123
- minNumAcceptedOffer: 0,
1124
- avgNumAcceptedOffer: 0,
1125
- totalPrice: 0,
1126
- maxPrice: 0,
1127
- minPrice: 0,
1128
- avgPrice: 0
1129
- }
1130
- };
1131
1093
  }
1132
- return { aggregation: aggregations[0] };
1133
- });
1094
+ ])
1095
+ .exec();
1096
+ if (aggregations.length === 0) {
1097
+ return {
1098
+ aggregation: {
1099
+ orderCount: 0,
1100
+ totalNumAcceptedOffer: 0,
1101
+ maxNumAcceptedOffer: 0,
1102
+ minNumAcceptedOffer: 0,
1103
+ avgNumAcceptedOffer: 0,
1104
+ totalPrice: 0,
1105
+ maxPrice: 0,
1106
+ minPrice: 0,
1107
+ avgPrice: 0
1108
+ }
1109
+ };
1110
+ }
1111
+ return { aggregation: aggregations[0] };
1134
1112
  }
1135
- aggregateOrderOfSeat(params) {
1136
- return __awaiter(this, void 0, void 0, function* () {
1137
- var _a, _b;
1138
- const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
1139
- const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
1140
- const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
1141
- const customerEmailIn = (_b = (_a = params.customer) === null || _a === void 0 ? void 0 : _a.email) === null || _b === void 0 ? void 0 : _b.$in;
1142
- const matchConditions = Object.assign({ orderDate: {
1143
- $gte: params.orderDate.$gte,
1144
- $lte: params.orderDate.$lte
1145
- }, typeOf: { $eq: factory.order.OrderType.Order }, 'project.id': { $eq: params.project.id.$eq }, 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode }, 'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode }, 'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber } }, (Array.isArray(customerEmailIn))
1113
+ async aggregateOrderOfSeat(params) {
1114
+ const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
1115
+ const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
1116
+ const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
1117
+ const customerEmailIn = params.customer?.email?.$in;
1118
+ const matchConditions = {
1119
+ orderDate: {
1120
+ $gte: params.orderDate.$gte,
1121
+ $lte: params.orderDate.$lte
1122
+ },
1123
+ typeOf: { $eq: factory.order.OrderType.Order },
1124
+ 'project.id': { $eq: params.project.id.$eq },
1125
+ 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode },
1126
+ 'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode },
1127
+ 'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber },
1128
+ ...(Array.isArray(customerEmailIn))
1146
1129
  ? { 'customer.email': { $exists: true, $in: customerEmailIn } }
1147
- : undefined);
1148
- const aggregations4email = yield this.orderModel.aggregate([
1149
- { $match: matchConditions },
1150
- {
1151
- $group: {
1152
- _id: '$customer.email'
1153
- }
1154
- },
1155
- {
1156
- $count: 'emailCount'
1130
+ : undefined
1131
+ };
1132
+ const aggregations4email = await this.orderModel.aggregate([
1133
+ { $match: matchConditions },
1134
+ {
1135
+ $group: {
1136
+ _id: '$customer.email'
1157
1137
  }
1158
- ])
1159
- .exec();
1160
- const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
1161
- const aggregations = yield this.orderModel.aggregate([
1162
- { $match: matchConditions },
1163
- {
1164
- $project: {
1165
- typeOf: '$typeOf',
1166
- graceTime: {
1167
- $subtract: [
1168
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1169
- '$orderDate'
1170
- ]
1171
- }
1172
- }
1173
- },
1174
- {
1175
- $group: {
1176
- _id: '$typeOf',
1177
- orderCount: { $sum: 1 },
1178
- sumGraceTime: { $sum: '$graceTime' }
1179
- }
1180
- },
1181
- {
1182
- $project: {
1183
- _id: 0,
1184
- orderCount: '$orderCount',
1185
- sumGraceTime: '$sumGraceTime'
1138
+ },
1139
+ {
1140
+ $count: 'emailCount'
1141
+ }
1142
+ ])
1143
+ .exec();
1144
+ const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
1145
+ const aggregations = await this.orderModel.aggregate([
1146
+ { $match: matchConditions },
1147
+ {
1148
+ $project: {
1149
+ typeOf: '$typeOf',
1150
+ graceTime: {
1151
+ $subtract: [
1152
+ { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1153
+ '$orderDate'
1154
+ ]
1186
1155
  }
1187
1156
  }
1188
- ])
1189
- .exec();
1190
- if (aggregations.length === 0) {
1191
- return {
1192
- aggregation: {
1193
- orderCount: 0
1194
- }
1195
- };
1157
+ },
1158
+ {
1159
+ $group: {
1160
+ _id: '$typeOf',
1161
+ orderCount: { $sum: 1 },
1162
+ sumGraceTime: { $sum: '$graceTime' }
1163
+ }
1164
+ },
1165
+ {
1166
+ $project: {
1167
+ _id: 0,
1168
+ orderCount: '$orderCount',
1169
+ sumGraceTime: '$sumGraceTime'
1170
+ }
1196
1171
  }
1172
+ ])
1173
+ .exec();
1174
+ if (aggregations.length === 0) {
1197
1175
  return {
1198
- aggregation: Object.assign(Object.assign({}, aggregations[0]), { emailCount })
1176
+ aggregation: {
1177
+ orderCount: 0
1178
+ }
1199
1179
  };
1200
- });
1180
+ }
1181
+ return {
1182
+ aggregation: {
1183
+ ...aggregations[0],
1184
+ emailCount
1185
+ }
1186
+ };
1201
1187
  }
1202
- aggregateOrderOfCustomerByProject(params) {
1203
- return __awaiter(this, void 0, void 0, function* () {
1204
- var _a;
1205
- const matchConditions = Object.assign(Object.assign({ orderDate: {
1206
- $gte: params.orderDate.$gte,
1207
- $lte: params.orderDate.$lte
1208
- }, typeOf: { $eq: factory.order.OrderType.Order } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined), { 'customer.email': { $exists: true, $eq: params.customer.email.$eq } });
1209
- const aggregations = yield this.orderModel.aggregate([
1210
- { $match: matchConditions },
1211
- {
1212
- $project: {
1213
- typeOf: '$typeOf',
1214
- graceTime: {
1215
- $subtract: [
1216
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1217
- '$orderDate'
1218
- ]
1219
- }
1220
- }
1221
- },
1222
- {
1223
- $group: {
1224
- _id: '$typeOf',
1225
- orderCount: { $sum: 1 },
1226
- sumGraceTime: { $sum: '$graceTime' }
1227
- }
1228
- },
1229
- {
1230
- $project: {
1231
- _id: 0,
1232
- orderCount: '$orderCount',
1233
- sumGraceTime: '$sumGraceTime'
1188
+ async aggregateOrderOfCustomerByProject(params) {
1189
+ const matchConditions = {
1190
+ orderDate: {
1191
+ $gte: params.orderDate.$gte,
1192
+ $lte: params.orderDate.$lte
1193
+ },
1194
+ typeOf: { $eq: factory.order.OrderType.Order },
1195
+ ...(typeof params.project?.id.$eq === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined,
1196
+ 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1197
+ };
1198
+ const aggregations = await this.orderModel.aggregate([
1199
+ { $match: matchConditions },
1200
+ {
1201
+ $project: {
1202
+ typeOf: '$typeOf',
1203
+ graceTime: {
1204
+ $subtract: [
1205
+ { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1206
+ '$orderDate'
1207
+ ]
1234
1208
  }
1235
1209
  }
1236
- ])
1237
- .exec();
1238
- if (aggregations.length === 0) {
1239
- return {
1240
- aggregation: {
1241
- orderCount: 0
1242
- }
1243
- };
1210
+ },
1211
+ {
1212
+ $group: {
1213
+ _id: '$typeOf',
1214
+ orderCount: { $sum: 1 },
1215
+ sumGraceTime: { $sum: '$graceTime' }
1216
+ }
1217
+ },
1218
+ {
1219
+ $project: {
1220
+ _id: 0,
1221
+ orderCount: '$orderCount',
1222
+ sumGraceTime: '$sumGraceTime'
1223
+ }
1244
1224
  }
1225
+ ])
1226
+ .exec();
1227
+ if (aggregations.length === 0) {
1245
1228
  return {
1246
- aggregation: Object.assign({}, aggregations[0])
1229
+ aggregation: {
1230
+ orderCount: 0
1231
+ }
1247
1232
  };
1248
- });
1233
+ }
1234
+ return {
1235
+ aggregation: {
1236
+ ...aggregations[0]
1237
+ }
1238
+ };
1249
1239
  }
1250
- aggregateOrderOfCustomerGlobally(params) {
1251
- return __awaiter(this, void 0, void 0, function* () {
1252
- const matchConditions = {
1253
- orderDate: {
1254
- $gte: params.orderDate.$gte,
1255
- $lte: params.orderDate.$lte
1256
- },
1257
- typeOf: { $eq: factory.order.OrderType.Order },
1258
- 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1259
- };
1260
- const aggregations = yield this.orderModel.aggregate([
1261
- { $match: matchConditions },
1262
- {
1263
- $project: {
1264
- typeOf: '$typeOf'
1265
- }
1266
- },
1267
- {
1268
- $group: {
1269
- _id: '$typeOf',
1270
- orderCount: { $sum: 1 }
1271
- }
1272
- },
1273
- {
1274
- $project: {
1275
- _id: 0,
1276
- orderCount: '$orderCount'
1277
- }
1240
+ async aggregateOrderOfCustomerGlobally(params) {
1241
+ const matchConditions = {
1242
+ orderDate: {
1243
+ $gte: params.orderDate.$gte,
1244
+ $lte: params.orderDate.$lte
1245
+ },
1246
+ typeOf: { $eq: factory.order.OrderType.Order },
1247
+ 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1248
+ };
1249
+ const aggregations = await this.orderModel.aggregate([
1250
+ { $match: matchConditions },
1251
+ {
1252
+ $project: {
1253
+ typeOf: '$typeOf'
1278
1254
  }
1279
- ])
1280
- .exec();
1281
- if (aggregations.length === 0) {
1282
- return {
1283
- aggregation: {
1284
- orderCount: 0,
1285
- aggregateProject: { projectCount: 0 }
1286
- }
1287
- };
1288
- }
1289
- const aggregations2 = yield this.orderModel.aggregate([
1290
- { $match: matchConditions },
1291
- {
1292
- $project: {
1293
- project: '$project'
1294
- }
1295
- },
1296
- {
1297
- $group: {
1298
- _id: '$project.id'
1299
- }
1300
- },
1301
- {
1302
- $count: 'projectCount'
1303
- },
1304
- {
1305
- $project: {
1306
- aggregateProject: { projectCount: '$projectCount' }
1307
- }
1255
+ },
1256
+ {
1257
+ $group: {
1258
+ _id: '$typeOf',
1259
+ orderCount: { $sum: 1 }
1308
1260
  }
1309
- ])
1310
- .exec();
1261
+ },
1262
+ {
1263
+ $project: {
1264
+ _id: 0,
1265
+ orderCount: '$orderCount'
1266
+ }
1267
+ }
1268
+ ])
1269
+ .exec();
1270
+ if (aggregations.length === 0) {
1311
1271
  return {
1312
- aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
1272
+ aggregation: {
1273
+ orderCount: 0,
1274
+ aggregateProject: { projectCount: 0 }
1275
+ }
1313
1276
  };
1314
- });
1277
+ }
1278
+ const aggregations2 = await this.orderModel.aggregate([
1279
+ { $match: matchConditions },
1280
+ {
1281
+ $project: {
1282
+ project: '$project'
1283
+ }
1284
+ },
1285
+ {
1286
+ $group: {
1287
+ _id: '$project.id'
1288
+ }
1289
+ },
1290
+ {
1291
+ $count: 'projectCount'
1292
+ },
1293
+ {
1294
+ $project: {
1295
+ aggregateProject: { projectCount: '$projectCount' }
1296
+ }
1297
+ }
1298
+ ])
1299
+ .exec();
1300
+ return {
1301
+ aggregation: {
1302
+ ...aggregations[0],
1303
+ ...aggregations2[0]
1304
+ }
1305
+ };
1315
1306
  }
1316
1307
  }
1317
1308
  exports.OrderRepo = OrderRepo;