@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
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,16 +19,16 @@ 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
26
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
35
27
|
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
28
|
const andConditions = [
|
|
38
29
|
{ typeOf: { $eq: factory.order.OrderType.Order } }
|
|
39
30
|
];
|
|
40
|
-
const projectIdEq =
|
|
31
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
41
32
|
if (typeof projectIdEq === 'string') {
|
|
42
33
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
43
34
|
}
|
|
@@ -65,15 +56,15 @@ class OrderRepo {
|
|
|
65
56
|
});
|
|
66
57
|
}
|
|
67
58
|
}
|
|
68
|
-
const providerIdEq =
|
|
59
|
+
const providerIdEq = params.provider?.id?.$eq;
|
|
69
60
|
if (typeof providerIdEq === 'string') {
|
|
70
61
|
andConditions.push({ 'seller.id': { $exists: true, $eq: providerIdEq } });
|
|
71
62
|
}
|
|
72
|
-
const sellerIdEq =
|
|
63
|
+
const sellerIdEq = params.seller?.id?.$eq;
|
|
73
64
|
if (typeof sellerIdEq === 'string') {
|
|
74
65
|
andConditions.push({ 'seller.id': { $exists: true, $eq: sellerIdEq } });
|
|
75
66
|
}
|
|
76
|
-
const sellerIds =
|
|
67
|
+
const sellerIds = params.seller?.ids;
|
|
77
68
|
if (Array.isArray(sellerIds)) {
|
|
78
69
|
if (sellerIds.length === 1) {
|
|
79
70
|
// use $eq(2025-04-01~)
|
|
@@ -83,7 +74,7 @@ class OrderRepo {
|
|
|
83
74
|
andConditions.push({ 'seller.id': { $exists: true, $in: sellerIds } });
|
|
84
75
|
}
|
|
85
76
|
}
|
|
86
|
-
const brokerIdEq =
|
|
77
|
+
const brokerIdEq = params.broker?.id?.$eq;
|
|
87
78
|
if (typeof brokerIdEq === 'string') {
|
|
88
79
|
andConditions.push({
|
|
89
80
|
'broker.id': {
|
|
@@ -300,7 +291,7 @@ class OrderRepo {
|
|
|
300
291
|
}
|
|
301
292
|
}
|
|
302
293
|
}
|
|
303
|
-
const nameEq =
|
|
294
|
+
const nameEq = params.name?.$eq;
|
|
304
295
|
if (typeof nameEq === 'string') {
|
|
305
296
|
andConditions.push({
|
|
306
297
|
name: {
|
|
@@ -309,7 +300,7 @@ class OrderRepo {
|
|
|
309
300
|
}
|
|
310
301
|
});
|
|
311
302
|
}
|
|
312
|
-
const nameRegex =
|
|
303
|
+
const nameRegex = params.name?.$regex;
|
|
313
304
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
314
305
|
andConditions.push({
|
|
315
306
|
name: {
|
|
@@ -345,19 +336,19 @@ class OrderRepo {
|
|
|
345
336
|
andConditions.push({ confirmationNumber: { $exists: true, $in: params.confirmationNumbers } });
|
|
346
337
|
}
|
|
347
338
|
}
|
|
348
|
-
const orderedItemSize =
|
|
339
|
+
const orderedItemSize = params.orderedItem?.$size;
|
|
349
340
|
if (typeof orderedItemSize === 'number') {
|
|
350
341
|
andConditions.push({ orderedItem: { $size: orderedItemSize } });
|
|
351
342
|
}
|
|
352
|
-
const acceptedOffersSize =
|
|
343
|
+
const acceptedOffersSize = params.acceptedOffers?.$size;
|
|
353
344
|
if (typeof acceptedOffersSize === 'number') {
|
|
354
345
|
andConditions.push({ acceptedOffers: { $size: acceptedOffersSize } });
|
|
355
346
|
}
|
|
356
|
-
const serialNumberEq =
|
|
347
|
+
const serialNumberEq = params.acceptedOffers?.serialNumber?.$eq;
|
|
357
348
|
if (typeof serialNumberEq === 'string') {
|
|
358
349
|
andConditions.push({ 'acceptedOffers.serialNumber': { $exists: true, $eq: serialNumberEq } });
|
|
359
350
|
}
|
|
360
|
-
const itemOfferedIdentifierIn =
|
|
351
|
+
const itemOfferedIdentifierIn = params.acceptedOffers?.itemOffered?.identifier?.$in;
|
|
361
352
|
if (Array.isArray(itemOfferedIdentifierIn)) {
|
|
362
353
|
andConditions.push({
|
|
363
354
|
'acceptedOffers.itemOffered.identifier': {
|
|
@@ -366,7 +357,7 @@ class OrderRepo {
|
|
|
366
357
|
}
|
|
367
358
|
});
|
|
368
359
|
}
|
|
369
|
-
const itemOfferedTypeOfIn =
|
|
360
|
+
const itemOfferedTypeOfIn = params.acceptedOffers?.itemOffered?.typeOf?.$in;
|
|
370
361
|
if (Array.isArray(itemOfferedTypeOfIn)) {
|
|
371
362
|
andConditions.push({
|
|
372
363
|
'acceptedOffers.itemOffered.typeOf': {
|
|
@@ -375,7 +366,7 @@ class OrderRepo {
|
|
|
375
366
|
}
|
|
376
367
|
});
|
|
377
368
|
}
|
|
378
|
-
const itemOfferedIssuedThroughTypeOfEq =
|
|
369
|
+
const itemOfferedIssuedThroughTypeOfEq = params.acceptedOffers?.itemOffered?.issuedThrough?.typeOf?.$eq;
|
|
379
370
|
if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
|
|
380
371
|
andConditions.push({
|
|
381
372
|
'acceptedOffers.itemOffered.issuedThrough.typeOf': {
|
|
@@ -384,7 +375,7 @@ class OrderRepo {
|
|
|
384
375
|
}
|
|
385
376
|
});
|
|
386
377
|
}
|
|
387
|
-
const itemOfferedIssuedThroughIdIn =
|
|
378
|
+
const itemOfferedIssuedThroughIdIn = params.acceptedOffers?.itemOffered?.issuedThrough?.id?.$in;
|
|
388
379
|
if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
|
|
389
380
|
andConditions.push({
|
|
390
381
|
'acceptedOffers.itemOffered.issuedThrough.id': {
|
|
@@ -393,7 +384,7 @@ class OrderRepo {
|
|
|
393
384
|
}
|
|
394
385
|
});
|
|
395
386
|
}
|
|
396
|
-
const itemOfferedProgramMembershipUsedIdentifierEq =
|
|
387
|
+
const itemOfferedProgramMembershipUsedIdentifierEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.identifier?.$eq;
|
|
397
388
|
if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
|
|
398
389
|
andConditions.push({
|
|
399
390
|
'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
|
|
@@ -402,7 +393,7 @@ class OrderRepo {
|
|
|
402
393
|
}
|
|
403
394
|
});
|
|
404
395
|
}
|
|
405
|
-
const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq =
|
|
396
|
+
const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
|
|
406
397
|
if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
|
|
407
398
|
andConditions.push({
|
|
408
399
|
'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
|
|
@@ -411,7 +402,7 @@ class OrderRepo {
|
|
|
411
402
|
}
|
|
412
403
|
});
|
|
413
404
|
}
|
|
414
|
-
const itemOfferedReservedTicketIdentifierEq =
|
|
405
|
+
const itemOfferedReservedTicketIdentifierEq = params.acceptedOffers?.itemOffered?.reservedTicket?.identifier?.$eq;
|
|
415
406
|
if (typeof itemOfferedReservedTicketIdentifierEq === 'string') {
|
|
416
407
|
andConditions.push({
|
|
417
408
|
'acceptedOffers.itemOffered.reservedTicket.identifier': {
|
|
@@ -595,11 +586,11 @@ class OrderRepo {
|
|
|
595
586
|
}
|
|
596
587
|
}
|
|
597
588
|
}
|
|
598
|
-
const paymentMethodIdentifierIn =
|
|
589
|
+
const paymentMethodIdentifierIn = params.paymentMethods?.paymentMethod?.identifier?.$in;
|
|
599
590
|
if (Array.isArray(paymentMethodIdentifierIn)) {
|
|
600
591
|
andConditions.push({ 'paymentMethods.paymentMethod.identifier': { $exists: true, $in: paymentMethodIdentifierIn } });
|
|
601
592
|
}
|
|
602
|
-
const paymentMethodsTypeOfIn =
|
|
593
|
+
const paymentMethodsTypeOfIn = params.paymentMethods?.typeOfs;
|
|
603
594
|
if (Array.isArray(paymentMethodsTypeOfIn)) {
|
|
604
595
|
// paymentMethod.identifierで検索(2023-11-15~)
|
|
605
596
|
// andConditions.push({ 'paymentMethods.typeOf': { $exists: true, $in: paymentMethodsTypeOfIn } });
|
|
@@ -629,7 +620,7 @@ class OrderRepo {
|
|
|
629
620
|
});
|
|
630
621
|
}
|
|
631
622
|
}
|
|
632
|
-
const paymentMethodAdditionalPropertyAll =
|
|
623
|
+
const paymentMethodAdditionalPropertyAll = params.paymentMethods?.additionalProperty?.$all;
|
|
633
624
|
if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
|
|
634
625
|
andConditions.push({
|
|
635
626
|
'paymentMethods.additionalProperty': {
|
|
@@ -638,7 +629,7 @@ class OrderRepo {
|
|
|
638
629
|
}
|
|
639
630
|
});
|
|
640
631
|
}
|
|
641
|
-
const paymentMethodAdditionalPropertyIn =
|
|
632
|
+
const paymentMethodAdditionalPropertyIn = params.paymentMethods?.additionalProperty?.$in;
|
|
642
633
|
if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
|
|
643
634
|
andConditions.push({
|
|
644
635
|
'paymentMethods.additionalProperty': {
|
|
@@ -696,622 +687,622 @@ class OrderRepo {
|
|
|
696
687
|
/**
|
|
697
688
|
* なければ作成する
|
|
698
689
|
*/
|
|
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;
|
|
690
|
+
async createIfNotExist(order) {
|
|
691
|
+
try {
|
|
692
|
+
// 存在しなければ上書き
|
|
693
|
+
// updateOneに変更(2024-01-14~)
|
|
694
|
+
// await this.orderModel.findOneAndUpdate(
|
|
695
|
+
await this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
|
|
696
|
+
// new: true,
|
|
697
|
+
upsert: true
|
|
698
|
+
})
|
|
699
|
+
.exec();
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
let throwsError = true;
|
|
703
|
+
if (await (0, errorHandler_1.isMongoError)(error)) {
|
|
704
|
+
// すでにorderNumberが存在する場合ok
|
|
705
|
+
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
706
|
+
throwsError = false;
|
|
721
707
|
}
|
|
722
708
|
}
|
|
723
|
-
|
|
709
|
+
if (throwsError) {
|
|
710
|
+
throw error;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
724
713
|
}
|
|
725
714
|
/**
|
|
726
715
|
* 注文ステータスを変更する
|
|
727
716
|
*/
|
|
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
|
-
|
|
717
|
+
async changeStatus(params) {
|
|
718
|
+
const { orderNumber, previousOrderStatus, orderStatus } = params;
|
|
719
|
+
const doc = await this.orderModel.findOneAndUpdate({
|
|
720
|
+
orderNumber: { $eq: orderNumber },
|
|
721
|
+
orderStatus: { $eq: previousOrderStatus },
|
|
722
|
+
'project.id': { $eq: params.project.id },
|
|
723
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
724
|
+
}, {
|
|
725
|
+
$set: {
|
|
726
|
+
previousOrderStatus, // 追加(2023-08-31~)
|
|
727
|
+
orderStatus
|
|
728
|
+
}
|
|
729
|
+
}, {
|
|
730
|
+
new: true,
|
|
731
|
+
// inclusion projection(2024-07-25~)
|
|
732
|
+
projection: {
|
|
733
|
+
_id: 0, // hide _id(2024-07-25~)
|
|
734
|
+
id: { $toString: '$_id' },
|
|
735
|
+
orderNumber: 1, broker: 1, confirmationNumber: 1, customer: 1, dateReturned: 1,
|
|
736
|
+
name: 1, orderDate: 1, orderStatus: 1, orderedItem: 1, paymentMethods: 1,
|
|
737
|
+
previousOrderStatus: 1, price: 1, priceCurrency: 1, project: 1, returner: 1, seller: 1, typeOf: 1
|
|
738
|
+
}
|
|
739
|
+
// projection: {
|
|
740
|
+
// __v: 0,
|
|
741
|
+
// createdAt: 0,
|
|
742
|
+
// updatedAt: 0,
|
|
743
|
+
// acceptedOffers: 0 // 除外(2023-12-08~)
|
|
744
|
+
// }
|
|
745
|
+
})
|
|
746
|
+
.lean() // lean(2024-07-25~)
|
|
747
|
+
.exec();
|
|
748
|
+
// NotFoundであれば状態確認
|
|
749
|
+
if (doc === null) {
|
|
750
|
+
const order = await this.projectFieldsByOrderNumber({
|
|
751
|
+
orderNumber: params.orderNumber,
|
|
752
|
+
project: { id: params.project.id },
|
|
753
|
+
inclusion: [
|
|
754
|
+
'orderNumber', 'broker', 'confirmationNumber', 'customer', 'dateReturned',
|
|
755
|
+
'name', 'orderDate', 'orderStatus', 'orderedItem', 'paymentMethods',
|
|
756
|
+
'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf'
|
|
757
|
+
] // inclusion projection(2024-07-25~)
|
|
758
|
+
});
|
|
759
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
760
|
+
/* istanbul ignore next */
|
|
761
|
+
if (order.orderStatus === params.orderStatus) {
|
|
762
|
+
// すでに変更済の場合
|
|
763
|
+
return order;
|
|
771
764
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
772
765
|
/* 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
766
|
}
|
|
783
|
-
|
|
784
|
-
|
|
767
|
+
else {
|
|
768
|
+
throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return doc;
|
|
785
772
|
}
|
|
786
773
|
/**
|
|
787
774
|
* 注文を返品する
|
|
788
775
|
*/
|
|
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
|
-
|
|
776
|
+
async returnOrder(params) {
|
|
777
|
+
const { dateReturned, returner, orderNumber, project } = params;
|
|
778
|
+
const doc = await this.orderModel.findOneAndUpdate({
|
|
779
|
+
orderNumber: { $eq: orderNumber },
|
|
780
|
+
orderStatus: { $eq: factory.orderStatus.OrderDelivered },
|
|
781
|
+
'project.id': { $eq: project.id },
|
|
782
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
783
|
+
}, {
|
|
784
|
+
$set: {
|
|
785
|
+
previousOrderStatus: factory.orderStatus.OrderDelivered,
|
|
786
|
+
orderStatus: factory.orderStatus.OrderReturned,
|
|
787
|
+
dateReturned,
|
|
788
|
+
returner
|
|
789
|
+
}
|
|
790
|
+
}, {
|
|
791
|
+
new: true,
|
|
792
|
+
projection: {
|
|
793
|
+
_id: 0, // hide _id(2024-07-30~)
|
|
794
|
+
id: { $toString: '$_id' },
|
|
795
|
+
// _id: 1,
|
|
796
|
+
project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
|
|
797
|
+
customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
|
|
798
|
+
// __v: 0,
|
|
799
|
+
// createdAt: 0,
|
|
800
|
+
// updatedAt: 0
|
|
801
|
+
}
|
|
802
|
+
})
|
|
803
|
+
.lean() // lean(2024-07-30~)
|
|
804
|
+
.exec();
|
|
805
|
+
// NotFoundであれば状態確認
|
|
806
|
+
if (doc === null) {
|
|
807
|
+
const order = await this.projectFieldsByOrderNumber({
|
|
808
|
+
orderNumber: params.orderNumber,
|
|
809
|
+
project: { id: params.project.id },
|
|
810
|
+
inclusion: [
|
|
811
|
+
'project', 'typeOf', 'orderNumber', 'dateReturned',
|
|
812
|
+
'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
|
|
813
|
+
]
|
|
814
|
+
});
|
|
815
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
816
|
+
/* istanbul ignore next */
|
|
817
|
+
if (order.orderStatus === factory.orderStatus.OrderReturned) {
|
|
818
|
+
// すでに変更済の場合
|
|
819
|
+
return order;
|
|
829
820
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
830
821
|
/* 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
822
|
}
|
|
841
|
-
|
|
842
|
-
|
|
823
|
+
else {
|
|
824
|
+
throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return doc;
|
|
843
828
|
}
|
|
844
829
|
/**
|
|
845
830
|
* 変更可能な属性を更新する
|
|
846
831
|
*/
|
|
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);
|
|
832
|
+
async updateChangeableAttributes(params) {
|
|
833
|
+
const updatedAt = new Date();
|
|
834
|
+
const { orderNumber, project, name } = params;
|
|
835
|
+
const doc = await this.orderModel.findOneAndUpdate({
|
|
836
|
+
orderNumber: { $eq: orderNumber },
|
|
837
|
+
'project.id': { $eq: project.id },
|
|
838
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
839
|
+
}, {
|
|
840
|
+
$set: {
|
|
841
|
+
...(typeof name === 'string') ? { name } : undefined
|
|
842
|
+
}
|
|
843
|
+
}, {
|
|
844
|
+
new: false,
|
|
845
|
+
projection: {
|
|
846
|
+
_id: 1
|
|
847
|
+
// updatedAt: 1 // discontinue(2024-06-17~)
|
|
868
848
|
}
|
|
869
|
-
|
|
870
|
-
|
|
849
|
+
})
|
|
850
|
+
.lean() // lean(2024-07-30~)
|
|
851
|
+
.exec();
|
|
852
|
+
if (doc === null) {
|
|
853
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
854
|
+
}
|
|
855
|
+
return { updatedAt };
|
|
871
856
|
}
|
|
872
857
|
/**
|
|
873
858
|
* 注文後に決済方法区分を確定する
|
|
874
859
|
*/
|
|
875
|
-
fixPaymentMethodIdentifier(params) {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
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);
|
|
860
|
+
async fixPaymentMethodIdentifier(params) {
|
|
861
|
+
const doc = await this.orderModel.findOneAndUpdate({
|
|
862
|
+
orderNumber: { $eq: params.orderNumber },
|
|
863
|
+
'project.id': { $eq: params.project.id },
|
|
864
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
865
|
+
'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
|
|
866
|
+
}, {
|
|
867
|
+
$set: {
|
|
868
|
+
'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
|
|
869
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
870
|
+
// TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
|
|
871
|
+
'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
|
|
900
872
|
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
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
|
-
});
|
|
919
|
-
}
|
|
920
|
-
else {
|
|
921
|
-
// discontinue(2024-07-25~)
|
|
922
|
-
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
923
|
-
}
|
|
924
|
-
const doc = yield this.orderModel.findOne({
|
|
925
|
-
_id: { $eq: params.id },
|
|
926
|
-
typeOf: { $eq: factory.order.OrderType.Order }
|
|
927
|
-
}, projection)
|
|
928
|
-
.lean() // lean(2024-07-25~)
|
|
929
|
-
.exec();
|
|
930
|
-
if (doc === null) {
|
|
931
|
-
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
873
|
+
}, {
|
|
874
|
+
arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
|
|
875
|
+
new: true,
|
|
876
|
+
projection: {
|
|
877
|
+
_id: 1
|
|
932
878
|
}
|
|
933
|
-
|
|
934
|
-
|
|
879
|
+
})
|
|
880
|
+
.lean() // lean(2024-07-30~)
|
|
881
|
+
.exec();
|
|
882
|
+
if (doc === null) {
|
|
883
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
async projectFieldsById(params) {
|
|
887
|
+
const projection = {
|
|
888
|
+
// _id: 1
|
|
889
|
+
_id: 0, // hide _id(2024-07-25~)
|
|
890
|
+
id: { $toString: '$_id' }
|
|
891
|
+
};
|
|
892
|
+
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
893
|
+
params.inclusion.forEach((field) => {
|
|
894
|
+
// if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
|
|
895
|
+
// projection[field] = 1;
|
|
896
|
+
// }
|
|
897
|
+
if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
|
|
898
|
+
projection[field] = 1;
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
// discontinue(2024-07-25~)
|
|
904
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
905
|
+
}
|
|
906
|
+
const doc = await this.orderModel.findOne({
|
|
907
|
+
_id: { $eq: params.id },
|
|
908
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
909
|
+
}, projection)
|
|
910
|
+
.lean() // lean(2024-07-25~)
|
|
911
|
+
.exec();
|
|
912
|
+
if (doc === null) {
|
|
913
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
914
|
+
}
|
|
915
|
+
return doc;
|
|
935
916
|
}
|
|
936
917
|
/**
|
|
937
918
|
* 注文番号から注文を取得する
|
|
938
919
|
*/
|
|
939
|
-
projectFieldsByOrderNumber(
|
|
920
|
+
async projectFieldsByOrderNumber(
|
|
940
921
|
// public async findByOrderNumber(
|
|
941
922
|
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
|
-
});
|
|
923
|
+
const projection = {
|
|
924
|
+
_id: 0, // hide _id(2024-07-25~)
|
|
925
|
+
id: { $toString: '$_id' }
|
|
926
|
+
};
|
|
927
|
+
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
928
|
+
params.inclusion.forEach((field) => {
|
|
929
|
+
// if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
|
|
930
|
+
// projection[field] = 1;
|
|
931
|
+
// }
|
|
932
|
+
if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
|
|
933
|
+
projection[field] = 1;
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
// discontinue(2024-07-25~)
|
|
939
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
940
|
+
}
|
|
941
|
+
const doc = await this.orderModel.findOne({
|
|
942
|
+
orderNumber: { $eq: params.orderNumber },
|
|
943
|
+
'project.id': { $eq: params.project.id },
|
|
944
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
945
|
+
}, projection)
|
|
946
|
+
.lean() // lean(2024-07-25~)
|
|
947
|
+
.exec();
|
|
948
|
+
if (doc === null) {
|
|
949
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
950
|
+
}
|
|
951
|
+
return doc;
|
|
973
952
|
}
|
|
974
|
-
findByOrderNumberAndReservationId(params) {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
|
|
953
|
+
async findByOrderNumberAndReservationId(params) {
|
|
954
|
+
const projection = {
|
|
955
|
+
orderStatus: 1,
|
|
956
|
+
typeOf: 1,
|
|
957
|
+
orderNumber: 1,
|
|
958
|
+
_id: 0
|
|
959
|
+
};
|
|
960
|
+
const doc = await this.orderModel.findOne({
|
|
961
|
+
orderNumber: { $eq: params.orderNumber },
|
|
962
|
+
'project.id': { $eq: params.project.id },
|
|
963
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
964
|
+
acceptedOffers: {
|
|
965
|
+
$elemMatch: {
|
|
966
|
+
'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
|
|
967
|
+
'itemOffered.id': { $eq: params.reservationId }
|
|
968
|
+
}
|
|
969
|
+
},
|
|
970
|
+
...(typeof params.seller?.id === 'string')
|
|
989
971
|
? { 'seller.id': { $exists: true, $eq: params.seller.id } }
|
|
990
|
-
: undefined
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
972
|
+
: undefined
|
|
973
|
+
}, projection)
|
|
974
|
+
// projection的にleanで十分
|
|
975
|
+
.lean()
|
|
976
|
+
.exec();
|
|
977
|
+
if (doc === null) {
|
|
978
|
+
throw new factory.errors.NotFound(this.orderModel.modelName);
|
|
979
|
+
}
|
|
980
|
+
return doc;
|
|
999
981
|
}
|
|
1000
982
|
/**
|
|
1001
983
|
* 注文番号で削除する
|
|
1002
984
|
*/
|
|
1003
|
-
deleteByOrderNumber(params) {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
.exec();
|
|
1010
|
-
});
|
|
985
|
+
async deleteByOrderNumber(params) {
|
|
986
|
+
await this.orderModel.deleteOne({
|
|
987
|
+
orderNumber: { $eq: params.orderNumber },
|
|
988
|
+
typeOf: { $eq: factory.order.OrderType.Order }
|
|
989
|
+
})
|
|
990
|
+
.exec();
|
|
1011
991
|
}
|
|
1012
|
-
count(params) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
.exec();
|
|
1018
|
-
});
|
|
992
|
+
async count(params) {
|
|
993
|
+
const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
994
|
+
return this.orderModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
995
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
996
|
+
.exec();
|
|
1019
997
|
}
|
|
1020
998
|
/**
|
|
1021
999
|
* 注文を検索する(inclusion projection)
|
|
1022
1000
|
* redefine from search(2024-07-31~)
|
|
1023
1001
|
*/
|
|
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
|
-
|
|
1002
|
+
async projectFields(params, options) {
|
|
1003
|
+
const { inclusion } = options;
|
|
1004
|
+
const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
1005
|
+
let projectStage = {};
|
|
1006
|
+
const positiveProjectionFields = (Array.isArray(inclusion))
|
|
1007
|
+
? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
|
|
1008
|
+
: [];
|
|
1009
|
+
if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
|
|
1010
|
+
projectStage = {
|
|
1011
|
+
_id: 0, // hide _id(2024-07-25~)
|
|
1012
|
+
id: { $toString: '$_id' },
|
|
1013
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
else {
|
|
1017
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
1018
|
+
}
|
|
1019
|
+
const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
|
|
1020
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
1021
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
1022
|
+
query.limit(params.limit)
|
|
1023
|
+
.skip(params.limit * (page - 1));
|
|
1024
|
+
}
|
|
1025
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
1026
|
+
/* istanbul ignore else */
|
|
1027
|
+
if (params.sort?.orderDate !== undefined) {
|
|
1028
|
+
query.sort({ orderDate: params.sort.orderDate });
|
|
1029
|
+
}
|
|
1030
|
+
// const explainResult = await (<any>query).explain();
|
|
1031
|
+
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
1032
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
1033
|
+
.lean() // lean(2024-07-25~)
|
|
1034
|
+
.exec();
|
|
1056
1035
|
}
|
|
1057
1036
|
getCursor(conditions, projection) {
|
|
1058
1037
|
return this.orderModel.find(conditions, projection)
|
|
1059
1038
|
.sort({ orderDate: factory.sortType.Descending })
|
|
1060
1039
|
.cursor();
|
|
1061
1040
|
}
|
|
1062
|
-
unsetUnnecessaryFields(params) {
|
|
1063
|
-
return
|
|
1064
|
-
|
|
1065
|
-
.exec();
|
|
1066
|
-
});
|
|
1041
|
+
async unsetUnnecessaryFields(params) {
|
|
1042
|
+
return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
1043
|
+
.exec();
|
|
1067
1044
|
}
|
|
1068
1045
|
// tslint:disable-next-line:max-func-body-length
|
|
1069
|
-
aggregateOrder(params) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1046
|
+
async aggregateOrder(params) {
|
|
1047
|
+
const matchConditions = {
|
|
1048
|
+
orderDate: {
|
|
1049
|
+
$gte: params.orderDate.$gte,
|
|
1050
|
+
$lte: params.orderDate.$lte
|
|
1051
|
+
},
|
|
1052
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1053
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
1076
1054
|
? { '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
|
-
|
|
1055
|
+
: undefined
|
|
1056
|
+
};
|
|
1057
|
+
const aggregations = await this.orderModel.aggregate([
|
|
1058
|
+
{ $match: matchConditions },
|
|
1059
|
+
{
|
|
1060
|
+
$project: {
|
|
1061
|
+
typeOf: '$typeOf',
|
|
1062
|
+
price: '$price',
|
|
1063
|
+
numAcceptedOffers: { $size: '$acceptedOffers' }
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
$group: {
|
|
1068
|
+
_id: '$typeOf',
|
|
1069
|
+
orderCount: { $sum: 1 },
|
|
1070
|
+
totalNumAcceptedOffer: { $sum: '$numAcceptedOffers' },
|
|
1071
|
+
maxNumAcceptedOffer: { $max: '$numAcceptedOffers' },
|
|
1072
|
+
minNumAcceptedOffer: { $min: '$numAcceptedOffers' },
|
|
1073
|
+
avgNumAcceptedOffer: { $avg: '$numAcceptedOffers' },
|
|
1074
|
+
totalPrice: { $sum: '$price' },
|
|
1075
|
+
maxPrice: { $max: '$price' },
|
|
1076
|
+
minPrice: { $min: '$price' },
|
|
1077
|
+
avgPrice: { $avg: '$price' }
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
$project: {
|
|
1082
|
+
_id: 0,
|
|
1083
|
+
orderCount: '$orderCount',
|
|
1084
|
+
totalNumAcceptedOffer: '$totalNumAcceptedOffer',
|
|
1085
|
+
maxNumAcceptedOffer: '$maxNumAcceptedOffer',
|
|
1086
|
+
minNumAcceptedOffer: '$minNumAcceptedOffer',
|
|
1087
|
+
avgNumAcceptedOffer: '$avgNumAcceptedOffer',
|
|
1088
|
+
totalPrice: '$totalPrice',
|
|
1089
|
+
maxPrice: '$maxPrice',
|
|
1090
|
+
minPrice: '$minPrice',
|
|
1091
|
+
avgPrice: '$avgPrice'
|
|
1114
1092
|
}
|
|
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
1093
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1094
|
+
])
|
|
1095
|
+
.exec();
|
|
1096
|
+
if (aggregations.length === 0) {
|
|
1097
|
+
return {
|
|
1098
|
+
aggregation: {
|
|
1099
|
+
orderCount: 0,
|
|
1100
|
+
totalNumAcceptedOffer: 0,
|
|
1101
|
+
maxNumAcceptedOffer: 0,
|
|
1102
|
+
minNumAcceptedOffer: 0,
|
|
1103
|
+
avgNumAcceptedOffer: 0,
|
|
1104
|
+
totalPrice: 0,
|
|
1105
|
+
maxPrice: 0,
|
|
1106
|
+
minPrice: 0,
|
|
1107
|
+
avgPrice: 0
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
return { aggregation: aggregations[0] };
|
|
1134
1112
|
}
|
|
1135
|
-
aggregateOrderOfSeat(params) {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1113
|
+
async aggregateOrderOfSeat(params) {
|
|
1114
|
+
const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
|
|
1115
|
+
const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
|
|
1116
|
+
const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
|
|
1117
|
+
const customerEmailIn = params.customer?.email?.$in;
|
|
1118
|
+
const matchConditions = {
|
|
1119
|
+
orderDate: {
|
|
1120
|
+
$gte: params.orderDate.$gte,
|
|
1121
|
+
$lte: params.orderDate.$lte
|
|
1122
|
+
},
|
|
1123
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1124
|
+
'project.id': { $eq: params.project.id.$eq },
|
|
1125
|
+
'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode },
|
|
1126
|
+
'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode },
|
|
1127
|
+
'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber },
|
|
1128
|
+
...(Array.isArray(customerEmailIn))
|
|
1146
1129
|
? { 'customer.email': { $exists: true, $in: customerEmailIn } }
|
|
1147
|
-
: undefined
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
$count: 'emailCount'
|
|
1130
|
+
: undefined
|
|
1131
|
+
};
|
|
1132
|
+
const aggregations4email = await this.orderModel.aggregate([
|
|
1133
|
+
{ $match: matchConditions },
|
|
1134
|
+
{
|
|
1135
|
+
$group: {
|
|
1136
|
+
_id: '$customer.email'
|
|
1157
1137
|
}
|
|
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'
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
$count: 'emailCount'
|
|
1141
|
+
}
|
|
1142
|
+
])
|
|
1143
|
+
.exec();
|
|
1144
|
+
const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
|
|
1145
|
+
const aggregations = await this.orderModel.aggregate([
|
|
1146
|
+
{ $match: matchConditions },
|
|
1147
|
+
{
|
|
1148
|
+
$project: {
|
|
1149
|
+
typeOf: '$typeOf',
|
|
1150
|
+
graceTime: {
|
|
1151
|
+
$subtract: [
|
|
1152
|
+
{ $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
|
|
1153
|
+
'$orderDate'
|
|
1154
|
+
]
|
|
1186
1155
|
}
|
|
1187
1156
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
$group: {
|
|
1160
|
+
_id: '$typeOf',
|
|
1161
|
+
orderCount: { $sum: 1 },
|
|
1162
|
+
sumGraceTime: { $sum: '$graceTime' }
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
$project: {
|
|
1167
|
+
_id: 0,
|
|
1168
|
+
orderCount: '$orderCount',
|
|
1169
|
+
sumGraceTime: '$sumGraceTime'
|
|
1170
|
+
}
|
|
1196
1171
|
}
|
|
1172
|
+
])
|
|
1173
|
+
.exec();
|
|
1174
|
+
if (aggregations.length === 0) {
|
|
1197
1175
|
return {
|
|
1198
|
-
aggregation:
|
|
1176
|
+
aggregation: {
|
|
1177
|
+
orderCount: 0
|
|
1178
|
+
}
|
|
1199
1179
|
};
|
|
1200
|
-
}
|
|
1180
|
+
}
|
|
1181
|
+
return {
|
|
1182
|
+
aggregation: {
|
|
1183
|
+
...aggregations[0],
|
|
1184
|
+
emailCount
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1201
1187
|
}
|
|
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'
|
|
1188
|
+
async aggregateOrderOfCustomerByProject(params) {
|
|
1189
|
+
const matchConditions = {
|
|
1190
|
+
orderDate: {
|
|
1191
|
+
$gte: params.orderDate.$gte,
|
|
1192
|
+
$lte: params.orderDate.$lte
|
|
1193
|
+
},
|
|
1194
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1195
|
+
...(typeof params.project?.id.$eq === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined,
|
|
1196
|
+
'customer.email': { $exists: true, $eq: params.customer.email.$eq }
|
|
1197
|
+
};
|
|
1198
|
+
const aggregations = await this.orderModel.aggregate([
|
|
1199
|
+
{ $match: matchConditions },
|
|
1200
|
+
{
|
|
1201
|
+
$project: {
|
|
1202
|
+
typeOf: '$typeOf',
|
|
1203
|
+
graceTime: {
|
|
1204
|
+
$subtract: [
|
|
1205
|
+
{ $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
|
|
1206
|
+
'$orderDate'
|
|
1207
|
+
]
|
|
1234
1208
|
}
|
|
1235
1209
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
$group: {
|
|
1213
|
+
_id: '$typeOf',
|
|
1214
|
+
orderCount: { $sum: 1 },
|
|
1215
|
+
sumGraceTime: { $sum: '$graceTime' }
|
|
1216
|
+
}
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
$project: {
|
|
1220
|
+
_id: 0,
|
|
1221
|
+
orderCount: '$orderCount',
|
|
1222
|
+
sumGraceTime: '$sumGraceTime'
|
|
1223
|
+
}
|
|
1244
1224
|
}
|
|
1225
|
+
])
|
|
1226
|
+
.exec();
|
|
1227
|
+
if (aggregations.length === 0) {
|
|
1245
1228
|
return {
|
|
1246
|
-
aggregation:
|
|
1229
|
+
aggregation: {
|
|
1230
|
+
orderCount: 0
|
|
1231
|
+
}
|
|
1247
1232
|
};
|
|
1248
|
-
}
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
aggregation: {
|
|
1236
|
+
...aggregations[0]
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1249
1239
|
}
|
|
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
|
-
}
|
|
1240
|
+
async aggregateOrderOfCustomerGlobally(params) {
|
|
1241
|
+
const matchConditions = {
|
|
1242
|
+
orderDate: {
|
|
1243
|
+
$gte: params.orderDate.$gte,
|
|
1244
|
+
$lte: params.orderDate.$lte
|
|
1245
|
+
},
|
|
1246
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1247
|
+
'customer.email': { $exists: true, $eq: params.customer.email.$eq }
|
|
1248
|
+
};
|
|
1249
|
+
const aggregations = await this.orderModel.aggregate([
|
|
1250
|
+
{ $match: matchConditions },
|
|
1251
|
+
{
|
|
1252
|
+
$project: {
|
|
1253
|
+
typeOf: '$typeOf'
|
|
1278
1254
|
}
|
|
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
|
-
}
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
$group: {
|
|
1258
|
+
_id: '$typeOf',
|
|
1259
|
+
orderCount: { $sum: 1 }
|
|
1308
1260
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
$project: {
|
|
1264
|
+
_id: 0,
|
|
1265
|
+
orderCount: '$orderCount'
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
])
|
|
1269
|
+
.exec();
|
|
1270
|
+
if (aggregations.length === 0) {
|
|
1311
1271
|
return {
|
|
1312
|
-
aggregation:
|
|
1272
|
+
aggregation: {
|
|
1273
|
+
orderCount: 0,
|
|
1274
|
+
aggregateProject: { projectCount: 0 }
|
|
1275
|
+
}
|
|
1313
1276
|
};
|
|
1314
|
-
}
|
|
1277
|
+
}
|
|
1278
|
+
const aggregations2 = await this.orderModel.aggregate([
|
|
1279
|
+
{ $match: matchConditions },
|
|
1280
|
+
{
|
|
1281
|
+
$project: {
|
|
1282
|
+
project: '$project'
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
$group: {
|
|
1287
|
+
_id: '$project.id'
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
$count: 'projectCount'
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
$project: {
|
|
1295
|
+
aggregateProject: { projectCount: '$projectCount' }
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
])
|
|
1299
|
+
.exec();
|
|
1300
|
+
return {
|
|
1301
|
+
aggregation: {
|
|
1302
|
+
...aggregations[0],
|
|
1303
|
+
...aggregations2[0]
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1315
1306
|
}
|
|
1316
1307
|
}
|
|
1317
1308
|
exports.OrderRepo = OrderRepo;
|