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