@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,24 +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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
3
|
exports.ActionRepo = void 0;
|
|
24
4
|
const moment = require("moment");
|
|
@@ -57,23 +37,23 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
57
37
|
* アクションリポジトリ
|
|
58
38
|
*/
|
|
59
39
|
class ActionRepo {
|
|
40
|
+
actionModel;
|
|
41
|
+
actionRecipeModel;
|
|
60
42
|
constructor(connection) {
|
|
61
43
|
this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
|
|
62
44
|
this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
|
|
63
45
|
}
|
|
64
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
65
46
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
66
|
-
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, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76;
|
|
67
47
|
const andConditions = [];
|
|
68
|
-
const idIn =
|
|
48
|
+
const idIn = params.id?.$in;
|
|
69
49
|
if (Array.isArray(idIn)) {
|
|
70
50
|
andConditions.push({ _id: { $in: idIn } });
|
|
71
51
|
}
|
|
72
|
-
const idNin =
|
|
52
|
+
const idNin = params.id?.$nin;
|
|
73
53
|
if (Array.isArray(idNin)) {
|
|
74
54
|
andConditions.push({ _id: { $nin: idNin } });
|
|
75
55
|
}
|
|
76
|
-
const projectIdEq =
|
|
56
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
77
57
|
if (typeof projectIdEq === 'string') {
|
|
78
58
|
andConditions.push({
|
|
79
59
|
'project.id': {
|
|
@@ -81,7 +61,7 @@ class ActionRepo {
|
|
|
81
61
|
}
|
|
82
62
|
});
|
|
83
63
|
}
|
|
84
|
-
const agentTypeOfIn =
|
|
64
|
+
const agentTypeOfIn = params.agent?.typeOf?.$in;
|
|
85
65
|
if (Array.isArray(agentTypeOfIn)) {
|
|
86
66
|
andConditions.push({
|
|
87
67
|
'agent.typeOf': {
|
|
@@ -90,7 +70,7 @@ class ActionRepo {
|
|
|
90
70
|
}
|
|
91
71
|
});
|
|
92
72
|
}
|
|
93
|
-
const agentIdIn =
|
|
73
|
+
const agentIdIn = params.agent?.id?.$in;
|
|
94
74
|
if (Array.isArray(agentIdIn)) {
|
|
95
75
|
andConditions.push({
|
|
96
76
|
'agent.id': {
|
|
@@ -99,27 +79,27 @@ class ActionRepo {
|
|
|
99
79
|
}
|
|
100
80
|
});
|
|
101
81
|
}
|
|
102
|
-
const instrumentTransactionNumberEq =
|
|
82
|
+
const instrumentTransactionNumberEq = params.instrument?.transactionNumber?.$eq;
|
|
103
83
|
if (typeof instrumentTransactionNumberEq === 'string') {
|
|
104
84
|
andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
|
|
105
85
|
}
|
|
106
|
-
const instrumentTypeOfEq =
|
|
86
|
+
const instrumentTypeOfEq = params.instrument?.typeOf?.$eq;
|
|
107
87
|
if (typeof instrumentTypeOfEq === 'string') {
|
|
108
88
|
andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
|
|
109
89
|
}
|
|
110
|
-
const instrumentIdentifierEq =
|
|
90
|
+
const instrumentIdentifierEq = params.instrument?.identifier?.$eq;
|
|
111
91
|
if (typeof instrumentIdentifierEq === 'string') {
|
|
112
92
|
andConditions.push({ 'instrument.identifier': { $exists: true, $eq: instrumentIdentifierEq } });
|
|
113
93
|
}
|
|
114
|
-
const instrumentIdEq =
|
|
94
|
+
const instrumentIdEq = params.instrument?.id?.$eq;
|
|
115
95
|
if (typeof instrumentIdEq === 'string') {
|
|
116
96
|
andConditions.push({ 'instrument.id': { $exists: true, $eq: instrumentIdEq } });
|
|
117
97
|
}
|
|
118
|
-
const instrumentOrderNumberEq =
|
|
98
|
+
const instrumentOrderNumberEq = params.instrument?.orderNumber?.$eq;
|
|
119
99
|
if (typeof instrumentOrderNumberEq === 'string') {
|
|
120
100
|
andConditions.push({ 'instrument.orderNumber': { $exists: true, $eq: instrumentOrderNumberEq } });
|
|
121
101
|
}
|
|
122
|
-
const locationIdEq =
|
|
102
|
+
const locationIdEq = params.location?.id?.$eq;
|
|
123
103
|
if (typeof locationIdEq === 'string') {
|
|
124
104
|
andConditions.push({
|
|
125
105
|
'location.id': {
|
|
@@ -128,7 +108,7 @@ class ActionRepo {
|
|
|
128
108
|
}
|
|
129
109
|
});
|
|
130
110
|
}
|
|
131
|
-
const locationIdentifierEq =
|
|
111
|
+
const locationIdentifierEq = params.location?.identifier?.$eq;
|
|
132
112
|
if (typeof locationIdentifierEq === 'string') {
|
|
133
113
|
andConditions.push({
|
|
134
114
|
'location.identifier': {
|
|
@@ -137,7 +117,7 @@ class ActionRepo {
|
|
|
137
117
|
}
|
|
138
118
|
});
|
|
139
119
|
}
|
|
140
|
-
const objectMovieTicketsIdentifierEq =
|
|
120
|
+
const objectMovieTicketsIdentifierEq = params.object?.movieTickets?.identifier?.$eq;
|
|
141
121
|
if (typeof objectMovieTicketsIdentifierEq === 'string') {
|
|
142
122
|
andConditions.push({
|
|
143
123
|
'object.movieTickets.identifier': {
|
|
@@ -146,7 +126,7 @@ class ActionRepo {
|
|
|
146
126
|
}
|
|
147
127
|
});
|
|
148
128
|
}
|
|
149
|
-
const objectMovieTicketsServiceOutputReservationForIdEq =
|
|
129
|
+
const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
|
|
150
130
|
if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
|
|
151
131
|
andConditions.push({
|
|
152
132
|
'object.movieTickets.serviceOutput.reservationFor.id': {
|
|
@@ -155,7 +135,7 @@ class ActionRepo {
|
|
|
155
135
|
}
|
|
156
136
|
});
|
|
157
137
|
}
|
|
158
|
-
const objectPaymentMethodIdEq =
|
|
138
|
+
const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
|
|
159
139
|
if (typeof objectPaymentMethodIdEq === 'string') {
|
|
160
140
|
andConditions.push({
|
|
161
141
|
'object.paymentMethodId': {
|
|
@@ -164,7 +144,7 @@ class ActionRepo {
|
|
|
164
144
|
}
|
|
165
145
|
});
|
|
166
146
|
}
|
|
167
|
-
const objectObjectPaymentMethodIdEq =
|
|
147
|
+
const objectObjectPaymentMethodIdEq = params.object?.object?.paymentMethodId?.$eq;
|
|
168
148
|
if (typeof objectObjectPaymentMethodIdEq === 'string') {
|
|
169
149
|
andConditions.push({
|
|
170
150
|
'object.object.paymentMethodId': {
|
|
@@ -173,7 +153,7 @@ class ActionRepo {
|
|
|
173
153
|
}
|
|
174
154
|
});
|
|
175
155
|
}
|
|
176
|
-
const objectReservationForIdEq =
|
|
156
|
+
const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
|
|
177
157
|
if (typeof objectReservationForIdEq === 'string') {
|
|
178
158
|
andConditions.push({
|
|
179
159
|
'object.reservationFor.id': {
|
|
@@ -182,7 +162,7 @@ class ActionRepo {
|
|
|
182
162
|
}
|
|
183
163
|
});
|
|
184
164
|
}
|
|
185
|
-
const objectReservationNumberEq =
|
|
165
|
+
const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
|
|
186
166
|
if (typeof objectReservationNumberEq === 'string') {
|
|
187
167
|
andConditions.push({
|
|
188
168
|
'object.reservationNumber': {
|
|
@@ -191,7 +171,7 @@ class ActionRepo {
|
|
|
191
171
|
}
|
|
192
172
|
});
|
|
193
173
|
}
|
|
194
|
-
const objectReservationNumberIn =
|
|
174
|
+
const objectReservationNumberIn = params.object?.reservationNumber?.$in;
|
|
195
175
|
if (Array.isArray(objectReservationNumberIn)) {
|
|
196
176
|
andConditions.push({
|
|
197
177
|
'object.reservationNumber': {
|
|
@@ -200,7 +180,7 @@ class ActionRepo {
|
|
|
200
180
|
}
|
|
201
181
|
});
|
|
202
182
|
}
|
|
203
|
-
const objectPaymentMethodAccountIdEq =
|
|
183
|
+
const objectPaymentMethodAccountIdEq = params.object?.paymentMethod?.accountId?.$eq;
|
|
204
184
|
if (typeof objectPaymentMethodAccountIdEq === 'string') {
|
|
205
185
|
andConditions.push({
|
|
206
186
|
'object.paymentMethod.accountId': {
|
|
@@ -209,7 +189,7 @@ class ActionRepo {
|
|
|
209
189
|
}
|
|
210
190
|
});
|
|
211
191
|
}
|
|
212
|
-
const objectPaymentMethodPaymentMethodIdEq =
|
|
192
|
+
const objectPaymentMethodPaymentMethodIdEq = params.object?.paymentMethod?.paymentMethodId?.$eq;
|
|
213
193
|
if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
|
|
214
194
|
andConditions.push({
|
|
215
195
|
'object.paymentMethod.paymentMethodId': {
|
|
@@ -218,7 +198,7 @@ class ActionRepo {
|
|
|
218
198
|
}
|
|
219
199
|
});
|
|
220
200
|
}
|
|
221
|
-
const objectPaymentMethodPaymentMethodIdIn =
|
|
201
|
+
const objectPaymentMethodPaymentMethodIdIn = params.object?.paymentMethod?.paymentMethodId?.$in;
|
|
222
202
|
if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
|
|
223
203
|
andConditions.push({
|
|
224
204
|
'object.paymentMethod.paymentMethodId': {
|
|
@@ -227,7 +207,7 @@ class ActionRepo {
|
|
|
227
207
|
}
|
|
228
208
|
});
|
|
229
209
|
}
|
|
230
|
-
const objectPaymentMethodTypeOfEq =
|
|
210
|
+
const objectPaymentMethodTypeOfEq = params.object?.paymentMethod?.typeOf?.$eq;
|
|
231
211
|
if (typeof objectPaymentMethodTypeOfEq === 'string') {
|
|
232
212
|
andConditions.push({
|
|
233
213
|
'object.paymentMethod.typeOf': {
|
|
@@ -236,7 +216,7 @@ class ActionRepo {
|
|
|
236
216
|
}
|
|
237
217
|
});
|
|
238
218
|
}
|
|
239
|
-
const objectTypeOfEq =
|
|
219
|
+
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
240
220
|
if (typeof objectTypeOfEq === 'string') {
|
|
241
221
|
andConditions.push({
|
|
242
222
|
'object.typeOf': {
|
|
@@ -245,7 +225,7 @@ class ActionRepo {
|
|
|
245
225
|
}
|
|
246
226
|
});
|
|
247
227
|
}
|
|
248
|
-
const objectTypeOfIn =
|
|
228
|
+
const objectTypeOfIn = params.object?.typeOf?.$in;
|
|
249
229
|
if (Array.isArray(objectTypeOfIn)) {
|
|
250
230
|
andConditions.push({
|
|
251
231
|
'object.typeOf': {
|
|
@@ -254,7 +234,7 @@ class ActionRepo {
|
|
|
254
234
|
}
|
|
255
235
|
});
|
|
256
236
|
}
|
|
257
|
-
const objectIdEq =
|
|
237
|
+
const objectIdEq = params.object?.id?.$eq;
|
|
258
238
|
if (typeof objectIdEq === 'string') {
|
|
259
239
|
andConditions.push({
|
|
260
240
|
'object.id': {
|
|
@@ -263,7 +243,7 @@ class ActionRepo {
|
|
|
263
243
|
}
|
|
264
244
|
});
|
|
265
245
|
}
|
|
266
|
-
const objectIdIn =
|
|
246
|
+
const objectIdIn = params.object?.id?.$in;
|
|
267
247
|
if (Array.isArray(objectIdIn)) {
|
|
268
248
|
andConditions.push({
|
|
269
249
|
'object.id': {
|
|
@@ -272,7 +252,7 @@ class ActionRepo {
|
|
|
272
252
|
}
|
|
273
253
|
});
|
|
274
254
|
}
|
|
275
|
-
const objectOrderNumberIn =
|
|
255
|
+
const objectOrderNumberIn = params.object?.orderNumber?.$in;
|
|
276
256
|
if (Array.isArray(objectOrderNumberIn)) {
|
|
277
257
|
andConditions.push({
|
|
278
258
|
'object.orderNumber': {
|
|
@@ -281,7 +261,7 @@ class ActionRepo {
|
|
|
281
261
|
}
|
|
282
262
|
});
|
|
283
263
|
}
|
|
284
|
-
const objectEventIdIn =
|
|
264
|
+
const objectEventIdIn = params.object?.event?.id?.$in;
|
|
285
265
|
if (Array.isArray(objectEventIdIn)) {
|
|
286
266
|
andConditions.push({
|
|
287
267
|
'object.event.id': {
|
|
@@ -301,7 +281,7 @@ class ActionRepo {
|
|
|
301
281
|
// }
|
|
302
282
|
// });
|
|
303
283
|
// }
|
|
304
|
-
const objectTransactionNumberEq =
|
|
284
|
+
const objectTransactionNumberEq = params.object?.transactionNumber?.$eq;
|
|
305
285
|
if (typeof objectTransactionNumberEq === 'string') {
|
|
306
286
|
andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
|
|
307
287
|
}
|
|
@@ -311,14 +291,14 @@ class ActionRepo {
|
|
|
311
291
|
});
|
|
312
292
|
}
|
|
313
293
|
else {
|
|
314
|
-
const typeOfEq =
|
|
294
|
+
const typeOfEq = params.typeOf?.$eq;
|
|
315
295
|
if (typeof typeOfEq === 'string') {
|
|
316
296
|
andConditions.push({
|
|
317
297
|
typeOf: { $eq: typeOfEq }
|
|
318
298
|
});
|
|
319
299
|
}
|
|
320
300
|
}
|
|
321
|
-
const actionStatusIn =
|
|
301
|
+
const actionStatusIn = params.actionStatus?.$in;
|
|
322
302
|
if (Array.isArray(actionStatusIn)) {
|
|
323
303
|
andConditions.push({
|
|
324
304
|
actionStatus: { $in: actionStatusIn }
|
|
@@ -341,7 +321,7 @@ class ActionRepo {
|
|
|
341
321
|
startDate: { $lte: startDateLte }
|
|
342
322
|
});
|
|
343
323
|
}
|
|
344
|
-
const fromLocationTypeOfIn =
|
|
324
|
+
const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
|
|
345
325
|
if (Array.isArray(fromLocationTypeOfIn)) {
|
|
346
326
|
andConditions.push({
|
|
347
327
|
'fromLocation.typeOf': {
|
|
@@ -350,7 +330,7 @@ class ActionRepo {
|
|
|
350
330
|
}
|
|
351
331
|
});
|
|
352
332
|
}
|
|
353
|
-
const fromLocationAccountNumberIn =
|
|
333
|
+
const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
|
|
354
334
|
if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
355
335
|
andConditions.push({
|
|
356
336
|
'fromLocation.accountNumber': {
|
|
@@ -359,7 +339,7 @@ class ActionRepo {
|
|
|
359
339
|
}
|
|
360
340
|
});
|
|
361
341
|
}
|
|
362
|
-
const fromLocationAccountTypeIn =
|
|
342
|
+
const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
|
|
363
343
|
if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
364
344
|
andConditions.push({
|
|
365
345
|
'fromLocation.accountType': {
|
|
@@ -368,7 +348,7 @@ class ActionRepo {
|
|
|
368
348
|
}
|
|
369
349
|
});
|
|
370
350
|
}
|
|
371
|
-
const toLocationTypeOfIn =
|
|
351
|
+
const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
|
|
372
352
|
if (Array.isArray(toLocationTypeOfIn)) {
|
|
373
353
|
andConditions.push({
|
|
374
354
|
'toLocation.typeOf': {
|
|
@@ -377,7 +357,7 @@ class ActionRepo {
|
|
|
377
357
|
}
|
|
378
358
|
});
|
|
379
359
|
}
|
|
380
|
-
const toLocationAccountNumberIn =
|
|
360
|
+
const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
|
|
381
361
|
if (Array.isArray(toLocationAccountNumberIn)) {
|
|
382
362
|
andConditions.push({
|
|
383
363
|
'toLocation.accountNumber': {
|
|
@@ -386,7 +366,7 @@ class ActionRepo {
|
|
|
386
366
|
}
|
|
387
367
|
});
|
|
388
368
|
}
|
|
389
|
-
const toLocationAccountTypeIn =
|
|
369
|
+
const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
|
|
390
370
|
if (Array.isArray(toLocationAccountTypeIn)) {
|
|
391
371
|
andConditions.push({
|
|
392
372
|
'toLocation.accountType': {
|
|
@@ -395,7 +375,7 @@ class ActionRepo {
|
|
|
395
375
|
}
|
|
396
376
|
});
|
|
397
377
|
}
|
|
398
|
-
const purposeTypeOfIn =
|
|
378
|
+
const purposeTypeOfIn = params.purpose?.typeOf?.$in;
|
|
399
379
|
if (Array.isArray(purposeTypeOfIn)) {
|
|
400
380
|
andConditions.push({
|
|
401
381
|
'purpose.typeOf': {
|
|
@@ -404,7 +384,7 @@ class ActionRepo {
|
|
|
404
384
|
}
|
|
405
385
|
});
|
|
406
386
|
}
|
|
407
|
-
const purposeIdIn =
|
|
387
|
+
const purposeIdIn = params.purpose?.id?.$in;
|
|
408
388
|
if (Array.isArray(purposeIdIn)) {
|
|
409
389
|
andConditions.push({
|
|
410
390
|
'purpose.id': {
|
|
@@ -413,7 +393,7 @@ class ActionRepo {
|
|
|
413
393
|
}
|
|
414
394
|
});
|
|
415
395
|
}
|
|
416
|
-
const purposeOrderNumberIn =
|
|
396
|
+
const purposeOrderNumberIn = params.purpose?.orderNumber?.$in;
|
|
417
397
|
if (Array.isArray(purposeOrderNumberIn)) {
|
|
418
398
|
andConditions.push({
|
|
419
399
|
'purpose.orderNumber': {
|
|
@@ -422,7 +402,7 @@ class ActionRepo {
|
|
|
422
402
|
}
|
|
423
403
|
});
|
|
424
404
|
}
|
|
425
|
-
const resultTypeOfIn =
|
|
405
|
+
const resultTypeOfIn = params.result?.typeOf?.$in;
|
|
426
406
|
if (Array.isArray(resultTypeOfIn)) {
|
|
427
407
|
andConditions.push({
|
|
428
408
|
'result.typeOf': {
|
|
@@ -431,7 +411,7 @@ class ActionRepo {
|
|
|
431
411
|
}
|
|
432
412
|
});
|
|
433
413
|
}
|
|
434
|
-
const resultIdIn =
|
|
414
|
+
const resultIdIn = params.result?.id?.$in;
|
|
435
415
|
if (Array.isArray(resultIdIn)) {
|
|
436
416
|
andConditions.push({
|
|
437
417
|
'result.id': {
|
|
@@ -440,7 +420,7 @@ class ActionRepo {
|
|
|
440
420
|
}
|
|
441
421
|
});
|
|
442
422
|
}
|
|
443
|
-
const resultOrderNumberIn =
|
|
423
|
+
const resultOrderNumberIn = params.result?.orderNumber?.$in;
|
|
444
424
|
if (Array.isArray(resultOrderNumberIn)) {
|
|
445
425
|
andConditions.push({
|
|
446
426
|
'result.orderNumber': {
|
|
@@ -449,7 +429,7 @@ class ActionRepo {
|
|
|
449
429
|
}
|
|
450
430
|
});
|
|
451
431
|
}
|
|
452
|
-
const resultCodeIn =
|
|
432
|
+
const resultCodeIn = params.result?.code?.$in;
|
|
453
433
|
if (Array.isArray(resultCodeIn)) {
|
|
454
434
|
andConditions.push({
|
|
455
435
|
'result.code': {
|
|
@@ -459,11 +439,11 @@ class ActionRepo {
|
|
|
459
439
|
});
|
|
460
440
|
}
|
|
461
441
|
// sameAs(2024-04-23~)
|
|
462
|
-
const sameAsIdEq =
|
|
442
|
+
const sameAsIdEq = params.sameAs?.id?.$eq;
|
|
463
443
|
if (typeof sameAsIdEq === 'string') {
|
|
464
444
|
andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
|
|
465
445
|
}
|
|
466
|
-
const aboutOrderNumberEq =
|
|
446
|
+
const aboutOrderNumberEq = params.about?.orderNumber?.$eq;
|
|
467
447
|
if (typeof aboutOrderNumberEq === 'string') {
|
|
468
448
|
andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
|
|
469
449
|
}
|
|
@@ -472,404 +452,393 @@ class ActionRepo {
|
|
|
472
452
|
/**
|
|
473
453
|
* アクション検索
|
|
474
454
|
*/
|
|
475
|
-
search(params, inclusion) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
455
|
+
async search(params, inclusion) {
|
|
456
|
+
const conditions = ActionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
457
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
458
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
459
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
460
|
+
}
|
|
461
|
+
const projection = {
|
|
462
|
+
_id: 0,
|
|
463
|
+
id: { $toString: '$_id' },
|
|
464
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
465
|
+
};
|
|
466
|
+
const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
467
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
468
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
469
|
+
query.limit(params.limit)
|
|
470
|
+
.skip(params.limit * (page - 1));
|
|
471
|
+
}
|
|
472
|
+
/* istanbul ignore else */
|
|
473
|
+
if (params.sort?.startDate !== undefined) {
|
|
474
|
+
query.sort({ startDate: params.sort.startDate });
|
|
475
|
+
}
|
|
476
|
+
// const explainResult = await (<any>query).explain();
|
|
477
|
+
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
478
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
479
|
+
.lean() // 2024-08-26~
|
|
480
|
+
.exec();
|
|
501
481
|
}
|
|
502
482
|
/**
|
|
503
483
|
* アクション開始
|
|
504
484
|
*/
|
|
505
|
-
start(attributes, options) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
485
|
+
async start(attributes, options) {
|
|
486
|
+
const startDate = new Date();
|
|
487
|
+
const creatingAction = {
|
|
488
|
+
...attributes,
|
|
489
|
+
actionStatus: factory.actionStatusType.ActiveActionStatus,
|
|
490
|
+
startDate
|
|
491
|
+
};
|
|
492
|
+
// reimplemnt with insertMany(2024-08-29~)
|
|
493
|
+
const result = await this.actionModel.insertMany(creatingAction, { rawResult: true });
|
|
494
|
+
const id = result.insertedIds?.[0]?.toHexString();
|
|
495
|
+
if (typeof id !== 'string') {
|
|
496
|
+
throw new factory.errors.Internal('action not saved');
|
|
497
|
+
}
|
|
498
|
+
// add recipe(2024-06-09~)
|
|
499
|
+
const savingRecipe = options?.recipe;
|
|
500
|
+
if (savingRecipe?.typeOf === 'Recipe') {
|
|
501
|
+
await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf } });
|
|
502
|
+
}
|
|
503
|
+
return { id, startDate, typeOf: creatingAction.typeOf };
|
|
523
504
|
}
|
|
524
|
-
completeWithVoid(params) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
result: params.result,
|
|
537
|
-
endDate: new Date()
|
|
538
|
-
}
|
|
539
|
-
}, { new: false, projection: { _id: 1 } })
|
|
540
|
-
.lean()
|
|
541
|
-
.exec();
|
|
542
|
-
if (doc === null) {
|
|
543
|
-
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
505
|
+
async completeWithVoid(params) {
|
|
506
|
+
if (params.recipe?.typeOf === 'Recipe') {
|
|
507
|
+
await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
508
|
+
}
|
|
509
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
510
|
+
_id: { $eq: params.id },
|
|
511
|
+
typeOf: { $eq: params.typeOf }
|
|
512
|
+
}, {
|
|
513
|
+
$set: {
|
|
514
|
+
actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
515
|
+
result: params.result,
|
|
516
|
+
endDate: new Date()
|
|
544
517
|
}
|
|
545
|
-
})
|
|
518
|
+
}, { new: false, projection: { _id: 1 } })
|
|
519
|
+
.lean()
|
|
520
|
+
.exec();
|
|
521
|
+
if (doc === null) {
|
|
522
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
523
|
+
}
|
|
546
524
|
}
|
|
547
525
|
/**
|
|
548
526
|
* アクション取消
|
|
549
527
|
*/
|
|
550
|
-
cancelWithVoid(params) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
typeOf: { $eq: params.typeOf },
|
|
558
|
-
actionStatus: { $ne: factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
|
|
559
|
-
}, {
|
|
560
|
-
$set: Object.assign({ actionStatus: factory.actionStatusType.CanceledActionStatus }, (cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
|
|
561
|
-
)
|
|
562
|
-
}, { new: false, projection: { _id: 1 } })
|
|
563
|
-
.lean()
|
|
564
|
-
.exec();
|
|
565
|
-
if (doc === null) {
|
|
566
|
-
// 既にCanceledActionStatusであればok
|
|
567
|
-
const existingAction = yield this.findById({ id: params.id, typeOf: params.typeOf }, ['actionStatus'], []);
|
|
568
|
-
if (existingAction.actionStatus !== factory.actionStatusType.CanceledActionStatus) {
|
|
569
|
-
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
570
|
-
}
|
|
528
|
+
async cancelWithVoid(params) {
|
|
529
|
+
const cancelDate = new Date();
|
|
530
|
+
const cancelAction = (params.cancelAction !== undefined)
|
|
531
|
+
? {
|
|
532
|
+
...params.cancelAction,
|
|
533
|
+
endTime: cancelDate,
|
|
534
|
+
typeOf: factory.actionType.CancelAction
|
|
571
535
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
536
|
+
: undefined;
|
|
537
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
538
|
+
_id: { $eq: params.id },
|
|
539
|
+
typeOf: { $eq: params.typeOf },
|
|
540
|
+
actionStatus: { $ne: factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
|
|
541
|
+
}, {
|
|
542
|
+
$set: {
|
|
543
|
+
actionStatus: factory.actionStatusType.CanceledActionStatus,
|
|
544
|
+
...(cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
|
|
545
|
+
}
|
|
546
|
+
}, { new: false, projection: { _id: 1 } })
|
|
547
|
+
.lean()
|
|
548
|
+
.exec();
|
|
549
|
+
if (doc === null) {
|
|
550
|
+
// 既にCanceledActionStatusであればok
|
|
551
|
+
const existingAction = await this.findById({ id: params.id, typeOf: params.typeOf }, ['actionStatus'], []);
|
|
552
|
+
if (existingAction.actionStatus !== factory.actionStatusType.CanceledActionStatus) {
|
|
553
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
// endDateが存在しなければセット(2024-04-22~)
|
|
557
|
+
await this.actionModel.updateOne({
|
|
558
|
+
_id: { $eq: params.id },
|
|
559
|
+
endDate: { $exists: false }
|
|
560
|
+
}, { $set: { endDate: cancelDate } })
|
|
561
|
+
.exec();
|
|
579
562
|
}
|
|
580
563
|
/**
|
|
581
564
|
* アクション失敗
|
|
582
565
|
*/
|
|
583
|
-
giveUp(params) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
error: actionError,
|
|
599
|
-
endDate: new Date()
|
|
600
|
-
}
|
|
601
|
-
}, { new: true, projection: { _id: 1 } })
|
|
602
|
-
.lean()
|
|
603
|
-
.exec();
|
|
604
|
-
if (doc === null) {
|
|
605
|
-
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
566
|
+
async giveUp(params) {
|
|
567
|
+
const actionError = (Array.isArray(params.error))
|
|
568
|
+
? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
|
|
569
|
+
: { ...params.error, message: params.error.message, name: params.error.name };
|
|
570
|
+
if (params.recipe?.typeOf === 'Recipe') {
|
|
571
|
+
await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
572
|
+
}
|
|
573
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
574
|
+
typeOf: { $eq: params.typeOf },
|
|
575
|
+
_id: { $eq: params.id }
|
|
576
|
+
}, {
|
|
577
|
+
$set: {
|
|
578
|
+
actionStatus: factory.actionStatusType.FailedActionStatus,
|
|
579
|
+
error: actionError,
|
|
580
|
+
endDate: new Date()
|
|
606
581
|
}
|
|
607
|
-
})
|
|
582
|
+
}, { new: true, projection: { _id: 1 } })
|
|
583
|
+
.lean()
|
|
584
|
+
.exec();
|
|
585
|
+
if (doc === null) {
|
|
586
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
587
|
+
}
|
|
608
588
|
}
|
|
609
589
|
/**
|
|
610
590
|
* アクション再開
|
|
611
591
|
*/
|
|
612
|
-
reStart(params) {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
|
|
634
|
-
}
|
|
635
|
-
});
|
|
592
|
+
async reStart(params) {
|
|
593
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
594
|
+
_id: { $eq: params.id },
|
|
595
|
+
typeOf: { $eq: params.typeOf },
|
|
596
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
597
|
+
}, {
|
|
598
|
+
$set: {
|
|
599
|
+
actionStatus: factory.actionStatusType.ActiveActionStatus,
|
|
600
|
+
startDate: new Date()
|
|
601
|
+
},
|
|
602
|
+
$unset: { endDate: 1 }
|
|
603
|
+
}, { new: false, projection: { _id: 1 } })
|
|
604
|
+
.lean()
|
|
605
|
+
.exec();
|
|
606
|
+
if (doc === null) {
|
|
607
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
608
|
+
}
|
|
609
|
+
// add recipe(2024-06-09~)
|
|
610
|
+
if (params.recipe?.typeOf === 'Recipe') {
|
|
611
|
+
await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
612
|
+
}
|
|
636
613
|
}
|
|
637
614
|
/**
|
|
638
615
|
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
639
616
|
*/
|
|
640
|
-
giveUpStartDatePassedCertainPeriod(params) {
|
|
641
|
-
return
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
617
|
+
async giveUpStartDatePassedCertainPeriod(params) {
|
|
618
|
+
return this.actionModel.updateMany({
|
|
619
|
+
actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus },
|
|
620
|
+
// 一定期間過ぎたもの
|
|
621
|
+
startDate: { $lt: params.startDate.$lt },
|
|
622
|
+
...(typeof params.id?.$eq === 'string') ? { _id: { $eq: params.id.$eq } } : undefined
|
|
623
|
+
}, {
|
|
624
|
+
actionStatus: factory.actionStatusType.FailedActionStatus,
|
|
625
|
+
error: params.error,
|
|
626
|
+
endDate: new Date()
|
|
627
|
+
})
|
|
628
|
+
.exec();
|
|
652
629
|
}
|
|
653
|
-
findById(params, inclusion, exclusion) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
665
|
-
const doc = yield this.actionModel.findOne({
|
|
666
|
-
typeOf: { $eq: params.typeOf },
|
|
667
|
-
_id: { $eq: params.id }
|
|
668
|
-
}, projection)
|
|
669
|
-
.lean() // 2024-08-26~
|
|
670
|
-
.exec();
|
|
671
|
-
if (doc === null) {
|
|
672
|
-
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
630
|
+
async findById(params, inclusion, exclusion) {
|
|
631
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
632
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
633
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
637
|
+
positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
673
638
|
}
|
|
674
|
-
|
|
675
|
-
|
|
639
|
+
}
|
|
640
|
+
const projection = {
|
|
641
|
+
_id: 0,
|
|
642
|
+
id: { $toString: '$_id' },
|
|
643
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
644
|
+
};
|
|
645
|
+
const doc = await this.actionModel.findOne({
|
|
646
|
+
typeOf: { $eq: params.typeOf },
|
|
647
|
+
_id: { $eq: params.id }
|
|
648
|
+
}, projection)
|
|
649
|
+
.lean() // 2024-08-26~
|
|
650
|
+
.exec();
|
|
651
|
+
if (doc === null) {
|
|
652
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
653
|
+
}
|
|
654
|
+
return doc;
|
|
676
655
|
}
|
|
677
|
-
findPayAction(params) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}, []);
|
|
690
|
-
return payActions.shift();
|
|
691
|
-
});
|
|
656
|
+
async findPayAction(params) {
|
|
657
|
+
const payActions = await this.search({
|
|
658
|
+
limit: 1,
|
|
659
|
+
page: 1,
|
|
660
|
+
actionStatus: (Array.isArray(params.actionStatus?.$in))
|
|
661
|
+
? { $in: params.actionStatus?.$in }
|
|
662
|
+
: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
663
|
+
project: { id: { $eq: params.project.id } },
|
|
664
|
+
typeOf: { $eq: factory.actionType.PayAction },
|
|
665
|
+
object: { paymentMethod: { paymentMethodId: { $eq: params.paymentMethodId } } }
|
|
666
|
+
}, []);
|
|
667
|
+
return payActions.shift();
|
|
692
668
|
}
|
|
693
669
|
/**
|
|
694
670
|
* 取引に対するアクションを検索する
|
|
695
671
|
*/
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
672
|
+
async searchByPurpose(params) {
|
|
673
|
+
const andConditions = [
|
|
674
|
+
{ 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
|
|
675
|
+
{ 'purpose.id': { $exists: true, $eq: params.purpose.id } }
|
|
676
|
+
];
|
|
677
|
+
// const idNin = params.id?.$nin;
|
|
678
|
+
// if (Array.isArray(idNin)) {
|
|
679
|
+
// andConditions.push({ _id: { $nin: idNin } });
|
|
680
|
+
// }
|
|
681
|
+
const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
|
|
682
|
+
if (typeof objectPaymentMethodIdEq === 'string') {
|
|
683
|
+
andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
|
|
684
|
+
}
|
|
685
|
+
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
686
|
+
if (typeof objectTypeOfEq === 'string') {
|
|
687
|
+
andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
|
|
688
|
+
}
|
|
689
|
+
if (typeof params.typeOf === 'string') {
|
|
690
|
+
andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
691
|
+
}
|
|
692
|
+
const actionStatusEq = params.actionStatus?.$eq;
|
|
693
|
+
if (typeof actionStatusEq === 'string') {
|
|
694
|
+
andConditions.push({ actionStatus: { $eq: actionStatusEq } });
|
|
695
|
+
}
|
|
696
|
+
const positiveProjectionFields = [
|
|
697
|
+
'project',
|
|
698
|
+
'actionStatus',
|
|
699
|
+
'typeOf',
|
|
700
|
+
'description',
|
|
701
|
+
'agent',
|
|
702
|
+
'recipient',
|
|
703
|
+
'result',
|
|
704
|
+
'error',
|
|
705
|
+
'object',
|
|
706
|
+
'startDate',
|
|
707
|
+
'endDate',
|
|
708
|
+
'purpose',
|
|
709
|
+
'potentialActions',
|
|
710
|
+
'instrument',
|
|
711
|
+
'location',
|
|
712
|
+
'sameAs',
|
|
713
|
+
'cancelAction',
|
|
714
|
+
'identifier'
|
|
715
|
+
];
|
|
716
|
+
const projection = {
|
|
717
|
+
_id: 0,
|
|
718
|
+
id: { $toString: '$_id' },
|
|
719
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
720
|
+
};
|
|
721
|
+
const query = this.actionModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
722
|
+
if (typeof params.sort?.startDate === 'number') {
|
|
723
|
+
query.sort({ startDate: params.sort.startDate });
|
|
724
|
+
}
|
|
725
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
726
|
+
.lean()
|
|
727
|
+
.exec();
|
|
728
|
+
// return <Promise<IAction4transaction<T>[]>><Promise<unknown[]>>this.search<T>(
|
|
729
|
+
// {
|
|
730
|
+
// purpose: {
|
|
731
|
+
// id: { $in: [params.purpose.id] },
|
|
732
|
+
// typeOf: { $in: [params.purpose.typeOf] }
|
|
733
|
+
// },
|
|
734
|
+
// object: {
|
|
735
|
+
// ...(typeof params.object?.typeOf?.$eq === 'string')
|
|
736
|
+
// ? { typeOf: { $eq: params.object.typeOf.$eq } }
|
|
737
|
+
// : undefined,
|
|
738
|
+
// ...(typeof params.object?.paymentMethodId?.$eq === 'string')
|
|
739
|
+
// ? { paymentMethodId: { $eq: params.object.paymentMethodId.$eq } }
|
|
740
|
+
// : undefined
|
|
741
|
+
// },
|
|
742
|
+
// ...(typeof params.actionStatus?.$eq === 'string') ? { actionStatus: { $in: [params.actionStatus.$eq] } } : undefined,
|
|
743
|
+
// ...(typeof params.typeOf === 'string') ? { typeOf: { $eq: params.typeOf } } : undefined,
|
|
744
|
+
// ...(Array.isArray(params.id?.$nin)) ? { id: { $nin: params.id?.$nin } } : undefined,
|
|
745
|
+
// ...(typeof params.sort?.startDate === 'number') ? { sort: params.sort } : undefined
|
|
746
|
+
// },
|
|
747
|
+
// [],
|
|
748
|
+
// []
|
|
749
|
+
// );
|
|
774
750
|
}
|
|
775
751
|
/**
|
|
776
752
|
* 注文番号から、注文に対するアクションを検索する
|
|
777
753
|
*/
|
|
778
|
-
searchByOrderNumber(params) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
$
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
754
|
+
async searchByOrderNumber(params) {
|
|
755
|
+
const filter = {
|
|
756
|
+
$or: [
|
|
757
|
+
{ 'object.orderNumber': { $exists: true, $eq: params.orderNumber } },
|
|
758
|
+
{ 'purpose.orderNumber': { $exists: true, $eq: params.orderNumber } },
|
|
759
|
+
// consider inform returnAction(2025-01-22~)
|
|
760
|
+
{ 'about.orderNumber': { $exists: true, $eq: params.orderNumber } },
|
|
761
|
+
// consider reserveAction,cancelReservationAction(2025-02-17~)
|
|
762
|
+
{ 'instrument.orderNumber': { $exists: true, $eq: params.orderNumber } }
|
|
763
|
+
]
|
|
764
|
+
};
|
|
765
|
+
const projection = {
|
|
766
|
+
_id: 0,
|
|
767
|
+
id: { $toString: '$_id' },
|
|
768
|
+
...Object.fromEntries(AVAILABLE_PROJECT_FIELDS.map((key) => ([key, 1])))
|
|
769
|
+
};
|
|
770
|
+
const query = this.actionModel.find(filter, projection);
|
|
771
|
+
// .select({ __v: 0, createdAt: 0, updatedAt: 0 });
|
|
772
|
+
/* istanbul ignore else */
|
|
773
|
+
if (params.sort?.startDate !== undefined) {
|
|
774
|
+
query.sort({ startDate: params.sort.startDate });
|
|
775
|
+
}
|
|
776
|
+
return query
|
|
777
|
+
.lean() // 2024-08-26~
|
|
778
|
+
.exec();
|
|
803
779
|
}
|
|
804
|
-
searchBySameAs(params) {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
780
|
+
async searchBySameAs(params) {
|
|
781
|
+
const projection = {
|
|
782
|
+
_id: 0,
|
|
783
|
+
id: { $toString: '$_id' },
|
|
784
|
+
actionStatus: 1,
|
|
785
|
+
error: 1,
|
|
786
|
+
purpose: 1
|
|
787
|
+
};
|
|
788
|
+
const query = this.actionModel.find({
|
|
789
|
+
typeOf: { $eq: params.typeOf.$eq },
|
|
790
|
+
'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq },
|
|
791
|
+
...(typeof params.purpose?.id.$eq === 'string')
|
|
815
792
|
? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
|
|
816
|
-
: undefined
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
793
|
+
: undefined
|
|
794
|
+
}, projection)
|
|
795
|
+
// .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
|
|
796
|
+
.limit(1);
|
|
797
|
+
return query
|
|
798
|
+
.lean() // 2024-08-26~
|
|
799
|
+
.exec();
|
|
823
800
|
}
|
|
824
|
-
deleteByProject(params) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
.exec();
|
|
830
|
-
});
|
|
801
|
+
async deleteByProject(params) {
|
|
802
|
+
await this.actionModel.deleteMany({
|
|
803
|
+
'project.id': { $eq: params.project.id }
|
|
804
|
+
})
|
|
805
|
+
.exec();
|
|
831
806
|
}
|
|
832
|
-
reCompleteAuthorizeEventOfferAction(params) {
|
|
833
|
-
return
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
});
|
|
807
|
+
async reCompleteAuthorizeEventOfferAction(params) {
|
|
808
|
+
return this.actionModel.findOneAndUpdate({
|
|
809
|
+
// typeOf: factory.actionType.AuthorizeAction,
|
|
810
|
+
_id: { $eq: params.id },
|
|
811
|
+
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
812
|
+
// actionStatus: factory.actionStatusType.CompletedActionStatus
|
|
813
|
+
actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus }
|
|
814
|
+
}, {
|
|
815
|
+
$set: {
|
|
816
|
+
actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
817
|
+
object: params.object,
|
|
818
|
+
result: params.result,
|
|
819
|
+
endDate: new Date()
|
|
820
|
+
}
|
|
821
|
+
}, { new: true, projection: { _id: 1 } })
|
|
822
|
+
.lean()
|
|
823
|
+
.exec()
|
|
824
|
+
.then((doc) => {
|
|
825
|
+
if (doc === null) {
|
|
826
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
827
|
+
}
|
|
855
828
|
});
|
|
856
829
|
}
|
|
857
|
-
updateById(params) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
.exec();
|
|
861
|
-
});
|
|
830
|
+
async updateById(params) {
|
|
831
|
+
await this.actionModel.updateOne({ _id: { $eq: params.id } }, params.update)
|
|
832
|
+
.exec();
|
|
862
833
|
}
|
|
863
|
-
findByIdAndUpdate(params) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}
|
|
872
|
-
});
|
|
834
|
+
async findByIdAndUpdate(params) {
|
|
835
|
+
await this.actionModel.findOneAndUpdate({ _id: { $eq: params.id } }, params.update, { projection: { _id: 1 } })
|
|
836
|
+
.lean()
|
|
837
|
+
.exec()
|
|
838
|
+
.then((doc) => {
|
|
839
|
+
if (doc === null) {
|
|
840
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
841
|
+
}
|
|
873
842
|
});
|
|
874
843
|
}
|
|
875
844
|
/**
|
|
@@ -932,158 +901,148 @@ class ActionRepo {
|
|
|
932
901
|
// ])
|
|
933
902
|
// .exec();
|
|
934
903
|
// }
|
|
935
|
-
searchYkknInfoByCheckRecipe(filter) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
.exec();
|
|
978
|
-
});
|
|
904
|
+
async searchYkknInfoByCheckRecipe(filter) {
|
|
905
|
+
const filterQuery = {
|
|
906
|
+
_id: { $eq: filter.id },
|
|
907
|
+
'project.id': { $eq: filter.project.id },
|
|
908
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
909
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
910
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
911
|
+
};
|
|
912
|
+
const actionDoc = await this.actionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
|
|
913
|
+
.exec();
|
|
914
|
+
if (actionDoc === null) {
|
|
915
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
916
|
+
}
|
|
917
|
+
const filterQuery4recipe = {
|
|
918
|
+
'recipeFor.id': { $eq: filter.id }
|
|
919
|
+
};
|
|
920
|
+
const projectStage = {
|
|
921
|
+
_id: 0,
|
|
922
|
+
knyknrNo: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.knyknrNo',
|
|
923
|
+
ykknshTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.ykknshTyp',
|
|
924
|
+
eishhshkTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.eishhshkTyp',
|
|
925
|
+
ykknKnshbtsmiNum: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.ykknKnshbtsmiNum',
|
|
926
|
+
knshknhmbiUnip: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.knshknhmbiUnip',
|
|
927
|
+
kijUnip: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo.kijUnip'
|
|
928
|
+
};
|
|
929
|
+
const aggregate = this.actionRecipeModel.aggregate([
|
|
930
|
+
{ $unwind: '$step' },
|
|
931
|
+
{ $unwind: '$step.itemListElement' },
|
|
932
|
+
{ $unwind: '$step.itemListElement.itemListElement' },
|
|
933
|
+
{ $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut' },
|
|
934
|
+
{ $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo' },
|
|
935
|
+
{ $match: filterQuery4recipe },
|
|
936
|
+
{ $project: projectStage }
|
|
937
|
+
]);
|
|
938
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
939
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
940
|
+
aggregate.limit(filter.limit * page)
|
|
941
|
+
.skip(filter.limit * (page - 1));
|
|
942
|
+
}
|
|
943
|
+
return aggregate
|
|
944
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
945
|
+
.exec();
|
|
979
946
|
}
|
|
980
|
-
searchMkknInfoByCheckRecipe(filter) {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
.exec();
|
|
1027
|
-
});
|
|
947
|
+
async searchMkknInfoByCheckRecipe(filter) {
|
|
948
|
+
const filterQuery = {
|
|
949
|
+
_id: { $eq: filter.id },
|
|
950
|
+
'project.id': { $eq: filter.project.id },
|
|
951
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
952
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
953
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
954
|
+
};
|
|
955
|
+
const actionDoc = this.actionModel.findOne(filterQuery, { _id: 1 }, { lean: true })
|
|
956
|
+
.exec();
|
|
957
|
+
if (actionDoc === null) {
|
|
958
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
959
|
+
}
|
|
960
|
+
const filterQuery4recipe = {
|
|
961
|
+
'recipeFor.id': { $eq: filter.id }
|
|
962
|
+
};
|
|
963
|
+
const projectStage = {
|
|
964
|
+
_id: 0,
|
|
965
|
+
knyknrNo: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.knyknrNo',
|
|
966
|
+
mkknshTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkknshTyp',
|
|
967
|
+
mkknKnshbtsmiNum: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkknKnshbtsmiNum',
|
|
968
|
+
mkjyTyp: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.mkjyTyp',
|
|
969
|
+
yykDt: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.yykDt',
|
|
970
|
+
shyJeiDt: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyJeiDt',
|
|
971
|
+
shyStCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyStCd',
|
|
972
|
+
shyScrnCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shyScrnCd',
|
|
973
|
+
shySkhnCd: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shySkhnCd',
|
|
974
|
+
shySkhnNm: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo.shySkhnNm'
|
|
975
|
+
};
|
|
976
|
+
const aggregate = this.actionRecipeModel.aggregate([
|
|
977
|
+
{ $unwind: '$step' },
|
|
978
|
+
{ $unwind: '$step.itemListElement' },
|
|
979
|
+
{ $unwind: '$step.itemListElement.itemListElement' },
|
|
980
|
+
{ $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut' },
|
|
981
|
+
{ $unwind: '$step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo' },
|
|
982
|
+
{ $match: filterQuery4recipe },
|
|
983
|
+
{ $project: projectStage }
|
|
984
|
+
]);
|
|
985
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
986
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
987
|
+
aggregate.limit(filter.limit * page)
|
|
988
|
+
.skip(filter.limit * (page - 1));
|
|
989
|
+
}
|
|
990
|
+
return aggregate
|
|
991
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
992
|
+
.exec();
|
|
1028
993
|
}
|
|
1029
994
|
/**
|
|
1030
995
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
1031
996
|
*/
|
|
1032
|
-
deleteStartDatePassedCertainPeriod(params) {
|
|
1033
|
-
return
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
.exec();
|
|
1040
|
-
});
|
|
997
|
+
async deleteStartDatePassedCertainPeriod(params) {
|
|
998
|
+
return this.actionModel.deleteMany({
|
|
999
|
+
startDate: {
|
|
1000
|
+
$lt: params.$lt
|
|
1001
|
+
}
|
|
1002
|
+
})
|
|
1003
|
+
.exec();
|
|
1041
1004
|
}
|
|
1042
1005
|
/**
|
|
1043
1006
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
1044
1007
|
* 作成日時を一定期間過ぎたアクションレシピも削除する
|
|
1045
1008
|
*/
|
|
1046
|
-
deleteEndDatePassedCertainPeriod(params) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1009
|
+
async deleteEndDatePassedCertainPeriod(params) {
|
|
1010
|
+
const { $lt } = params;
|
|
1011
|
+
if ($lt instanceof Date) {
|
|
1012
|
+
await this.actionModel.deleteMany({
|
|
1013
|
+
// 終了日時を一定期間過ぎたもの
|
|
1014
|
+
endDate: { $exists: true, $lt }
|
|
1015
|
+
})
|
|
1016
|
+
.exec();
|
|
1017
|
+
// clean actionRecipes(2025-01-10~)
|
|
1018
|
+
const dateCreatedLt = moment($lt)
|
|
1019
|
+
.add(-1, 'day') // レシピ作成とアクション終了の時間差を考慮
|
|
1020
|
+
.toDate();
|
|
1021
|
+
await this.actionRecipeModel.deleteMany({
|
|
1022
|
+
dateCreated: { $lt: dateCreatedLt }
|
|
1023
|
+
})
|
|
1024
|
+
.exec();
|
|
1025
|
+
}
|
|
1065
1026
|
}
|
|
1066
1027
|
/**
|
|
1067
1028
|
* 取引からアクションを削除する
|
|
1068
1029
|
*/
|
|
1069
|
-
deleteByPurpose(params) {
|
|
1070
|
-
return
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
};
|
|
1086
|
-
});
|
|
1030
|
+
async deleteByPurpose(params) {
|
|
1031
|
+
return this.actionModel.deleteMany({
|
|
1032
|
+
'project.id': { $eq: params.project.id },
|
|
1033
|
+
typeOf: { $in: params.typeOf.$in },
|
|
1034
|
+
'purpose.id': { $exists: true, $eq: params.purpose.id },
|
|
1035
|
+
'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf }
|
|
1036
|
+
})
|
|
1037
|
+
.exec()
|
|
1038
|
+
.then((result) => {
|
|
1039
|
+
return {
|
|
1040
|
+
// n: result?.n,
|
|
1041
|
+
// opTime: result.opTime,
|
|
1042
|
+
// ok: result?.ok,
|
|
1043
|
+
// operationTime,
|
|
1044
|
+
deletedCount: result?.deletedCount
|
|
1045
|
+
};
|
|
1087
1046
|
});
|
|
1088
1047
|
}
|
|
1089
1048
|
// public async saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
|
|
@@ -1109,359 +1068,366 @@ class ActionRepo {
|
|
|
1109
1068
|
// )
|
|
1110
1069
|
// .exec();
|
|
1111
1070
|
// }
|
|
1112
|
-
saveActionWithEndDate(savingAction) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
.exec();
|
|
1134
|
-
});
|
|
1071
|
+
async saveActionWithEndDate(savingAction) {
|
|
1072
|
+
const { sameAs, typeOf, project, agent, object, ...updateFields } = savingAction;
|
|
1073
|
+
const filter = {
|
|
1074
|
+
'project.id': { $eq: project.id },
|
|
1075
|
+
// 'agent.id': { $exists: true, $eq: agent.id },
|
|
1076
|
+
// 'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
1077
|
+
'object.paymentMethodId': { $exists: true, $eq: object.paymentMethodId },
|
|
1078
|
+
typeOf: { $eq: typeOf },
|
|
1079
|
+
'sameAs.id': { $exists: true, $eq: sameAs.id }
|
|
1080
|
+
};
|
|
1081
|
+
const setOnInsert = { typeOf, project, agent, object, sameAs };
|
|
1082
|
+
const setKeys = updateFields;
|
|
1083
|
+
const update = {
|
|
1084
|
+
$setOnInsert: setOnInsert,
|
|
1085
|
+
$set: setKeys
|
|
1086
|
+
};
|
|
1087
|
+
return this.actionModel.updateOne(filter, update, {
|
|
1088
|
+
upsert: true,
|
|
1089
|
+
includeResultMetadata: true
|
|
1090
|
+
})
|
|
1091
|
+
.exec();
|
|
1135
1092
|
}
|
|
1136
|
-
findRecipeByAction(params) {
|
|
1137
|
-
return
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
)
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
// return result;
|
|
1150
|
-
});
|
|
1093
|
+
async findRecipeByAction(params) {
|
|
1094
|
+
return this.actionRecipeModel.findOne({
|
|
1095
|
+
'project.id': { $eq: params.project.id },
|
|
1096
|
+
'recipeFor.id': { $eq: params.recipeFor.id }
|
|
1097
|
+
}, { step: 1, recipeCategory: 1 }
|
|
1098
|
+
// { lean: true }
|
|
1099
|
+
)
|
|
1100
|
+
.lean()
|
|
1101
|
+
.exec();
|
|
1102
|
+
// if (result === null) {
|
|
1103
|
+
// throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
|
|
1104
|
+
// }
|
|
1105
|
+
// return result;
|
|
1151
1106
|
}
|
|
1152
|
-
findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
.exec();
|
|
1169
|
-
return (_c = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.afterMedia;
|
|
1170
|
-
});
|
|
1107
|
+
async findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params) {
|
|
1108
|
+
const recipe = await this.actionRecipeModel.findOne({
|
|
1109
|
+
'project.id': { $eq: params.project.id },
|
|
1110
|
+
'recipeFor.id': { $eq: params.recipeFor.id }
|
|
1111
|
+
}, {
|
|
1112
|
+
project: 0,
|
|
1113
|
+
typeOf: 0,
|
|
1114
|
+
recipeCategory: 0,
|
|
1115
|
+
recipeFor: 0,
|
|
1116
|
+
dateCreated: 0,
|
|
1117
|
+
dateModified: 0,
|
|
1118
|
+
'step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo': 0,
|
|
1119
|
+
'step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo': 0
|
|
1120
|
+
}, { lean: true })
|
|
1121
|
+
.exec();
|
|
1122
|
+
return recipe?.step[0]?.itemListElement[0]?.itemListElement[0]?.afterMedia;
|
|
1171
1123
|
}
|
|
1172
|
-
aggregateAuthorizeEventServiceOfferAction(params) {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1124
|
+
async aggregateAuthorizeEventServiceOfferAction(params) {
|
|
1125
|
+
const statuses = await Promise.all([
|
|
1126
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1127
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1128
|
+
factory.actionStatusType.FailedActionStatus
|
|
1129
|
+
].map(async (actionStatus) => {
|
|
1130
|
+
const matchConditions = {
|
|
1131
|
+
startDate: {
|
|
1132
|
+
$gte: params.startFrom,
|
|
1133
|
+
$lte: params.startThrough
|
|
1134
|
+
},
|
|
1135
|
+
typeOf: { $eq: params.typeOf },
|
|
1136
|
+
actionStatus: { $eq: actionStatus },
|
|
1137
|
+
'object.typeOf': {
|
|
1138
|
+
$exists: true,
|
|
1139
|
+
$eq: factory.action.authorize.offer.eventService.ObjectType.SeatReservation
|
|
1140
|
+
},
|
|
1141
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1187
1142
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1188
|
-
: undefined
|
|
1189
|
-
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1143
|
+
: undefined
|
|
1144
|
+
};
|
|
1145
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1146
|
+
}));
|
|
1147
|
+
return { statuses };
|
|
1193
1148
|
}
|
|
1194
|
-
aggregateAuthorizePaymentAction(params) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1149
|
+
async aggregateAuthorizePaymentAction(params) {
|
|
1150
|
+
const statuses = await Promise.all([
|
|
1151
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1152
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1153
|
+
factory.actionStatusType.FailedActionStatus
|
|
1154
|
+
].map(async (actionStatus) => {
|
|
1155
|
+
const matchConditions = {
|
|
1156
|
+
startDate: {
|
|
1157
|
+
$gte: params.startFrom,
|
|
1158
|
+
$lte: params.startThrough
|
|
1159
|
+
},
|
|
1160
|
+
typeOf: { $eq: params.typeOf },
|
|
1161
|
+
actionStatus: { $eq: actionStatus },
|
|
1162
|
+
'object.typeOf': {
|
|
1163
|
+
$exists: true,
|
|
1164
|
+
$eq: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
1165
|
+
},
|
|
1166
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1209
1167
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1210
|
-
: undefined
|
|
1211
|
-
|
|
1212
|
-
})
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1168
|
+
: undefined
|
|
1169
|
+
};
|
|
1170
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1171
|
+
}));
|
|
1172
|
+
return { statuses };
|
|
1215
1173
|
}
|
|
1216
|
-
aggregateAuthorizeOrderAction(params) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1174
|
+
async aggregateAuthorizeOrderAction(params) {
|
|
1175
|
+
const statuses = await Promise.all([
|
|
1176
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1177
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1178
|
+
factory.actionStatusType.FailedActionStatus
|
|
1179
|
+
].map(async (actionStatus) => {
|
|
1180
|
+
const matchConditions = {
|
|
1181
|
+
startDate: {
|
|
1182
|
+
$gte: params.startFrom,
|
|
1183
|
+
$lte: params.startThrough
|
|
1184
|
+
},
|
|
1185
|
+
typeOf: { $eq: params.typeOf },
|
|
1186
|
+
actionStatus: { $eq: actionStatus },
|
|
1187
|
+
'object.typeOf': {
|
|
1188
|
+
$exists: true,
|
|
1189
|
+
$eq: factory.order.OrderType.Order
|
|
1190
|
+
},
|
|
1191
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1231
1192
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1232
|
-
: undefined
|
|
1233
|
-
|
|
1234
|
-
})
|
|
1235
|
-
|
|
1236
|
-
}
|
|
1193
|
+
: undefined
|
|
1194
|
+
};
|
|
1195
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1196
|
+
}));
|
|
1197
|
+
return { statuses };
|
|
1237
1198
|
}
|
|
1238
|
-
aggregateCancelReservationAction(params) {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1199
|
+
async aggregateCancelReservationAction(params) {
|
|
1200
|
+
const statuses = await Promise.all([
|
|
1201
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1202
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1203
|
+
factory.actionStatusType.FailedActionStatus
|
|
1204
|
+
].map(async (actionStatus) => {
|
|
1205
|
+
const matchConditions = {
|
|
1206
|
+
startDate: {
|
|
1207
|
+
$gte: params.startFrom,
|
|
1208
|
+
$lte: params.startThrough
|
|
1209
|
+
},
|
|
1210
|
+
typeOf: { $eq: factory.actionType.CancelAction },
|
|
1211
|
+
actionStatus: { $eq: actionStatus },
|
|
1212
|
+
'object.typeOf': {
|
|
1213
|
+
$exists: true,
|
|
1214
|
+
$in: [
|
|
1215
|
+
factory.reservationType.BusReservation,
|
|
1216
|
+
factory.reservationType.EventReservation,
|
|
1217
|
+
factory.reservationType.ReservationPackage
|
|
1218
|
+
]
|
|
1219
|
+
},
|
|
1220
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1257
1221
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1258
|
-
: undefined
|
|
1259
|
-
|
|
1260
|
-
})
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1222
|
+
: undefined
|
|
1223
|
+
};
|
|
1224
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1225
|
+
}));
|
|
1226
|
+
return { statuses };
|
|
1263
1227
|
}
|
|
1264
1228
|
/**
|
|
1265
1229
|
* アクションタイプによる汎用的な集計
|
|
1266
1230
|
*/
|
|
1267
|
-
aggregateByTypeOf(params) {
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1231
|
+
async aggregateByTypeOf(params) {
|
|
1232
|
+
const statuses = await Promise.all([
|
|
1233
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1234
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1235
|
+
factory.actionStatusType.FailedActionStatus
|
|
1236
|
+
].map(async (actionStatus) => {
|
|
1237
|
+
const matchConditions = {
|
|
1238
|
+
startDate: {
|
|
1239
|
+
$gte: params.startFrom,
|
|
1240
|
+
$lte: params.startThrough
|
|
1241
|
+
},
|
|
1242
|
+
typeOf: { $eq: params.typeOf },
|
|
1243
|
+
actionStatus: { $eq: actionStatus },
|
|
1244
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1279
1245
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1280
|
-
: undefined
|
|
1281
|
-
|
|
1282
|
-
})
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1246
|
+
: undefined
|
|
1247
|
+
};
|
|
1248
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1249
|
+
}));
|
|
1250
|
+
return { statuses };
|
|
1285
1251
|
}
|
|
1286
|
-
aggregateCheckMovieTicketAction(params) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1252
|
+
async aggregateCheckMovieTicketAction(params) {
|
|
1253
|
+
const statuses = await Promise.all([
|
|
1254
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1255
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1256
|
+
factory.actionStatusType.FailedActionStatus
|
|
1257
|
+
].map(async (actionStatus) => {
|
|
1258
|
+
const matchConditions = {
|
|
1259
|
+
startDate: {
|
|
1260
|
+
$gte: params.startFrom,
|
|
1261
|
+
$lte: params.startThrough
|
|
1262
|
+
},
|
|
1263
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
1264
|
+
'object.typeOf': {
|
|
1265
|
+
$exists: true,
|
|
1266
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
1267
|
+
},
|
|
1268
|
+
actionStatus: { $eq: actionStatus },
|
|
1269
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1301
1270
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1302
|
-
: undefined
|
|
1303
|
-
|
|
1304
|
-
})
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1271
|
+
: undefined
|
|
1272
|
+
};
|
|
1273
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1274
|
+
}));
|
|
1275
|
+
return { statuses };
|
|
1307
1276
|
}
|
|
1308
|
-
aggregatePayMovieTicketAction(params) {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1277
|
+
async aggregatePayMovieTicketAction(params) {
|
|
1278
|
+
const statuses = await Promise.all([
|
|
1279
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
1280
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
1281
|
+
factory.actionStatusType.FailedActionStatus
|
|
1282
|
+
].map(async (actionStatus) => {
|
|
1283
|
+
const matchConditions = {
|
|
1284
|
+
startDate: {
|
|
1285
|
+
$gte: params.startFrom,
|
|
1286
|
+
$lte: params.startThrough
|
|
1287
|
+
},
|
|
1288
|
+
typeOf: { $eq: factory.actionType.PayAction },
|
|
1289
|
+
'object.typeOf': {
|
|
1290
|
+
$exists: true,
|
|
1291
|
+
$eq: factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
1292
|
+
},
|
|
1293
|
+
actionStatus: { $eq: actionStatus },
|
|
1294
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1323
1295
|
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1324
|
-
: undefined
|
|
1325
|
-
|
|
1326
|
-
})
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1296
|
+
: undefined
|
|
1297
|
+
};
|
|
1298
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
1299
|
+
}));
|
|
1300
|
+
return { statuses };
|
|
1329
1301
|
}
|
|
1330
1302
|
getCursor(conditions, projection) {
|
|
1331
1303
|
return this.actionModel.find(conditions, projection)
|
|
1332
1304
|
.sort({ startDate: factory.sortType.Descending })
|
|
1333
1305
|
.cursor();
|
|
1334
1306
|
}
|
|
1335
|
-
unsetUnnecessaryFields(params) {
|
|
1336
|
-
return
|
|
1337
|
-
|
|
1338
|
-
.exec();
|
|
1339
|
-
});
|
|
1307
|
+
async unsetUnnecessaryFields(params) {
|
|
1308
|
+
return this.actionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
1309
|
+
.exec();
|
|
1340
1310
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
endDate: '$endDate',
|
|
1352
|
-
typeOf: '$typeOf'
|
|
1353
|
-
}
|
|
1354
|
-
},
|
|
1355
|
-
{
|
|
1356
|
-
$group: {
|
|
1357
|
-
_id: '$typeOf',
|
|
1358
|
-
actionCount: { $sum: 1 },
|
|
1359
|
-
maxDuration: { $max: '$duration' },
|
|
1360
|
-
minDuration: { $min: '$duration' },
|
|
1361
|
-
avgDuration: { $avg: '$duration' }
|
|
1362
|
-
}
|
|
1363
|
-
},
|
|
1364
|
-
{
|
|
1365
|
-
$project: {
|
|
1366
|
-
_id: 0,
|
|
1367
|
-
actionCount: '$actionCount',
|
|
1368
|
-
avgDuration: '$avgDuration',
|
|
1369
|
-
maxDuration: '$maxDuration',
|
|
1370
|
-
minDuration: '$minDuration'
|
|
1371
|
-
}
|
|
1311
|
+
async agggregateByStatus(params) {
|
|
1312
|
+
const aggregations = await this.actionModel.aggregate([
|
|
1313
|
+
{ $match: params.matchConditions },
|
|
1314
|
+
{
|
|
1315
|
+
$project: {
|
|
1316
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1317
|
+
actionStatus: '$actionStatus',
|
|
1318
|
+
startDate: '$startDate',
|
|
1319
|
+
endDate: '$endDate',
|
|
1320
|
+
typeOf: '$typeOf'
|
|
1372
1321
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
actionCount: 0,
|
|
1382
|
-
avgDuration: 0,
|
|
1383
|
-
maxDuration: 0,
|
|
1384
|
-
minDuration: 0,
|
|
1385
|
-
percentilesDuration: percents.map((percent) => {
|
|
1386
|
-
return {
|
|
1387
|
-
name: String(percent),
|
|
1388
|
-
value: 0
|
|
1389
|
-
};
|
|
1390
|
-
})
|
|
1391
|
-
}
|
|
1392
|
-
};
|
|
1393
|
-
}
|
|
1394
|
-
const ranks4percentile = percents.map((percentile) => {
|
|
1395
|
-
return {
|
|
1396
|
-
percentile,
|
|
1397
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
1398
|
-
rank: Math.floor(aggregations[0].actionCount * percentile / 100)
|
|
1399
|
-
};
|
|
1400
|
-
});
|
|
1401
|
-
const aggregations2 = yield this.actionModel.aggregate([
|
|
1402
|
-
{
|
|
1403
|
-
$match: params.matchConditions
|
|
1404
|
-
},
|
|
1405
|
-
{
|
|
1406
|
-
$project: {
|
|
1407
|
-
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1408
|
-
actionStatus: '$actionStatus',
|
|
1409
|
-
startDate: '$startDate',
|
|
1410
|
-
endDate: '$endDate',
|
|
1411
|
-
typeOf: '$typeOf'
|
|
1412
|
-
}
|
|
1413
|
-
},
|
|
1414
|
-
{ $sort: { duration: 1 } },
|
|
1415
|
-
{
|
|
1416
|
-
$group: {
|
|
1417
|
-
_id: '$typeOf',
|
|
1418
|
-
durations: { $push: '$duration' }
|
|
1419
|
-
}
|
|
1420
|
-
},
|
|
1421
|
-
{
|
|
1422
|
-
$project: {
|
|
1423
|
-
_id: 0,
|
|
1424
|
-
avgSmallDuration: '$avgSmallDuration',
|
|
1425
|
-
avgMediumDuration: '$avgMediumDuration',
|
|
1426
|
-
avgLargeDuration: '$avgLargeDuration',
|
|
1427
|
-
percentilesDuration: ranks4percentile.map((rank) => {
|
|
1428
|
-
return {
|
|
1429
|
-
name: String(rank.percentile),
|
|
1430
|
-
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
1431
|
-
};
|
|
1432
|
-
})
|
|
1433
|
-
}
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
$group: {
|
|
1325
|
+
_id: '$typeOf',
|
|
1326
|
+
actionCount: { $sum: 1 },
|
|
1327
|
+
maxDuration: { $max: '$duration' },
|
|
1328
|
+
minDuration: { $min: '$duration' },
|
|
1329
|
+
avgDuration: { $avg: '$duration' }
|
|
1434
1330
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
$project: {
|
|
1334
|
+
_id: 0,
|
|
1335
|
+
actionCount: '$actionCount',
|
|
1336
|
+
avgDuration: '$avgDuration',
|
|
1337
|
+
maxDuration: '$maxDuration',
|
|
1338
|
+
minDuration: '$minDuration'
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
])
|
|
1342
|
+
.exec();
|
|
1343
|
+
const percents = [50, 95, 99];
|
|
1344
|
+
if (aggregations.length === 0) {
|
|
1437
1345
|
return {
|
|
1438
1346
|
status: params.actionStatus,
|
|
1439
|
-
aggregation:
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
project, typeOf, recipeCategory, recipeFor,
|
|
1452
|
-
dateCreated: dateModified
|
|
1347
|
+
aggregation: {
|
|
1348
|
+
actionCount: 0,
|
|
1349
|
+
avgDuration: 0,
|
|
1350
|
+
maxDuration: 0,
|
|
1351
|
+
minDuration: 0,
|
|
1352
|
+
percentilesDuration: percents.map((percent) => {
|
|
1353
|
+
return {
|
|
1354
|
+
name: String(percent),
|
|
1355
|
+
value: 0
|
|
1356
|
+
};
|
|
1357
|
+
})
|
|
1358
|
+
}
|
|
1453
1359
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1360
|
+
}
|
|
1361
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
1362
|
+
return {
|
|
1363
|
+
percentile,
|
|
1364
|
+
rank: Math.floor(aggregations[0].actionCount * percentile / 100)
|
|
1458
1365
|
};
|
|
1459
|
-
return this.actionRecipeModel.updateOne(filter, update, {
|
|
1460
|
-
upsert: true,
|
|
1461
|
-
includeResultMetadata: true
|
|
1462
|
-
})
|
|
1463
|
-
.exec();
|
|
1464
1366
|
});
|
|
1367
|
+
const aggregations2 = await this.actionModel.aggregate([
|
|
1368
|
+
{
|
|
1369
|
+
$match: params.matchConditions
|
|
1370
|
+
},
|
|
1371
|
+
{
|
|
1372
|
+
$project: {
|
|
1373
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1374
|
+
actionStatus: '$actionStatus',
|
|
1375
|
+
startDate: '$startDate',
|
|
1376
|
+
endDate: '$endDate',
|
|
1377
|
+
typeOf: '$typeOf'
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
{ $sort: { duration: 1 } },
|
|
1381
|
+
{
|
|
1382
|
+
$group: {
|
|
1383
|
+
_id: '$typeOf',
|
|
1384
|
+
durations: { $push: '$duration' }
|
|
1385
|
+
}
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
$project: {
|
|
1389
|
+
_id: 0,
|
|
1390
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
1391
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
1392
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
1393
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
1394
|
+
return {
|
|
1395
|
+
name: String(rank.percentile),
|
|
1396
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
1397
|
+
};
|
|
1398
|
+
})
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
])
|
|
1402
|
+
.exec();
|
|
1403
|
+
return {
|
|
1404
|
+
status: params.actionStatus,
|
|
1405
|
+
aggregation: {
|
|
1406
|
+
...aggregations[0],
|
|
1407
|
+
...aggregations2[0]
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
async upsertRecipe(savingRecipe) {
|
|
1412
|
+
const dateModified = new Date();
|
|
1413
|
+
const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
|
|
1414
|
+
const filter = {
|
|
1415
|
+
'recipeFor.id': { $eq: recipeFor.id }
|
|
1416
|
+
};
|
|
1417
|
+
const setOnInsert = {
|
|
1418
|
+
project, typeOf, recipeCategory, recipeFor,
|
|
1419
|
+
dateCreated: dateModified
|
|
1420
|
+
};
|
|
1421
|
+
const setKeys = { step, dateModified };
|
|
1422
|
+
const update = {
|
|
1423
|
+
$setOnInsert: setOnInsert,
|
|
1424
|
+
$set: setKeys
|
|
1425
|
+
};
|
|
1426
|
+
return this.actionRecipeModel.updateOne(filter, update, {
|
|
1427
|
+
upsert: true,
|
|
1428
|
+
includeResultMetadata: true
|
|
1429
|
+
})
|
|
1430
|
+
.exec();
|
|
1465
1431
|
}
|
|
1466
1432
|
}
|
|
1467
1433
|
exports.ActionRepo = ActionRepo;
|