@chevre/domain 21.2.0-alpha.1 → 21.2.0-alpha.100
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/example/src/chevre/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
- package/example/src/chevre/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/lockStockHolder.ts +48 -0
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processReserve.ts +6 -3
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchActions.ts +33 -0
- package/example/src/chevre/searchEventSeats.ts +42 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/example/src/playOnMoment.ts +24 -0
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +0 -4
- package/lib/chevre/repo/accountTitle.js +0 -4
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +1 -58
- package/lib/chevre/repo/accountingReport.js +0 -4
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +98 -59
- package/lib/chevre/repo/additionalProperty.js +0 -4
- package/lib/chevre/repo/aggregation.js +0 -4
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +261 -89
- package/lib/chevre/repo/categoryCode.js +0 -4
- package/lib/chevre/repo/code.js +0 -4
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -9
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +0 -4
- package/lib/chevre/repo/customer.js +0 -4
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +0 -4
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +0 -4
- package/lib/chevre/repo/member.js +0 -4
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +20 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +33 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +64 -5
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offer.js +0 -5
- package/lib/chevre/repo/offerCatalog.js +0 -4
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +120 -0
- package/lib/chevre/repo/order.d.ts +55 -3
- package/lib/chevre/repo/order.js +56 -9
- package/lib/chevre/repo/orderNumber.d.ts +0 -1
- package/lib/chevre/repo/orderNumber.js +2 -12
- package/lib/chevre/repo/ownershipInfo.js +0 -4
- package/lib/chevre/repo/permit.js +0 -4
- package/lib/chevre/repo/place.d.ts +5 -1
- package/lib/chevre/repo/place.js +1 -10
- package/lib/chevre/repo/priceSpecification.js +0 -4
- package/lib/chevre/repo/product.js +0 -4
- package/lib/chevre/repo/project.js +0 -4
- package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
- package/lib/chevre/repo/rateLimit/offer.js +14 -14
- package/lib/chevre/repo/reservation.d.ts +12 -4
- package/lib/chevre/repo/reservation.js +16 -48
- package/lib/chevre/repo/role.js +0 -4
- package/lib/chevre/repo/seller.js +19 -23
- package/lib/chevre/repo/serviceOutput.js +0 -4
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
- package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -8
- package/lib/chevre/repo/stockHolder.js +273 -0
- package/lib/chevre/repo/task.d.ts +45 -2
- package/lib/chevre/repo/task.js +101 -12
- package/lib/chevre/repo/telemetry.js +0 -4
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +174 -58
- package/lib/chevre/repo/transactionNumber.d.ts +2 -1
- package/lib/chevre/repo/transactionNumber.js +14 -15
- package/lib/chevre/repo/trip.js +0 -4
- package/lib/chevre/repository.d.ts +8 -7
- package/lib/chevre/repository.js +12 -11
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
- package/lib/chevre/service/assetTransaction/pay.js +18 -32
- package/lib/chevre/service/assetTransaction/refund.js +1 -23
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
- package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
- package/lib/chevre/service/assetTransaction/reserve.d.ts +14 -5
- package/lib/chevre/service/assetTransaction/reserve.js +156 -74
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/authorize.d.ts +5 -2
- package/lib/chevre/service/offer/event/authorize.js +8 -2
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
- package/lib/chevre/service/offer/event/factory.d.ts +3 -0
- package/lib/chevre/service/offer/event/factory.js +16 -5
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +4 -2
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer.d.ts +13 -26
- package/lib/chevre/service/offer.js +22 -117
- package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -0
- package/lib/chevre/service/order/placeOrder.js +41 -24
- package/lib/chevre/service/order/returnOrder.d.ts +1 -0
- package/lib/chevre/service/order/returnOrder.js +7 -12
- package/lib/chevre/service/order/sendOrder.d.ts +1 -0
- package/lib/chevre/service/order/sendOrder.js +7 -10
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +9 -5
- package/lib/chevre/service/payment/any.js +80 -18
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +21 -15
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +7 -6
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +54 -31
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +5 -4
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.d.ts +8 -6
- package/lib/chevre/service/reserve/cancelReservation.js +153 -145
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
- package/lib/chevre/service/reserve/checkInReservation.js +77 -3
- package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
- package/lib/chevre/service/reserve/confirmReservation.js +125 -58
- package/lib/chevre/service/reserve/factory.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/useReservation.js +61 -71
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
- package/lib/chevre/service/reserve.d.ts +3 -2
- package/lib/chevre/service/reserve.js +4 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +8 -4
- package/lib/chevre/service/task/cancelReservation.js +3 -3
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
- package/lib/chevre/service/task/placeOrder.js +1 -1
- package/lib/chevre/service/task/reserve.js +10 -7
- package/lib/chevre/service/task/returnOrder.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/sendOrder.js +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/useReservation.js +36 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +6 -4
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
- package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder.js +225 -35
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +16 -6
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -181
- package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
- package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
- package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
- package/lib/chevre/service/task/deleteOrder.js +0 -35
|
@@ -12,17 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
16
15
|
const transaction_1 = require("./mongoose/schemas/transaction");
|
|
16
|
+
const transaction_2 = require("../eventEmitter/transaction");
|
|
17
17
|
/**
|
|
18
18
|
* 取引リポジトリ
|
|
19
19
|
*/
|
|
20
20
|
class MongoRepository {
|
|
21
21
|
constructor(connection) {
|
|
22
22
|
this.transactionModel = connection.model(transaction_1.modelName, transaction_1.schema);
|
|
23
|
-
if (connection.get('autoIndex') === true) {
|
|
24
|
-
this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
25
|
-
}
|
|
26
23
|
}
|
|
27
24
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
28
25
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
@@ -267,7 +264,9 @@ class MongoRepository {
|
|
|
267
264
|
else {
|
|
268
265
|
expires = params.expires;
|
|
269
266
|
}
|
|
270
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires,
|
|
267
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportAction: {
|
|
268
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
269
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
271
270
|
.then((doc) => doc.toObject());
|
|
272
271
|
});
|
|
273
272
|
}
|
|
@@ -276,10 +275,29 @@ class MongoRepository {
|
|
|
276
275
|
*/
|
|
277
276
|
findById(params) {
|
|
278
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
let projection = {};
|
|
279
|
+
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
280
|
+
params.inclusion.forEach((field) => {
|
|
281
|
+
projection[field] = 1;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
projection = {
|
|
286
|
+
__v: 0,
|
|
287
|
+
createdAt: 0,
|
|
288
|
+
updatedAt: 0
|
|
289
|
+
};
|
|
290
|
+
if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
|
|
291
|
+
params.exclusion.forEach((field) => {
|
|
292
|
+
projection[field] = 0;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
279
296
|
const doc = yield this.transactionModel.findOne({
|
|
280
297
|
_id: { $eq: params.id },
|
|
281
298
|
typeOf: { $eq: params.typeOf }
|
|
282
299
|
})
|
|
300
|
+
.select(projection)
|
|
283
301
|
.exec();
|
|
284
302
|
if (doc === null) {
|
|
285
303
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -295,7 +313,9 @@ class MongoRepository {
|
|
|
295
313
|
const doc = yield this.transactionModel.findOne({
|
|
296
314
|
_id: { $eq: params.id },
|
|
297
315
|
typeOf: { $eq: params.typeOf },
|
|
298
|
-
status: { $eq: factory.transactionStatusType.InProgress }
|
|
316
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
317
|
+
// expiresを条件に追加(2023-05-12~),
|
|
318
|
+
expires: { $gt: new Date() }
|
|
299
319
|
})
|
|
300
320
|
.exec();
|
|
301
321
|
if (doc === null) {
|
|
@@ -347,9 +367,9 @@ class MongoRepository {
|
|
|
347
367
|
var _a, _b;
|
|
348
368
|
return __awaiter(this, void 0, void 0, function* () {
|
|
349
369
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
350
|
-
_id: params.id,
|
|
351
|
-
typeOf: params.typeOf,
|
|
352
|
-
status: factory.transactionStatusType.InProgress
|
|
370
|
+
_id: { $eq: params.id },
|
|
371
|
+
typeOf: { $eq: params.typeOf },
|
|
372
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
353
373
|
}, {
|
|
354
374
|
$set: Object.assign(Object.assign({ 'agent.id': params.agent.id }, (typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined), (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { 'object.customer': params.object.customer } : undefined)
|
|
355
375
|
}, {
|
|
@@ -367,9 +387,9 @@ class MongoRepository {
|
|
|
367
387
|
updateExpires(params) {
|
|
368
388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
369
389
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
370
|
-
_id: params.id,
|
|
371
|
-
typeOf: params.typeOf,
|
|
372
|
-
status: factory.transactionStatusType.InProgress
|
|
390
|
+
_id: { $eq: params.id },
|
|
391
|
+
typeOf: { $eq: params.typeOf },
|
|
392
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
373
393
|
}, {
|
|
374
394
|
$set: {
|
|
375
395
|
expires: params.expires
|
|
@@ -391,9 +411,9 @@ class MongoRepository {
|
|
|
391
411
|
var _a;
|
|
392
412
|
return __awaiter(this, void 0, void 0, function* () {
|
|
393
413
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
394
|
-
_id: params.id,
|
|
395
|
-
typeOf: params.typeOf,
|
|
396
|
-
status: factory.transactionStatusType.InProgress
|
|
414
|
+
_id: { $eq: params.id },
|
|
415
|
+
typeOf: { $eq: params.typeOf },
|
|
416
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
397
417
|
}, {
|
|
398
418
|
$set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
|
|
399
419
|
}, {
|
|
@@ -411,9 +431,9 @@ class MongoRepository {
|
|
|
411
431
|
confirm(params) {
|
|
412
432
|
return __awaiter(this, void 0, void 0, function* () {
|
|
413
433
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
414
|
-
_id: params.id,
|
|
415
|
-
typeOf: params.typeOf,
|
|
416
|
-
status: factory.transactionStatusType.InProgress
|
|
434
|
+
_id: { $eq: params.id },
|
|
435
|
+
typeOf: { $eq: params.typeOf },
|
|
436
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
417
437
|
}, {
|
|
418
438
|
status: factory.transactionStatusType.Confirmed,
|
|
419
439
|
endDate: new Date(),
|
|
@@ -428,43 +448,49 @@ class MongoRepository {
|
|
|
428
448
|
// NotFoundであれば取引状態確認
|
|
429
449
|
if (doc === null) {
|
|
430
450
|
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
431
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
432
|
-
/* istanbul ignore next */
|
|
433
451
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
434
|
-
//
|
|
435
|
-
return;
|
|
436
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
437
|
-
/* istanbul ignore next */
|
|
452
|
+
// すでに確定済の場合スルー
|
|
438
453
|
}
|
|
439
454
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
440
455
|
throw new factory.errors.Argument('Transaction id', 'Already expired');
|
|
441
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
442
|
-
/* istanbul ignore next */
|
|
443
456
|
}
|
|
444
457
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
445
458
|
throw new factory.errors.Argument('Transaction id', 'Already canceled');
|
|
446
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
447
|
-
/* istanbul ignore next */
|
|
448
459
|
}
|
|
449
460
|
else {
|
|
450
461
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
451
462
|
}
|
|
452
463
|
}
|
|
453
|
-
|
|
464
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
465
|
+
id: params.id,
|
|
466
|
+
typeOf: params.typeOf,
|
|
467
|
+
status: factory.transactionStatusType.Confirmed
|
|
468
|
+
});
|
|
454
469
|
});
|
|
455
470
|
}
|
|
456
471
|
/**
|
|
457
472
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
458
473
|
*/
|
|
459
474
|
startExportTasks(params) {
|
|
475
|
+
var _a;
|
|
460
476
|
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
477
|
+
switch (params.status) {
|
|
478
|
+
case factory.transactionStatusType.InProgress:
|
|
479
|
+
throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
|
|
480
|
+
default:
|
|
481
|
+
// no op
|
|
482
|
+
}
|
|
483
|
+
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
484
|
+
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.project !== undefined) ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
485
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
486
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
487
|
+
'tasksExportAction.startDate': new Date(),
|
|
488
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
489
|
+
}, { new: true })
|
|
490
|
+
.select({
|
|
491
|
+
_id: 1,
|
|
492
|
+
typeOf: 1
|
|
493
|
+
})
|
|
468
494
|
.exec()
|
|
469
495
|
// tslint:disable-next-line:no-null-keyword
|
|
470
496
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -477,17 +503,74 @@ class MongoRepository {
|
|
|
477
503
|
*/
|
|
478
504
|
reexportTasks(params) {
|
|
479
505
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
-
yield this.transactionModel.
|
|
481
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
506
|
+
const reexportingTransactions = yield this.transactionModel.find({
|
|
507
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
482
508
|
updatedAt: {
|
|
483
509
|
$lt: moment()
|
|
484
510
|
.add(-params.intervalInMinutes, 'minutes')
|
|
485
511
|
.toDate()
|
|
486
512
|
}
|
|
487
|
-
}, {
|
|
488
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
489
513
|
})
|
|
514
|
+
.select({
|
|
515
|
+
_id: 1,
|
|
516
|
+
typeOf: 1,
|
|
517
|
+
status: 1
|
|
518
|
+
})
|
|
519
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
520
|
+
.exec();
|
|
521
|
+
if (reexportingTransactions.length > 0) {
|
|
522
|
+
for (const reexportingTransaction of reexportingTransactions) {
|
|
523
|
+
yield this.transactionModel.updateOne({
|
|
524
|
+
_id: { $eq: reexportingTransaction.id },
|
|
525
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
526
|
+
}, {
|
|
527
|
+
tasksExportAction: {
|
|
528
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
529
|
+
},
|
|
530
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
531
|
+
})
|
|
532
|
+
.exec();
|
|
533
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
534
|
+
id: reexportingTransaction.id,
|
|
535
|
+
typeOf: reexportingTransaction.typeOf,
|
|
536
|
+
status: reexportingTransaction.status
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
544
|
+
*/
|
|
545
|
+
exportTasks(params) {
|
|
546
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
547
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
548
|
+
status: { $in: params.status.$in },
|
|
549
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
550
|
+
endDate: {
|
|
551
|
+
$exists: true,
|
|
552
|
+
$lt: moment(params.now)
|
|
553
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
554
|
+
.toDate()
|
|
555
|
+
}
|
|
556
|
+
})
|
|
557
|
+
.select({
|
|
558
|
+
_id: 1,
|
|
559
|
+
typeOf: 1,
|
|
560
|
+
status: 1
|
|
561
|
+
})
|
|
562
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
490
563
|
.exec();
|
|
564
|
+
if (delayedTransactions.length > 0) {
|
|
565
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
566
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
567
|
+
id: delayedTransaction.id,
|
|
568
|
+
typeOf: delayedTransaction.typeOf,
|
|
569
|
+
status: delayedTransaction.status
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return delayedTransactions;
|
|
491
574
|
});
|
|
492
575
|
}
|
|
493
576
|
/**
|
|
@@ -496,9 +579,15 @@ class MongoRepository {
|
|
|
496
579
|
*/
|
|
497
580
|
setTasksExportedById(params) {
|
|
498
581
|
return __awaiter(this, void 0, void 0, function* () {
|
|
499
|
-
|
|
582
|
+
const endDate = new Date();
|
|
583
|
+
yield this.transactionModel.updateOne({
|
|
584
|
+
_id: { $eq: params.id },
|
|
585
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
586
|
+
}, {
|
|
500
587
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
501
|
-
tasksExportedAt:
|
|
588
|
+
tasksExportedAt: endDate,
|
|
589
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
590
|
+
'tasksExportAction.endDate': endDate
|
|
502
591
|
})
|
|
503
592
|
.exec();
|
|
504
593
|
});
|
|
@@ -508,15 +597,36 @@ class MongoRepository {
|
|
|
508
597
|
*/
|
|
509
598
|
makeExpired(params) {
|
|
510
599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
511
|
-
//
|
|
512
|
-
yield this.transactionModel.
|
|
513
|
-
status: factory.transactionStatusType.InProgress,
|
|
514
|
-
expires: { $lt: params.expires }
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
600
|
+
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
601
|
+
const expiringTransactions = yield this.transactionModel.find({
|
|
602
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
603
|
+
expires: { $lt: params.expires.$lt }
|
|
604
|
+
})
|
|
605
|
+
.select({
|
|
606
|
+
_id: 1,
|
|
607
|
+
typeOf: 1
|
|
518
608
|
})
|
|
609
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
519
610
|
.exec();
|
|
611
|
+
if (expiringTransactions.length > 0) {
|
|
612
|
+
// ステータスと期限を見て更新
|
|
613
|
+
yield this.transactionModel.updateMany({
|
|
614
|
+
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
615
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
616
|
+
expires: { $lt: params.expires.$lt }
|
|
617
|
+
}, {
|
|
618
|
+
status: factory.transactionStatusType.Expired,
|
|
619
|
+
endDate: new Date()
|
|
620
|
+
})
|
|
621
|
+
.exec();
|
|
622
|
+
expiringTransactions.forEach((expiringTransaction) => {
|
|
623
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
624
|
+
id: expiringTransaction.id,
|
|
625
|
+
typeOf: expiringTransaction.typeOf,
|
|
626
|
+
status: factory.transactionStatusType.Expired
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
}
|
|
520
630
|
});
|
|
521
631
|
}
|
|
522
632
|
/**
|
|
@@ -541,11 +651,8 @@ class MongoRepository {
|
|
|
541
651
|
// NotFoundであれば取引状態確認
|
|
542
652
|
if (doc === null) {
|
|
543
653
|
const transaction = yield this.findById(params);
|
|
544
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
545
|
-
/* istanbul ignore next */
|
|
546
654
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
547
|
-
//
|
|
548
|
-
return;
|
|
655
|
+
// すでに中止済の場合スルー
|
|
549
656
|
}
|
|
550
657
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
551
658
|
throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
|
|
@@ -557,7 +664,11 @@ class MongoRepository {
|
|
|
557
664
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
558
665
|
}
|
|
559
666
|
}
|
|
560
|
-
|
|
667
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
668
|
+
id: params.id,
|
|
669
|
+
typeOf: params.typeOf,
|
|
670
|
+
status: factory.transactionStatusType.Canceled
|
|
671
|
+
});
|
|
561
672
|
});
|
|
562
673
|
}
|
|
563
674
|
count(params) {
|
|
@@ -615,9 +726,12 @@ class MongoRepository {
|
|
|
615
726
|
/**
|
|
616
727
|
* 特定の取引を更新する(汎用)
|
|
617
728
|
*/
|
|
618
|
-
|
|
729
|
+
findByIdAndUpdateInProgress(params) {
|
|
619
730
|
return __awaiter(this, void 0, void 0, function* () {
|
|
620
|
-
yield this.transactionModel.findOneAndUpdate({
|
|
731
|
+
yield this.transactionModel.findOneAndUpdate({
|
|
732
|
+
_id: { $eq: params.id },
|
|
733
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
734
|
+
}, params.update, {
|
|
621
735
|
// new: true,
|
|
622
736
|
projection: { _id: 1 }
|
|
623
737
|
})
|
|
@@ -632,7 +746,8 @@ class MongoRepository {
|
|
|
632
746
|
saveOrderNumberIfNotExist(params) {
|
|
633
747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
634
748
|
yield this.transactionModel.updateOne({
|
|
635
|
-
_id: params.id,
|
|
749
|
+
_id: { $eq: params.id },
|
|
750
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
636
751
|
'object.orderNumber': { $exists: false }
|
|
637
752
|
}, { 'object.orderNumber': params.orderNumber })
|
|
638
753
|
.exec();
|
|
@@ -641,7 +756,8 @@ class MongoRepository {
|
|
|
641
756
|
saveConfirmationNumberIfNotExist(params) {
|
|
642
757
|
return __awaiter(this, void 0, void 0, function* () {
|
|
643
758
|
yield this.transactionModel.updateOne({
|
|
644
|
-
_id: params.id,
|
|
759
|
+
_id: { $eq: params.id },
|
|
760
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
645
761
|
'object.confirmationNumber': { $exists: false }
|
|
646
762
|
}, { 'object.confirmationNumber': params.confirmationNumber })
|
|
647
763
|
.exec();
|
|
@@ -6,9 +6,10 @@ interface IPublishResult {
|
|
|
6
6
|
* 取引番号リポジトリ
|
|
7
7
|
*/
|
|
8
8
|
export declare class RedisRepository {
|
|
9
|
-
static REDIS_KEY_PREFIX
|
|
9
|
+
private static readonly REDIS_KEY_PREFIX;
|
|
10
10
|
private readonly redisClient;
|
|
11
11
|
constructor(redisClient: RedisClientType);
|
|
12
|
+
private static createKey;
|
|
12
13
|
/**
|
|
13
14
|
* タイムスタンプから発行する
|
|
14
15
|
*/
|
|
@@ -23,6 +23,9 @@ class RedisRepository {
|
|
|
23
23
|
constructor(redisClient) {
|
|
24
24
|
this.redisClient = redisClient;
|
|
25
25
|
}
|
|
26
|
+
static createKey(params) {
|
|
27
|
+
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, params.timestamp);
|
|
28
|
+
}
|
|
26
29
|
/**
|
|
27
30
|
* タイムスタンプから発行する
|
|
28
31
|
*/
|
|
@@ -35,30 +38,26 @@ class RedisRepository {
|
|
|
35
38
|
const TTL = moment(params.startDate)
|
|
36
39
|
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
37
40
|
.diff(now, 'seconds');
|
|
38
|
-
const key =
|
|
41
|
+
const key = RedisRepository.createKey({ startDate: params.startDate, timestamp });
|
|
39
42
|
const [incrReply] = yield this.redisClient.multi()
|
|
40
43
|
.incr(key)
|
|
41
44
|
.expire(key, TTL)
|
|
42
45
|
.exec();
|
|
43
46
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
44
47
|
/* istanbul ignore else: please write tests */
|
|
45
|
-
if (typeof incrReply
|
|
46
|
-
let transactionNumber = timestamp;
|
|
47
|
-
const no = incrReply;
|
|
48
|
-
transactionNumber = `${transactionNumber}${no}`;
|
|
49
|
-
// checkdigit
|
|
50
|
-
const cd = cdigit.luhn.compute(transactionNumber);
|
|
51
|
-
const cipher = fpe({ password: cd });
|
|
52
|
-
transactionNumber = cipher.encrypt(transactionNumber);
|
|
53
|
-
transactionNumber = `${cd}${transactionNumber}`;
|
|
54
|
-
return { transactionNumber };
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
48
|
+
if (typeof incrReply !== 'number') {
|
|
57
49
|
// 基本的にありえないフロー
|
|
58
|
-
throw new factory.errors.ServiceUnavailable('
|
|
50
|
+
throw new factory.errors.ServiceUnavailable('transaction number not incremented unexpectedly');
|
|
59
51
|
}
|
|
52
|
+
let transactionNumber = `${timestamp}${incrReply}`;
|
|
53
|
+
// checkdigit
|
|
54
|
+
const cd = cdigit.luhn.compute(transactionNumber);
|
|
55
|
+
transactionNumber = fpe({ password: cd })
|
|
56
|
+
.encrypt(transactionNumber);
|
|
57
|
+
transactionNumber = `${cd}${transactionNumber}`;
|
|
58
|
+
return { transactionNumber };
|
|
60
59
|
});
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
|
-
RedisRepository.REDIS_KEY_PREFIX = '
|
|
62
|
+
RedisRepository.REDIS_KEY_PREFIX = 'transactionNumber';
|
|
64
63
|
exports.RedisRepository = RedisRepository;
|
package/lib/chevre/repo/trip.js
CHANGED
|
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
24
|
const factory = require("../factory");
|
|
25
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
26
25
|
const trip_1 = require("./mongoose/schemas/trip");
|
|
27
26
|
/**
|
|
28
27
|
* トリップリポジトリ
|
|
@@ -30,9 +29,6 @@ const trip_1 = require("./mongoose/schemas/trip");
|
|
|
30
29
|
class MongoRepository {
|
|
31
30
|
constructor(connection) {
|
|
32
31
|
this.tripModel = connection.model(trip_1.modelName, trip_1.schema);
|
|
33
|
-
if (connection.get('autoIndex') === true) {
|
|
34
|
-
this.tripModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
35
|
-
}
|
|
36
32
|
}
|
|
37
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
38
34
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
@@ -16,11 +16,11 @@ import { MongoRepository as CreativeWorkRepo } from './repo/creativeWork';
|
|
|
16
16
|
import { MongoRepository as CustomerRepo } from './repo/customer';
|
|
17
17
|
import { MongoRepository as EmailMessageRepo } from './repo/emailMessage';
|
|
18
18
|
import { MongoRepository as EventRepo } from './repo/event';
|
|
19
|
-
import { RedisRepository as ScreeningEventItemAvailabilityRepo } from './repo/itemAvailability/screeningEvent';
|
|
20
19
|
import { MongoRepository as MemberRepo } from './repo/member';
|
|
21
20
|
import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
22
21
|
import { MongoRepository as OfferRepo } from './repo/offer';
|
|
23
22
|
import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
|
|
23
|
+
import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
24
24
|
import { MongoRepository as OrderRepo } from './repo/order';
|
|
25
25
|
import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
26
26
|
import { MongoRepository as PermitRepo } from './repo/permit';
|
|
@@ -34,6 +34,7 @@ import { MongoRepository as RoleRepo } from './repo/role';
|
|
|
34
34
|
import { MongoRepository as SellerRepo } from './repo/seller';
|
|
35
35
|
import { MongoRepository as ServiceOutputRepo } from './repo/serviceOutput';
|
|
36
36
|
import { RedisRepository as ServiceOutputIdentifierRepo } from './repo/serviceOutputIdentifier';
|
|
37
|
+
import { StockHolderRepository as StockHolderRepo } from './repo/stockHolder';
|
|
37
38
|
import { MongoRepository as TaskRepo } from './repo/task';
|
|
38
39
|
import { MongoRepository as TelemetryRepo } from './repo/telemetry';
|
|
39
40
|
import { MongoRepository as TransactionRepo } from './repo/transaction';
|
|
@@ -123,10 +124,12 @@ export declare class Member extends MemberRepo {
|
|
|
123
124
|
*/
|
|
124
125
|
export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
|
|
125
126
|
}
|
|
126
|
-
export declare class Offer extends OfferRepo {
|
|
127
|
-
}
|
|
128
127
|
export declare class OfferCatalog extends OfferCatalogRepo {
|
|
129
128
|
}
|
|
129
|
+
export declare class OfferItemCondition extends OfferItemConditionRepo {
|
|
130
|
+
}
|
|
131
|
+
export declare class Offer extends OfferRepo {
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* 注文リポジトリ
|
|
132
135
|
*/
|
|
@@ -183,6 +186,8 @@ export declare class ServiceOutput extends ServiceOutputRepo {
|
|
|
183
186
|
}
|
|
184
187
|
export declare class ServiceOutputIdentifier extends ServiceOutputIdentifierRepo {
|
|
185
188
|
}
|
|
189
|
+
export declare class StockHolder extends StockHolderRepo {
|
|
190
|
+
}
|
|
186
191
|
export declare class Task extends TaskRepo {
|
|
187
192
|
}
|
|
188
193
|
export declare class Telemetry extends TelemetryRepo {
|
|
@@ -193,10 +198,6 @@ export declare class TransactionNumber extends TransactionNumberRepo {
|
|
|
193
198
|
}
|
|
194
199
|
export declare class Trip extends TripRepo {
|
|
195
200
|
}
|
|
196
|
-
export declare namespace itemAvailability {
|
|
197
|
-
class ScreeningEvent extends ScreeningEventItemAvailabilityRepo {
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
201
|
export declare namespace rateLimit {
|
|
201
202
|
class Offer extends OfferRateLimitRepo {
|
|
202
203
|
}
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.
|
|
3
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -20,11 +20,11 @@ const creativeWork_1 = require("./repo/creativeWork");
|
|
|
20
20
|
const customer_1 = require("./repo/customer");
|
|
21
21
|
const emailMessage_1 = require("./repo/emailMessage");
|
|
22
22
|
const event_1 = require("./repo/event");
|
|
23
|
-
const screeningEvent_1 = require("./repo/itemAvailability/screeningEvent");
|
|
24
23
|
const member_1 = require("./repo/member");
|
|
25
24
|
const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
|
|
26
25
|
const offer_1 = require("./repo/offer");
|
|
27
26
|
const offerCatalog_1 = require("./repo/offerCatalog");
|
|
27
|
+
const offerItemCondition_1 = require("./repo/offerItemCondition");
|
|
28
28
|
const order_1 = require("./repo/order");
|
|
29
29
|
const ownershipInfo_1 = require("./repo/ownershipInfo");
|
|
30
30
|
const permit_1 = require("./repo/permit");
|
|
@@ -38,6 +38,7 @@ const role_1 = require("./repo/role");
|
|
|
38
38
|
const seller_1 = require("./repo/seller");
|
|
39
39
|
const serviceOutput_1 = require("./repo/serviceOutput");
|
|
40
40
|
const serviceOutputIdentifier_1 = require("./repo/serviceOutputIdentifier");
|
|
41
|
+
const stockHolder_1 = require("./repo/stockHolder");
|
|
41
42
|
const task_1 = require("./repo/task");
|
|
42
43
|
const telemetry_1 = require("./repo/telemetry");
|
|
43
44
|
const transaction_1 = require("./repo/transaction");
|
|
@@ -147,12 +148,15 @@ exports.Member = Member;
|
|
|
147
148
|
class MerchantReturnPolicy extends merchantReturnPolicy_1.MongoRepository {
|
|
148
149
|
}
|
|
149
150
|
exports.MerchantReturnPolicy = MerchantReturnPolicy;
|
|
150
|
-
class Offer extends offer_1.MongoRepository {
|
|
151
|
-
}
|
|
152
|
-
exports.Offer = Offer;
|
|
153
151
|
class OfferCatalog extends offerCatalog_1.MongoRepository {
|
|
154
152
|
}
|
|
155
153
|
exports.OfferCatalog = OfferCatalog;
|
|
154
|
+
class OfferItemCondition extends offerItemCondition_1.MongoRepository {
|
|
155
|
+
}
|
|
156
|
+
exports.OfferItemCondition = OfferItemCondition;
|
|
157
|
+
class Offer extends offer_1.MongoRepository {
|
|
158
|
+
}
|
|
159
|
+
exports.Offer = Offer;
|
|
156
160
|
/**
|
|
157
161
|
* 注文リポジトリ
|
|
158
162
|
*/
|
|
@@ -225,6 +229,9 @@ exports.ServiceOutput = ServiceOutput;
|
|
|
225
229
|
class ServiceOutputIdentifier extends serviceOutputIdentifier_1.RedisRepository {
|
|
226
230
|
}
|
|
227
231
|
exports.ServiceOutputIdentifier = ServiceOutputIdentifier;
|
|
232
|
+
class StockHolder extends stockHolder_1.StockHolderRepository {
|
|
233
|
+
}
|
|
234
|
+
exports.StockHolder = StockHolder;
|
|
228
235
|
class Task extends task_1.MongoRepository {
|
|
229
236
|
}
|
|
230
237
|
exports.Task = Task;
|
|
@@ -240,12 +247,6 @@ exports.TransactionNumber = TransactionNumber;
|
|
|
240
247
|
class Trip extends trip_1.MongoRepository {
|
|
241
248
|
}
|
|
242
249
|
exports.Trip = Trip;
|
|
243
|
-
var itemAvailability;
|
|
244
|
-
(function (itemAvailability) {
|
|
245
|
-
class ScreeningEvent extends screeningEvent_1.RedisRepository {
|
|
246
|
-
}
|
|
247
|
-
itemAvailability.ScreeningEvent = ScreeningEvent;
|
|
248
|
-
})(itemAvailability = exports.itemAvailability || (exports.itemAvailability = {}));
|
|
249
250
|
var rateLimit;
|
|
250
251
|
(function (rateLimit) {
|
|
251
252
|
// tslint:disable-next-line:no-shadowed-variable
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
|
-
import { RedisRepository as EventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
3
2
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
3
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
5
4
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
@@ -7,11 +6,12 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
|
7
6
|
import { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
8
7
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
9
8
|
import { MongoRepository as ReservationRepo } from '../../../repo/reservation';
|
|
9
|
+
import { StockHolderRepository as StockHolderRepo } from '../../../repo/stockHolder';
|
|
10
10
|
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
11
11
|
import * as factory from '../../../factory';
|
|
12
12
|
export type IAggregateScreeningEventOperation<T> = (repos: {
|
|
13
13
|
event: EventRepo;
|
|
14
|
-
|
|
14
|
+
stockHolder: StockHolderRepo;
|
|
15
15
|
offer: OfferRepo;
|
|
16
16
|
offerCatalog: OfferCatalogRepo;
|
|
17
17
|
offerRateLimit: OfferRateLimitRepo;
|
|
@@ -387,13 +387,14 @@ function filterByEligibleSeatingType(params) {
|
|
|
387
387
|
const maximumAttendeeCapacity = eligibleSeatOffers.length;
|
|
388
388
|
let remainingAttendeeCapacity;
|
|
389
389
|
if (maximumAttendeeCapacity > 0) {
|
|
390
|
-
const availabilities = yield repos.
|
|
390
|
+
const availabilities = yield repos.stockHolder.searchHolders({
|
|
391
391
|
eventId: params.event.id,
|
|
392
392
|
startDate: moment(params.event.startDate)
|
|
393
393
|
.toDate(),
|
|
394
394
|
offers: eligibleSeatOffers
|
|
395
395
|
});
|
|
396
|
-
remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
396
|
+
// remainingAttendeeCapacity = availabilities.filter((a) => a.availability === factory.itemAvailability.InStock).length;
|
|
397
|
+
remainingAttendeeCapacity = availabilities.filter((holder) => typeof holder !== 'string').length;
|
|
397
398
|
}
|
|
398
399
|
else {
|
|
399
400
|
remainingAttendeeCapacity = 0;
|
|
@@ -438,7 +439,7 @@ function aggregateReservationByEvent(params) {
|
|
|
438
439
|
// remainingAttendeeCapacityを決定
|
|
439
440
|
if (typeof maximumAttendeeCapacity === 'number') {
|
|
440
441
|
// 残席数を座席ロック数から計算
|
|
441
|
-
const unavailableOfferCount = yield repos.
|
|
442
|
+
const unavailableOfferCount = yield repos.stockHolder.countUnavailableOffers({
|
|
442
443
|
event: {
|
|
443
444
|
id: params.event.id,
|
|
444
445
|
startDate: moment(params.event.startDate)
|