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