@chevre/domain 24.0.0-alpha.25 → 24.0.0-alpha.27
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/action/acceptPay.d.ts +18 -0
- package/lib/chevre/repo/action/acceptPay.js +45 -30
- package/lib/chevre/repo/action/actionProcess.d.ts +30 -0
- package/lib/chevre/repo/action/actionProcess.js +496 -1
- package/lib/chevre/repo/action/authorizeInvoice.d.ts +14 -1
- package/lib/chevre/repo/action/authorizeInvoice.js +36 -0
- package/lib/chevre/repo/action/authorizePaymentMethod.d.ts +10 -1
- package/lib/chevre/repo/action/authorizePaymentMethod.js +10 -48
- package/lib/chevre/repo/action.d.ts +0 -1
- package/lib/chevre/repo/action.js +3 -509
- package/lib/chevre/service/order/sendOrder.js +0 -1
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +5 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +12 -8
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +33 -16
- package/lib/chevre/service/payment/any/authorize.d.ts +2 -0
- package/lib/chevre/service/payment/any/authorize.js +8 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +9 -8
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +15 -7
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +2 -0
- package/lib/chevre/service/task/voidPayment.js +2 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export type IAcceptPayAction = factory.action.accept.pay.IAction;
|
|
|
7
7
|
export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAction, IActionRecipe<factory.recipe.RecipeCategory.publishPaymentUrl>> {
|
|
8
8
|
/**
|
|
9
9
|
* 注文取引から検索する
|
|
10
|
+
* 件数はlimitされない
|
|
10
11
|
*/
|
|
11
12
|
findAcceptActionsByPurpose(params: {
|
|
12
13
|
project: {
|
|
@@ -16,4 +17,21 @@ export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAct
|
|
|
16
17
|
id: string;
|
|
17
18
|
};
|
|
18
19
|
}, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
|
|
20
|
+
/**
|
|
21
|
+
* 決済取引番号から完了済の決済採用アクションを参照する
|
|
22
|
+
*/
|
|
23
|
+
findCompletedAcceptActionsByTransactionNumber(params: {
|
|
24
|
+
project: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
purpose: {
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
object: {
|
|
31
|
+
/**
|
|
32
|
+
* 決済取引番号
|
|
33
|
+
*/
|
|
34
|
+
transactionNumber: string;
|
|
35
|
+
};
|
|
36
|
+
}, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
|
|
19
37
|
}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.AcceptPayActionRepo = void 0;
|
|
27
27
|
const factory = __importStar(require("../../factory"));
|
|
28
|
-
|
|
28
|
+
// import { MONGO_MAX_TIME_MS } from '../../settings';
|
|
29
29
|
// import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
|
|
30
30
|
// import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
|
|
31
31
|
const actionProcess_1 = require("./actionProcess");
|
|
@@ -35,38 +35,53 @@ const actionProcess_1 = require("./actionProcess");
|
|
|
35
35
|
class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
36
36
|
/**
|
|
37
37
|
* 注文取引から検索する
|
|
38
|
+
* 件数はlimitされない
|
|
38
39
|
*/
|
|
39
40
|
async findAcceptActionsByPurpose(params, inclusion) {
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
58
|
-
// query.limit(params.limit)
|
|
59
|
-
// .skip(params.limit * (page - 1));
|
|
41
|
+
return this.findAnyActions({
|
|
42
|
+
project: { id: { $eq: params.project.id } },
|
|
43
|
+
typeOf: { $eq: factory.actionType.AcceptAction }, // 採用アクション
|
|
44
|
+
purpose: { id: { $in: [params.purpose.id] } },
|
|
45
|
+
object: {
|
|
46
|
+
typeOf: { $eq: factory.assetTransactionType.Pay } // 対象が決済取引
|
|
47
|
+
}
|
|
48
|
+
}, inclusion);
|
|
49
|
+
// const andConditions: FilterQuery<IAcceptPayAction>[] = [
|
|
50
|
+
// { typeOf: { $eq: factory.actionType.AcceptAction } },
|
|
51
|
+
// { 'project.id': { $eq: params.project.id } },
|
|
52
|
+
// { 'object.typeOf': { $exists: true, $eq: factory.assetTransactionType.Pay } },
|
|
53
|
+
// { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
|
|
54
|
+
// ];
|
|
55
|
+
// let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
|
|
56
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
57
|
+
// positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
60
58
|
// }
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
return query.setOptions({ maxTimeMS:
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
// const projection: ProjectionType<IAcceptPayAction> = {
|
|
60
|
+
// _id: 0,
|
|
61
|
+
// id: { $toString: '$_id' },
|
|
62
|
+
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
63
|
+
// };
|
|
64
|
+
// const query = this.actionModel.find({ $and: andConditions }, projection);
|
|
65
|
+
// return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
66
|
+
// .lean<IAcceptPayAction[]>()
|
|
67
|
+
// .exec();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 決済取引番号から完了済の決済採用アクションを参照する
|
|
71
|
+
*/
|
|
72
|
+
async findCompletedAcceptActionsByTransactionNumber(params, inclusion) {
|
|
73
|
+
return this.findAnyActions({
|
|
74
|
+
limit: 1, // ひとまず1つだけでよい
|
|
75
|
+
page: 1,
|
|
76
|
+
project: { id: { $eq: params.project.id } },
|
|
77
|
+
typeOf: { $eq: factory.actionType.AcceptAction }, // 採用アクション
|
|
78
|
+
actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
|
|
79
|
+
purpose: { id: { $in: [params.purpose.id] } },
|
|
80
|
+
object: {
|
|
81
|
+
transactionNumber: { $eq: params.object.transactionNumber },
|
|
82
|
+
typeOf: { $eq: factory.assetTransactionType.Pay } // 対象が決済取引
|
|
83
|
+
}
|
|
84
|
+
}, inclusion);
|
|
70
85
|
}
|
|
71
86
|
}
|
|
72
87
|
exports.AcceptPayActionRepo = AcceptPayActionRepo;
|
|
@@ -39,6 +39,7 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
|
|
|
39
39
|
protected readonly actionModel: IActionModel;
|
|
40
40
|
protected readonly actionRecipeModel: IActionRecipeModel;
|
|
41
41
|
constructor(connection: Connection);
|
|
42
|
+
static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): any[];
|
|
42
43
|
/**
|
|
43
44
|
* アクション開始
|
|
44
45
|
*/
|
|
@@ -111,5 +112,34 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
|
|
|
111
112
|
};
|
|
112
113
|
}): Promise<Pick<TAction, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
|
|
113
114
|
private findActionStatusById;
|
|
115
|
+
/**
|
|
116
|
+
* 汎用アクション検索
|
|
117
|
+
* 継承クラスから呼ぶ想定
|
|
118
|
+
*/
|
|
119
|
+
protected findAnyActions(params: factory.action.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<TAction[]>;
|
|
120
|
+
/**
|
|
121
|
+
* 取引に対する汎用アクション検索
|
|
122
|
+
* 継承クラスから呼ぶ想定
|
|
123
|
+
* 件数はlimitされない
|
|
124
|
+
*/
|
|
125
|
+
protected findAnyActionsByPurpose<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction>(params: {
|
|
126
|
+
typeOf?: T;
|
|
127
|
+
purpose: {
|
|
128
|
+
typeOf: factory.transactionType;
|
|
129
|
+
id: string;
|
|
130
|
+
};
|
|
131
|
+
object?: {
|
|
132
|
+
typeOf?: {
|
|
133
|
+
$eq?: factory.action.authorize.offer.eventService.ObjectType.SeatReservation | factory.action.authorize.paymentMethod.any.ResultType.Payment | factory.offerType.AggregateOffer;
|
|
134
|
+
};
|
|
135
|
+
paymentMethodId?: {
|
|
136
|
+
$eq?: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
actionStatus?: {
|
|
140
|
+
$eq?: factory.actionStatusType.CompletedActionStatus;
|
|
141
|
+
};
|
|
142
|
+
sort?: factory.action.ISortOrder;
|
|
143
|
+
}): Promise<TAction[]>;
|
|
114
144
|
protected upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
115
145
|
}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ActionProcessRepo = exports.AVAILABLE_PROJECT_FIELDS = void 0;
|
|
27
27
|
const factory = __importStar(require("../../factory"));
|
|
28
|
-
|
|
28
|
+
const settings_1 = require("../../settings");
|
|
29
29
|
const action_1 = require("../mongoose/schemas/action");
|
|
30
30
|
const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
|
|
31
31
|
exports.AVAILABLE_PROJECT_FIELDS = [
|
|
@@ -65,6 +65,412 @@ class ActionProcessRepo {
|
|
|
65
65
|
this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
|
|
66
66
|
this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
|
|
67
67
|
}
|
|
68
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
69
|
+
const andConditions = [];
|
|
70
|
+
const idIn = params.id?.$in;
|
|
71
|
+
if (Array.isArray(idIn)) {
|
|
72
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
73
|
+
}
|
|
74
|
+
const idNin = params.id?.$nin;
|
|
75
|
+
if (Array.isArray(idNin)) {
|
|
76
|
+
andConditions.push({ _id: { $nin: idNin } });
|
|
77
|
+
}
|
|
78
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
79
|
+
if (typeof projectIdEq === 'string') {
|
|
80
|
+
andConditions.push({
|
|
81
|
+
'project.id': {
|
|
82
|
+
$eq: projectIdEq
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const agentTypeOfIn = params.agent?.typeOf?.$in;
|
|
87
|
+
if (Array.isArray(agentTypeOfIn)) {
|
|
88
|
+
andConditions.push({
|
|
89
|
+
'agent.typeOf': {
|
|
90
|
+
$exists: true,
|
|
91
|
+
$in: agentTypeOfIn
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const agentIdIn = params.agent?.id?.$in;
|
|
96
|
+
if (Array.isArray(agentIdIn)) {
|
|
97
|
+
andConditions.push({
|
|
98
|
+
'agent.id': {
|
|
99
|
+
$exists: true,
|
|
100
|
+
$in: agentIdIn
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const instrumentTransactionNumberEq = params.instrument?.transactionNumber?.$eq;
|
|
105
|
+
if (typeof instrumentTransactionNumberEq === 'string') {
|
|
106
|
+
andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
|
|
107
|
+
}
|
|
108
|
+
const instrumentTypeOfEq = params.instrument?.typeOf?.$eq;
|
|
109
|
+
if (typeof instrumentTypeOfEq === 'string') {
|
|
110
|
+
andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
|
|
111
|
+
}
|
|
112
|
+
const instrumentIdentifierEq = params.instrument?.identifier?.$eq;
|
|
113
|
+
if (typeof instrumentIdentifierEq === 'string') {
|
|
114
|
+
andConditions.push({ 'instrument.identifier': { $exists: true, $eq: instrumentIdentifierEq } });
|
|
115
|
+
}
|
|
116
|
+
const instrumentIdEq = params.instrument?.id?.$eq;
|
|
117
|
+
if (typeof instrumentIdEq === 'string') {
|
|
118
|
+
andConditions.push({ 'instrument.id': { $exists: true, $eq: instrumentIdEq } });
|
|
119
|
+
}
|
|
120
|
+
const instrumentOrderNumberEq = params.instrument?.orderNumber?.$eq;
|
|
121
|
+
if (typeof instrumentOrderNumberEq === 'string') {
|
|
122
|
+
andConditions.push({ 'instrument.orderNumber': { $exists: true, $eq: instrumentOrderNumberEq } });
|
|
123
|
+
}
|
|
124
|
+
const locationIdEq = params.location?.id?.$eq;
|
|
125
|
+
if (typeof locationIdEq === 'string') {
|
|
126
|
+
andConditions.push({
|
|
127
|
+
'location.id': {
|
|
128
|
+
$exists: true,
|
|
129
|
+
$eq: locationIdEq
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const locationIdentifierEq = params.location?.identifier?.$eq;
|
|
134
|
+
if (typeof locationIdentifierEq === 'string') {
|
|
135
|
+
andConditions.push({
|
|
136
|
+
'location.identifier': {
|
|
137
|
+
$exists: true,
|
|
138
|
+
$eq: locationIdentifierEq
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const objectMovieTicketsIdentifierEq = params.object?.movieTickets?.identifier?.$eq;
|
|
143
|
+
if (typeof objectMovieTicketsIdentifierEq === 'string') {
|
|
144
|
+
andConditions.push({
|
|
145
|
+
'object.movieTickets.identifier': {
|
|
146
|
+
$exists: true,
|
|
147
|
+
$eq: objectMovieTicketsIdentifierEq
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
|
|
152
|
+
if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
|
|
153
|
+
andConditions.push({
|
|
154
|
+
'object.movieTickets.serviceOutput.reservationFor.id': {
|
|
155
|
+
$exists: true,
|
|
156
|
+
$eq: objectMovieTicketsServiceOutputReservationForIdEq
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
|
|
161
|
+
if (typeof objectPaymentMethodIdEq === 'string') {
|
|
162
|
+
andConditions.push({
|
|
163
|
+
'object.paymentMethodId': {
|
|
164
|
+
$exists: true,
|
|
165
|
+
$eq: objectPaymentMethodIdEq
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const objectObjectPaymentMethodIdEq = params.object?.object?.paymentMethodId?.$eq;
|
|
170
|
+
if (typeof objectObjectPaymentMethodIdEq === 'string') {
|
|
171
|
+
andConditions.push({
|
|
172
|
+
'object.object.paymentMethodId': {
|
|
173
|
+
$exists: true,
|
|
174
|
+
$eq: objectObjectPaymentMethodIdEq
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
|
|
179
|
+
if (typeof objectReservationForIdEq === 'string') {
|
|
180
|
+
andConditions.push({
|
|
181
|
+
'object.reservationFor.id': {
|
|
182
|
+
$exists: true,
|
|
183
|
+
$eq: objectReservationForIdEq
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
|
|
188
|
+
if (typeof objectReservationNumberEq === 'string') {
|
|
189
|
+
andConditions.push({
|
|
190
|
+
'object.reservationNumber': {
|
|
191
|
+
$exists: true,
|
|
192
|
+
$eq: objectReservationNumberEq
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const objectReservationNumberIn = params.object?.reservationNumber?.$in;
|
|
197
|
+
if (Array.isArray(objectReservationNumberIn)) {
|
|
198
|
+
andConditions.push({
|
|
199
|
+
'object.reservationNumber': {
|
|
200
|
+
$exists: true,
|
|
201
|
+
$in: objectReservationNumberIn
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const objectPaymentMethodAccountIdEq = params.object?.paymentMethod?.accountId?.$eq;
|
|
206
|
+
if (typeof objectPaymentMethodAccountIdEq === 'string') {
|
|
207
|
+
andConditions.push({
|
|
208
|
+
'object.paymentMethod.accountId': {
|
|
209
|
+
$exists: true,
|
|
210
|
+
$eq: objectPaymentMethodAccountIdEq
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const objectPaymentMethodPaymentMethodIdEq = params.object?.paymentMethod?.paymentMethodId?.$eq;
|
|
215
|
+
if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
|
|
216
|
+
andConditions.push({
|
|
217
|
+
'object.paymentMethod.paymentMethodId': {
|
|
218
|
+
$exists: true,
|
|
219
|
+
$eq: objectPaymentMethodPaymentMethodIdEq
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const objectPaymentMethodPaymentMethodIdIn = params.object?.paymentMethod?.paymentMethodId?.$in;
|
|
224
|
+
if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
|
|
225
|
+
andConditions.push({
|
|
226
|
+
'object.paymentMethod.paymentMethodId': {
|
|
227
|
+
$exists: true,
|
|
228
|
+
$in: objectPaymentMethodPaymentMethodIdIn
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const objectPaymentMethodTypeOfEq = params.object?.paymentMethod?.typeOf?.$eq;
|
|
233
|
+
if (typeof objectPaymentMethodTypeOfEq === 'string') {
|
|
234
|
+
andConditions.push({
|
|
235
|
+
'object.paymentMethod.typeOf': {
|
|
236
|
+
$exists: true,
|
|
237
|
+
$eq: objectPaymentMethodTypeOfEq
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
242
|
+
if (typeof objectTypeOfEq === 'string') {
|
|
243
|
+
andConditions.push({
|
|
244
|
+
'object.typeOf': {
|
|
245
|
+
$exists: true,
|
|
246
|
+
$eq: objectTypeOfEq
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const objectTypeOfIn = params.object?.typeOf?.$in;
|
|
251
|
+
if (Array.isArray(objectTypeOfIn)) {
|
|
252
|
+
andConditions.push({
|
|
253
|
+
'object.typeOf': {
|
|
254
|
+
$exists: true,
|
|
255
|
+
$in: objectTypeOfIn
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const objectIdEq = params.object?.id?.$eq;
|
|
260
|
+
if (typeof objectIdEq === 'string') {
|
|
261
|
+
andConditions.push({
|
|
262
|
+
'object.id': {
|
|
263
|
+
$exists: true,
|
|
264
|
+
$eq: objectIdEq
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const objectIdIn = params.object?.id?.$in;
|
|
269
|
+
if (Array.isArray(objectIdIn)) {
|
|
270
|
+
andConditions.push({
|
|
271
|
+
'object.id': {
|
|
272
|
+
$exists: true,
|
|
273
|
+
$in: objectIdIn
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
const objectOrderNumberIn = params.object?.orderNumber?.$in;
|
|
278
|
+
if (Array.isArray(objectOrderNumberIn)) {
|
|
279
|
+
andConditions.push({
|
|
280
|
+
'object.orderNumber': {
|
|
281
|
+
$exists: true,
|
|
282
|
+
$in: objectOrderNumberIn
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const objectEventIdIn = params.object?.event?.id?.$in;
|
|
287
|
+
if (Array.isArray(objectEventIdIn)) {
|
|
288
|
+
andConditions.push({
|
|
289
|
+
'object.event.id': {
|
|
290
|
+
$exists: true,
|
|
291
|
+
$in: objectEventIdIn
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// discontinue(2024-06-18~)
|
|
296
|
+
// const objectAcceptedOfferSeatNumberIn =
|
|
297
|
+
// params.object?.acceptedOffer?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.seatNumber?.$in;
|
|
298
|
+
// if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
|
|
299
|
+
// andConditions.push({
|
|
300
|
+
// 'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
|
|
301
|
+
// $exists: true,
|
|
302
|
+
// $in: objectAcceptedOfferSeatNumberIn
|
|
303
|
+
// }
|
|
304
|
+
// });
|
|
305
|
+
// }
|
|
306
|
+
const objectTransactionNumberEq = params.object?.transactionNumber?.$eq;
|
|
307
|
+
if (typeof objectTransactionNumberEq === 'string') {
|
|
308
|
+
andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
|
|
309
|
+
}
|
|
310
|
+
if (typeof params.typeOf === 'string') {
|
|
311
|
+
andConditions.push({
|
|
312
|
+
typeOf: params.typeOf
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
const typeOfEq = params.typeOf?.$eq;
|
|
317
|
+
if (typeof typeOfEq === 'string') {
|
|
318
|
+
andConditions.push({
|
|
319
|
+
typeOf: { $eq: typeOfEq }
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const actionStatusIn = params.actionStatus?.$in;
|
|
324
|
+
if (Array.isArray(actionStatusIn)) {
|
|
325
|
+
andConditions.push({
|
|
326
|
+
actionStatus: { $in: actionStatusIn }
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (Array.isArray(params.actionStatusTypes)) {
|
|
330
|
+
andConditions.push({
|
|
331
|
+
actionStatus: { $in: params.actionStatusTypes }
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
const startDateGte = params.startFrom;
|
|
335
|
+
if (startDateGte instanceof Date) {
|
|
336
|
+
andConditions.push({
|
|
337
|
+
startDate: { $gte: startDateGte }
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
const startDateLte = params.startThrough;
|
|
341
|
+
if (startDateLte instanceof Date) {
|
|
342
|
+
andConditions.push({
|
|
343
|
+
startDate: { $lte: startDateLte }
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
|
|
347
|
+
if (Array.isArray(fromLocationTypeOfIn)) {
|
|
348
|
+
andConditions.push({
|
|
349
|
+
'fromLocation.typeOf': {
|
|
350
|
+
$exists: true,
|
|
351
|
+
$in: fromLocationTypeOfIn
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
|
|
356
|
+
if (Array.isArray(fromLocationAccountNumberIn)) {
|
|
357
|
+
andConditions.push({
|
|
358
|
+
'fromLocation.accountNumber': {
|
|
359
|
+
$exists: true,
|
|
360
|
+
$in: fromLocationAccountNumberIn
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
|
|
365
|
+
if (Array.isArray(fromLocationAccountTypeIn)) {
|
|
366
|
+
andConditions.push({
|
|
367
|
+
'fromLocation.accountType': {
|
|
368
|
+
$exists: true,
|
|
369
|
+
$in: fromLocationAccountTypeIn
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
|
|
374
|
+
if (Array.isArray(toLocationTypeOfIn)) {
|
|
375
|
+
andConditions.push({
|
|
376
|
+
'toLocation.typeOf': {
|
|
377
|
+
$exists: true,
|
|
378
|
+
$in: toLocationTypeOfIn
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
|
|
383
|
+
if (Array.isArray(toLocationAccountNumberIn)) {
|
|
384
|
+
andConditions.push({
|
|
385
|
+
'toLocation.accountNumber': {
|
|
386
|
+
$exists: true,
|
|
387
|
+
$in: toLocationAccountNumberIn
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
|
|
392
|
+
if (Array.isArray(toLocationAccountTypeIn)) {
|
|
393
|
+
andConditions.push({
|
|
394
|
+
'toLocation.accountType': {
|
|
395
|
+
$exists: true,
|
|
396
|
+
$in: toLocationAccountTypeIn
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
const purposeTypeOfIn = params.purpose?.typeOf?.$in;
|
|
401
|
+
if (Array.isArray(purposeTypeOfIn)) {
|
|
402
|
+
andConditions.push({
|
|
403
|
+
'purpose.typeOf': {
|
|
404
|
+
$exists: true,
|
|
405
|
+
$in: purposeTypeOfIn
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
const purposeIdIn = params.purpose?.id?.$in;
|
|
410
|
+
if (Array.isArray(purposeIdIn)) {
|
|
411
|
+
andConditions.push({
|
|
412
|
+
'purpose.id': {
|
|
413
|
+
$exists: true,
|
|
414
|
+
$in: purposeIdIn
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
const purposeOrderNumberIn = params.purpose?.orderNumber?.$in;
|
|
419
|
+
if (Array.isArray(purposeOrderNumberIn)) {
|
|
420
|
+
andConditions.push({
|
|
421
|
+
'purpose.orderNumber': {
|
|
422
|
+
$exists: true,
|
|
423
|
+
$in: purposeOrderNumberIn
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
const resultTypeOfIn = params.result?.typeOf?.$in;
|
|
428
|
+
if (Array.isArray(resultTypeOfIn)) {
|
|
429
|
+
andConditions.push({
|
|
430
|
+
'result.typeOf': {
|
|
431
|
+
$exists: true,
|
|
432
|
+
$in: resultTypeOfIn
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
const resultIdIn = params.result?.id?.$in;
|
|
437
|
+
if (Array.isArray(resultIdIn)) {
|
|
438
|
+
andConditions.push({
|
|
439
|
+
'result.id': {
|
|
440
|
+
$exists: true,
|
|
441
|
+
$in: resultIdIn
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
const resultOrderNumberIn = params.result?.orderNumber?.$in;
|
|
446
|
+
if (Array.isArray(resultOrderNumberIn)) {
|
|
447
|
+
andConditions.push({
|
|
448
|
+
'result.orderNumber': {
|
|
449
|
+
$exists: true,
|
|
450
|
+
$in: resultOrderNumberIn
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
const resultCodeIn = params.result?.code?.$in;
|
|
455
|
+
if (Array.isArray(resultCodeIn)) {
|
|
456
|
+
andConditions.push({
|
|
457
|
+
'result.code': {
|
|
458
|
+
$exists: true,
|
|
459
|
+
$in: resultCodeIn
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
// sameAs(2024-04-23~)
|
|
464
|
+
const sameAsIdEq = params.sameAs?.id?.$eq;
|
|
465
|
+
if (typeof sameAsIdEq === 'string') {
|
|
466
|
+
andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
|
|
467
|
+
}
|
|
468
|
+
const aboutOrderNumberEq = params.about?.orderNumber?.$eq;
|
|
469
|
+
if (typeof aboutOrderNumberEq === 'string') {
|
|
470
|
+
andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
|
|
471
|
+
}
|
|
472
|
+
return andConditions;
|
|
473
|
+
}
|
|
68
474
|
/**
|
|
69
475
|
* アクション開始
|
|
70
476
|
*/
|
|
@@ -268,6 +674,95 @@ class ActionProcessRepo {
|
|
|
268
674
|
}
|
|
269
675
|
return doc;
|
|
270
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* 汎用アクション検索
|
|
679
|
+
* 継承クラスから呼ぶ想定
|
|
680
|
+
*/
|
|
681
|
+
async findAnyActions(params, inclusion) {
|
|
682
|
+
const conditions = ActionProcessRepo.CREATE_MONGO_CONDITIONS(params);
|
|
683
|
+
let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
|
|
684
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
685
|
+
positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
686
|
+
}
|
|
687
|
+
const projection = {
|
|
688
|
+
_id: 0,
|
|
689
|
+
id: { $toString: '$_id' },
|
|
690
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
691
|
+
};
|
|
692
|
+
const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
693
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
694
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
695
|
+
query.limit(params.limit)
|
|
696
|
+
.skip(params.limit * (page - 1));
|
|
697
|
+
}
|
|
698
|
+
/* istanbul ignore else */
|
|
699
|
+
if (params.sort?.startDate !== undefined) {
|
|
700
|
+
query.sort({ startDate: params.sort.startDate });
|
|
701
|
+
}
|
|
702
|
+
// const explainResult = await (<any>query).explain();
|
|
703
|
+
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
704
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
705
|
+
.lean() // 2024-08-26~
|
|
706
|
+
.exec();
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* 取引に対する汎用アクション検索
|
|
710
|
+
* 継承クラスから呼ぶ想定
|
|
711
|
+
* 件数はlimitされない
|
|
712
|
+
*/
|
|
713
|
+
async findAnyActionsByPurpose(params) {
|
|
714
|
+
const andConditions = [
|
|
715
|
+
{ 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
|
|
716
|
+
{ 'purpose.id': { $exists: true, $eq: params.purpose.id } }
|
|
717
|
+
];
|
|
718
|
+
const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
|
|
719
|
+
if (typeof objectPaymentMethodIdEq === 'string') {
|
|
720
|
+
andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
|
|
721
|
+
}
|
|
722
|
+
const objectTypeOfEq = params.object?.typeOf?.$eq;
|
|
723
|
+
if (typeof objectTypeOfEq === 'string') {
|
|
724
|
+
andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
|
|
725
|
+
}
|
|
726
|
+
if (typeof params.typeOf === 'string') {
|
|
727
|
+
andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
728
|
+
}
|
|
729
|
+
const actionStatusEq = params.actionStatus?.$eq;
|
|
730
|
+
if (typeof actionStatusEq === 'string') {
|
|
731
|
+
andConditions.push({ actionStatus: { $eq: actionStatusEq } });
|
|
732
|
+
}
|
|
733
|
+
const positiveProjectionFields = [
|
|
734
|
+
'project',
|
|
735
|
+
'actionStatus',
|
|
736
|
+
'typeOf',
|
|
737
|
+
'description',
|
|
738
|
+
'agent',
|
|
739
|
+
'recipient',
|
|
740
|
+
'result',
|
|
741
|
+
'error',
|
|
742
|
+
'object',
|
|
743
|
+
'startDate',
|
|
744
|
+
'endDate',
|
|
745
|
+
'purpose',
|
|
746
|
+
'potentialActions',
|
|
747
|
+
'instrument',
|
|
748
|
+
'location',
|
|
749
|
+
'sameAs',
|
|
750
|
+
'cancelAction',
|
|
751
|
+
'identifier'
|
|
752
|
+
];
|
|
753
|
+
const projection = {
|
|
754
|
+
_id: 0,
|
|
755
|
+
id: { $toString: '$_id' },
|
|
756
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
757
|
+
};
|
|
758
|
+
const query = this.actionModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
759
|
+
if (typeof params.sort?.startDate === 'number') {
|
|
760
|
+
query.sort({ startDate: params.sort.startDate });
|
|
761
|
+
}
|
|
762
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
763
|
+
.lean()
|
|
764
|
+
.exec();
|
|
765
|
+
}
|
|
271
766
|
async upsertRecipe(savingRecipe) {
|
|
272
767
|
const dateModified = new Date();
|
|
273
768
|
const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
|