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