@chevre/domain 24.0.0-alpha.1 → 24.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/acceptedPaymentMethod.js +1 -1
- package/lib/chevre/repo/additionalProperty.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +1 -1
- package/lib/chevre/repo/confirmationNumber.js +2 -4
- package/lib/chevre/repo/creativeWork.js +1 -1
- package/lib/chevre/repo/eventOffer.js +1 -1
- package/lib/chevre/repo/eventSeries.js +1 -1
- package/lib/chevre/repo/identity.js +1 -2
- package/lib/chevre/repo/issuer.js +2 -4
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
- package/lib/chevre/repo/note.js +1 -1
- package/lib/chevre/repo/noteAboutOrder.js +1 -1
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
- package/lib/chevre/repo/offerItemCondition.js +1 -1
- package/lib/chevre/repo/order.js +1 -1
- package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
- package/lib/chevre/repo/orderInTransaction.js +17 -4
- package/lib/chevre/repo/orderNumber.d.ts +3 -2
- package/lib/chevre/repo/orderNumber.js +25 -32
- package/lib/chevre/repo/place/movieTheater.js +1 -1
- package/lib/chevre/repo/place/seat.js +1 -1
- package/lib/chevre/repo/product.js +1 -1
- package/lib/chevre/repo/productOffer.js +1 -1
- package/lib/chevre/repo/project.js +1 -1
- package/lib/chevre/repo/reservation.js +1 -1
- package/lib/chevre/repo/role.js +1 -2
- package/lib/chevre/repo/seller.js +1 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
- package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
- package/lib/chevre/repo/transaction/placeOrder.js +528 -0
- package/lib/chevre/repo/transaction/returnOrder.d.ts +23 -0
- package/lib/chevre/repo/transaction/returnOrder.js +213 -0
- package/lib/chevre/repo/transaction.d.ts +11 -84
- package/lib/chevre/repo/transaction.js +331 -270
- package/lib/chevre/repo/transactionNumber.js +2 -4
- package/lib/chevre/repo/trip.js +1 -2
- package/lib/chevre/repository.d.ts +12 -0
- package/lib/chevre/repository.js +26 -1
- package/lib/chevre/service/account.js +14 -21
- package/lib/chevre/service/accountTransaction/deposit.js +2 -8
- package/lib/chevre/service/accountTransaction/transfer.js +2 -8
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
- package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
- package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
- package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
- package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +53 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
- package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
- package/lib/chevre/service/assetTransaction/refund.js +13 -20
- package/lib/chevre/service/assetTransaction/registerService.js +1 -7
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
- package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
- package/lib/chevre/service/delivery/product/factory.js +1 -2
- package/lib/chevre/service/delivery/reservation/factory.js +1 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
- package/lib/chevre/service/event.js +0 -1
- package/lib/chevre/service/moneyTransfer.js +2 -2
- package/lib/chevre/service/notification/factory.js +1 -1
- package/lib/chevre/service/notification/notifyByEmail.js +50 -56
- package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
- package/lib/chevre/service/notification/triggerWebhook.js +32 -37
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.js +4 -4
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -2
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +6 -6
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +53 -57
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
- package/lib/chevre/service/offer/product.d.ts +3 -3
- package/lib/chevre/service/offer/product.js +4 -4
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +4 -4
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +10 -19
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated.js +1 -2
- package/lib/chevre/service/order/payOrder.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -3
- package/lib/chevre/service/order/placeOrder.d.ts +2 -2
- package/lib/chevre/service/order/returnOrder.d.ts +2 -2
- package/lib/chevre/service/order/returnOrder.js +2 -2
- package/lib/chevre/service/order/sendOrder.d.ts +2 -2
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -2
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -8
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
- package/lib/chevre/service/payment/any.d.ts +6 -6
- package/lib/chevre/service/payment/any.js +10 -11
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
- package/lib/chevre/service/payment/paymentCard.js +2 -4
- package/lib/chevre/service/report/telemetry.d.ts +4 -0
- package/lib/chevre/service/report/telemetry.js +7 -12
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
- package/lib/chevre/service/task/acceptCOAOffer.js +6 -4
- package/lib/chevre/service/task/authorizePayment.js +4 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
- package/lib/chevre/service/task/deleteTransaction.js +5 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
- package/lib/chevre/service/task/pay.js +1 -2
- package/lib/chevre/service/task/placeOrder.js +6 -4
- package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
- package/lib/chevre/service/task/returnOrder.js +4 -4
- package/lib/chevre/service/task/returnPayTransaction.js +4 -3
- package/lib/chevre/service/task/sendOrder.js +2 -2
- package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
- package/lib/chevre/service/task/voidPayTransaction.js +4 -2
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
- package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +4 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +57 -15
- package/lib/chevre/service/transaction/moneyTransfer.js +15 -23
- package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -13
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
- package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrder.js +3 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +4 -4
- package/lib/chevre/service/transaction.d.ts +5 -21
- package/lib/chevre/service/transaction.js +5 -111
- package/package.json +6 -18
|
@@ -58,29 +58,27 @@ class TransactionRepo {
|
|
|
58
58
|
this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
|
|
59
59
|
}
|
|
60
60
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
61
|
+
if (params.typeOf !== factory.transactionType.MoneyTransfer) {
|
|
62
|
+
throw new factory.errors.Argument('typeOf', `must be ${factory.transactionType.MoneyTransfer}`);
|
|
63
|
+
}
|
|
61
64
|
const andConditions = [];
|
|
62
65
|
const projectIdEq = params.project?.id?.$eq;
|
|
63
|
-
/* istanbul ignore else */
|
|
64
66
|
if (typeof projectIdEq === 'string') {
|
|
65
67
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
66
68
|
}
|
|
67
|
-
/* istanbul ignore else */
|
|
68
69
|
if (typeof params.typeOf === 'string') {
|
|
69
70
|
andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
70
71
|
}
|
|
71
|
-
/* istanbul ignore else */
|
|
72
72
|
if (params.startFrom !== undefined) {
|
|
73
73
|
andConditions.push({
|
|
74
74
|
startDate: { $gte: params.startFrom }
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
/* istanbul ignore else */
|
|
78
77
|
if (params.startThrough !== undefined) {
|
|
79
78
|
andConditions.push({
|
|
80
79
|
startDate: { $lte: params.startThrough }
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
|
-
/* istanbul ignore else */
|
|
84
82
|
if (params.endFrom !== undefined) {
|
|
85
83
|
andConditions.push({
|
|
86
84
|
endDate: {
|
|
@@ -89,7 +87,6 @@ class TransactionRepo {
|
|
|
89
87
|
}
|
|
90
88
|
});
|
|
91
89
|
}
|
|
92
|
-
/* istanbul ignore else */
|
|
93
90
|
if (params.endThrough !== undefined) {
|
|
94
91
|
andConditions.push({
|
|
95
92
|
endDate: {
|
|
@@ -98,24 +95,19 @@ class TransactionRepo {
|
|
|
98
95
|
}
|
|
99
96
|
});
|
|
100
97
|
}
|
|
101
|
-
/* istanbul ignore else */
|
|
102
98
|
if (Array.isArray(params.ids)) {
|
|
103
99
|
andConditions.push({
|
|
104
100
|
_id: { $in: params.ids }
|
|
105
101
|
});
|
|
106
102
|
}
|
|
107
|
-
/* istanbul ignore else */
|
|
108
103
|
if (Array.isArray(params.statuses)) {
|
|
109
104
|
andConditions.push({ status: { $in: params.statuses } });
|
|
110
105
|
}
|
|
111
|
-
/* istanbul ignore else */
|
|
112
106
|
const statusIn = params.status?.$in;
|
|
113
107
|
if (Array.isArray(statusIn)) {
|
|
114
108
|
andConditions.push({ status: { $in: statusIn } });
|
|
115
109
|
}
|
|
116
|
-
/* istanbul ignore else */
|
|
117
110
|
if (params.agent !== undefined) {
|
|
118
|
-
/* istanbul ignore else */
|
|
119
111
|
if (params.agent.typeOf !== undefined) {
|
|
120
112
|
andConditions.push({
|
|
121
113
|
'agent.typeOf': {
|
|
@@ -124,7 +116,6 @@ class TransactionRepo {
|
|
|
124
116
|
}
|
|
125
117
|
});
|
|
126
118
|
}
|
|
127
|
-
/* istanbul ignore else */
|
|
128
119
|
if (Array.isArray(params.agent.ids)) {
|
|
129
120
|
andConditions.push({
|
|
130
121
|
'agent.id': {
|
|
@@ -133,7 +124,6 @@ class TransactionRepo {
|
|
|
133
124
|
}
|
|
134
125
|
});
|
|
135
126
|
}
|
|
136
|
-
/* istanbul ignore else */
|
|
137
127
|
if (Array.isArray(params.agent.identifiers)) {
|
|
138
128
|
andConditions.push({
|
|
139
129
|
'agent.identifier': {
|
|
@@ -142,87 +132,52 @@ class TransactionRepo {
|
|
|
142
132
|
}
|
|
143
133
|
});
|
|
144
134
|
}
|
|
145
|
-
// if (typeof params.agent.familyName === 'string' && params.agent.familyName.length > 0) {
|
|
146
|
-
// andConditions.push({
|
|
147
|
-
// 'agent.familyName': {
|
|
148
|
-
// $exists: true,
|
|
149
|
-
// $regex: new RegExp(params.agent.familyName)
|
|
150
|
-
// }
|
|
151
|
-
// });
|
|
152
|
-
// }
|
|
153
|
-
// if (typeof params.agent.givenName === 'string' && params.agent.givenName.length > 0) {
|
|
154
|
-
// andConditions.push({
|
|
155
|
-
// 'agent.givenName': {
|
|
156
|
-
// $exists: true,
|
|
157
|
-
// $regex: new RegExp(params.agent.givenName)
|
|
158
|
-
// }
|
|
159
|
-
// });
|
|
160
|
-
// }
|
|
161
|
-
// if (typeof params.agent.email === 'string' && params.agent.email.length > 0) {
|
|
162
|
-
// andConditions.push({
|
|
163
|
-
// 'agent.email': {
|
|
164
|
-
// $exists: true,
|
|
165
|
-
// $regex: new RegExp(params.agent.email)
|
|
166
|
-
// }
|
|
167
|
-
// });
|
|
168
|
-
// }
|
|
169
|
-
// if (typeof params.agent.telephone === 'string' && params.agent.telephone.length > 0) {
|
|
170
|
-
// andConditions.push({
|
|
171
|
-
// 'agent.telephone': {
|
|
172
|
-
// $exists: true,
|
|
173
|
-
// $regex: new RegExp(params.agent.telephone)
|
|
174
|
-
// }
|
|
175
|
-
// });
|
|
176
|
-
// }
|
|
177
135
|
}
|
|
178
136
|
const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
179
|
-
/* istanbul ignore else */
|
|
180
137
|
if (Array.isArray(tasksExportActionStatusIn)) {
|
|
181
138
|
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
182
139
|
}
|
|
183
140
|
const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
184
|
-
/* istanbul ignore else */
|
|
185
141
|
if (typeof tasksExportActionStatusEq === 'string') {
|
|
186
142
|
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
|
|
187
143
|
}
|
|
188
144
|
switch (params.typeOf) {
|
|
189
145
|
case factory.transactionType.PlaceOrder:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
146
|
+
throw new factory.errors.NotImplemented(`use PlaceOrderRepo`);
|
|
147
|
+
// const sellerIdIn = params.seller?.ids;
|
|
148
|
+
// if (Array.isArray(sellerIdIn)) {
|
|
149
|
+
// andConditions.push({ 'seller.id': { $exists: true, $in: sellerIdIn } });
|
|
150
|
+
// }
|
|
151
|
+
// const resultOrderNumberIn = params.result?.order?.orderNumbers;
|
|
152
|
+
// if (Array.isArray(resultOrderNumberIn)) {
|
|
153
|
+
// andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
|
|
154
|
+
// }
|
|
155
|
+
// const resultOrderConfirmationNumberEq = params.result?.order?.confirmationNumber?.$eq;
|
|
156
|
+
// if (typeof resultOrderConfirmationNumberEq === 'string') {
|
|
157
|
+
// andConditions.push({
|
|
158
|
+
// 'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
|
|
159
|
+
// });
|
|
160
|
+
// }
|
|
161
|
+
// const objectOrderNumberEq = params.object?.orderNumber?.$eq;
|
|
162
|
+
// if (typeof objectOrderNumberEq === 'string') {
|
|
163
|
+
// andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
|
|
164
|
+
// }
|
|
165
|
+
// break;
|
|
209
166
|
case factory.transactionType.ReturnOrder:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
167
|
+
throw new factory.errors.NotImplemented(`use ReturnOrderRepo`);
|
|
168
|
+
// if (params.object !== undefined) {
|
|
169
|
+
// if (params.object.order !== undefined) {
|
|
170
|
+
// if (Array.isArray(params.object.order.orderNumbers)) {
|
|
171
|
+
// andConditions.push({
|
|
172
|
+
// 'object.order.orderNumber': {
|
|
173
|
+
// $exists: true,
|
|
174
|
+
// $in: params.object.order.orderNumbers
|
|
175
|
+
// }
|
|
176
|
+
// });
|
|
177
|
+
// }
|
|
178
|
+
// }
|
|
179
|
+
// }
|
|
180
|
+
// break;
|
|
226
181
|
default:
|
|
227
182
|
}
|
|
228
183
|
return andConditions;
|
|
@@ -230,15 +185,14 @@ class TransactionRepo {
|
|
|
230
185
|
/**
|
|
231
186
|
* 取引を開始する
|
|
232
187
|
*/
|
|
233
|
-
async
|
|
188
|
+
async startNoPlaceOrder(params) {
|
|
234
189
|
const status = factory.transactionStatusType.InProgress;
|
|
235
190
|
const tasksExportAction = { actionStatus: factory.actionStatusType.PotentialActionStatus };
|
|
236
191
|
// const tasksExportationStatus = factory.transactionTasksExportationStatus.Unexported; // discontinue(2024-06-20~)
|
|
237
192
|
const startDate = new Date();
|
|
238
193
|
let expires;
|
|
239
194
|
const { typeOf } = params;
|
|
240
|
-
if (typeOf === factory.transactionType.
|
|
241
|
-
|| typeOf === factory.transactionType.ReturnOrder) {
|
|
195
|
+
if (typeOf === factory.transactionType.ReturnOrder) {
|
|
242
196
|
// expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
|
|
243
197
|
if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
|
|
244
198
|
expires = (0, moment_1.default)(startDate)
|
|
@@ -260,14 +214,6 @@ class TransactionRepo {
|
|
|
260
214
|
agent, project, seller, object, recipient
|
|
261
215
|
};
|
|
262
216
|
}
|
|
263
|
-
else if (typeOf === factory.transactionType.PlaceOrder) {
|
|
264
|
-
const { agent, project, object, seller, instrument } = params;
|
|
265
|
-
creatingTransaction = {
|
|
266
|
-
status, startDate, expires, typeOf, tasksExportAction,
|
|
267
|
-
agent, project, seller, object,
|
|
268
|
-
...(typeof instrument?.id === 'string') ? { instrument } : undefined
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
217
|
else if (typeOf === factory.transactionType.ReturnOrder) {
|
|
272
218
|
const { agent, project, object, seller } = params;
|
|
273
219
|
creatingTransaction = {
|
|
@@ -291,7 +237,7 @@ class TransactionRepo {
|
|
|
291
237
|
/**
|
|
292
238
|
* 特定取引検索
|
|
293
239
|
*/
|
|
294
|
-
async
|
|
240
|
+
async projectFieldsByIdNoPlaceOrder(params, inclusion // make required(2024-05-31~)
|
|
295
241
|
) {
|
|
296
242
|
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
297
243
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
@@ -331,7 +277,7 @@ class TransactionRepo {
|
|
|
331
277
|
/**
|
|
332
278
|
* 進行中の取引を取得する
|
|
333
279
|
*/
|
|
334
|
-
async
|
|
280
|
+
async findMoneyTransferInProgressById(params, inclusion // make required(2024-05-29~)
|
|
335
281
|
) {
|
|
336
282
|
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
337
283
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
@@ -345,24 +291,6 @@ class TransactionRepo {
|
|
|
345
291
|
id: { $toString: '$_id' },
|
|
346
292
|
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
347
293
|
};
|
|
348
|
-
// let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: ProjectionElementType } = {};
|
|
349
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
350
|
-
// inclusion.forEach((field) => {
|
|
351
|
-
// projection[field] = 1;
|
|
352
|
-
// });
|
|
353
|
-
// } else {
|
|
354
|
-
// // minimize(2024-05-29~)
|
|
355
|
-
// projection = {
|
|
356
|
-
// __v: 0,
|
|
357
|
-
// createdAt: 0,
|
|
358
|
-
// updatedAt: 0,
|
|
359
|
-
// tasksExportAction: 0,
|
|
360
|
-
// ...{
|
|
361
|
-
// tasksExportedAt: 0,
|
|
362
|
-
// tasksExportationStatus: 0
|
|
363
|
-
// }
|
|
364
|
-
// };
|
|
365
|
-
// }
|
|
366
294
|
const filter = {
|
|
367
295
|
_id: { $eq: params.id },
|
|
368
296
|
typeOf: { $eq: params.typeOf },
|
|
@@ -378,124 +306,229 @@ class TransactionRepo {
|
|
|
378
306
|
}
|
|
379
307
|
return doc;
|
|
380
308
|
}
|
|
381
|
-
/**
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
async
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
309
|
+
// /**
|
|
310
|
+
// * 進行中の取引を取得する
|
|
311
|
+
// */
|
|
312
|
+
// public async projectFieldsInProgressById<T extends factory.transactionType.MoneyTransfer>(
|
|
313
|
+
// params: {
|
|
314
|
+
// typeOf: T;
|
|
315
|
+
// id: string;
|
|
316
|
+
// },
|
|
317
|
+
// inclusion: IKeyOfProjection<T>[] // make required(2024-05-29~)
|
|
318
|
+
// ): Promise<ITransactionInProgress<T>> {
|
|
319
|
+
// let positiveProjectionFields: (IKeyOfProjection<factory.transactionType.MoneyTransfer>
|
|
320
|
+
// | IKeyOfProjection<factory.transactionType.PlaceOrder>
|
|
321
|
+
// | IKeyOfProjection<factory.transactionType.ReturnOrder>
|
|
322
|
+
// )[] = AVAILABLE_PROJECT_FIELDS;
|
|
323
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
324
|
+
// positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection<T>>key));
|
|
325
|
+
// } else {
|
|
326
|
+
// throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
|
|
327
|
+
// }
|
|
328
|
+
// const projection: ProjectionType<factory.transaction.ITransaction<T>> = {
|
|
329
|
+
// _id: 0,
|
|
330
|
+
// id: { $toString: '$_id' },
|
|
331
|
+
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
332
|
+
// };
|
|
333
|
+
// const filter: FilterQuery<factory.transaction.ITransaction<T>> = {
|
|
334
|
+
// _id: { $eq: params.id },
|
|
335
|
+
// typeOf: { $eq: params.typeOf },
|
|
336
|
+
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
337
|
+
// // expiresを条件に追加(2023-05-12~),
|
|
338
|
+
// expires: { $gt: new Date() }
|
|
339
|
+
// };
|
|
340
|
+
// const doc = await this.transactionModel.findOne(filter, projection)
|
|
341
|
+
// .lean<factory.transaction.ITransaction<T>>() // 2024-08-26~
|
|
342
|
+
// .exec();
|
|
343
|
+
// if (doc === null) {
|
|
344
|
+
// throw new factory.errors.NotFound(
|
|
345
|
+
// this.transactionModel.modelName,
|
|
346
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
347
|
+
// );
|
|
348
|
+
// }
|
|
349
|
+
// return doc;
|
|
350
|
+
// }
|
|
351
|
+
// /**
|
|
352
|
+
// * 進行中取引に保管された採用済決済方法を検索する
|
|
353
|
+
// */
|
|
354
|
+
// public async findInProgressPaymentMethodId(params: {
|
|
355
|
+
// id: string;
|
|
356
|
+
// }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined> {
|
|
357
|
+
// const doc = await this.transactionModel.findOne(
|
|
358
|
+
// {
|
|
359
|
+
// _id: { $eq: params.id },
|
|
360
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
361
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
362
|
+
// },
|
|
363
|
+
// { 'object.paymentMethods': 1 }
|
|
364
|
+
// )
|
|
365
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>() // 2024-08-26~
|
|
366
|
+
// .exec();
|
|
367
|
+
// if (doc === null) {
|
|
368
|
+
// throw new factory.errors.NotFound(
|
|
369
|
+
// this.transactionModel.modelName,
|
|
370
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
371
|
+
// );
|
|
372
|
+
// }
|
|
373
|
+
// return doc.object.paymentMethods;
|
|
374
|
+
// }
|
|
375
|
+
// /**
|
|
376
|
+
// * 取引の注文番号を検索する
|
|
377
|
+
// */
|
|
378
|
+
// public async findInProgressOrderNumberById(params: {
|
|
379
|
+
// id: string;
|
|
380
|
+
// }): Promise<string | undefined> {
|
|
381
|
+
// const doc = await this.transactionModel.findOne(
|
|
382
|
+
// {
|
|
383
|
+
// _id: { $eq: params.id },
|
|
384
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
385
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
386
|
+
// },
|
|
387
|
+
// { 'object.orderNumber': 1 }
|
|
388
|
+
// )
|
|
389
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
|
|
390
|
+
// .exec();
|
|
391
|
+
// if (doc === null) {
|
|
392
|
+
// throw new factory.errors.NotFound(
|
|
393
|
+
// this.transactionModel.modelName,
|
|
394
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
395
|
+
// );
|
|
396
|
+
// }
|
|
397
|
+
// return doc.object.orderNumber;
|
|
398
|
+
// }
|
|
399
|
+
// /**
|
|
400
|
+
// * 取引の確認番号を検索する
|
|
401
|
+
// */
|
|
402
|
+
// public async findInProgressConfirmationNumberById(params: {
|
|
403
|
+
// id: string;
|
|
404
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
405
|
+
// }): Promise<string | undefined> {
|
|
406
|
+
// const doc = await this.transactionModel.findOne(
|
|
407
|
+
// {
|
|
408
|
+
// _id: { $eq: params.id },
|
|
409
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
410
|
+
// status: { $in: params.status.$in }
|
|
411
|
+
// },
|
|
412
|
+
// { 'object.confirmationNumber': 1 }
|
|
413
|
+
// )
|
|
414
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
|
|
415
|
+
// .exec();
|
|
416
|
+
// if (doc === null) {
|
|
417
|
+
// throw new factory.errors.NotFound(
|
|
418
|
+
// this.transactionModel.modelName,
|
|
419
|
+
// `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
|
|
420
|
+
// );
|
|
421
|
+
// }
|
|
422
|
+
// return doc.object.confirmationNumber;
|
|
423
|
+
// }
|
|
424
|
+
// /**
|
|
425
|
+
// * 取引進行者プロフィールを更新
|
|
426
|
+
// */
|
|
427
|
+
// public async updateAgent<T extends factory.transactionType>(params: {
|
|
428
|
+
// typeOf: T;
|
|
429
|
+
// id: string;
|
|
430
|
+
// agent: Pick<factory.transaction.IAgent, 'id'>;
|
|
431
|
+
// object?: {
|
|
432
|
+
// customer?: factory.order.ICustomer;
|
|
433
|
+
// };
|
|
434
|
+
// }): Promise<void> {
|
|
435
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
436
|
+
// {
|
|
437
|
+
// _id: { $eq: params.id },
|
|
438
|
+
// typeOf: { $eq: params.typeOf },
|
|
439
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
440
|
+
// },
|
|
441
|
+
// {
|
|
442
|
+
// $set: {
|
|
443
|
+
// 'agent.id': params.agent.id,
|
|
444
|
+
// // ...(typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined,
|
|
445
|
+
// ...(typeof params.object?.customer?.typeOf === 'string') ? { 'object.customer': params.object.customer } : undefined
|
|
446
|
+
// }
|
|
447
|
+
// },
|
|
448
|
+
// {
|
|
449
|
+
// projection: { _id: 1 }
|
|
450
|
+
// }
|
|
451
|
+
// )
|
|
452
|
+
// .lean<{ _id: ObjectId }>()
|
|
453
|
+
// .exec();
|
|
454
|
+
// if (doc === null) {
|
|
455
|
+
// throw new factory.errors.NotFound(
|
|
456
|
+
// this.transactionModel.modelName,
|
|
457
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
458
|
+
// );
|
|
459
|
+
// }
|
|
460
|
+
// }
|
|
461
|
+
// /**
|
|
462
|
+
// * 取引期限変更
|
|
463
|
+
// */
|
|
464
|
+
// public async updateExpires<T extends factory.transactionType>(params: {
|
|
465
|
+
// typeOf: T;
|
|
466
|
+
// id: string;
|
|
467
|
+
// expires: Date;
|
|
468
|
+
// }): Promise<void> {
|
|
469
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
470
|
+
// {
|
|
471
|
+
// _id: { $eq: params.id },
|
|
472
|
+
// typeOf: { $eq: params.typeOf },
|
|
473
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
474
|
+
// },
|
|
475
|
+
// {
|
|
476
|
+
// $set: {
|
|
477
|
+
// expires: params.expires
|
|
478
|
+
// }
|
|
479
|
+
// },
|
|
480
|
+
// {
|
|
481
|
+
// projection: { _id: 1 }
|
|
482
|
+
// }
|
|
483
|
+
// )
|
|
484
|
+
// .lean<{ _id: ObjectId }>()
|
|
485
|
+
// .exec();
|
|
486
|
+
// if (doc === null) {
|
|
487
|
+
// throw new factory.errors.NotFound(
|
|
488
|
+
// this.transactionModel.modelName,
|
|
489
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
490
|
+
// );
|
|
491
|
+
// }
|
|
492
|
+
// }
|
|
493
|
+
// /**
|
|
494
|
+
// * 取引オブジェクトを更新
|
|
495
|
+
// * 注文名称など
|
|
496
|
+
// */
|
|
497
|
+
// public async updateObject<T extends factory.transactionType>(params: {
|
|
498
|
+
// typeOf: T;
|
|
499
|
+
// id: string;
|
|
500
|
+
// object?: {
|
|
501
|
+
// name?: string;
|
|
502
|
+
// };
|
|
503
|
+
// }): Promise<void> {
|
|
504
|
+
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
505
|
+
// {
|
|
506
|
+
// _id: { $eq: params.id },
|
|
507
|
+
// typeOf: { $eq: params.typeOf },
|
|
508
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
509
|
+
// },
|
|
510
|
+
// {
|
|
511
|
+
// $set: {
|
|
512
|
+
// ...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
|
|
513
|
+
// }
|
|
514
|
+
// },
|
|
515
|
+
// {
|
|
516
|
+
// projection: { _id: 1 }
|
|
517
|
+
// }
|
|
518
|
+
// )
|
|
519
|
+
// .lean<{ _id: ObjectId }>()
|
|
520
|
+
// .exec();
|
|
521
|
+
// if (doc === null) {
|
|
522
|
+
// throw new factory.errors.NotFound(
|
|
523
|
+
// this.transactionModel.modelName,
|
|
524
|
+
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
525
|
+
// );
|
|
526
|
+
// }
|
|
527
|
+
// }
|
|
495
528
|
/**
|
|
496
529
|
* 取引を確定する
|
|
497
530
|
*/
|
|
498
|
-
async
|
|
531
|
+
async confirmNoPlaceOrder(params) {
|
|
499
532
|
const endDate = new Date();
|
|
500
533
|
const doc = await this.transactionModel.findOneAndUpdate({
|
|
501
534
|
_id: { $eq: params.id },
|
|
@@ -516,7 +549,7 @@ class TransactionRepo {
|
|
|
516
549
|
.exec();
|
|
517
550
|
// NotFoundであれば取引状態確認
|
|
518
551
|
if (doc === null) {
|
|
519
|
-
const { expires, status } = await this.
|
|
552
|
+
const { expires, status } = await this.projectFieldsByIdNoPlaceOrder({ typeOf: params.typeOf, id: params.id }, ['expires', 'status']);
|
|
520
553
|
if (status === factory.transactionStatusType.Confirmed) {
|
|
521
554
|
// すでに確定済の場合スルー
|
|
522
555
|
}
|
|
@@ -864,7 +897,7 @@ class TransactionRepo {
|
|
|
864
897
|
/**
|
|
865
898
|
* 取引を中止する
|
|
866
899
|
*/
|
|
867
|
-
async
|
|
900
|
+
async cancelNoPlaceOrder(params) {
|
|
868
901
|
const endDate = new Date();
|
|
869
902
|
// 進行中ステータスの取引を中止する
|
|
870
903
|
const doc = await this.transactionModel.findOneAndUpdate({
|
|
@@ -882,7 +915,7 @@ class TransactionRepo {
|
|
|
882
915
|
.exec();
|
|
883
916
|
// NotFoundであれば取引状態確認
|
|
884
917
|
if (doc === null) {
|
|
885
|
-
const { status } = await this.
|
|
918
|
+
const { status } = await this.projectFieldsByIdNoPlaceOrder(params, ['status']);
|
|
886
919
|
if (status === factory.transactionStatusType.Canceled) {
|
|
887
920
|
// すでに中止済の場合スルー
|
|
888
921
|
}
|
|
@@ -902,7 +935,7 @@ class TransactionRepo {
|
|
|
902
935
|
status: factory.transactionStatusType.Canceled
|
|
903
936
|
});
|
|
904
937
|
}
|
|
905
|
-
async
|
|
938
|
+
async countMoneyTransfer(params) {
|
|
906
939
|
const { limit } = params;
|
|
907
940
|
const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
908
941
|
const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
@@ -916,7 +949,7 @@ class TransactionRepo {
|
|
|
916
949
|
/**
|
|
917
950
|
* 取引を検索する
|
|
918
951
|
*/
|
|
919
|
-
async
|
|
952
|
+
async findMoneyTransferTransactions(params) {
|
|
920
953
|
const { inclusion } = params;
|
|
921
954
|
const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
922
955
|
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
@@ -947,52 +980,80 @@ class TransactionRepo {
|
|
|
947
980
|
query.limit(params.limit)
|
|
948
981
|
.skip(params.limit * (page - 1));
|
|
949
982
|
}
|
|
950
|
-
/* istanbul ignore else */
|
|
951
983
|
if (params.sort?.startDate !== undefined) {
|
|
952
984
|
query.sort({ startDate: params.sort.startDate });
|
|
953
985
|
}
|
|
954
986
|
// const explainResult = await (<any>query).explain();
|
|
955
987
|
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
956
988
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
957
|
-
.lean() // 2024-08-26~
|
|
958
|
-
.exec();
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* 特定の進行中取引を更新する(汎用)
|
|
962
|
-
*/
|
|
963
|
-
async findByIdAndUpdateInProgress(params) {
|
|
964
|
-
await this.transactionModel.findOneAndUpdate({
|
|
965
|
-
_id: { $eq: params.id },
|
|
966
|
-
status: { $eq: factory.transactionStatusType.InProgress }
|
|
967
|
-
}, params.update, {
|
|
968
|
-
// new: true,
|
|
969
|
-
projection: { _id: 1 }
|
|
970
|
-
})
|
|
971
989
|
.lean()
|
|
972
|
-
.exec()
|
|
973
|
-
.then((doc) => {
|
|
974
|
-
if (doc === null) {
|
|
975
|
-
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
async saveOrderNumberIfNotExist(params) {
|
|
980
|
-
await this.transactionModel.updateOne({
|
|
981
|
-
_id: { $eq: params.id },
|
|
982
|
-
status: { $eq: factory.transactionStatusType.InProgress },
|
|
983
|
-
'object.orderNumber': { $exists: false }
|
|
984
|
-
}, { 'object.orderNumber': params.orderNumber })
|
|
985
|
-
.exec();
|
|
986
|
-
}
|
|
987
|
-
async saveConfirmationNumberIfNotExist(params) {
|
|
988
|
-
await this.transactionModel.updateOne({
|
|
989
|
-
_id: { $eq: params.id },
|
|
990
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
991
|
-
status: { $in: params.status.$in },
|
|
992
|
-
'object.confirmationNumber': { $exists: false }
|
|
993
|
-
}, { $set: { 'object.confirmationNumber': params.confirmationNumber } })
|
|
994
990
|
.exec();
|
|
995
991
|
}
|
|
992
|
+
// /**
|
|
993
|
+
// * 特定の進行中取引を更新する(汎用)
|
|
994
|
+
// */
|
|
995
|
+
// public async findByIdAndUpdateInProgress(params: {
|
|
996
|
+
// id: string;
|
|
997
|
+
// update: {
|
|
998
|
+
// $set?: { 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl };
|
|
999
|
+
// // $unset?: any;
|
|
1000
|
+
// // $pull?: any;
|
|
1001
|
+
// // $push?: any;
|
|
1002
|
+
// };
|
|
1003
|
+
// }): Promise<void> {
|
|
1004
|
+
// await this.transactionModel.findOneAndUpdate(
|
|
1005
|
+
// {
|
|
1006
|
+
// _id: { $eq: params.id },
|
|
1007
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
1008
|
+
// },
|
|
1009
|
+
// params.update,
|
|
1010
|
+
// {
|
|
1011
|
+
// // new: true,
|
|
1012
|
+
// projection: { _id: 1 }
|
|
1013
|
+
// }
|
|
1014
|
+
// )
|
|
1015
|
+
// .lean<{ _id: ObjectId }>()
|
|
1016
|
+
// .exec()
|
|
1017
|
+
// .then((doc) => {
|
|
1018
|
+
// if (doc === null) {
|
|
1019
|
+
// throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
1020
|
+
// }
|
|
1021
|
+
// });
|
|
1022
|
+
// }
|
|
1023
|
+
// /**
|
|
1024
|
+
// * 進行中取引のobjectに注文番号を保管する
|
|
1025
|
+
// */
|
|
1026
|
+
// public async saveOrderNumberIfNotExist(params: {
|
|
1027
|
+
// id: string;
|
|
1028
|
+
// orderNumber: string;
|
|
1029
|
+
// }): Promise<{ modifiedCount: number }> {
|
|
1030
|
+
// const result = await this.transactionModel.updateOne(
|
|
1031
|
+
// {
|
|
1032
|
+
// _id: { $eq: params.id },
|
|
1033
|
+
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
1034
|
+
// 'object.orderNumber': { $exists: false }
|
|
1035
|
+
// },
|
|
1036
|
+
// { $set: { 'object.orderNumber': params.orderNumber } }
|
|
1037
|
+
// )
|
|
1038
|
+
// .exec();
|
|
1039
|
+
// return { modifiedCount: result.modifiedCount };
|
|
1040
|
+
// }
|
|
1041
|
+
// public async saveConfirmationNumberIfNotExist(params: {
|
|
1042
|
+
// id: string;
|
|
1043
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
1044
|
+
// confirmationNumber: string;
|
|
1045
|
+
// }): Promise<void> {
|
|
1046
|
+
// await this.transactionModel.updateOne(
|
|
1047
|
+
// {
|
|
1048
|
+
// _id: { $eq: params.id },
|
|
1049
|
+
// // status: { $eq: factory.transactionStatusType.InProgress },
|
|
1050
|
+
// status: { $in: params.status.$in },
|
|
1051
|
+
// 'object.confirmationNumber': { $exists: false }
|
|
1052
|
+
// },
|
|
1053
|
+
// { $set: { 'object.confirmationNumber': params.confirmationNumber } }
|
|
1054
|
+
// )
|
|
1055
|
+
// .exec();
|
|
1056
|
+
// }
|
|
996
1057
|
async findByIdAndDelete(params) {
|
|
997
1058
|
await this.transactionModel.findByIdAndDelete(params.id)
|
|
998
1059
|
.exec();
|