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