@chevre/domain 23.2.0-alpha.60 → 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.
- package/lib/chevre/credentials/customSearch.js +2 -0
- package/lib/chevre/credentials/lineNotify.js +4 -0
- package/lib/chevre/credentials/sendGrid.js +2 -0
- package/lib/chevre/credentials.js +15 -30
- package/lib/chevre/emailMessageBuilder.js +225 -250
- package/lib/chevre/errorHandler.js +38 -54
- package/lib/chevre/factory/event.js +69 -42
- package/lib/chevre/factory/transactionNumber.js +3 -1
- package/lib/chevre/index.js +15 -30
- package/lib/chevre/repo/acceptedOffer.js +178 -197
- package/lib/chevre/repo/acceptedPaymentMethod.js +131 -143
- package/lib/chevre/repo/account.js +196 -223
- package/lib/chevre/repo/accountTitle.js +9 -21
- package/lib/chevre/repo/accountTransaction.js +189 -189
- package/lib/chevre/repo/accountingReport.js +88 -107
- package/lib/chevre/repo/action.js +853 -880
- package/lib/chevre/repo/additionalProperty.js +65 -91
- package/lib/chevre/repo/advanceBookingRequirement.js +69 -90
- package/lib/chevre/repo/aggregateOffer.js +394 -427
- package/lib/chevre/repo/aggregateOrder.js +50 -62
- package/lib/chevre/repo/aggregateReservation.js +76 -89
- package/lib/chevre/repo/aggregation.js +42 -63
- package/lib/chevre/repo/assetTransaction.js +696 -716
- package/lib/chevre/repo/authorization.js +115 -127
- package/lib/chevre/repo/categoryCode.js +115 -143
- package/lib/chevre/repo/comment.js +74 -82
- package/lib/chevre/repo/concurrentLock.js +17 -29
- package/lib/chevre/repo/confirmationNumber.js +21 -33
- package/lib/chevre/repo/creativeWork.js +154 -176
- package/lib/chevre/repo/credentials.js +40 -51
- package/lib/chevre/repo/customer.js +65 -88
- package/lib/chevre/repo/customerType.js +52 -61
- package/lib/chevre/repo/emailMessage.js +52 -80
- package/lib/chevre/repo/event.d.ts +0 -15
- package/lib/chevre/repo/event.js +720 -744
- package/lib/chevre/repo/eventOffer.js +122 -125
- package/lib/chevre/repo/eventSellerMakesOffer.js +64 -76
- package/lib/chevre/repo/eventSeries.d.ts +1 -7
- package/lib/chevre/repo/eventSeries.js +258 -277
- package/lib/chevre/repo/identity.js +94 -106
- package/lib/chevre/repo/identityProvider.js +72 -95
- package/lib/chevre/repo/issuer.js +102 -135
- package/lib/chevre/repo/member.js +238 -258
- package/lib/chevre/repo/memberProgram.js +157 -177
- package/lib/chevre/repo/merchantReturnPolicy.js +62 -93
- package/lib/chevre/repo/message.js +122 -135
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/advanceBookingRequirement.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateOrder.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/civicStructure.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/customerType.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +41 -14
- package/lib/chevre/repo/mongoose/schemas/identity.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/identityProvider.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/issuer.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/member/global.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/note.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/paymentService.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/potentialAction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/productModel.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/productOffer.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/reserveInterface.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/schedule.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/seller.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/ticket.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/transaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/transactionNumber.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/webSite.js +1 -1
- package/lib/chevre/repo/movieTicketType.js +68 -89
- package/lib/chevre/repo/note.js +143 -146
- package/lib/chevre/repo/noteAboutOrder.js +112 -113
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +331 -313
- package/lib/chevre/repo/offerCatalog.js +302 -333
- package/lib/chevre/repo/offerCatalogItem.js +289 -316
- package/lib/chevre/repo/offerItemCondition.js +60 -85
- package/lib/chevre/repo/order.js +563 -572
- package/lib/chevre/repo/orderInTransaction.js +113 -136
- package/lib/chevre/repo/orderNumber.d.ts +0 -1
- package/lib/chevre/repo/orderNumber.js +108 -122
- package/lib/chevre/repo/ownershipInfo.js +213 -233
- package/lib/chevre/repo/passport.js +94 -102
- package/lib/chevre/repo/paymentMethod/creditCard.js +153 -169
- package/lib/chevre/repo/paymentService.js +180 -199
- package/lib/chevre/repo/paymentServiceChannel.js +76 -99
- package/lib/chevre/repo/paymentServiceProvider.js +186 -201
- package/lib/chevre/repo/pendingReservation.js +275 -305
- package/lib/chevre/repo/permit.js +47 -42
- package/lib/chevre/repo/person.js +227 -247
- package/lib/chevre/repo/place/busStop.js +77 -103
- package/lib/chevre/repo/place/entranceGate.js +123 -128
- package/lib/chevre/repo/place/hasPOS.js +108 -120
- package/lib/chevre/repo/place/movieTheater.js +187 -219
- package/lib/chevre/repo/place/screeningRoom.js +340 -324
- package/lib/chevre/repo/place/seat.js +539 -475
- package/lib/chevre/repo/place/section.js +329 -292
- package/lib/chevre/repo/potentialAction.js +67 -86
- package/lib/chevre/repo/priceSpecification.js +103 -141
- package/lib/chevre/repo/product.js +204 -238
- package/lib/chevre/repo/productHasOfferCatalog.js +39 -50
- package/lib/chevre/repo/productModel.js +94 -126
- package/lib/chevre/repo/productOffer.js +119 -118
- package/lib/chevre/repo/project.js +123 -141
- package/lib/chevre/repo/projectMakesOffer.js +96 -108
- package/lib/chevre/repo/rateLimit/offer.js +43 -56
- package/lib/chevre/repo/reservation.js +370 -345
- package/lib/chevre/repo/reserveInterface.js +31 -42
- package/lib/chevre/repo/role.js +94 -112
- package/lib/chevre/repo/schedule.js +25 -36
- package/lib/chevre/repo/seller.js +115 -145
- package/lib/chevre/repo/sellerMakesOffer.js +95 -110
- package/lib/chevre/repo/sellerPaymentAccepted.js +92 -109
- package/lib/chevre/repo/sellerReturnPolicy.js +74 -96
- package/lib/chevre/repo/service/availableHour.js +27 -38
- package/lib/chevre/repo/serviceOutput.js +55 -66
- package/lib/chevre/repo/serviceOutputIdentifier.js +46 -57
- package/lib/chevre/repo/setting/jwt.js +40 -50
- package/lib/chevre/repo/setting.js +48 -48
- package/lib/chevre/repo/stockHolder.js +179 -197
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/task.js +615 -617
- package/lib/chevre/repo/telemetry.js +1 -0
- package/lib/chevre/repo/ticket.js +52 -65
- package/lib/chevre/repo/transaction.js +758 -795
- package/lib/chevre/repo/transactionNumber.js +67 -80
- package/lib/chevre/repo/transactionNumberCounter.js +69 -79
- package/lib/chevre/repo/transactionProcess.js +36 -47
- package/lib/chevre/repo/trip.js +145 -163
- package/lib/chevre/repo/webSite.js +90 -105
- package/lib/chevre/repository.js +455 -646
- package/lib/chevre/service/account.js +9 -18
- package/lib/chevre/service/accountTransaction/deposit.js +16 -17
- package/lib/chevre/service/accountTransaction/transfer.js +18 -19
- package/lib/chevre/service/accountTransaction/withdraw.js +16 -17
- package/lib/chevre/service/accountTransaction.js +4 -13
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +63 -60
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +52 -55
- package/lib/chevre/service/aggregation/event/findEventOffers.js +7 -17
- package/lib/chevre/service/aggregation/event/importFromCOA.js +4 -13
- package/lib/chevre/service/aggregation/project.js +10 -19
- package/lib/chevre/service/aggregation/system.js +182 -99
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +31 -17
- package/lib/chevre/service/assetTransaction/cancelReservation/start.js +17 -23
- package/lib/chevre/service/assetTransaction/cancelReservation/startAndConfirm.js +17 -15
- package/lib/chevre/service/assetTransaction/cancelReservation.js +7 -16
- package/lib/chevre/service/assetTransaction/cancelReservationCOA/factory.js +11 -4
- package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +4 -13
- package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/fixInformAction.js +9 -16
- package/lib/chevre/service/assetTransaction/moneyTransfer/potentialActions.js +13 -25
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +101 -88
- package/lib/chevre/service/assetTransaction/pay/cancel.d.ts +12 -0
- package/lib/chevre/service/assetTransaction/pay/cancel.js +16 -0
- package/lib/chevre/service/assetTransaction/pay/check.d.ts +23 -0
- package/lib/chevre/service/assetTransaction/pay/check.js +27 -0
- package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +24 -0
- package/lib/chevre/service/assetTransaction/pay/confirm.js +69 -0
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.d.ts +18 -0
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +102 -0
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +48 -0
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +165 -0
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +20 -0
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +49 -0
- package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.js +7 -17
- package/lib/chevre/service/assetTransaction/pay/{factory.d.ts → start/factory.d.ts} +1 -1
- package/lib/chevre/service/assetTransaction/pay/{factory.js → start/factory.js} +65 -37
- package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.d.ts → start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts} +4 -4
- package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.js → start/preStart/validateAcceptedPaymentMethodIfNeeded.js} +8 -21
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +8 -0
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +44 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +13 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +39 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +29 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +31 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +42 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +22 -0
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +60 -0
- package/lib/chevre/service/assetTransaction/pay/start.js +139 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +8 -170
- package/lib/chevre/service/assetTransaction/pay.js +16 -623
- package/lib/chevre/service/assetTransaction/refund/factory.js +36 -16
- package/lib/chevre/service/assetTransaction/refund/potentialActions.js +12 -21
- package/lib/chevre/service/assetTransaction/refund.js +35 -39
- package/lib/chevre/service/assetTransaction/registerService/factory.js +65 -28
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +50 -41
- package/lib/chevre/service/assetTransaction/registerService.js +45 -52
- package/lib/chevre/service/assetTransaction/reserve/cancel.js +5 -14
- package/lib/chevre/service/assetTransaction/reserve/confirm/factory.js +15 -3
- package/lib/chevre/service/assetTransaction/reserve/confirm.js +21 -26
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +3 -12
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +99 -79
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +17 -12
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +108 -70
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +69 -30
- package/lib/chevre/service/assetTransaction/reserve/start/factory/price.js +29 -20
- package/lib/chevre/service/assetTransaction/reserve/start.js +91 -106
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +5 -15
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +41 -54
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +42 -55
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +7 -17
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +15 -27
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +24 -24
- package/lib/chevre/service/assetTransaction/reserveCOA/factory.js +12 -4
- package/lib/chevre/service/assetTransaction/reserveCOA.js +4 -13
- package/lib/chevre/service/assetTransaction.js +17 -21
- package/lib/chevre/service/delivery/factory.js +3 -4
- package/lib/chevre/service/delivery/product/factory.js +16 -7
- package/lib/chevre/service/delivery/reservation/factory.js +14 -3
- package/lib/chevre/service/delivery.js +47 -49
- package/lib/chevre/service/event/processUpdateMovieTheater.js +21 -23
- package/lib/chevre/service/event/saveScreeningEventSeries.js +56 -37
- package/lib/chevre/service/event/saveScreeningEvents.js +14 -23
- package/lib/chevre/service/event.js +34 -27
- package/lib/chevre/service/iam.js +8 -17
- package/lib/chevre/service/moneyTransfer.js +128 -112
- package/lib/chevre/service/notification/factory.js +11 -8
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +11 -15
- package/lib/chevre/service/notification/notifyByEmail.js +7 -17
- package/lib/chevre/service/notification/sendEmailMessage.js +23 -26
- package/lib/chevre/service/notification/triggerWebhook.js +58 -54
- package/lib/chevre/service/offer/any.js +6 -15
- package/lib/chevre/service/offer/event/authorize/factory.js +139 -61
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +8 -18
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +43 -27
- package/lib/chevre/service/offer/event/authorize.js +114 -68
- package/lib/chevre/service/offer/event/checkAvailability.js +5 -15
- package/lib/chevre/service/offer/event/importFromCOA/factory.js +9 -2
- package/lib/chevre/service/offer/event/importFromCOA.js +13 -19
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +38 -39
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +26 -38
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +11 -22
- package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +13 -24
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +15 -22
- package/lib/chevre/service/offer/event/searchOffersByIds.js +24 -36
- package/lib/chevre/service/offer/event/searchPriceSpecs4event.js +5 -14
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +4 -13
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +6 -15
- package/lib/chevre/service/offer/event/voidTransaction.js +35 -39
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +14 -20
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +52 -40
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +5 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +34 -37
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +45 -22
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +67 -59
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +16 -26
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +8 -18
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +42 -41
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +22 -25
- package/lib/chevre/service/offer/factory.js +18 -7
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +31 -36
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +9 -18
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +10 -19
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +14 -24
- package/lib/chevre/service/offer/onEventChanged.js +69 -64
- package/lib/chevre/service/offer/product/factory.js +54 -29
- package/lib/chevre/service/offer/product/searchProductOffers.js +30 -23
- package/lib/chevre/service/offer/product.js +106 -80
- package/lib/chevre/service/offer.js +48 -44
- package/lib/chevre/service/order/confirmPayTransaction.js +28 -27
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +54 -41
- package/lib/chevre/service/order/deleteOrder.js +28 -35
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +3 -12
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +64 -68
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +1 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +3 -12
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +11 -6
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +5 -14
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +22 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +5 -14
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +23 -26
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +13 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +5 -14
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +24 -13
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +23 -32
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +8 -18
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +10 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +23 -28
- package/lib/chevre/service/order/onOrderUpdated/factory.js +3 -5
- package/lib/chevre/service/order/onOrderUpdated.js +13 -15
- package/lib/chevre/service/order/payOrder.js +3 -12
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +9 -19
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +31 -15
- package/lib/chevre/service/order/placeOrder/factory.js +35 -22
- package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.js +3 -12
- package/lib/chevre/service/order/placeOrder.js +12 -22
- package/lib/chevre/service/order/placeOrderWithoutTransaction.js +10 -18
- package/lib/chevre/service/order/returnOrder.js +27 -29
- package/lib/chevre/service/order/sendOrder.js +37 -36
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +19 -25
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +24 -37
- package/lib/chevre/service/payment/any/factory.js +106 -49
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -13
- package/lib/chevre/service/payment/any/onPayActionCompleted.js +13 -18
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +34 -37
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +18 -24
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +16 -16
- package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +15 -20
- package/lib/chevre/service/payment/any/person2username.js +33 -45
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +8 -18
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +5 -15
- package/lib/chevre/service/payment/any.js +181 -137
- package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.js +2 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +44 -24
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +6 -15
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.js +5 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.js +10 -2
- package/lib/chevre/service/payment/creditCard/authorize.js +20 -22
- package/lib/chevre/service/payment/creditCard/factory.js +22 -4
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +8 -18
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +31 -36
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +40 -49
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +33 -45
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +15 -25
- package/lib/chevre/service/payment/faceToFace.js +14 -23
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +44 -25
- package/lib/chevre/service/payment/factory.js +50 -23
- package/lib/chevre/service/payment/movieTicket/authorize.js +35 -28
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +22 -25
- package/lib/chevre/service/payment/movieTicket/factory.js +33 -10
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +5 -15
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +29 -40
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +8 -18
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +60 -59
- package/lib/chevre/service/payment/movieTicket/validation.js +41 -36
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +8 -18
- package/lib/chevre/service/payment/paymentCard.js +87 -103
- package/lib/chevre/service/permit.js +36 -35
- package/lib/chevre/service/product.js +23 -27
- package/lib/chevre/service/project.js +22 -31
- package/lib/chevre/service/report/ownershipInfo.js +3 -4
- package/lib/chevre/service/report/telemetry.js +51 -55
- package/lib/chevre/service/reserve/cancelReservation.js +92 -90
- package/lib/chevre/service/reserve/checkInReservation.js +24 -29
- package/lib/chevre/service/reserve/confirmReservation.js +33 -38
- package/lib/chevre/service/reserve/factory.js +42 -20
- package/lib/chevre/service/reserve/findByCode.js +13 -18
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +18 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +17 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +38 -29
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +45 -35
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +37 -32
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +17 -23
- package/lib/chevre/service/reserve/searchByOrder.js +10 -19
- package/lib/chevre/service/reserve/useReservation.js +47 -32
- package/lib/chevre/service/reserve/verifyToken4reservation.js +7 -14
- package/lib/chevre/service/reserveCOA/cancelReservation.js +7 -16
- package/lib/chevre/service/reserveCOA/factory.js +5 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +20 -24
- package/lib/chevre/service/task/aggregateOffers.js +3 -12
- package/lib/chevre/service/task/aggregateOnSystem.js +4 -14
- package/lib/chevre/service/task/aggregateScreeningEvent.js +3 -12
- package/lib/chevre/service/task/authorizePayment.js +9 -15
- package/lib/chevre/service/task/cancelMoneyTransfer.js +3 -12
- package/lib/chevre/service/task/cancelPendingReservation.js +10 -20
- package/lib/chevre/service/task/cancelReservation.js +3 -12
- package/lib/chevre/service/task/checkMovieTicket.js +16 -19
- package/lib/chevre/service/task/checkResource.js +7 -16
- package/lib/chevre/service/task/confirmMoneyTransfer.js +3 -12
- package/lib/chevre/service/task/confirmPayTransaction.js +6 -12
- package/lib/chevre/service/task/confirmRegisterService.js +3 -12
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +24 -31
- package/lib/chevre/service/task/confirmReserveTransaction.js +48 -42
- package/lib/chevre/service/task/createAccountingReport.js +14 -20
- package/lib/chevre/service/task/deletePerson.js +48 -58
- package/lib/chevre/service/task/deleteTransaction.js +3 -12
- package/lib/chevre/service/task/givePointAward.js +3 -12
- package/lib/chevre/service/task/handleNotification.js +4 -14
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +6 -16
- package/lib/chevre/service/task/importEventsFromCOA.js +6 -16
- package/lib/chevre/service/task/importOffersFromCOA.js +8 -18
- package/lib/chevre/service/task/invalidatePaymentUrl.js +6 -12
- package/lib/chevre/service/task/moneyTransfer.js +3 -12
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +3 -12
- package/lib/chevre/service/task/onAuthorizationCreated.js +11 -18
- package/lib/chevre/service/task/onEventChanged.js +3 -12
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +3 -12
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +7 -16
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +7 -16
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +8 -17
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +10 -19
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +8 -17
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +6 -15
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +14 -23
- package/lib/chevre/service/task/onResourceDeleted.js +17 -26
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +9 -21
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +3 -12
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +11 -23
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +13 -25
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +9 -15
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +21 -27
- package/lib/chevre/service/task/onResourceUpdated.js +113 -153
- package/lib/chevre/service/task/pay.js +8 -16
- package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.js +4 -14
- package/lib/chevre/service/task/payment/payByTask.js +49 -38
- package/lib/chevre/service/task/payment/refundByTask.js +7 -17
- package/lib/chevre/service/task/payment/voidPaymentByTask.js +6 -15
- package/lib/chevre/service/task/placeOrder.js +6 -12
- package/lib/chevre/service/task/publishPaymentUrl.js +9 -14
- package/lib/chevre/service/task/refund.js +8 -16
- package/lib/chevre/service/task/registerService.js +3 -12
- package/lib/chevre/service/task/reserve.js +3 -12
- package/lib/chevre/service/task/returnMoneyTransfer.js +3 -12
- package/lib/chevre/service/task/returnOrder.js +6 -12
- package/lib/chevre/service/task/returnPayTransaction.js +54 -48
- package/lib/chevre/service/task/returnPointAward.js +3 -12
- package/lib/chevre/service/task/returnReserveTransaction.js +29 -30
- package/lib/chevre/service/task/sendEmailMessage.js +6 -13
- package/lib/chevre/service/task/sendOrder.js +12 -15
- package/lib/chevre/service/task/syncResourcesFromCOA.js +39 -40
- package/lib/chevre/service/task/triggerWebhook.js +6 -12
- package/lib/chevre/service/task/useReservation.js +11 -14
- package/lib/chevre/service/task/voidMoneyTransferTransaction.js +3 -12
- package/lib/chevre/service/task/voidPayTransaction.js +7 -12
- package/lib/chevre/service/task/voidPayment.js +3 -12
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -12
- package/lib/chevre/service/task/voidReserveTransaction.js +10 -16
- package/lib/chevre/service/task.js +16 -22
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +9 -20
- package/lib/chevre/service/taskHandler/onOperationFailed.js +20 -17
- package/lib/chevre/service/taskHandler.js +19 -21
- package/lib/chevre/service/transaction/deleteTransaction.js +104 -84
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +15 -6
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +13 -4
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +12 -24
- package/lib/chevre/service/transaction/moneyTransfer.js +119 -96
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +49 -51
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +14 -25
- package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +4 -14
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +3 -4
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.js +3 -4
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +30 -45
- package/lib/chevre/service/transaction/placeOrder/confirm.js +75 -55
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +31 -13
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +6 -15
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +6 -15
- package/lib/chevre/service/transaction/placeOrder/publishOrderNumberIfNotExist.js +7 -16
- package/lib/chevre/service/transaction/placeOrder/start/factory.js +27 -7
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +53 -59
- package/lib/chevre/service/transaction/placeOrder/start.js +14 -18
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +13 -6
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +176 -190
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +77 -89
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +40 -48
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +52 -56
- package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.js +100 -102
- package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +60 -80
- package/lib/chevre/service/transaction/returnOrder/preStart.js +42 -46
- package/lib/chevre/service/transaction/returnOrder.js +32 -36
- package/lib/chevre/service/transaction.js +75 -46
- package/lib/chevre/service/validation/validateEvent.js +2 -11
- package/lib/chevre/service/validation/validateOrder.js +7 -16
- package/lib/chevre/service.js +85 -128
- package/lib/chevre/settings/aggregation.js +4 -0
- package/lib/chevre/settings.js +7 -0
- package/package.json +8 -11
- package/example/src/chevre/addEventBySchedule.ts +0 -46
- package/example/src/chevre/orderNumber/decryptOrderNumber.ts +0 -14
- package/example/src/idaas/auth0/adminApplications.ts +0 -183
- package/example/src/idaas/auth0/getToken.ts +0 -55
- package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +0 -84
- package/lib/chevre/service/task/createEvent/createEvent.d.ts +0 -25
- package/lib/chevre/service/task/createEvent/createEvent.js +0 -45
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +0 -22
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +0 -190
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +0 -15
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +0 -118
- package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +0 -25
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +0 -107
- package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +0 -13
- package/lib/chevre/service/task/createEvent/createEventSeries.js +0 -118
- package/lib/chevre/service/task/createEvent.d.ts +0 -6
- package/lib/chevre/service/task/createEvent.js +0 -46
|
@@ -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.AssetTransactionRepo = void 0;
|
|
13
4
|
const moment = require("moment");
|
|
@@ -19,16 +10,17 @@ const settings_1 = require("../settings");
|
|
|
19
10
|
* 資産取引リポジトリ
|
|
20
11
|
*/
|
|
21
12
|
class AssetTransactionRepo {
|
|
13
|
+
// private化(2022-06-08~)
|
|
14
|
+
transactionModel;
|
|
22
15
|
constructor(connection) {
|
|
23
16
|
this.transactionModel = connection.model(assetTransaction_1.modelName, (0, assetTransaction_1.createSchema)());
|
|
24
17
|
}
|
|
25
18
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
26
19
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
27
|
-
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, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36;
|
|
28
20
|
const andConditions = [
|
|
29
21
|
{ typeOf: { $eq: params.typeOf } }
|
|
30
22
|
];
|
|
31
|
-
const projectIdEq =
|
|
23
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
32
24
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
33
25
|
/* istanbul ignore else */
|
|
34
26
|
if (typeof projectIdEq === 'string') {
|
|
@@ -82,7 +74,7 @@ class AssetTransactionRepo {
|
|
|
82
74
|
}
|
|
83
75
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
84
76
|
/* istanbul ignore else */
|
|
85
|
-
const statusIn =
|
|
77
|
+
const statusIn = params.status?.$in;
|
|
86
78
|
if (Array.isArray(statusIn)) {
|
|
87
79
|
andConditions.push({ status: { $in: statusIn } });
|
|
88
80
|
}
|
|
@@ -95,21 +87,21 @@ class AssetTransactionRepo {
|
|
|
95
87
|
});
|
|
96
88
|
}
|
|
97
89
|
}
|
|
98
|
-
const transactionNumberEq =
|
|
90
|
+
const transactionNumberEq = params.transactionNumber?.$eq;
|
|
99
91
|
if (typeof transactionNumberEq === 'string') {
|
|
100
92
|
andConditions.push({ transactionNumber: { $eq: transactionNumberEq } });
|
|
101
93
|
}
|
|
102
|
-
const transactionNumberIn =
|
|
94
|
+
const transactionNumberIn = params.transactionNumber?.$in;
|
|
103
95
|
if (Array.isArray(transactionNumberIn)) {
|
|
104
96
|
andConditions.push({ transactionNumber: { $in: transactionNumberIn } });
|
|
105
97
|
}
|
|
106
|
-
const tasksExportActionStatusIn =
|
|
98
|
+
const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
107
99
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
108
100
|
/* istanbul ignore else */
|
|
109
101
|
if (Array.isArray(tasksExportActionStatusIn)) {
|
|
110
102
|
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
111
103
|
}
|
|
112
|
-
const tasksExportActionStatusEq =
|
|
104
|
+
const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
113
105
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
114
106
|
/* istanbul ignore else */
|
|
115
107
|
if (typeof tasksExportActionStatusEq === 'string') {
|
|
@@ -117,17 +109,17 @@ class AssetTransactionRepo {
|
|
|
117
109
|
}
|
|
118
110
|
switch (params.typeOf) {
|
|
119
111
|
case factory.assetTransactionType.Pay:
|
|
120
|
-
const objectAccountIdEq =
|
|
112
|
+
const objectAccountIdEq = params.object?.accountId?.$eq;
|
|
121
113
|
if (typeof objectAccountIdEq === 'string') {
|
|
122
114
|
andConditions.push({ 'object.accountId': { $exists: true, $eq: objectAccountIdEq } });
|
|
123
115
|
}
|
|
124
|
-
const objectTypeOfEq =
|
|
116
|
+
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
125
117
|
if (typeof objectTypeOfEq === 'string') {
|
|
126
118
|
andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
|
|
127
119
|
}
|
|
128
120
|
break;
|
|
129
121
|
case factory.assetTransactionType.Refund:
|
|
130
|
-
const objectAccountIdEq4refund =
|
|
122
|
+
const objectAccountIdEq4refund = params.object?.accountId?.$eq;
|
|
131
123
|
if (typeof objectAccountIdEq4refund === 'string') {
|
|
132
124
|
andConditions.push({
|
|
133
125
|
'object.accountId': {
|
|
@@ -136,13 +128,13 @@ class AssetTransactionRepo {
|
|
|
136
128
|
}
|
|
137
129
|
});
|
|
138
130
|
}
|
|
139
|
-
const objectPaymentMethodIdEq4refund =
|
|
131
|
+
const objectPaymentMethodIdEq4refund = params.object?.paymentMethodId?.$eq;
|
|
140
132
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
141
133
|
andConditions.push({
|
|
142
134
|
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
143
135
|
});
|
|
144
136
|
}
|
|
145
|
-
const objectPaymentMethodIdIn4refund =
|
|
137
|
+
const objectPaymentMethodIdIn4refund = params.object?.paymentMethodId?.$in;
|
|
146
138
|
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
147
139
|
andConditions.push({
|
|
148
140
|
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
@@ -150,7 +142,7 @@ class AssetTransactionRepo {
|
|
|
150
142
|
}
|
|
151
143
|
break;
|
|
152
144
|
case factory.assetTransactionType.MoneyTransfer:
|
|
153
|
-
const fromLocationIdentifierEq =
|
|
145
|
+
const fromLocationIdentifierEq = params.object?.fromLocation?.identifier?.$eq;
|
|
154
146
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
155
147
|
andConditions.push({
|
|
156
148
|
'object.fromLocation.identifier': {
|
|
@@ -159,7 +151,7 @@ class AssetTransactionRepo {
|
|
|
159
151
|
}
|
|
160
152
|
});
|
|
161
153
|
}
|
|
162
|
-
const toLocationIdentifierEq =
|
|
154
|
+
const toLocationIdentifierEq = params.object?.toLocation?.identifier?.$eq;
|
|
163
155
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
164
156
|
andConditions.push({
|
|
165
157
|
'object.toLocation.identifier': {
|
|
@@ -168,7 +160,7 @@ class AssetTransactionRepo {
|
|
|
168
160
|
}
|
|
169
161
|
});
|
|
170
162
|
}
|
|
171
|
-
const pendingTransactionIdentifierEq =
|
|
163
|
+
const pendingTransactionIdentifierEq = params.object?.pendingTransaction?.identifier?.$eq;
|
|
172
164
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
173
165
|
andConditions.push({
|
|
174
166
|
'object.pendingTransaction.identifier': {
|
|
@@ -179,13 +171,13 @@ class AssetTransactionRepo {
|
|
|
179
171
|
}
|
|
180
172
|
break;
|
|
181
173
|
case factory.assetTransactionType.CancelReservation:
|
|
182
|
-
const objectReservationNumberIn4cancelReservation =
|
|
174
|
+
const objectReservationNumberIn4cancelReservation = params.object?.reservationNumber?.$in;
|
|
183
175
|
if (Array.isArray(objectReservationNumberIn4cancelReservation)) {
|
|
184
176
|
andConditions.push({
|
|
185
177
|
'object.reservationNumber': { $exists: true, $in: objectReservationNumberIn4cancelReservation }
|
|
186
178
|
});
|
|
187
179
|
}
|
|
188
|
-
const objectReservationNumberEq4cancelReservation =
|
|
180
|
+
const objectReservationNumberEq4cancelReservation = params.object?.reservationNumber?.$eq;
|
|
189
181
|
if (typeof objectReservationNumberEq4cancelReservation === 'string') {
|
|
190
182
|
andConditions.push({
|
|
191
183
|
'object.reservationNumber': { $exists: true, $eq: objectReservationNumberEq4cancelReservation }
|
|
@@ -193,11 +185,11 @@ class AssetTransactionRepo {
|
|
|
193
185
|
}
|
|
194
186
|
break;
|
|
195
187
|
case factory.assetTransactionType.Reserve:
|
|
196
|
-
const objectProviderIdEq =
|
|
188
|
+
const objectProviderIdEq = params.object?.provider?.id?.$eq;
|
|
197
189
|
if (typeof objectProviderIdEq === 'string') {
|
|
198
190
|
andConditions.push({ 'object.provider.id': { $exists: true, $eq: objectProviderIdEq } });
|
|
199
191
|
}
|
|
200
|
-
const objectReservationForIdEq =
|
|
192
|
+
const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
|
|
201
193
|
if (typeof objectReservationForIdEq === 'string') {
|
|
202
194
|
andConditions.push({
|
|
203
195
|
'object.reservationFor.id': {
|
|
@@ -206,19 +198,19 @@ class AssetTransactionRepo {
|
|
|
206
198
|
}
|
|
207
199
|
});
|
|
208
200
|
}
|
|
209
|
-
const objectReservationNumberIn =
|
|
201
|
+
const objectReservationNumberIn = params.object?.reservationNumber?.$in;
|
|
210
202
|
if (Array.isArray(objectReservationNumberIn)) {
|
|
211
203
|
andConditions.push({
|
|
212
204
|
'object.reservationNumber': { $exists: true, $in: objectReservationNumberIn }
|
|
213
205
|
});
|
|
214
206
|
}
|
|
215
|
-
const objectReservationNumberEq =
|
|
207
|
+
const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
|
|
216
208
|
if (typeof objectReservationNumberEq === 'string') {
|
|
217
209
|
andConditions.push({
|
|
218
210
|
'object.reservationNumber': { $exists: true, $eq: objectReservationNumberEq }
|
|
219
211
|
});
|
|
220
212
|
}
|
|
221
|
-
const objectSubReservationIdIn =
|
|
213
|
+
const objectSubReservationIdIn = params.object?.reservations?.id?.$in;
|
|
222
214
|
if (Array.isArray(objectSubReservationIdIn)) {
|
|
223
215
|
andConditions.push({
|
|
224
216
|
'object.subReservation.id': {
|
|
@@ -253,7 +245,7 @@ class AssetTransactionRepo {
|
|
|
253
245
|
}
|
|
254
246
|
}
|
|
255
247
|
}
|
|
256
|
-
const objectUnderNameIdEq =
|
|
248
|
+
const objectUnderNameIdEq = params.object?.underName?.id?.$eq;
|
|
257
249
|
if (typeof objectUnderNameIdEq === 'string') {
|
|
258
250
|
andConditions.push({
|
|
259
251
|
'object.underName.id': {
|
|
@@ -262,7 +254,7 @@ class AssetTransactionRepo {
|
|
|
262
254
|
}
|
|
263
255
|
});
|
|
264
256
|
}
|
|
265
|
-
const objectSubReservationSeatNumberEq =
|
|
257
|
+
const objectSubReservationSeatNumberEq = params.object?.reservations?.reservedTicket?.ticketedSeat?.seatNumber?.$eq;
|
|
266
258
|
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
267
259
|
andConditions.push({
|
|
268
260
|
'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
@@ -273,7 +265,7 @@ class AssetTransactionRepo {
|
|
|
273
265
|
}
|
|
274
266
|
break;
|
|
275
267
|
case factory.assetTransactionType.RegisterService:
|
|
276
|
-
const objectItemOfferedServiceOutputIdentifierEq =
|
|
268
|
+
const objectItemOfferedServiceOutputIdentifierEq = params.object?.itemOffered?.serviceOutput?.identifier?.$eq;
|
|
277
269
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
278
270
|
andConditions.push({
|
|
279
271
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -282,7 +274,7 @@ class AssetTransactionRepo {
|
|
|
282
274
|
}
|
|
283
275
|
});
|
|
284
276
|
}
|
|
285
|
-
const objectItemOfferedServiceOutputIdentifierIn =
|
|
277
|
+
const objectItemOfferedServiceOutputIdentifierIn = params.object?.itemOffered?.serviceOutput?.identifier?.$in;
|
|
286
278
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
287
279
|
andConditions.push({
|
|
288
280
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -299,213 +291,223 @@ class AssetTransactionRepo {
|
|
|
299
291
|
/**
|
|
300
292
|
* 取引を開始する
|
|
301
293
|
*/
|
|
302
|
-
start(params
|
|
294
|
+
async start(params
|
|
303
295
|
// ): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id'>> {
|
|
304
296
|
) {
|
|
305
|
-
return
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
-
var _a, _b;
|
|
315
|
-
const { typeOf } = params;
|
|
316
|
-
const startDate = new Date();
|
|
317
|
-
const creatingTransaction = Object.assign(Object.assign({}, params), { typeOf, status: factory.transactionStatusType.InProgress, startDate,
|
|
318
|
-
// endDate: undefined,
|
|
319
|
-
tasksExportAction: {
|
|
320
|
-
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
321
|
-
} });
|
|
322
|
-
const result = yield this.transactionModel.insertMany(creatingTransaction, { ordered: false, rawResult: true });
|
|
323
|
-
const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
324
|
-
if (typeof id !== 'string') {
|
|
325
|
-
throw new factory.errors.Internal('assetTransaction not saved');
|
|
297
|
+
return this.transactionModel.create({
|
|
298
|
+
...params,
|
|
299
|
+
typeOf: params.typeOf,
|
|
300
|
+
status: factory.transactionStatusType.InProgress,
|
|
301
|
+
startDate: new Date(),
|
|
302
|
+
endDate: undefined,
|
|
303
|
+
tasksExportAction: {
|
|
304
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
326
305
|
}
|
|
327
|
-
|
|
328
|
-
})
|
|
306
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
|
|
307
|
+
})
|
|
308
|
+
.then((doc) => doc.toObject());
|
|
329
309
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
310
|
+
async startWithMinimalResponse(params) {
|
|
311
|
+
const { typeOf } = params;
|
|
312
|
+
const startDate = new Date();
|
|
313
|
+
const creatingTransaction = {
|
|
314
|
+
...params,
|
|
315
|
+
typeOf,
|
|
316
|
+
status: factory.transactionStatusType.InProgress,
|
|
317
|
+
startDate,
|
|
318
|
+
// endDate: undefined,
|
|
319
|
+
tasksExportAction: {
|
|
320
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
340
321
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
return doc.toObject();
|
|
350
|
-
});
|
|
322
|
+
};
|
|
323
|
+
const result = await this.transactionModel.insertMany(creatingTransaction, { ordered: false, rawResult: true });
|
|
324
|
+
const id = result.insertedIds?.[0]?.toHexString();
|
|
325
|
+
if (typeof id !== 'string') {
|
|
326
|
+
throw new factory.errors.Internal('assetTransaction not saved');
|
|
327
|
+
}
|
|
328
|
+
return { id, startDate };
|
|
351
329
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return doc.toObject();
|
|
372
|
-
});
|
|
330
|
+
async findById(params, inclusion) {
|
|
331
|
+
let projection = {};
|
|
332
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
333
|
+
inclusion.forEach((field) => {
|
|
334
|
+
projection[field] = 1;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
projection = {};
|
|
339
|
+
}
|
|
340
|
+
const doc = await this.transactionModel.findOne({
|
|
341
|
+
_id: { $eq: params.id },
|
|
342
|
+
typeOf: { $eq: params.typeOf }
|
|
343
|
+
}, projection)
|
|
344
|
+
.exec();
|
|
345
|
+
if (doc === null) {
|
|
346
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
347
|
+
}
|
|
348
|
+
return doc.toObject();
|
|
373
349
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
350
|
+
async findByTransactionNumber(params, inclusion) {
|
|
351
|
+
let projection = {};
|
|
352
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
353
|
+
inclusion.forEach((field) => {
|
|
354
|
+
projection[field] = 1;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
projection = {};
|
|
359
|
+
}
|
|
360
|
+
const doc = await this.transactionModel.findOne({
|
|
361
|
+
transactionNumber: { $eq: params.transactionNumber },
|
|
362
|
+
typeOf: { $eq: params.typeOf }
|
|
363
|
+
}, projection)
|
|
364
|
+
.exec();
|
|
365
|
+
if (doc === null) {
|
|
366
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
367
|
+
}
|
|
368
|
+
return doc.toObject();
|
|
369
|
+
}
|
|
370
|
+
async addReservations(params) {
|
|
371
|
+
const doc = await this.transactionModel.findOneAndUpdate({
|
|
372
|
+
_id: { $eq: params.id },
|
|
373
|
+
typeOf: { $eq: params.typeOf },
|
|
374
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
375
|
+
}, {
|
|
376
|
+
$set: {
|
|
377
|
+
'object.acceptedOffer': params.object.acceptedOffer,
|
|
378
|
+
// 'object.issuedThrough': params.object.issuedThrough, // start時保管へ移行(2024-07-01~)
|
|
379
|
+
// 'object.reservationFor': params.object.reservationFor, // start時保管へ移行(2024-07-01~)
|
|
380
|
+
'object.subReservation': params.object.subReservation
|
|
391
381
|
}
|
|
392
|
-
|
|
393
|
-
|
|
382
|
+
}, { new: false, projection: { _id: 1 } })
|
|
383
|
+
.exec();
|
|
384
|
+
if (doc === null) {
|
|
385
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
386
|
+
}
|
|
387
|
+
// return doc.toObject();
|
|
394
388
|
}
|
|
395
389
|
/**
|
|
396
390
|
* 取引を確定する
|
|
397
391
|
*/
|
|
398
|
-
confirm(params) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
392
|
+
async confirm(params) {
|
|
393
|
+
const doc = await this.transactionModel.findOneAndUpdate({
|
|
394
|
+
_id: { $eq: params.id },
|
|
395
|
+
typeOf: { $eq: params.typeOf },
|
|
396
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
397
|
+
}, {
|
|
398
|
+
status: factory.transactionStatusType.Confirmed, // ステータス変更
|
|
399
|
+
endDate: new Date(),
|
|
400
|
+
result: params.result, // resultを更新
|
|
401
|
+
potentialActions: params.potentialActions, // resultを更新
|
|
402
|
+
...(typeof params.object?.underName?.typeOf === 'string')
|
|
406
403
|
? { 'object.underName': params.object.underName }
|
|
407
|
-
: undefined
|
|
404
|
+
: undefined,
|
|
405
|
+
...(typeof params.object?.paymentMethod?.identifier === 'string')
|
|
408
406
|
? { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }
|
|
409
|
-
: undefined
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
421
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already expired`);
|
|
422
|
-
}
|
|
423
|
-
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
424
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already canceled`);
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
428
|
-
}
|
|
407
|
+
: undefined
|
|
408
|
+
}, {
|
|
409
|
+
new: true,
|
|
410
|
+
projection: { _id: 1 }
|
|
411
|
+
})
|
|
412
|
+
.exec();
|
|
413
|
+
// NotFoundであれば取引状態確認
|
|
414
|
+
if (doc === null) {
|
|
415
|
+
const transaction = await this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
|
|
416
|
+
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
417
|
+
// すでに確定済の場合スルー
|
|
429
418
|
}
|
|
430
|
-
|
|
431
|
-
id
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
419
|
+
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
420
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already expired`);
|
|
421
|
+
}
|
|
422
|
+
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
423
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already canceled`);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
430
|
+
id: params.id,
|
|
431
|
+
typeOf: params.typeOf,
|
|
432
|
+
status: factory.transactionStatusType.Confirmed
|
|
435
433
|
});
|
|
436
434
|
}
|
|
437
435
|
/**
|
|
438
436
|
* 取引を開始&確定
|
|
439
437
|
*/
|
|
440
|
-
startAndConfirm(params) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
438
|
+
async startAndConfirm(params) {
|
|
439
|
+
const startDate = new Date();
|
|
440
|
+
await this.transactionModel.create({
|
|
441
|
+
...params,
|
|
442
|
+
_id: params.id,
|
|
443
|
+
typeOf: params.typeOf,
|
|
444
|
+
startDate,
|
|
445
|
+
status: factory.transactionStatusType.Confirmed,
|
|
446
|
+
tasksExportAction: {
|
|
447
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
448
|
+
},
|
|
449
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, // discontinue(2024-06-20~)
|
|
450
|
+
endDate: startDate,
|
|
451
|
+
result: params.result,
|
|
452
|
+
potentialActions: params.potentialActions
|
|
453
|
+
})
|
|
454
|
+
.then((doc) => doc.toObject());
|
|
455
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
456
|
+
id: params.id,
|
|
457
|
+
typeOf: params.typeOf,
|
|
458
|
+
status: factory.transactionStatusType.Confirmed
|
|
455
459
|
});
|
|
460
|
+
return { id: params.id };
|
|
456
461
|
}
|
|
457
|
-
countPotentiallyExportTasks(params) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
endDate: { $exists: true, $lt: endDateLt }
|
|
477
|
-
});
|
|
478
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
479
|
-
query.limit(limit);
|
|
480
|
-
}
|
|
481
|
-
const count = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
482
|
-
.exec();
|
|
483
|
-
return { count };
|
|
462
|
+
async countPotentiallyExportTasks(params) {
|
|
463
|
+
const { endDate, limit } = params;
|
|
464
|
+
const endDateLt = endDate?.$lt;
|
|
465
|
+
if (!(endDateLt instanceof Date)) {
|
|
466
|
+
throw new factory.errors.Argument('endDate.$lt', 'must be Date');
|
|
467
|
+
}
|
|
468
|
+
const query = this.transactionModel.countDocuments({
|
|
469
|
+
status: {
|
|
470
|
+
$in: [
|
|
471
|
+
factory.transactionStatusType.Canceled,
|
|
472
|
+
factory.transactionStatusType.Confirmed,
|
|
473
|
+
factory.transactionStatusType.Expired
|
|
474
|
+
]
|
|
475
|
+
},
|
|
476
|
+
'tasksExportAction.actionStatus': {
|
|
477
|
+
$exists: true,
|
|
478
|
+
$eq: factory.actionStatusType.PotentialActionStatus
|
|
479
|
+
},
|
|
480
|
+
endDate: { $exists: true, $lt: endDateLt }
|
|
484
481
|
});
|
|
482
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
483
|
+
query.limit(limit);
|
|
484
|
+
}
|
|
485
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
486
|
+
.exec();
|
|
487
|
+
return { count };
|
|
485
488
|
}
|
|
486
489
|
/**
|
|
487
490
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
488
491
|
*/
|
|
489
|
-
startExportTasks(params) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
default:
|
|
499
|
-
// no op
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
if (!(endDateLt instanceof Date)) {
|
|
503
|
-
throw new factory.errors.Argument('endDate.$lt', 'must be Date');
|
|
492
|
+
async startExportTasks(params) {
|
|
493
|
+
const statusEq = params.status?.$eq;
|
|
494
|
+
const endDateLt = params.endDate?.$lt;
|
|
495
|
+
if (typeof statusEq === 'string') {
|
|
496
|
+
switch (statusEq) {
|
|
497
|
+
case factory.transactionStatusType.InProgress:
|
|
498
|
+
throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
|
|
499
|
+
default:
|
|
500
|
+
// no op
|
|
504
501
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
}
|
|
503
|
+
if (!(endDateLt instanceof Date)) {
|
|
504
|
+
throw new factory.errors.Argument('endDate.$lt', 'must be Date');
|
|
505
|
+
}
|
|
506
|
+
// const typeOfIn = params.typeOf?.$in;
|
|
507
|
+
const query = this.transactionModel.findOneAndUpdate({
|
|
508
|
+
// ...(Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined,
|
|
509
|
+
status: {
|
|
510
|
+
...(typeof statusEq === 'string')
|
|
509
511
|
? { $eq: statusEq }
|
|
510
512
|
: {
|
|
511
513
|
$in: [
|
|
@@ -513,31 +515,35 @@ class AssetTransactionRepo {
|
|
|
513
515
|
factory.transactionStatusType.Confirmed,
|
|
514
516
|
factory.transactionStatusType.Expired
|
|
515
517
|
]
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
'tasksExportAction.actionStatus': {
|
|
521
|
+
$exists: true,
|
|
522
|
+
$eq: factory.actionStatusType.PotentialActionStatus
|
|
523
|
+
},
|
|
524
|
+
endDate: { $exists: true, $lt: endDateLt },
|
|
525
|
+
...(typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined
|
|
526
|
+
}, {
|
|
527
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
528
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
529
|
+
'tasksExportAction.startDate': new Date()
|
|
530
|
+
}, {
|
|
531
|
+
new: true,
|
|
532
|
+
projection: {
|
|
533
|
+
// _id: 1,
|
|
534
|
+
_id: 0,
|
|
535
|
+
id: { $toString: '$_id' },
|
|
536
|
+
typeOf: 1
|
|
534
537
|
}
|
|
535
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
536
|
-
.lean()
|
|
537
|
-
.exec()
|
|
538
|
-
// tslint:disable-next-line:no-null-keyword
|
|
539
|
-
.then((doc) => (doc === null) ? null : doc);
|
|
540
538
|
});
|
|
539
|
+
if (typeof params.sort?.endDate === 'number') {
|
|
540
|
+
query.sort(params.sort);
|
|
541
|
+
}
|
|
542
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
543
|
+
.lean()
|
|
544
|
+
.exec()
|
|
545
|
+
// tslint:disable-next-line:no-null-keyword
|
|
546
|
+
.then((doc) => (doc === null) ? null : doc);
|
|
541
547
|
}
|
|
542
548
|
// discontinue(2025-03-10~)
|
|
543
549
|
// public async reexportTasksByExportAction(params: {
|
|
@@ -595,418 +601,390 @@ class AssetTransactionRepo {
|
|
|
595
601
|
* PotentialActionStatusに変更する
|
|
596
602
|
* 2025-03-10~
|
|
597
603
|
*/
|
|
598
|
-
reExportAction(params) {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
604
|
+
async reExportAction(params) {
|
|
605
|
+
const { startDate } = params;
|
|
606
|
+
if (!(startDate.$lt instanceof Date)) {
|
|
607
|
+
throw new factory.errors.Argument('startDate.$lt', 'must be Date');
|
|
608
|
+
}
|
|
609
|
+
return this.transactionModel.updateMany({
|
|
610
|
+
'tasksExportAction.actionStatus': {
|
|
611
|
+
$exists: true,
|
|
612
|
+
$eq: factory.actionStatusType.ActiveActionStatus
|
|
613
|
+
},
|
|
614
|
+
'tasksExportAction.startDate': {
|
|
615
|
+
$exists: true,
|
|
616
|
+
$lt: startDate.$lt
|
|
603
617
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
},
|
|
609
|
-
'tasksExportAction.startDate': {
|
|
610
|
-
$exists: true,
|
|
611
|
-
$lt: startDate.$lt
|
|
612
|
-
}
|
|
613
|
-
}, {
|
|
614
|
-
$set: {
|
|
615
|
-
tasksExportAction: {
|
|
616
|
-
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
617
|
-
}
|
|
618
|
+
}, {
|
|
619
|
+
$set: {
|
|
620
|
+
tasksExportAction: {
|
|
621
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
618
622
|
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
.exec();
|
|
622
626
|
}
|
|
623
627
|
/**
|
|
624
628
|
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
625
629
|
*/
|
|
626
|
-
exportTasksMany(params) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
.toDate()
|
|
639
|
-
}
|
|
640
|
-
})
|
|
641
|
-
.select({
|
|
642
|
-
_id: 0,
|
|
643
|
-
id: { $toString: '$_id' },
|
|
644
|
-
typeOf: 1,
|
|
645
|
-
status: 1
|
|
646
|
-
})
|
|
647
|
-
.limit(params.limit)
|
|
648
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
649
|
-
.lean()
|
|
650
|
-
.exec();
|
|
651
|
-
if (delayedTransactions.length > 0) {
|
|
652
|
-
delayedTransactions.forEach((delayedTransaction) => {
|
|
653
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
654
|
-
id: delayedTransaction.id,
|
|
655
|
-
typeOf: delayedTransaction.typeOf,
|
|
656
|
-
status: delayedTransaction.status
|
|
657
|
-
});
|
|
658
|
-
});
|
|
630
|
+
async exportTasksMany(params) {
|
|
631
|
+
const delayedTransactions = await this.transactionModel.find({
|
|
632
|
+
status: { $in: params.status.$in },
|
|
633
|
+
'tasksExportAction.actionStatus': {
|
|
634
|
+
$exists: true,
|
|
635
|
+
$eq: factory.actionStatusType.PotentialActionStatus
|
|
636
|
+
},
|
|
637
|
+
endDate: {
|
|
638
|
+
$exists: true,
|
|
639
|
+
$lt: moment(params.now)
|
|
640
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
641
|
+
.toDate()
|
|
659
642
|
}
|
|
660
|
-
|
|
661
|
-
|
|
643
|
+
})
|
|
644
|
+
.select({
|
|
645
|
+
_id: 0,
|
|
646
|
+
id: { $toString: '$_id' },
|
|
647
|
+
typeOf: 1,
|
|
648
|
+
status: 1
|
|
649
|
+
})
|
|
650
|
+
.limit(params.limit)
|
|
651
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
652
|
+
.lean()
|
|
653
|
+
.exec();
|
|
654
|
+
if (delayedTransactions.length > 0) {
|
|
655
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
656
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
657
|
+
id: delayedTransaction.id,
|
|
658
|
+
typeOf: delayedTransaction.typeOf,
|
|
659
|
+
status: delayedTransaction.status
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
return delayedTransactions;
|
|
662
664
|
}
|
|
663
665
|
/**
|
|
664
666
|
* set task status exported by transaction id
|
|
665
667
|
* IDでタスクをエクスポート済に変更する
|
|
666
668
|
*/
|
|
667
|
-
setTasksExportedById(params) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
.exec();
|
|
685
|
-
});
|
|
669
|
+
async setTasksExportedById(params) {
|
|
670
|
+
const endDate = new Date();
|
|
671
|
+
await this.transactionModel.updateOne({
|
|
672
|
+
_id: { $eq: params.id },
|
|
673
|
+
// remove dependency on tasksExportationStatus(2024-06-13~)
|
|
674
|
+
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
675
|
+
'tasksExportAction.actionStatus': {
|
|
676
|
+
$exists: true,
|
|
677
|
+
$eq: factory.actionStatusType.ActiveActionStatus
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exported, // discontinue(2024-06-20~)
|
|
681
|
+
// tasksExportedAt: endDate, // discontinue(2024-06-20~)
|
|
682
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
683
|
+
'tasksExportAction.endDate': endDate
|
|
684
|
+
})
|
|
685
|
+
.exec();
|
|
686
686
|
}
|
|
687
687
|
/**
|
|
688
688
|
* add(2025-03-17~)
|
|
689
689
|
*/
|
|
690
|
-
countPotentiallyExpired(params) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
expires: { $lt: expires.$lt }
|
|
696
|
-
});
|
|
697
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
698
|
-
query.limit(limit);
|
|
699
|
-
}
|
|
700
|
-
const count = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
701
|
-
.exec();
|
|
702
|
-
return { count };
|
|
690
|
+
async countPotentiallyExpired(params) {
|
|
691
|
+
const { expires, limit } = params;
|
|
692
|
+
const query = this.transactionModel.countDocuments({
|
|
693
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
694
|
+
expires: { $lt: expires.$lt }
|
|
703
695
|
});
|
|
696
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
697
|
+
query.limit(limit);
|
|
698
|
+
}
|
|
699
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
700
|
+
.exec();
|
|
701
|
+
return { count };
|
|
704
702
|
}
|
|
705
703
|
/**
|
|
706
704
|
* add(2025-03-12~)
|
|
707
705
|
*/
|
|
708
|
-
makeOneExpiredIfExists(params) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
typeOf: 1
|
|
726
|
-
}
|
|
727
|
-
})
|
|
728
|
-
.sort(sort)
|
|
729
|
-
.lean()
|
|
730
|
-
.exec();
|
|
731
|
-
if (doc === null) {
|
|
732
|
-
// no op
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
736
|
-
id: doc.id,
|
|
737
|
-
typeOf: doc.typeOf,
|
|
738
|
-
status: factory.transactionStatusType.Expired
|
|
739
|
-
});
|
|
740
|
-
return doc;
|
|
706
|
+
async makeOneExpiredIfExists(params) {
|
|
707
|
+
const endDate = new Date();
|
|
708
|
+
const sort = {
|
|
709
|
+
expires: factory.sortType.Ascending
|
|
710
|
+
};
|
|
711
|
+
const doc = await this.transactionModel.findOneAndUpdate({
|
|
712
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
713
|
+
expires: { $lt: params.expires.$lt }
|
|
714
|
+
}, {
|
|
715
|
+
status: factory.transactionStatusType.Expired,
|
|
716
|
+
endDate
|
|
717
|
+
}, {
|
|
718
|
+
new: true,
|
|
719
|
+
projection: {
|
|
720
|
+
_id: 0,
|
|
721
|
+
id: { $toString: '$_id' },
|
|
722
|
+
typeOf: 1
|
|
741
723
|
}
|
|
742
|
-
})
|
|
724
|
+
})
|
|
725
|
+
.sort(sort)
|
|
726
|
+
.lean()
|
|
727
|
+
.exec();
|
|
728
|
+
if (doc === null) {
|
|
729
|
+
// no op
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
733
|
+
id: doc.id,
|
|
734
|
+
typeOf: doc.typeOf,
|
|
735
|
+
status: factory.transactionStatusType.Expired
|
|
736
|
+
});
|
|
737
|
+
return doc;
|
|
738
|
+
}
|
|
743
739
|
}
|
|
744
740
|
/**
|
|
745
741
|
* 取引を期限切れにする
|
|
746
742
|
*/
|
|
747
|
-
makeExpired(params) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
743
|
+
async makeExpired(params) {
|
|
744
|
+
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
745
|
+
const expiringTransactions = await this.transactionModel.find({
|
|
746
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
747
|
+
expires: { $lt: params.expires.$lt }
|
|
748
|
+
})
|
|
749
|
+
.select({
|
|
750
|
+
_id: 1,
|
|
751
|
+
typeOf: 1
|
|
752
|
+
})
|
|
753
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
754
|
+
.exec();
|
|
755
|
+
if (expiringTransactions.length > 0) {
|
|
756
|
+
// ステータスと期限を見て更新
|
|
757
|
+
await this.transactionModel.updateMany({
|
|
758
|
+
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
751
759
|
status: { $eq: factory.transactionStatusType.InProgress },
|
|
752
760
|
expires: { $lt: params.expires.$lt }
|
|
761
|
+
}, {
|
|
762
|
+
status: factory.transactionStatusType.Expired,
|
|
763
|
+
endDate: new Date()
|
|
753
764
|
})
|
|
754
|
-
.select({
|
|
755
|
-
_id: 1,
|
|
756
|
-
typeOf: 1
|
|
757
|
-
})
|
|
758
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
759
765
|
.exec();
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
status:
|
|
765
|
-
expires: { $lt: params.expires.$lt }
|
|
766
|
-
}, {
|
|
767
|
-
status: factory.transactionStatusType.Expired,
|
|
768
|
-
endDate: new Date()
|
|
769
|
-
})
|
|
770
|
-
.exec();
|
|
771
|
-
expiringTransactions.forEach((expiringTransaction) => {
|
|
772
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
773
|
-
id: expiringTransaction.id,
|
|
774
|
-
typeOf: expiringTransaction.typeOf,
|
|
775
|
-
status: factory.transactionStatusType.Expired
|
|
776
|
-
});
|
|
766
|
+
expiringTransactions.forEach((expiringTransaction) => {
|
|
767
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
768
|
+
id: expiringTransaction.id,
|
|
769
|
+
typeOf: expiringTransaction.typeOf,
|
|
770
|
+
status: factory.transactionStatusType.Expired
|
|
777
771
|
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
780
774
|
}
|
|
781
775
|
/**
|
|
782
776
|
* 取引を中止する
|
|
783
777
|
*/
|
|
784
|
-
cancel(params) {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
778
|
+
async cancel(params) {
|
|
779
|
+
// 進行中ステータスの取引を中止する
|
|
780
|
+
const doc = await this.transactionModel.findOneAndUpdate({
|
|
781
|
+
typeOf: { $eq: params.typeOf },
|
|
782
|
+
...(typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined,
|
|
783
|
+
...(typeof params.transactionNumber === 'string')
|
|
788
784
|
? { transactionNumber: { $eq: params.transactionNumber } }
|
|
789
|
-
: undefined
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
814
|
-
}
|
|
815
|
-
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
816
|
-
// すでに中止済の場合スルー
|
|
817
|
-
}
|
|
818
|
-
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
819
|
-
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${transaction.id} already expired`);
|
|
820
|
-
}
|
|
821
|
-
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
822
|
-
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${params.typeOf} ${transaction.id} unable to cancel`);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
826
|
-
}
|
|
827
|
-
result = { id: transaction.id };
|
|
785
|
+
: undefined,
|
|
786
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
787
|
+
}, {
|
|
788
|
+
$set: {
|
|
789
|
+
status: factory.transactionStatusType.Canceled,
|
|
790
|
+
endDate: new Date()
|
|
791
|
+
}
|
|
792
|
+
}, {
|
|
793
|
+
new: true,
|
|
794
|
+
projection: { _id: 1 }
|
|
795
|
+
})
|
|
796
|
+
.exec();
|
|
797
|
+
let result;
|
|
798
|
+
// NotFoundであれば取引状態確認
|
|
799
|
+
if (doc === null) {
|
|
800
|
+
let transaction;
|
|
801
|
+
if (typeof params.id === 'string') {
|
|
802
|
+
transaction = await this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
|
|
803
|
+
}
|
|
804
|
+
else if (typeof params.transactionNumber === 'string') {
|
|
805
|
+
transaction = await this.findByTransactionNumber({
|
|
806
|
+
typeOf: params.typeOf,
|
|
807
|
+
transactionNumber: params.transactionNumber
|
|
808
|
+
}, ['status']);
|
|
828
809
|
}
|
|
829
810
|
else {
|
|
830
|
-
|
|
811
|
+
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
831
812
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
typeOf: params.typeOf,
|
|
835
|
-
status: factory.transactionStatusType.Canceled
|
|
836
|
-
});
|
|
837
|
-
return result;
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
count(params) {
|
|
841
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
842
|
-
const { limit } = params;
|
|
843
|
-
const conditions = AssetTransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
844
|
-
const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
845
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
846
|
-
query.limit(limit);
|
|
813
|
+
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
814
|
+
// すでに中止済の場合スルー
|
|
847
815
|
}
|
|
848
|
-
|
|
849
|
-
.
|
|
850
|
-
|
|
816
|
+
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
817
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${transaction.id} already expired`);
|
|
818
|
+
}
|
|
819
|
+
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
820
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${params.typeOf} ${transaction.id} unable to cancel`);
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
824
|
+
}
|
|
825
|
+
result = { id: transaction.id };
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
result = { id: doc.toObject().id };
|
|
829
|
+
}
|
|
830
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
831
|
+
id: result.id,
|
|
832
|
+
typeOf: params.typeOf,
|
|
833
|
+
status: factory.transactionStatusType.Canceled
|
|
851
834
|
});
|
|
835
|
+
return result;
|
|
836
|
+
}
|
|
837
|
+
async count(params) {
|
|
838
|
+
const { limit } = params;
|
|
839
|
+
const conditions = AssetTransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
840
|
+
const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
841
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
842
|
+
query.limit(limit);
|
|
843
|
+
}
|
|
844
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
845
|
+
.exec();
|
|
846
|
+
return { count };
|
|
852
847
|
}
|
|
853
848
|
/**
|
|
854
849
|
* 取引を検索する
|
|
855
850
|
*/
|
|
856
|
-
search(params, inclusion, exclusion) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
851
|
+
async search(params, inclusion, exclusion) {
|
|
852
|
+
const conditions = AssetTransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
853
|
+
let projection = {};
|
|
854
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
855
|
+
inclusion.forEach((field) => {
|
|
856
|
+
projection[field] = 1;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
projection = {
|
|
861
|
+
__v: 0,
|
|
862
|
+
createdAt: 0,
|
|
863
|
+
updatedAt: 0
|
|
864
|
+
};
|
|
865
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
866
|
+
exclusion.forEach((field) => {
|
|
867
|
+
projection[field] = 0;
|
|
864
868
|
});
|
|
865
869
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
query.limit(params.limit)
|
|
883
|
-
.skip(params.limit * (page - 1));
|
|
884
|
-
}
|
|
885
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
886
|
-
/* istanbul ignore else */
|
|
887
|
-
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
|
|
888
|
-
query.sort({ startDate: params.sort.startDate });
|
|
889
|
-
}
|
|
890
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
891
|
-
.exec()
|
|
892
|
-
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
893
|
-
});
|
|
870
|
+
}
|
|
871
|
+
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
872
|
+
.select(projection);
|
|
873
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
874
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
875
|
+
query.limit(params.limit)
|
|
876
|
+
.skip(params.limit * (page - 1));
|
|
877
|
+
}
|
|
878
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
879
|
+
/* istanbul ignore else */
|
|
880
|
+
if (params.sort?.startDate !== undefined) {
|
|
881
|
+
query.sort({ startDate: params.sort.startDate });
|
|
882
|
+
}
|
|
883
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
884
|
+
.exec()
|
|
885
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
894
886
|
}
|
|
895
887
|
/**
|
|
896
888
|
* 取引番号指定で削除する
|
|
897
889
|
*/
|
|
898
|
-
deleteByTransactionNumber(params) {
|
|
899
|
-
return
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
.exec();
|
|
906
|
-
});
|
|
890
|
+
async deleteByTransactionNumber(params) {
|
|
891
|
+
return this.transactionModel.deleteMany({
|
|
892
|
+
'project.id': { $eq: params.project.id },
|
|
893
|
+
transactionNumber: { $in: params.transactionNumbers },
|
|
894
|
+
typeOf: { $eq: params.typeOf }
|
|
895
|
+
})
|
|
896
|
+
.exec();
|
|
907
897
|
}
|
|
908
898
|
/**
|
|
909
899
|
* プロジェクト指定で削除する
|
|
910
900
|
*/
|
|
911
|
-
deleteByProject(params) {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
.exec();
|
|
917
|
-
});
|
|
901
|
+
async deleteByProject(params) {
|
|
902
|
+
await this.transactionModel.deleteMany({
|
|
903
|
+
'project.id': { $eq: params.project.id }
|
|
904
|
+
})
|
|
905
|
+
.exec();
|
|
918
906
|
}
|
|
919
907
|
/**
|
|
920
908
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
921
909
|
*/
|
|
922
|
-
deleteEndDatePassedCertainPeriod(params) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
.exec();
|
|
932
|
-
});
|
|
910
|
+
async deleteEndDatePassedCertainPeriod(params) {
|
|
911
|
+
await this.transactionModel.deleteMany({
|
|
912
|
+
// 終了日時を一定期間過ぎたもの
|
|
913
|
+
endDate: {
|
|
914
|
+
$exists: true,
|
|
915
|
+
$lt: params.$lt
|
|
916
|
+
}
|
|
917
|
+
})
|
|
918
|
+
.exec();
|
|
933
919
|
}
|
|
934
920
|
/**
|
|
935
921
|
* 特定の取引を更新する(汎用)
|
|
936
922
|
*/
|
|
937
|
-
findByIdAndUpdateInProgress(params) {
|
|
938
|
-
return
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
return doc.toObject();
|
|
949
|
-
});
|
|
923
|
+
async findByIdAndUpdateInProgress(params) {
|
|
924
|
+
return this.transactionModel.findOneAndUpdate({
|
|
925
|
+
_id: { $eq: params.id },
|
|
926
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
927
|
+
}, params.update, { new: true })
|
|
928
|
+
.exec()
|
|
929
|
+
.then((doc) => {
|
|
930
|
+
if (doc === null) {
|
|
931
|
+
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
932
|
+
}
|
|
933
|
+
return doc.toObject();
|
|
950
934
|
});
|
|
951
935
|
}
|
|
952
936
|
/**
|
|
953
937
|
* 互換性維持対応
|
|
954
938
|
*/
|
|
955
|
-
migrateObjectReservationNumber(params) {
|
|
956
|
-
return
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
return doc.toObject();
|
|
976
|
-
});
|
|
939
|
+
async migrateObjectReservationNumber(params) {
|
|
940
|
+
return this.transactionModel.findOneAndUpdate({
|
|
941
|
+
typeOf: { $eq: factory.assetTransactionType.CancelReservation },
|
|
942
|
+
_id: { $eq: params.id }
|
|
943
|
+
}, {
|
|
944
|
+
$set: {
|
|
945
|
+
'object.reservationNumber': params.object.reservationNumber,
|
|
946
|
+
'object.typeOf': factory.reservationType.ReservationPackage
|
|
947
|
+
}
|
|
948
|
+
}, {
|
|
949
|
+
timestamps: false,
|
|
950
|
+
new: true,
|
|
951
|
+
projection: { _id: 1 }
|
|
952
|
+
})
|
|
953
|
+
.exec()
|
|
954
|
+
.then((doc) => {
|
|
955
|
+
if (doc === null) {
|
|
956
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
957
|
+
}
|
|
958
|
+
return doc.toObject();
|
|
977
959
|
});
|
|
978
960
|
}
|
|
979
961
|
/**
|
|
980
962
|
* 互換性維持対応専用
|
|
981
963
|
*/
|
|
982
|
-
fixReservedTicketIdentifier(params) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
'object.paymentMethod.movieTickets': params.object.paymentMethod.movieTickets
|
|
991
|
-
}
|
|
992
|
-
}, {
|
|
993
|
-
timestamps: false,
|
|
994
|
-
new: true,
|
|
995
|
-
projection: {
|
|
996
|
-
_id: 1
|
|
997
|
-
}
|
|
998
|
-
})
|
|
999
|
-
.exec();
|
|
1000
|
-
if (doc === null) {
|
|
1001
|
-
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
964
|
+
async fixReservedTicketIdentifier(params) {
|
|
965
|
+
const doc = await this.transactionModel.findOneAndUpdate({
|
|
966
|
+
transactionNumber: { $eq: params.transactionNumber },
|
|
967
|
+
'project.id': { $eq: params.project.id },
|
|
968
|
+
typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
969
|
+
}, {
|
|
970
|
+
$set: {
|
|
971
|
+
'object.paymentMethod.movieTickets': params.object.paymentMethod.movieTickets
|
|
1002
972
|
}
|
|
1003
|
-
}
|
|
973
|
+
}, {
|
|
974
|
+
timestamps: false,
|
|
975
|
+
new: true,
|
|
976
|
+
projection: {
|
|
977
|
+
_id: 1
|
|
978
|
+
}
|
|
979
|
+
})
|
|
980
|
+
.exec();
|
|
981
|
+
if (doc === null) {
|
|
982
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
983
|
+
}
|
|
1004
984
|
}
|
|
1005
|
-
findByIdAndDelete(params) {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
.exec();
|
|
1009
|
-
});
|
|
985
|
+
async findByIdAndDelete(params) {
|
|
986
|
+
await this.transactionModel.findByIdAndDelete(params.id)
|
|
987
|
+
.exec();
|
|
1010
988
|
}
|
|
1011
989
|
getCursor(conditions, projection) {
|
|
1012
990
|
return this.transactionModel.find(conditions, projection)
|
|
@@ -1014,161 +992,163 @@ class AssetTransactionRepo {
|
|
|
1014
992
|
.sort({ startDate: factory.sortType.Descending })
|
|
1015
993
|
.cursor();
|
|
1016
994
|
}
|
|
1017
|
-
unsetUnnecessaryFields(params) {
|
|
1018
|
-
return
|
|
1019
|
-
|
|
1020
|
-
.exec();
|
|
1021
|
-
});
|
|
995
|
+
async unsetUnnecessaryFields(params) {
|
|
996
|
+
return this.transactionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
997
|
+
.exec();
|
|
1022
998
|
}
|
|
1023
|
-
aggregateAssetTransaction(params) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
999
|
+
async aggregateAssetTransaction(params) {
|
|
1000
|
+
const statuses = await Promise.all([
|
|
1001
|
+
factory.transactionStatusType.Confirmed,
|
|
1002
|
+
factory.transactionStatusType.Canceled,
|
|
1003
|
+
factory.transactionStatusType.Expired
|
|
1004
|
+
].map(async (transactionStatus) => {
|
|
1005
|
+
const matchConditions = {
|
|
1006
|
+
startDate: {
|
|
1007
|
+
$gte: params.startFrom,
|
|
1008
|
+
$lte: params.startThrough
|
|
1009
|
+
},
|
|
1010
|
+
typeOf: { $eq: params.typeOf },
|
|
1011
|
+
status: { $eq: transactionStatus },
|
|
1012
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1035
1013
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1036
|
-
: undefined
|
|
1014
|
+
: undefined,
|
|
1015
|
+
...(typeof params.project?.id?.$eq === 'string')
|
|
1037
1016
|
? { 'project.id': { $eq: params.project.id.$eq } }
|
|
1038
|
-
: undefined
|
|
1039
|
-
|
|
1040
|
-
})
|
|
1041
|
-
|
|
1042
|
-
}
|
|
1017
|
+
: undefined
|
|
1018
|
+
};
|
|
1019
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
1020
|
+
}));
|
|
1021
|
+
return { statuses };
|
|
1043
1022
|
}
|
|
1044
1023
|
// tslint:disable-next-line:max-func-body-length
|
|
1045
|
-
agggregateByStatus(params) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
{
|
|
1054
|
-
$
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
$
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
$
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
else: 0
|
|
1072
|
-
}
|
|
1024
|
+
async agggregateByStatus(params) {
|
|
1025
|
+
const matchConditions = params.matchConditions;
|
|
1026
|
+
const transactionStatus = params.status;
|
|
1027
|
+
const aggregations = await this.transactionModel.aggregate([
|
|
1028
|
+
{
|
|
1029
|
+
$match: matchConditions
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
$project: {
|
|
1033
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1034
|
+
graceTime: {
|
|
1035
|
+
$cond: {
|
|
1036
|
+
if: { $eq: ['$typeOf', factory.assetTransactionType.Reserve] },
|
|
1037
|
+
then: { $subtract: ['$object.reservationFor.startDate', '$startDate'] },
|
|
1038
|
+
else: 0
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
status: '$status',
|
|
1042
|
+
startDate: '$startDate',
|
|
1043
|
+
endDate: '$endDate',
|
|
1044
|
+
typeOf: '$typeOf',
|
|
1045
|
+
reservationCount: {
|
|
1046
|
+
$cond: {
|
|
1047
|
+
if: { $isArray: '$object.subReservation' },
|
|
1048
|
+
then: { $size: '$object.subReservation' },
|
|
1049
|
+
else: 0
|
|
1073
1050
|
}
|
|
1074
|
-
}
|
|
1075
|
-
},
|
|
1076
|
-
{
|
|
1077
|
-
$group: {
|
|
1078
|
-
_id: '$typeOf',
|
|
1079
|
-
transactionCount: { $sum: 1 },
|
|
1080
|
-
maxDuration: { $max: '$duration' },
|
|
1081
|
-
minDuration: { $min: '$duration' },
|
|
1082
|
-
avgDuration: { $avg: '$duration' },
|
|
1083
|
-
reservationCount: { $sum: '$reservationCount' },
|
|
1084
|
-
maxGraceTime: { $max: '$graceTime' },
|
|
1085
|
-
minGraceTime: { $min: '$graceTime' },
|
|
1086
|
-
avgGraceTime: { $avg: '$graceTime' }
|
|
1087
|
-
}
|
|
1088
|
-
},
|
|
1089
|
-
{
|
|
1090
|
-
$project: {
|
|
1091
|
-
_id: 0,
|
|
1092
|
-
transactionCount: '$transactionCount',
|
|
1093
|
-
avgDuration: '$avgDuration',
|
|
1094
|
-
maxDuration: '$maxDuration',
|
|
1095
|
-
minDuration: '$minDuration',
|
|
1096
|
-
reservationCount: '$reservationCount',
|
|
1097
|
-
avgGraceTime: '$avgGraceTime',
|
|
1098
|
-
maxGraceTime: '$maxGraceTime',
|
|
1099
|
-
minGraceTime: '$minGraceTime'
|
|
1100
1051
|
}
|
|
1101
1052
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
percentilesDuration: percents.map((percent) => {
|
|
1115
|
-
return {
|
|
1116
|
-
name: String(percent),
|
|
1117
|
-
value: 0
|
|
1118
|
-
};
|
|
1119
|
-
}),
|
|
1120
|
-
reservationCount: 0,
|
|
1121
|
-
avgGraceTime: 0,
|
|
1122
|
-
maxGraceTime: 0,
|
|
1123
|
-
minGraceTime: 0
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
const ranks4percentile = percents.map((percentile) => {
|
|
1128
|
-
return {
|
|
1129
|
-
percentile,
|
|
1130
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
1131
|
-
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
1132
|
-
};
|
|
1133
|
-
});
|
|
1134
|
-
const aggregations2 = yield this.transactionModel.aggregate([
|
|
1135
|
-
{
|
|
1136
|
-
$match: matchConditions
|
|
1137
|
-
},
|
|
1138
|
-
{
|
|
1139
|
-
$project: {
|
|
1140
|
-
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1141
|
-
status: '$status',
|
|
1142
|
-
startDate: '$startDate',
|
|
1143
|
-
endDate: '$endDate',
|
|
1144
|
-
typeOf: '$typeOf'
|
|
1145
|
-
}
|
|
1146
|
-
},
|
|
1147
|
-
{ $sort: { duration: 1 } },
|
|
1148
|
-
{
|
|
1149
|
-
$group: {
|
|
1150
|
-
_id: '$typeOf',
|
|
1151
|
-
durations: { $push: '$duration' }
|
|
1152
|
-
}
|
|
1153
|
-
},
|
|
1154
|
-
{
|
|
1155
|
-
$project: {
|
|
1156
|
-
_id: 0,
|
|
1157
|
-
percentilesDuration: ranks4percentile.map((rank) => {
|
|
1158
|
-
return {
|
|
1159
|
-
name: String(rank.percentile),
|
|
1160
|
-
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
1161
|
-
};
|
|
1162
|
-
})
|
|
1163
|
-
}
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
$group: {
|
|
1056
|
+
_id: '$typeOf',
|
|
1057
|
+
transactionCount: { $sum: 1 },
|
|
1058
|
+
maxDuration: { $max: '$duration' },
|
|
1059
|
+
minDuration: { $min: '$duration' },
|
|
1060
|
+
avgDuration: { $avg: '$duration' },
|
|
1061
|
+
reservationCount: { $sum: '$reservationCount' },
|
|
1062
|
+
maxGraceTime: { $max: '$graceTime' },
|
|
1063
|
+
minGraceTime: { $min: '$graceTime' },
|
|
1064
|
+
avgGraceTime: { $avg: '$graceTime' }
|
|
1164
1065
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
$project: {
|
|
1069
|
+
_id: 0,
|
|
1070
|
+
transactionCount: '$transactionCount',
|
|
1071
|
+
avgDuration: '$avgDuration',
|
|
1072
|
+
maxDuration: '$maxDuration',
|
|
1073
|
+
minDuration: '$minDuration',
|
|
1074
|
+
reservationCount: '$reservationCount',
|
|
1075
|
+
avgGraceTime: '$avgGraceTime',
|
|
1076
|
+
maxGraceTime: '$maxGraceTime',
|
|
1077
|
+
minGraceTime: '$minGraceTime'
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
])
|
|
1081
|
+
.exec();
|
|
1082
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
1083
|
+
const percents = [50, 95, 99];
|
|
1084
|
+
if (aggregations.length === 0) {
|
|
1167
1085
|
return {
|
|
1168
1086
|
status: transactionStatus,
|
|
1169
|
-
aggregation:
|
|
1087
|
+
aggregation: {
|
|
1088
|
+
transactionCount: 0,
|
|
1089
|
+
avgDuration: 0,
|
|
1090
|
+
maxDuration: 0,
|
|
1091
|
+
minDuration: 0,
|
|
1092
|
+
percentilesDuration: percents.map((percent) => {
|
|
1093
|
+
return {
|
|
1094
|
+
name: String(percent),
|
|
1095
|
+
value: 0
|
|
1096
|
+
};
|
|
1097
|
+
}),
|
|
1098
|
+
reservationCount: 0,
|
|
1099
|
+
avgGraceTime: 0,
|
|
1100
|
+
maxGraceTime: 0,
|
|
1101
|
+
minGraceTime: 0
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
1106
|
+
return {
|
|
1107
|
+
percentile,
|
|
1108
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
1109
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
1170
1110
|
};
|
|
1171
1111
|
});
|
|
1112
|
+
const aggregations2 = await this.transactionModel.aggregate([
|
|
1113
|
+
{
|
|
1114
|
+
$match: matchConditions
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
$project: {
|
|
1118
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1119
|
+
status: '$status',
|
|
1120
|
+
startDate: '$startDate',
|
|
1121
|
+
endDate: '$endDate',
|
|
1122
|
+
typeOf: '$typeOf'
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
{ $sort: { duration: 1 } },
|
|
1126
|
+
{
|
|
1127
|
+
$group: {
|
|
1128
|
+
_id: '$typeOf',
|
|
1129
|
+
durations: { $push: '$duration' }
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
$project: {
|
|
1134
|
+
_id: 0,
|
|
1135
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
1136
|
+
return {
|
|
1137
|
+
name: String(rank.percentile),
|
|
1138
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
1139
|
+
};
|
|
1140
|
+
})
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
])
|
|
1144
|
+
.exec();
|
|
1145
|
+
return {
|
|
1146
|
+
status: transactionStatus,
|
|
1147
|
+
aggregation: {
|
|
1148
|
+
...aggregations[0],
|
|
1149
|
+
...aggregations2[0]
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1172
1152
|
}
|
|
1173
1153
|
}
|
|
1174
1154
|
exports.AssetTransactionRepo = AssetTransactionRepo;
|