@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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ReturnOrderRepo = void 0;
|
|
27
|
+
// import { transactionEventEmitter } from '../../eventEmitter/transaction';
|
|
28
|
+
const factory = __importStar(require("../../factory"));
|
|
29
|
+
const settings_1 = require("../../settings");
|
|
30
|
+
const transaction_1 = require("../mongoose/schemas/transaction");
|
|
31
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
32
|
+
'project',
|
|
33
|
+
'status',
|
|
34
|
+
'typeOf',
|
|
35
|
+
'agent',
|
|
36
|
+
'recipient',
|
|
37
|
+
'seller',
|
|
38
|
+
'error',
|
|
39
|
+
'result',
|
|
40
|
+
'object',
|
|
41
|
+
'expires',
|
|
42
|
+
'startDate',
|
|
43
|
+
'endDate',
|
|
44
|
+
'tasksExportAction',
|
|
45
|
+
'potentialActions',
|
|
46
|
+
// 'instrument'
|
|
47
|
+
];
|
|
48
|
+
// type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
|
|
49
|
+
// export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
|
|
50
|
+
// type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
|
|
51
|
+
// export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
|
|
52
|
+
/**
|
|
53
|
+
* 返品取引リポジトリ
|
|
54
|
+
*/
|
|
55
|
+
class ReturnOrderRepo {
|
|
56
|
+
transactionModel;
|
|
57
|
+
constructor(connection) {
|
|
58
|
+
this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
|
|
59
|
+
}
|
|
60
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
61
|
+
if (params.typeOf !== factory.transactionType.ReturnOrder) {
|
|
62
|
+
throw new factory.errors.Argument('typeOf', `must be ${factory.transactionType.ReturnOrder}`);
|
|
63
|
+
}
|
|
64
|
+
const andConditions = [];
|
|
65
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
66
|
+
if (typeof projectIdEq === 'string') {
|
|
67
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
68
|
+
}
|
|
69
|
+
if (typeof params.typeOf === 'string') {
|
|
70
|
+
andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
71
|
+
}
|
|
72
|
+
if (params.startFrom !== undefined) {
|
|
73
|
+
andConditions.push({
|
|
74
|
+
startDate: { $gte: params.startFrom }
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (params.startThrough !== undefined) {
|
|
78
|
+
andConditions.push({
|
|
79
|
+
startDate: { $lte: params.startThrough }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (params.endFrom !== undefined) {
|
|
83
|
+
andConditions.push({
|
|
84
|
+
endDate: {
|
|
85
|
+
$exists: true,
|
|
86
|
+
$gte: params.endFrom
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (params.endThrough !== undefined) {
|
|
91
|
+
andConditions.push({
|
|
92
|
+
endDate: {
|
|
93
|
+
$exists: true,
|
|
94
|
+
$lt: params.endThrough
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(params.ids)) {
|
|
99
|
+
andConditions.push({
|
|
100
|
+
_id: { $in: params.ids }
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(params.statuses)) {
|
|
104
|
+
andConditions.push({ status: { $in: params.statuses } });
|
|
105
|
+
}
|
|
106
|
+
const statusIn = params.status?.$in;
|
|
107
|
+
if (Array.isArray(statusIn)) {
|
|
108
|
+
andConditions.push({ status: { $in: statusIn } });
|
|
109
|
+
}
|
|
110
|
+
if (params.agent !== undefined) {
|
|
111
|
+
if (params.agent.typeOf !== undefined) {
|
|
112
|
+
andConditions.push({
|
|
113
|
+
'agent.typeOf': {
|
|
114
|
+
$exists: true,
|
|
115
|
+
$eq: params.agent.typeOf
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(params.agent.ids)) {
|
|
120
|
+
andConditions.push({
|
|
121
|
+
'agent.id': {
|
|
122
|
+
$exists: true,
|
|
123
|
+
$in: params.agent.ids
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(params.agent.identifiers)) {
|
|
128
|
+
andConditions.push({
|
|
129
|
+
'agent.identifier': {
|
|
130
|
+
$exists: true,
|
|
131
|
+
$in: params.agent.identifiers
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
137
|
+
if (Array.isArray(tasksExportActionStatusIn)) {
|
|
138
|
+
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
139
|
+
}
|
|
140
|
+
const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
141
|
+
if (typeof tasksExportActionStatusEq === 'string') {
|
|
142
|
+
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
|
|
143
|
+
}
|
|
144
|
+
if (params.object !== undefined) {
|
|
145
|
+
if (params.object.order !== undefined) {
|
|
146
|
+
if (Array.isArray(params.object.order.orderNumbers)) {
|
|
147
|
+
andConditions.push({
|
|
148
|
+
'object.order.orderNumber': {
|
|
149
|
+
$exists: true,
|
|
150
|
+
$in: params.object.order.orderNumbers
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return andConditions;
|
|
157
|
+
}
|
|
158
|
+
async countReturnOrder(params) {
|
|
159
|
+
const { limit } = params;
|
|
160
|
+
const conditions = ReturnOrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
161
|
+
const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
162
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
163
|
+
query.limit(limit);
|
|
164
|
+
}
|
|
165
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
166
|
+
.exec();
|
|
167
|
+
return { count };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 取引を検索する
|
|
171
|
+
*/
|
|
172
|
+
async findReturnOrderTransactions(params) {
|
|
173
|
+
const { inclusion } = params;
|
|
174
|
+
const conditions = ReturnOrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
175
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
176
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
177
|
+
positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(key));
|
|
178
|
+
}
|
|
179
|
+
const projection = {
|
|
180
|
+
_id: 0,
|
|
181
|
+
id: { $toString: '$_id' },
|
|
182
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
183
|
+
};
|
|
184
|
+
// let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
|
|
185
|
+
// if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
186
|
+
// params.inclusion.forEach((field) => {
|
|
187
|
+
// projection[field] = 1;
|
|
188
|
+
// });
|
|
189
|
+
// } else {
|
|
190
|
+
// projection = {
|
|
191
|
+
// __v: 0,
|
|
192
|
+
// createdAt: 0,
|
|
193
|
+
// updatedAt: 0
|
|
194
|
+
// };
|
|
195
|
+
// }
|
|
196
|
+
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
197
|
+
.select(projection);
|
|
198
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
199
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
200
|
+
query.limit(params.limit)
|
|
201
|
+
.skip(params.limit * (page - 1));
|
|
202
|
+
}
|
|
203
|
+
if (params.sort?.startDate !== undefined) {
|
|
204
|
+
query.sort({ startDate: params.sort.startDate });
|
|
205
|
+
}
|
|
206
|
+
// const explainResult = await (<any>query).explain();
|
|
207
|
+
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
208
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
209
|
+
.lean()
|
|
210
|
+
.exec();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.ReturnOrderRepo = ReturnOrderRepo;
|
|
@@ -19,7 +19,7 @@ export interface IAggregatePlaceOrder {
|
|
|
19
19
|
statuses: IStatus[];
|
|
20
20
|
}
|
|
21
21
|
type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
|
|
22
|
-
export type
|
|
22
|
+
export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
|
|
23
23
|
type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
|
|
24
24
|
export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
|
|
25
25
|
/**
|
|
@@ -28,80 +28,29 @@ export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.
|
|
|
28
28
|
export declare class TransactionRepo {
|
|
29
29
|
private readonly transactionModel;
|
|
30
30
|
constructor(connection: Connection);
|
|
31
|
-
static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType>): FilterQuery<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction>[];
|
|
31
|
+
static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType.MoneyTransfer>): FilterQuery<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction>[];
|
|
32
32
|
/**
|
|
33
33
|
* 取引を開始する
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
startNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: factory.transaction.IStartParams<T>): Promise<IStartedTransaction>;
|
|
36
36
|
/**
|
|
37
37
|
* 特定取引検索
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
projectFieldsByIdNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
|
|
40
40
|
typeOf: T;
|
|
41
41
|
id: string;
|
|
42
42
|
}, inclusion: IKeyOfProjection<T>[]): Promise<factory.transaction.ITransaction<T>>;
|
|
43
43
|
/**
|
|
44
44
|
* 進行中の取引を取得する
|
|
45
45
|
*/
|
|
46
|
-
|
|
47
|
-
typeOf:
|
|
48
|
-
id: string;
|
|
49
|
-
}, inclusion: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
|
|
50
|
-
/**
|
|
51
|
-
* 進行中取引に保管された採用済決済方法を検索する
|
|
52
|
-
*/
|
|
53
|
-
findInProgressPaymentMethodId(params: {
|
|
54
|
-
id: string;
|
|
55
|
-
}): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* 取引の注文番号を検索する
|
|
58
|
-
*/
|
|
59
|
-
findInProgressOrderNumberById(params: {
|
|
60
|
-
id: string;
|
|
61
|
-
}): Promise<string | undefined>;
|
|
62
|
-
/**
|
|
63
|
-
* 取引の確認番号を検索する
|
|
64
|
-
*/
|
|
65
|
-
findInProgressConfirmationNumberById(params: {
|
|
66
|
-
id: string;
|
|
67
|
-
status: {
|
|
68
|
-
$in: factory.transactionStatusType[];
|
|
69
|
-
};
|
|
70
|
-
}): Promise<string | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* 取引進行者プロフィールを更新
|
|
73
|
-
*/
|
|
74
|
-
updateAgent<T extends factory.transactionType>(params: {
|
|
75
|
-
typeOf: T;
|
|
46
|
+
findMoneyTransferInProgressById(params: {
|
|
47
|
+
typeOf: factory.transactionType.MoneyTransfer;
|
|
76
48
|
id: string;
|
|
77
|
-
|
|
78
|
-
object?: {
|
|
79
|
-
customer?: factory.order.ICustomer;
|
|
80
|
-
};
|
|
81
|
-
}): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* 取引期限変更
|
|
84
|
-
*/
|
|
85
|
-
updateExpires<T extends factory.transactionType>(params: {
|
|
86
|
-
typeOf: T;
|
|
87
|
-
id: string;
|
|
88
|
-
expires: Date;
|
|
89
|
-
}): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* 取引オブジェクトを更新
|
|
92
|
-
* 注文名称など
|
|
93
|
-
*/
|
|
94
|
-
updateObject<T extends factory.transactionType>(params: {
|
|
95
|
-
typeOf: T;
|
|
96
|
-
id: string;
|
|
97
|
-
object?: {
|
|
98
|
-
name?: string;
|
|
99
|
-
};
|
|
100
|
-
}): Promise<void>;
|
|
49
|
+
}, inclusion: IKeyOfProjection<factory.transactionType.MoneyTransfer>[]): Promise<IMoneyTransferTransactionInProgress>;
|
|
101
50
|
/**
|
|
102
51
|
* 取引を確定する
|
|
103
52
|
*/
|
|
104
|
-
|
|
53
|
+
confirmNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
|
|
105
54
|
typeOf: T;
|
|
106
55
|
id: string;
|
|
107
56
|
result: factory.transaction.IResult<T>;
|
|
@@ -195,43 +144,21 @@ export declare class TransactionRepo {
|
|
|
195
144
|
/**
|
|
196
145
|
* 取引を中止する
|
|
197
146
|
*/
|
|
198
|
-
|
|
147
|
+
cancelNoPlaceOrder<T extends factory.transactionType.MoneyTransfer | factory.transactionType.ReturnOrder>(params: {
|
|
199
148
|
typeOf: T;
|
|
200
149
|
id: string;
|
|
201
150
|
}): Promise<void>;
|
|
202
|
-
|
|
151
|
+
countMoneyTransfer<T extends factory.transactionType.MoneyTransfer>(params: factory.transaction.ISearchConditions<T>): Promise<{
|
|
203
152
|
count: number;
|
|
204
153
|
}>;
|
|
205
154
|
/**
|
|
206
155
|
* 取引を検索する
|
|
207
156
|
*/
|
|
208
|
-
|
|
157
|
+
findMoneyTransferTransactions<T extends factory.transactionType.MoneyTransfer, F extends IKeyOfProjection<T>>(params: factory.transaction.ISearchConditions<T> & {
|
|
209
158
|
inclusion: F[];
|
|
210
159
|
}): Promise<(Pick<factory.transaction.ITransaction<T>, F> & {
|
|
211
160
|
id: string;
|
|
212
161
|
})[]>;
|
|
213
|
-
/**
|
|
214
|
-
* 特定の進行中取引を更新する(汎用)
|
|
215
|
-
*/
|
|
216
|
-
findByIdAndUpdateInProgress(params: {
|
|
217
|
-
id: string;
|
|
218
|
-
update: {
|
|
219
|
-
$set?: {
|
|
220
|
-
'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
}): Promise<void>;
|
|
224
|
-
saveOrderNumberIfNotExist(params: {
|
|
225
|
-
id: string;
|
|
226
|
-
orderNumber: string;
|
|
227
|
-
}): Promise<void>;
|
|
228
|
-
saveConfirmationNumberIfNotExist(params: {
|
|
229
|
-
id: string;
|
|
230
|
-
status: {
|
|
231
|
-
$in: factory.transactionStatusType[];
|
|
232
|
-
};
|
|
233
|
-
confirmationNumber: string;
|
|
234
|
-
}): Promise<void>;
|
|
235
162
|
findByIdAndDelete(params: {
|
|
236
163
|
id: string;
|
|
237
164
|
}): Promise<void>;
|