@chevre/domain 21.2.0-alpha.11 → 21.2.0-alpha.111
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/aggregation/aggregateSystem.ts +85 -27
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- package/example/src/chevre/processReserve.ts +4 -1
- 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/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 +3 -2
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +3 -55
- package/lib/chevre/repo/action.d.ts +42 -2
- package/lib/chevre/repo/action.js +130 -57
- package/lib/chevre/repo/additionalProperty.js +2 -1
- package/lib/chevre/repo/aggregation.d.ts +3 -0
- package/lib/chevre/repo/aggregation.js +3 -0
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +259 -87
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +37 -25
- package/lib/chevre/repo/code.js +3 -2
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +22 -6
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +2 -4
- package/lib/chevre/repo/creativeWork.js +35 -12
- package/lib/chevre/repo/customer.js +2 -1
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +2 -1
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +4 -3
- package/lib/chevre/repo/member.js +4 -3
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
- 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 +51 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
- package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
- package/lib/chevre/repo/offer.js +3 -2
- package/lib/chevre/repo/offerCatalog.js +0 -27
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +121 -0
- package/lib/chevre/repo/order.d.ts +55 -3
- package/lib/chevre/repo/order.js +62 -10
- package/lib/chevre/repo/ownershipInfo.js +2 -7
- package/lib/chevre/repo/place.js +3 -2
- package/lib/chevre/repo/priceSpecification.js +3 -2
- package/lib/chevre/repo/product.d.ts +1 -3
- package/lib/chevre/repo/product.js +25 -4
- package/lib/chevre/repo/project.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +20 -4
- package/lib/chevre/repo/reservation.js +40 -59
- package/lib/chevre/repo/role.js +3 -2
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +44 -23
- package/lib/chevre/repo/serviceOutput.js +2 -1
- package/lib/chevre/repo/task.d.ts +42 -2
- package/lib/chevre/repo/task.js +93 -11
- package/lib/chevre/repo/transaction.d.ts +23 -4
- package/lib/chevre/repo/transaction.js +179 -60
- package/lib/chevre/repo/trip.js +2 -1
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +110 -23
- package/lib/chevre/service/aggregation/system.js +213 -91
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -24
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
- 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 +20 -34
- package/lib/chevre/service/assetTransaction/refund.js +2 -24
- 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 +10 -1
- package/lib/chevre/service/assetTransaction/reserve.js +85 -69
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +16 -5
- 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 +3 -0
- package/lib/chevre/service/offer/event/authorize.js +8 -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/importFromCOA.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/offer.d.ts +16 -8
- package/lib/chevre/service/offer.js +69 -8
- 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 +23 -17
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +8 -7
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +55 -32
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +7 -6
- 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 +5 -3
- package/lib/chevre/service/reserve/cancelReservation.js +147 -139
- 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 +133 -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/cancelPendingReservation.js +5 -1
- 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/onEventChanged.d.ts +7 -0
- package/lib/chevre/service/task/{deleteOrder.js → onEventChanged.js} +8 -14
- package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
- package/lib/chevre/service/task/onResourceUpdated.js +199 -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 +3 -1
- 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.d.ts +1 -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 +10 -13
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +7 -3
- 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 +28 -15
- 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 +228 -36
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +11 -1
- package/lib/chevre/settings.js +50 -6
- package/package.json +5 -5
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -205
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- 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
|
@@ -13,6 +13,8 @@ exports.MongoRepository = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
|
|
15
15
|
const factory = require("../factory");
|
|
16
|
+
const assetTransaction_2 = require("../eventEmitter/assetTransaction");
|
|
17
|
+
const settings_1 = require("../settings");
|
|
16
18
|
/**
|
|
17
19
|
* 資産取引リポジトリ
|
|
18
20
|
*/
|
|
@@ -22,7 +24,7 @@ class MongoRepository {
|
|
|
22
24
|
}
|
|
23
25
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
26
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
-
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;
|
|
27
|
+
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;
|
|
26
28
|
const andConditions = [
|
|
27
29
|
{
|
|
28
30
|
typeOf: params.typeOf
|
|
@@ -132,15 +134,18 @@ class MongoRepository {
|
|
|
132
134
|
const objectPaymentMethodIdEq4refund = (_j = (_h = params.object) === null || _h === void 0 ? void 0 : _h.paymentMethodId) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
133
135
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
134
136
|
andConditions.push({
|
|
135
|
-
'object.paymentMethodId': {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const objectPaymentMethodIdIn4refund = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$in;
|
|
141
|
+
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
142
|
+
andConditions.push({
|
|
143
|
+
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
139
144
|
});
|
|
140
145
|
}
|
|
141
146
|
break;
|
|
142
147
|
case factory.assetTransactionType.MoneyTransfer:
|
|
143
|
-
const fromLocationIdentifierEq = (
|
|
148
|
+
const fromLocationIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.fromLocation) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
144
149
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
145
150
|
andConditions.push({
|
|
146
151
|
'object.fromLocation.identifier': {
|
|
@@ -149,7 +154,7 @@ class MongoRepository {
|
|
|
149
154
|
}
|
|
150
155
|
});
|
|
151
156
|
}
|
|
152
|
-
const toLocationIdentifierEq = (
|
|
157
|
+
const toLocationIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.toLocation) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
153
158
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
154
159
|
andConditions.push({
|
|
155
160
|
'object.toLocation.identifier': {
|
|
@@ -158,7 +163,7 @@ class MongoRepository {
|
|
|
158
163
|
}
|
|
159
164
|
});
|
|
160
165
|
}
|
|
161
|
-
const pendingTransactionIdentifierEq = (
|
|
166
|
+
const pendingTransactionIdentifierEq = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.pendingTransaction) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
162
167
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
163
168
|
andConditions.push({
|
|
164
169
|
'object.pendingTransaction.identifier': {
|
|
@@ -171,7 +176,25 @@ class MongoRepository {
|
|
|
171
176
|
case factory.assetTransactionType.CancelReservation:
|
|
172
177
|
break;
|
|
173
178
|
case factory.assetTransactionType.Reserve:
|
|
174
|
-
const
|
|
179
|
+
const objectReservationForIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationFor) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
|
|
180
|
+
if (typeof objectReservationForIdEq === 'string') {
|
|
181
|
+
andConditions.push({
|
|
182
|
+
'object.reservationFor.id': {
|
|
183
|
+
$exists: true,
|
|
184
|
+
$eq: objectReservationForIdEq
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const objectReservationNumberIn = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationNumber) === null || _0 === void 0 ? void 0 : _0.$in;
|
|
189
|
+
if (Array.isArray(objectReservationNumberIn)) {
|
|
190
|
+
andConditions.push({
|
|
191
|
+
'object.reservationNumber': {
|
|
192
|
+
$exists: true,
|
|
193
|
+
$in: objectReservationNumberIn
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const objectReservationNumberEq = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.reservationNumber) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
175
198
|
if (typeof objectReservationNumberEq === 'string') {
|
|
176
199
|
andConditions.push({
|
|
177
200
|
'object.reservationNumber': {
|
|
@@ -180,19 +203,17 @@ class MongoRepository {
|
|
|
180
203
|
}
|
|
181
204
|
});
|
|
182
205
|
}
|
|
206
|
+
const objectSubReservationIdIn = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservations) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$in;
|
|
207
|
+
if (Array.isArray(objectSubReservationIdIn)) {
|
|
208
|
+
andConditions.push({
|
|
209
|
+
'object.subReservation.id': {
|
|
210
|
+
$exists: true,
|
|
211
|
+
$in: objectSubReservationIdIn
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
183
215
|
if (params.object !== undefined) {
|
|
184
216
|
if (params.object.reservations !== undefined) {
|
|
185
|
-
if (params.object.reservations.id !== undefined) {
|
|
186
|
-
if (Array.isArray(params.object.reservations.id.$in)) {
|
|
187
|
-
andConditions.push({
|
|
188
|
-
// 'object.reservations.id': {
|
|
189
|
-
'object.subReservation.id': {
|
|
190
|
-
$exists: true,
|
|
191
|
-
$in: params.object.reservations.id.$in
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
217
|
if (params.object.reservations.reservationNumber !== undefined) {
|
|
197
218
|
if (Array.isArray(params.object.reservations.reservationNumber.$in)) {
|
|
198
219
|
andConditions.push({
|
|
@@ -217,9 +238,27 @@ class MongoRepository {
|
|
|
217
238
|
}
|
|
218
239
|
}
|
|
219
240
|
}
|
|
241
|
+
const objectUnderNameIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.underName) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$eq;
|
|
242
|
+
if (typeof objectUnderNameIdEq === 'string') {
|
|
243
|
+
andConditions.push({
|
|
244
|
+
'object.underName.id': {
|
|
245
|
+
$exists: true,
|
|
246
|
+
$eq: objectUnderNameIdEq
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const objectSubReservationSeatNumberEq = (_13 = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.reservations) === null || _10 === void 0 ? void 0 : _10.reservedTicket) === null || _11 === void 0 ? void 0 : _11.ticketedSeat) === null || _12 === void 0 ? void 0 : _12.seatNumber) === null || _13 === void 0 ? void 0 : _13.$eq;
|
|
251
|
+
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
252
|
+
andConditions.push({
|
|
253
|
+
'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
254
|
+
$exists: true,
|
|
255
|
+
$eq: objectSubReservationSeatNumberEq
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
220
259
|
break;
|
|
221
260
|
case factory.assetTransactionType.RegisterService:
|
|
222
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
261
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_17 = (_16 = (_15 = (_14 = params.object) === null || _14 === void 0 ? void 0 : _14.itemOffered) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.identifier) === null || _17 === void 0 ? void 0 : _17.$eq;
|
|
223
262
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
224
263
|
andConditions.push({
|
|
225
264
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -228,7 +267,7 @@ class MongoRepository {
|
|
|
228
267
|
}
|
|
229
268
|
});
|
|
230
269
|
}
|
|
231
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
270
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_21 = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
|
|
232
271
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
233
272
|
andConditions.push({
|
|
234
273
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -247,7 +286,9 @@ class MongoRepository {
|
|
|
247
286
|
*/
|
|
248
287
|
start(params) {
|
|
249
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined,
|
|
289
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
290
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
291
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
251
292
|
.then((doc) => doc.toObject());
|
|
252
293
|
});
|
|
253
294
|
}
|
|
@@ -277,26 +318,24 @@ class MongoRepository {
|
|
|
277
318
|
return doc.toObject();
|
|
278
319
|
});
|
|
279
320
|
}
|
|
280
|
-
/**
|
|
281
|
-
* 取引を確定する
|
|
282
|
-
*/
|
|
283
321
|
addReservations(params) {
|
|
322
|
+
var _a;
|
|
284
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
324
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
286
|
-
_id: params.id,
|
|
287
|
-
typeOf: params.typeOf,
|
|
288
|
-
status: factory.transactionStatusType.InProgress
|
|
289
|
-
}, {
|
|
290
|
-
'object.acceptedOffer': params.object.acceptedOffer,
|
|
325
|
+
_id: { $eq: params.id },
|
|
326
|
+
typeOf: { $eq: params.typeOf },
|
|
327
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
328
|
+
}, Object.assign({ 'object.acceptedOffer': params.object.acceptedOffer,
|
|
291
329
|
// 念のため残す(2021/10/14)が、そのうち削除
|
|
292
330
|
// 冗長なので削除(2021/10/19~)
|
|
293
331
|
// 'object.event': params.object.reservationFor,
|
|
294
|
-
'object.reservationFor': params.object.reservationFor,
|
|
332
|
+
'object.reservationFor': params.object.reservationFor,
|
|
295
333
|
// 念のため残す(2021/10/14)が、そのうち削除
|
|
296
334
|
// 冗長なので削除(2021/10/19~)
|
|
297
335
|
// 'object.reservations': params.object.subReservation,
|
|
298
|
-
'object.subReservation': params.object.subReservation
|
|
299
|
-
|
|
336
|
+
'object.subReservation': params.object.subReservation }, (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
337
|
+
? { 'object.issuedThrough': params.object.issuedThrough }
|
|
338
|
+
: undefined), { new: true })
|
|
300
339
|
.exec();
|
|
301
340
|
if (doc === null) {
|
|
302
341
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -308,36 +347,40 @@ class MongoRepository {
|
|
|
308
347
|
* 取引を確定する
|
|
309
348
|
*/
|
|
310
349
|
confirm(params) {
|
|
350
|
+
var _a, _b;
|
|
311
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
312
352
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
313
|
-
_id: params.id,
|
|
314
|
-
typeOf: params.typeOf,
|
|
315
|
-
status: factory.transactionStatusType.InProgress
|
|
316
|
-
}, {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
353
|
+
_id: { $eq: params.id },
|
|
354
|
+
typeOf: { $eq: params.typeOf },
|
|
355
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
356
|
+
}, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
357
|
+
? { 'object.underName': params.object.underName }
|
|
358
|
+
: undefined), {
|
|
359
|
+
new: true,
|
|
360
|
+
projection: { _id: 1 }
|
|
361
|
+
})
|
|
322
362
|
.exec();
|
|
323
363
|
// NotFoundであれば取引状態確認
|
|
324
364
|
if (doc === null) {
|
|
325
365
|
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
326
366
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
327
|
-
//
|
|
328
|
-
return transaction;
|
|
367
|
+
// すでに確定済の場合スルー
|
|
329
368
|
}
|
|
330
369
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
331
|
-
throw new factory.errors.Argument('Transaction id',
|
|
370
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
332
371
|
}
|
|
333
372
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
334
|
-
throw new factory.errors.Argument('Transaction id',
|
|
373
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
|
|
335
374
|
}
|
|
336
375
|
else {
|
|
337
376
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
338
377
|
}
|
|
339
378
|
}
|
|
340
|
-
|
|
379
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
380
|
+
id: params.id,
|
|
381
|
+
typeOf: params.typeOf,
|
|
382
|
+
status: factory.transactionStatusType.Confirmed
|
|
383
|
+
});
|
|
341
384
|
});
|
|
342
385
|
}
|
|
343
386
|
/**
|
|
@@ -345,23 +388,42 @@ class MongoRepository {
|
|
|
345
388
|
*/
|
|
346
389
|
startAndConfirm(params) {
|
|
347
390
|
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
-
|
|
391
|
+
const startDate = new Date();
|
|
392
|
+
const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
|
|
393
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
394
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
|
|
349
395
|
.then((doc) => doc.toObject());
|
|
396
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
397
|
+
id: params.id,
|
|
398
|
+
typeOf: params.typeOf,
|
|
399
|
+
status: factory.transactionStatusType.Confirmed
|
|
400
|
+
});
|
|
401
|
+
return confirmedTransaction;
|
|
350
402
|
});
|
|
351
403
|
}
|
|
352
404
|
/**
|
|
353
405
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
354
406
|
*/
|
|
355
407
|
startExportTasks(params) {
|
|
356
|
-
var _a, _b
|
|
408
|
+
var _a, _b;
|
|
357
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
410
|
+
switch (params.status) {
|
|
411
|
+
case factory.transactionStatusType.InProgress:
|
|
412
|
+
throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
|
|
413
|
+
default:
|
|
414
|
+
// no op
|
|
415
|
+
}
|
|
416
|
+
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
417
|
+
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { '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), {
|
|
418
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
419
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
420
|
+
'tasksExportAction.startDate': new Date(),
|
|
421
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
422
|
+
}, { new: true })
|
|
423
|
+
.select({
|
|
424
|
+
_id: 1,
|
|
425
|
+
typeOf: 1
|
|
426
|
+
})
|
|
365
427
|
.exec()
|
|
366
428
|
// tslint:disable-next-line:no-null-keyword
|
|
367
429
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -374,17 +436,74 @@ class MongoRepository {
|
|
|
374
436
|
*/
|
|
375
437
|
reexportTasks(params) {
|
|
376
438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
-
yield this.transactionModel.
|
|
378
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
439
|
+
const reexportingTransactions = yield this.transactionModel.find({
|
|
440
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
379
441
|
updatedAt: {
|
|
380
442
|
$lt: moment()
|
|
381
443
|
.add(-params.intervalInMinutes, 'minutes')
|
|
382
444
|
.toDate()
|
|
383
445
|
}
|
|
384
|
-
}, {
|
|
385
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
386
446
|
})
|
|
447
|
+
.select({
|
|
448
|
+
_id: 1,
|
|
449
|
+
typeOf: 1,
|
|
450
|
+
status: 1
|
|
451
|
+
})
|
|
452
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
453
|
+
.exec();
|
|
454
|
+
if (reexportingTransactions.length > 0) {
|
|
455
|
+
for (const reexportingTransaction of reexportingTransactions) {
|
|
456
|
+
yield this.transactionModel.updateOne({
|
|
457
|
+
_id: { $eq: reexportingTransaction.id },
|
|
458
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
459
|
+
}, {
|
|
460
|
+
tasksExportAction: {
|
|
461
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
462
|
+
},
|
|
463
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
464
|
+
})
|
|
465
|
+
.exec();
|
|
466
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
467
|
+
id: reexportingTransaction.id,
|
|
468
|
+
typeOf: reexportingTransaction.typeOf,
|
|
469
|
+
status: reexportingTransaction.status
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
477
|
+
*/
|
|
478
|
+
exportTasks(params) {
|
|
479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
481
|
+
status: { $in: params.status.$in },
|
|
482
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
483
|
+
endDate: {
|
|
484
|
+
$exists: true,
|
|
485
|
+
$lt: moment(params.now)
|
|
486
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
487
|
+
.toDate()
|
|
488
|
+
}
|
|
489
|
+
})
|
|
490
|
+
.select({
|
|
491
|
+
_id: 1,
|
|
492
|
+
typeOf: 1,
|
|
493
|
+
status: 1
|
|
494
|
+
})
|
|
495
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
387
496
|
.exec();
|
|
497
|
+
if (delayedTransactions.length > 0) {
|
|
498
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
499
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
500
|
+
id: delayedTransaction.id,
|
|
501
|
+
typeOf: delayedTransaction.typeOf,
|
|
502
|
+
status: delayedTransaction.status
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return delayedTransactions;
|
|
388
507
|
});
|
|
389
508
|
}
|
|
390
509
|
/**
|
|
@@ -393,10 +512,15 @@ class MongoRepository {
|
|
|
393
512
|
*/
|
|
394
513
|
setTasksExportedById(params) {
|
|
395
514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
-
|
|
515
|
+
const endDate = new Date();
|
|
516
|
+
yield this.transactionModel.updateOne({
|
|
517
|
+
_id: { $eq: params.id },
|
|
518
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
519
|
+
}, {
|
|
397
520
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
398
|
-
tasksExportedAt:
|
|
399
|
-
|
|
521
|
+
tasksExportedAt: endDate,
|
|
522
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
523
|
+
'tasksExportAction.endDate': endDate
|
|
400
524
|
})
|
|
401
525
|
.exec();
|
|
402
526
|
});
|
|
@@ -406,15 +530,36 @@ class MongoRepository {
|
|
|
406
530
|
*/
|
|
407
531
|
makeExpired(params) {
|
|
408
532
|
return __awaiter(this, void 0, void 0, function* () {
|
|
409
|
-
//
|
|
410
|
-
yield this.transactionModel.
|
|
411
|
-
status: factory.transactionStatusType.InProgress,
|
|
412
|
-
expires: { $lt: params.expires }
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
533
|
+
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
534
|
+
const expiringTransactions = yield this.transactionModel.find({
|
|
535
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
536
|
+
expires: { $lt: params.expires.$lt }
|
|
537
|
+
})
|
|
538
|
+
.select({
|
|
539
|
+
_id: 1,
|
|
540
|
+
typeOf: 1
|
|
416
541
|
})
|
|
542
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
417
543
|
.exec();
|
|
544
|
+
if (expiringTransactions.length > 0) {
|
|
545
|
+
// ステータスと期限を見て更新
|
|
546
|
+
yield this.transactionModel.updateMany({
|
|
547
|
+
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
548
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
549
|
+
expires: { $lt: params.expires.$lt }
|
|
550
|
+
}, {
|
|
551
|
+
status: factory.transactionStatusType.Expired,
|
|
552
|
+
endDate: new Date()
|
|
553
|
+
})
|
|
554
|
+
.exec();
|
|
555
|
+
expiringTransactions.forEach((expiringTransaction) => {
|
|
556
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
557
|
+
id: expiringTransaction.id,
|
|
558
|
+
typeOf: expiringTransaction.typeOf,
|
|
559
|
+
status: factory.transactionStatusType.Expired
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
}
|
|
418
563
|
});
|
|
419
564
|
}
|
|
420
565
|
/**
|
|
@@ -422,19 +567,18 @@ class MongoRepository {
|
|
|
422
567
|
*/
|
|
423
568
|
cancel(params) {
|
|
424
569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
-
const endDate =
|
|
426
|
-
.toDate();
|
|
570
|
+
const endDate = new Date();
|
|
427
571
|
// 進行中ステータスの取引を中止する
|
|
428
|
-
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: params.typeOf }, (typeof params.id === 'string') ? { _id: params.id } : undefined), (typeof params.transactionNumber === 'string')
|
|
572
|
+
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
|
|
429
573
|
? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
|
|
430
|
-
: undefined), { status: factory.transactionStatusType.InProgress }), {
|
|
574
|
+
: undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
|
|
431
575
|
status: factory.transactionStatusType.Canceled,
|
|
432
576
|
endDate: endDate
|
|
433
577
|
}, { new: true })
|
|
434
578
|
.exec();
|
|
579
|
+
let transaction;
|
|
435
580
|
// NotFoundであれば取引状態確認
|
|
436
581
|
if (doc === null) {
|
|
437
|
-
let transaction;
|
|
438
582
|
if (typeof params.id === 'string') {
|
|
439
583
|
transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
440
584
|
}
|
|
@@ -448,39 +592,64 @@ class MongoRepository {
|
|
|
448
592
|
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
449
593
|
}
|
|
450
594
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
451
|
-
//
|
|
452
|
-
return transaction;
|
|
595
|
+
// すでに中止済の場合スルー
|
|
453
596
|
}
|
|
454
597
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
455
|
-
throw new factory.errors.Argument('Transaction id',
|
|
598
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
456
599
|
}
|
|
457
600
|
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
458
|
-
throw new factory.errors.Argument('Transaction id',
|
|
601
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
|
|
459
602
|
}
|
|
460
603
|
else {
|
|
461
604
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
462
605
|
}
|
|
463
606
|
}
|
|
464
|
-
|
|
607
|
+
else {
|
|
608
|
+
transaction = doc.toObject();
|
|
609
|
+
}
|
|
610
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
611
|
+
id: transaction.id,
|
|
612
|
+
typeOf: params.typeOf,
|
|
613
|
+
status: factory.transactionStatusType.Canceled
|
|
614
|
+
});
|
|
615
|
+
return transaction;
|
|
465
616
|
});
|
|
466
617
|
}
|
|
467
618
|
count(params) {
|
|
468
619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
469
620
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
470
621
|
return this.transactionModel.countDocuments({ $and: conditions })
|
|
471
|
-
.setOptions({ maxTimeMS:
|
|
622
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
472
623
|
.exec();
|
|
473
624
|
});
|
|
474
625
|
}
|
|
475
626
|
/**
|
|
476
627
|
* 取引を検索する
|
|
477
628
|
*/
|
|
478
|
-
search(params,
|
|
629
|
+
search(params, inclusion, exclusion) {
|
|
479
630
|
var _a;
|
|
480
631
|
return __awaiter(this, void 0, void 0, function* () {
|
|
481
632
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
633
|
+
let projection = {};
|
|
634
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
635
|
+
inclusion.forEach((field) => {
|
|
636
|
+
projection[field] = 1;
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
projection = {
|
|
641
|
+
__v: 0,
|
|
642
|
+
createdAt: 0,
|
|
643
|
+
updatedAt: 0
|
|
644
|
+
};
|
|
645
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
646
|
+
exclusion.forEach((field) => {
|
|
647
|
+
projection[field] = 0;
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
482
651
|
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
483
|
-
.select(
|
|
652
|
+
.select(projection);
|
|
484
653
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
485
654
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
486
655
|
query.limit(params.limit)
|
|
@@ -491,7 +660,7 @@ class MongoRepository {
|
|
|
491
660
|
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
|
|
492
661
|
query.sort({ startDate: params.sort.startDate });
|
|
493
662
|
}
|
|
494
|
-
return query.setOptions({ maxTimeMS:
|
|
663
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
495
664
|
.exec()
|
|
496
665
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
497
666
|
});
|
|
@@ -523,9 +692,12 @@ class MongoRepository {
|
|
|
523
692
|
/**
|
|
524
693
|
* 特定の取引を更新する(汎用)
|
|
525
694
|
*/
|
|
526
|
-
|
|
695
|
+
findByIdAndUpdateInProgress(params) {
|
|
527
696
|
return __awaiter(this, void 0, void 0, function* () {
|
|
528
|
-
return this.transactionModel.findOneAndUpdate({
|
|
697
|
+
return this.transactionModel.findOneAndUpdate({
|
|
698
|
+
_id: { $eq: params.id },
|
|
699
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
700
|
+
}, params.update, { new: true })
|
|
529
701
|
.exec()
|
|
530
702
|
.then((doc) => {
|
|
531
703
|
if (doc === null) {
|
|
@@ -35,7 +35,7 @@ export declare class MongoRepository {
|
|
|
35
35
|
/**
|
|
36
36
|
* 検索
|
|
37
37
|
*/
|
|
38
|
-
search(params: factory.categoryCode.ISearchConditions): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
38
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
39
39
|
findById(params: {
|
|
40
40
|
id: string;
|
|
41
41
|
}): Promise<factory.categoryCode.ICategoryCode>;
|