@chevre/domain 24.1.0-alpha.61 → 24.1.0-alpha.62
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/transaction/placeOrder.d.ts +5 -3
- package/lib/chevre/repo/transaction/placeOrder.js +4 -0
- package/lib/chevre/repo/transaction.js +0 -776
- package/lib/chevre/service/order/{findPlaceOrderTransaction.d.ts → findConfirmedPlaceOrder.d.ts} +1 -1
- package/lib/chevre/service/order/{findPlaceOrderTransaction.js → findConfirmedPlaceOrder.js} +12 -7
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +2 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +2 -7
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +15 -6
- package/package.json +2 -2
|
@@ -17,20 +17,22 @@ export type IPlaceOrder = Pick<factory.transaction.placeOrder.ITransaction, IKey
|
|
|
17
17
|
};
|
|
18
18
|
type IStartedPlaceOrderFields = 'expires' | 'id' | 'startDate' | 'status';
|
|
19
19
|
export type IStartedPlaceOrder = Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, IStartedPlaceOrderFields>;
|
|
20
|
+
type IFindParams = factory.transaction.ISearchConditions<factory.transactionType.PlaceOrder>;
|
|
20
21
|
/**
|
|
21
22
|
* 注文取引リポジトリ
|
|
22
23
|
*/
|
|
23
24
|
export declare class PlaceOrderRepo {
|
|
24
25
|
private readonly transactionModel;
|
|
25
26
|
constructor(connection: Connection);
|
|
26
|
-
static CREATE_MONGO_CONDITIONS(params:
|
|
27
|
-
countPlaceOrder(params:
|
|
27
|
+
static CREATE_MONGO_CONDITIONS(params: IFindParams): FilterQuery<import("@chevre/factory/lib/chevre/transaction/placeOrder").ITransaction>[];
|
|
28
|
+
countPlaceOrder(params: IFindParams): Promise<{
|
|
28
29
|
count: number;
|
|
29
30
|
}>;
|
|
30
31
|
/**
|
|
31
32
|
* 取引を検索する
|
|
32
33
|
*/
|
|
33
|
-
findPlaceOrderTransactions(params:
|
|
34
|
+
findPlaceOrderTransactions(params: Omit<IFindParams, 'result'> & {
|
|
35
|
+
result?: never;
|
|
34
36
|
inclusion: IKeyOfProjection[];
|
|
35
37
|
}): Promise<(Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, IKeyOfProjection> & {
|
|
36
38
|
id: string;
|
|
@@ -136,6 +136,10 @@ class PlaceOrderRepo {
|
|
|
136
136
|
if (typeof objectOrderNumberEq === 'string') {
|
|
137
137
|
andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
|
|
138
138
|
}
|
|
139
|
+
const objectConfirmationNumberEq = params.object?.confirmationNumber?.$eq;
|
|
140
|
+
if (typeof objectConfirmationNumberEq === 'string') {
|
|
141
|
+
andConditions.push({ 'object.confirmationNumber': { $exists: true, $eq: objectConfirmationNumberEq } });
|
|
142
|
+
}
|
|
139
143
|
return andConditions;
|
|
140
144
|
}
|
|
141
145
|
async countPlaceOrder(params) {
|
|
@@ -9,10 +9,6 @@ const transaction_1 = require("../eventEmitter/transaction");
|
|
|
9
9
|
const factory_1 = require("../factory");
|
|
10
10
|
const settings_1 = require("../settings");
|
|
11
11
|
const transaction_2 = require("./mongoose/schemas/transaction");
|
|
12
|
-
// type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
|
|
13
|
-
// export type IMoneyTransferTransactionInProgress = Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress>;
|
|
14
|
-
// type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
|
|
15
|
-
// export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
|
|
16
12
|
/**
|
|
17
13
|
* 取引リポジトリ
|
|
18
14
|
*/
|
|
@@ -21,547 +17,6 @@ class TransactionRepo {
|
|
|
21
17
|
constructor(connection) {
|
|
22
18
|
this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
|
|
23
19
|
}
|
|
24
|
-
// public static CREATE_MONGO_CONDITIONS(params: factory.transaction.ISearchConditions<factory.transactionType.MoneyTransfer>) {
|
|
25
|
-
// if (params.typeOf !== factory.transactionType.MoneyTransfer) {
|
|
26
|
-
// throw new factory.errors.Argument('typeOf', `must be ${factory.transactionType.MoneyTransfer}`);
|
|
27
|
-
// }
|
|
28
|
-
// const andConditions: FilterQuery<factory.assetTransaction.ITransaction<factory.assetTransactionType>>[] = [];
|
|
29
|
-
// const projectIdEq = params.project?.id?.$eq;
|
|
30
|
-
// if (typeof projectIdEq === 'string') {
|
|
31
|
-
// andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
32
|
-
// }
|
|
33
|
-
// if (typeof params.typeOf === 'string') {
|
|
34
|
-
// andConditions.push({ typeOf: { $eq: params.typeOf } });
|
|
35
|
-
// }
|
|
36
|
-
// if (params.startFrom !== undefined) {
|
|
37
|
-
// andConditions.push({
|
|
38
|
-
// startDate: { $gte: params.startFrom }
|
|
39
|
-
// });
|
|
40
|
-
// }
|
|
41
|
-
// if (params.startThrough !== undefined) {
|
|
42
|
-
// andConditions.push({
|
|
43
|
-
// startDate: { $lte: params.startThrough }
|
|
44
|
-
// });
|
|
45
|
-
// }
|
|
46
|
-
// if (params.endFrom !== undefined) {
|
|
47
|
-
// andConditions.push({
|
|
48
|
-
// endDate: {
|
|
49
|
-
// $exists: true,
|
|
50
|
-
// $gte: params.endFrom
|
|
51
|
-
// }
|
|
52
|
-
// });
|
|
53
|
-
// }
|
|
54
|
-
// if (params.endThrough !== undefined) {
|
|
55
|
-
// andConditions.push({
|
|
56
|
-
// endDate: {
|
|
57
|
-
// $exists: true,
|
|
58
|
-
// $lt: params.endThrough
|
|
59
|
-
// }
|
|
60
|
-
// });
|
|
61
|
-
// }
|
|
62
|
-
// if (Array.isArray(params.ids)) {
|
|
63
|
-
// andConditions.push({
|
|
64
|
-
// _id: { $in: params.ids }
|
|
65
|
-
// });
|
|
66
|
-
// }
|
|
67
|
-
// if (Array.isArray(params.statuses)) {
|
|
68
|
-
// andConditions.push({ status: { $in: params.statuses } });
|
|
69
|
-
// }
|
|
70
|
-
// const statusIn = params.status?.$in;
|
|
71
|
-
// if (Array.isArray(statusIn)) {
|
|
72
|
-
// andConditions.push({ status: { $in: statusIn } });
|
|
73
|
-
// }
|
|
74
|
-
// if (params.agent !== undefined) {
|
|
75
|
-
// if (params.agent.typeOf !== undefined) {
|
|
76
|
-
// andConditions.push({
|
|
77
|
-
// 'agent.typeOf': {
|
|
78
|
-
// $exists: true,
|
|
79
|
-
// $eq: params.agent.typeOf
|
|
80
|
-
// }
|
|
81
|
-
// });
|
|
82
|
-
// }
|
|
83
|
-
// if (Array.isArray(params.agent.ids)) {
|
|
84
|
-
// andConditions.push({
|
|
85
|
-
// 'agent.id': {
|
|
86
|
-
// $exists: true,
|
|
87
|
-
// $in: params.agent.ids
|
|
88
|
-
// }
|
|
89
|
-
// });
|
|
90
|
-
// }
|
|
91
|
-
// if (Array.isArray(params.agent.identifiers)) {
|
|
92
|
-
// andConditions.push({
|
|
93
|
-
// 'agent.identifier': {
|
|
94
|
-
// $exists: true,
|
|
95
|
-
// $in: params.agent.identifiers
|
|
96
|
-
// }
|
|
97
|
-
// });
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
// const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
101
|
-
// if (Array.isArray(tasksExportActionStatusIn)) {
|
|
102
|
-
// andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
103
|
-
// }
|
|
104
|
-
// const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
105
|
-
// if (typeof tasksExportActionStatusEq === 'string') {
|
|
106
|
-
// andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
|
|
107
|
-
// }
|
|
108
|
-
// switch (params.typeOf) {
|
|
109
|
-
// case factory.transactionType.PlaceOrder as any:
|
|
110
|
-
// throw new factory.errors.NotImplemented(`use PlaceOrderRepo`);
|
|
111
|
-
// // const sellerIdIn = params.seller?.ids;
|
|
112
|
-
// // if (Array.isArray(sellerIdIn)) {
|
|
113
|
-
// // andConditions.push({ 'seller.id': { $exists: true, $in: sellerIdIn } });
|
|
114
|
-
// // }
|
|
115
|
-
// // const resultOrderNumberIn = params.result?.order?.orderNumbers;
|
|
116
|
-
// // if (Array.isArray(resultOrderNumberIn)) {
|
|
117
|
-
// // andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
|
|
118
|
-
// // }
|
|
119
|
-
// // const resultOrderConfirmationNumberEq = params.result?.order?.confirmationNumber?.$eq;
|
|
120
|
-
// // if (typeof resultOrderConfirmationNumberEq === 'string') {
|
|
121
|
-
// // andConditions.push({
|
|
122
|
-
// // 'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
|
|
123
|
-
// // });
|
|
124
|
-
// // }
|
|
125
|
-
// // const objectOrderNumberEq = params.object?.orderNumber?.$eq;
|
|
126
|
-
// // if (typeof objectOrderNumberEq === 'string') {
|
|
127
|
-
// // andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
|
|
128
|
-
// // }
|
|
129
|
-
// // break;
|
|
130
|
-
// case factory.transactionType.ReturnOrder as any:
|
|
131
|
-
// throw new factory.errors.NotImplemented(`use ReturnOrderRepo`);
|
|
132
|
-
// // if (params.object !== undefined) {
|
|
133
|
-
// // if (params.object.order !== undefined) {
|
|
134
|
-
// // if (Array.isArray(params.object.order.orderNumbers)) {
|
|
135
|
-
// // andConditions.push({
|
|
136
|
-
// // 'object.order.orderNumber': {
|
|
137
|
-
// // $exists: true,
|
|
138
|
-
// // $in: params.object.order.orderNumbers
|
|
139
|
-
// // }
|
|
140
|
-
// // });
|
|
141
|
-
// // }
|
|
142
|
-
// // }
|
|
143
|
-
// // }
|
|
144
|
-
// // break;
|
|
145
|
-
// default:
|
|
146
|
-
// }
|
|
147
|
-
// return andConditions;
|
|
148
|
-
// }
|
|
149
|
-
// /**
|
|
150
|
-
// * 取引を開始する
|
|
151
|
-
// */
|
|
152
|
-
// // public async startNoPlaceOrder<
|
|
153
|
-
// public async startMoneyTransfer(
|
|
154
|
-
// params: factory.transaction.IStartParams<factory.transactionType.MoneyTransfer>
|
|
155
|
-
// ): Promise<IStartedTransaction> {
|
|
156
|
-
// const status = factory.transactionStatusType.InProgress;
|
|
157
|
-
// const tasksExportAction: factory.transaction.ITasksExportAction = { actionStatus: factory.actionStatusType.PotentialActionStatus };
|
|
158
|
-
// // const tasksExportationStatus = factory.transactionTasksExportationStatus.Unexported; // discontinue(2024-06-20~)
|
|
159
|
-
// const startDate: Date = new Date();
|
|
160
|
-
// // let expires: Date;
|
|
161
|
-
// const { typeOf } = params;
|
|
162
|
-
// // if (typeOf === factory.transactionType.ReturnOrder) {
|
|
163
|
-
// // // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
|
|
164
|
-
// // if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
|
|
165
|
-
// // expires = moment(startDate)
|
|
166
|
-
// // .add(params.expiresInSeconds, 'seconds')
|
|
167
|
-
// // .toDate();
|
|
168
|
-
// // } else {
|
|
169
|
-
// // throw new factory.errors.ArgumentNull('expiresInSeconds');
|
|
170
|
-
// // }
|
|
171
|
-
// // } else {
|
|
172
|
-
// // expires = params.expires;
|
|
173
|
-
// // }
|
|
174
|
-
// const expires = params.expires;
|
|
175
|
-
// let creatingTransaction: factory.transaction.IAttributes<factory.transactionType.MoneyTransfer>;
|
|
176
|
-
// if (typeOf === factory.transactionType.MoneyTransfer) {
|
|
177
|
-
// const { agent, project, object, seller, recipient } = params;
|
|
178
|
-
// creatingTransaction = {
|
|
179
|
-
// status, startDate, expires, typeOf, tasksExportAction,
|
|
180
|
-
// agent, project, seller, object, recipient
|
|
181
|
-
// };
|
|
182
|
-
// // } else if (typeOf === factory.transactionType.ReturnOrder) {
|
|
183
|
-
// // const { agent, project, object, seller } = params;
|
|
184
|
-
// // creatingTransaction = {
|
|
185
|
-
// // status, startDate, expires, typeOf, tasksExportAction,
|
|
186
|
-
// // agent, project, seller, object
|
|
187
|
-
// // };
|
|
188
|
-
// } else {
|
|
189
|
-
// throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
|
|
190
|
-
// }
|
|
191
|
-
// // reimplemnt with insertMany(2024-05-30~)
|
|
192
|
-
// const result = await this.transactionModel.insertMany(
|
|
193
|
-
// creatingTransaction,
|
|
194
|
-
// { rawResult: true }
|
|
195
|
-
// );
|
|
196
|
-
// const id = result.insertedIds?.[0]?.toHexString();
|
|
197
|
-
// if (typeof id !== 'string') {
|
|
198
|
-
// throw new factory.errors.Internal('transaction not saved');
|
|
199
|
-
// }
|
|
200
|
-
// // 取引開始時にも取引イベントエミッター連携(2024-03-21~)
|
|
201
|
-
// transactionEventEmitter.emitTransactionStatusChanged({ id, typeOf, status });
|
|
202
|
-
// return { expires, id, startDate, status }; // minimize response(2024-05-30~)
|
|
203
|
-
// }
|
|
204
|
-
// /**
|
|
205
|
-
// * 特定取引検索
|
|
206
|
-
// */
|
|
207
|
-
// public async findMoneyTransferById(
|
|
208
|
-
// params: { typeOf: factory.transactionType.MoneyTransfer; id: string },
|
|
209
|
-
// inclusion: IKeyOfProjection[] // make required(2024-05-31~)
|
|
210
|
-
// ): Promise<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> {
|
|
211
|
-
// let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
|
|
212
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
213
|
-
// positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection>key));
|
|
214
|
-
// } else {
|
|
215
|
-
// throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
|
|
216
|
-
// }
|
|
217
|
-
// const projection: ProjectionType<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
|
|
218
|
-
// _id: 0,
|
|
219
|
-
// id: { $toString: '$_id' },
|
|
220
|
-
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
221
|
-
// };
|
|
222
|
-
// // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
|
|
223
|
-
// // if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
224
|
-
// // inclusion.forEach((field) => {
|
|
225
|
-
// // projection[field] = 1;
|
|
226
|
-
// // });
|
|
227
|
-
// // } else {
|
|
228
|
-
// // projection = {
|
|
229
|
-
// // __v: 0,
|
|
230
|
-
// // createdAt: 0,
|
|
231
|
-
// // updatedAt: 0
|
|
232
|
-
// // };
|
|
233
|
-
// // }
|
|
234
|
-
// const doc = await this.transactionModel.findOne(
|
|
235
|
-
// {
|
|
236
|
-
// _id: { $eq: params.id },
|
|
237
|
-
// typeOf: { $eq: params.typeOf }
|
|
238
|
-
// },
|
|
239
|
-
// projection
|
|
240
|
-
// )
|
|
241
|
-
// .lean<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>>() // 2024-08-26~
|
|
242
|
-
// .exec();
|
|
243
|
-
// if (doc === null) {
|
|
244
|
-
// throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} not found`);
|
|
245
|
-
// }
|
|
246
|
-
// return doc;
|
|
247
|
-
// }
|
|
248
|
-
// /**
|
|
249
|
-
// * 進行中の取引を取得する
|
|
250
|
-
// */
|
|
251
|
-
// public async findMoneyTransferInProgressById(
|
|
252
|
-
// params: {
|
|
253
|
-
// typeOf: factory.transactionType.MoneyTransfer;
|
|
254
|
-
// id: string;
|
|
255
|
-
// },
|
|
256
|
-
// inclusion: IKeyOfProjection[] // make required(2024-05-29~)
|
|
257
|
-
// ): Promise<IMoneyTransferTransactionInProgress> {
|
|
258
|
-
// let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
|
|
259
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
260
|
-
// positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection>key));
|
|
261
|
-
// } else {
|
|
262
|
-
// throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
|
|
263
|
-
// }
|
|
264
|
-
// const projection: ProjectionType<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
|
|
265
|
-
// _id: 0,
|
|
266
|
-
// id: { $toString: '$_id' },
|
|
267
|
-
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
268
|
-
// };
|
|
269
|
-
// const filter: FilterQuery<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>> = {
|
|
270
|
-
// _id: { $eq: params.id },
|
|
271
|
-
// typeOf: { $eq: params.typeOf },
|
|
272
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
273
|
-
// // expiresを条件に追加(2023-05-12~),
|
|
274
|
-
// expires: { $gt: new Date() }
|
|
275
|
-
// };
|
|
276
|
-
// const doc = await this.transactionModel.findOne(filter, projection)
|
|
277
|
-
// .lean<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>>() // 2024-08-26~
|
|
278
|
-
// .exec();
|
|
279
|
-
// if (doc === null) {
|
|
280
|
-
// throw new factory.errors.NotFound(
|
|
281
|
-
// this.transactionModel.modelName,
|
|
282
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
283
|
-
// );
|
|
284
|
-
// }
|
|
285
|
-
// return doc;
|
|
286
|
-
// }
|
|
287
|
-
// /**
|
|
288
|
-
// * 進行中の取引を取得する
|
|
289
|
-
// */
|
|
290
|
-
// public async projectFieldsInProgressById<T extends factory.transactionType.MoneyTransfer>(
|
|
291
|
-
// params: {
|
|
292
|
-
// typeOf: T;
|
|
293
|
-
// id: string;
|
|
294
|
-
// },
|
|
295
|
-
// inclusion: IKeyOfProjection<T>[] // make required(2024-05-29~)
|
|
296
|
-
// ): Promise<ITransactionInProgress<T>> {
|
|
297
|
-
// let positiveProjectionFields: (IKeyOfProjection<factory.transactionType.MoneyTransfer>
|
|
298
|
-
// | IKeyOfProjection<factory.transactionType.PlaceOrder>
|
|
299
|
-
// | IKeyOfProjection<factory.transactionType.ReturnOrder>
|
|
300
|
-
// )[] = AVAILABLE_PROJECT_FIELDS;
|
|
301
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
302
|
-
// positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<IKeyOfProjection<T>>key));
|
|
303
|
-
// } else {
|
|
304
|
-
// throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
|
|
305
|
-
// }
|
|
306
|
-
// const projection: ProjectionType<factory.transaction.ITransaction<T>> = {
|
|
307
|
-
// _id: 0,
|
|
308
|
-
// id: { $toString: '$_id' },
|
|
309
|
-
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
310
|
-
// };
|
|
311
|
-
// const filter: FilterQuery<factory.transaction.ITransaction<T>> = {
|
|
312
|
-
// _id: { $eq: params.id },
|
|
313
|
-
// typeOf: { $eq: params.typeOf },
|
|
314
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
315
|
-
// // expiresを条件に追加(2023-05-12~),
|
|
316
|
-
// expires: { $gt: new Date() }
|
|
317
|
-
// };
|
|
318
|
-
// const doc = await this.transactionModel.findOne(filter, projection)
|
|
319
|
-
// .lean<factory.transaction.ITransaction<T>>() // 2024-08-26~
|
|
320
|
-
// .exec();
|
|
321
|
-
// if (doc === null) {
|
|
322
|
-
// throw new factory.errors.NotFound(
|
|
323
|
-
// this.transactionModel.modelName,
|
|
324
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
325
|
-
// );
|
|
326
|
-
// }
|
|
327
|
-
// return doc;
|
|
328
|
-
// }
|
|
329
|
-
// /**
|
|
330
|
-
// * 進行中取引に保管された採用済決済方法を検索する
|
|
331
|
-
// */
|
|
332
|
-
// public async findInProgressPaymentMethodId(params: {
|
|
333
|
-
// id: string;
|
|
334
|
-
// }): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined> {
|
|
335
|
-
// const doc = await this.transactionModel.findOne(
|
|
336
|
-
// {
|
|
337
|
-
// _id: { $eq: params.id },
|
|
338
|
-
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
339
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
340
|
-
// },
|
|
341
|
-
// { 'object.paymentMethods': 1 }
|
|
342
|
-
// )
|
|
343
|
-
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>() // 2024-08-26~
|
|
344
|
-
// .exec();
|
|
345
|
-
// if (doc === null) {
|
|
346
|
-
// throw new factory.errors.NotFound(
|
|
347
|
-
// this.transactionModel.modelName,
|
|
348
|
-
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
349
|
-
// );
|
|
350
|
-
// }
|
|
351
|
-
// return doc.object.paymentMethods;
|
|
352
|
-
// }
|
|
353
|
-
// /**
|
|
354
|
-
// * 取引の注文番号を検索する
|
|
355
|
-
// */
|
|
356
|
-
// public async findInProgressOrderNumberById(params: {
|
|
357
|
-
// id: string;
|
|
358
|
-
// }): Promise<string | undefined> {
|
|
359
|
-
// const doc = await this.transactionModel.findOne(
|
|
360
|
-
// {
|
|
361
|
-
// _id: { $eq: params.id },
|
|
362
|
-
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
363
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
364
|
-
// },
|
|
365
|
-
// { 'object.orderNumber': 1 }
|
|
366
|
-
// )
|
|
367
|
-
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
|
|
368
|
-
// .exec();
|
|
369
|
-
// if (doc === null) {
|
|
370
|
-
// throw new factory.errors.NotFound(
|
|
371
|
-
// this.transactionModel.modelName,
|
|
372
|
-
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
373
|
-
// );
|
|
374
|
-
// }
|
|
375
|
-
// return doc.object.orderNumber;
|
|
376
|
-
// }
|
|
377
|
-
// /**
|
|
378
|
-
// * 取引の確認番号を検索する
|
|
379
|
-
// */
|
|
380
|
-
// public async findInProgressConfirmationNumberById(params: {
|
|
381
|
-
// id: string;
|
|
382
|
-
// status: { $in: factory.transactionStatusType[] };
|
|
383
|
-
// }): Promise<string | undefined> {
|
|
384
|
-
// const doc = await this.transactionModel.findOne(
|
|
385
|
-
// {
|
|
386
|
-
// _id: { $eq: params.id },
|
|
387
|
-
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
388
|
-
// status: { $in: params.status.$in }
|
|
389
|
-
// },
|
|
390
|
-
// { 'object.confirmationNumber': 1 }
|
|
391
|
-
// )
|
|
392
|
-
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
|
|
393
|
-
// .exec();
|
|
394
|
-
// if (doc === null) {
|
|
395
|
-
// throw new factory.errors.NotFound(
|
|
396
|
-
// this.transactionModel.modelName,
|
|
397
|
-
// `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
|
|
398
|
-
// );
|
|
399
|
-
// }
|
|
400
|
-
// return doc.object.confirmationNumber;
|
|
401
|
-
// }
|
|
402
|
-
// /**
|
|
403
|
-
// * 取引進行者プロフィールを更新
|
|
404
|
-
// */
|
|
405
|
-
// public async updateAgent<T extends factory.transactionType>(params: {
|
|
406
|
-
// typeOf: T;
|
|
407
|
-
// id: string;
|
|
408
|
-
// agent: Pick<factory.transaction.IAgent, 'id'>;
|
|
409
|
-
// object?: {
|
|
410
|
-
// customer?: factory.order.ICustomer;
|
|
411
|
-
// };
|
|
412
|
-
// }): Promise<void> {
|
|
413
|
-
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
414
|
-
// {
|
|
415
|
-
// _id: { $eq: params.id },
|
|
416
|
-
// typeOf: { $eq: params.typeOf },
|
|
417
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
418
|
-
// },
|
|
419
|
-
// {
|
|
420
|
-
// $set: {
|
|
421
|
-
// 'agent.id': params.agent.id,
|
|
422
|
-
// // ...(typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined,
|
|
423
|
-
// ...(typeof params.object?.customer?.typeOf === 'string') ? { 'object.customer': params.object.customer } : undefined
|
|
424
|
-
// }
|
|
425
|
-
// },
|
|
426
|
-
// {
|
|
427
|
-
// projection: { _id: 1 }
|
|
428
|
-
// }
|
|
429
|
-
// )
|
|
430
|
-
// .lean<{ _id: ObjectId }>()
|
|
431
|
-
// .exec();
|
|
432
|
-
// if (doc === null) {
|
|
433
|
-
// throw new factory.errors.NotFound(
|
|
434
|
-
// this.transactionModel.modelName,
|
|
435
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
436
|
-
// );
|
|
437
|
-
// }
|
|
438
|
-
// }
|
|
439
|
-
// /**
|
|
440
|
-
// * 取引期限変更
|
|
441
|
-
// */
|
|
442
|
-
// public async updateExpires<T extends factory.transactionType>(params: {
|
|
443
|
-
// typeOf: T;
|
|
444
|
-
// id: string;
|
|
445
|
-
// expires: Date;
|
|
446
|
-
// }): Promise<void> {
|
|
447
|
-
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
448
|
-
// {
|
|
449
|
-
// _id: { $eq: params.id },
|
|
450
|
-
// typeOf: { $eq: params.typeOf },
|
|
451
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
452
|
-
// },
|
|
453
|
-
// {
|
|
454
|
-
// $set: {
|
|
455
|
-
// expires: params.expires
|
|
456
|
-
// }
|
|
457
|
-
// },
|
|
458
|
-
// {
|
|
459
|
-
// projection: { _id: 1 }
|
|
460
|
-
// }
|
|
461
|
-
// )
|
|
462
|
-
// .lean<{ _id: ObjectId }>()
|
|
463
|
-
// .exec();
|
|
464
|
-
// if (doc === null) {
|
|
465
|
-
// throw new factory.errors.NotFound(
|
|
466
|
-
// this.transactionModel.modelName,
|
|
467
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
468
|
-
// );
|
|
469
|
-
// }
|
|
470
|
-
// }
|
|
471
|
-
// /**
|
|
472
|
-
// * 取引オブジェクトを更新
|
|
473
|
-
// * 注文名称など
|
|
474
|
-
// */
|
|
475
|
-
// public async updateObject<T extends factory.transactionType>(params: {
|
|
476
|
-
// typeOf: T;
|
|
477
|
-
// id: string;
|
|
478
|
-
// object?: {
|
|
479
|
-
// name?: string;
|
|
480
|
-
// };
|
|
481
|
-
// }): Promise<void> {
|
|
482
|
-
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
483
|
-
// {
|
|
484
|
-
// _id: { $eq: params.id },
|
|
485
|
-
// typeOf: { $eq: params.typeOf },
|
|
486
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
487
|
-
// },
|
|
488
|
-
// {
|
|
489
|
-
// $set: {
|
|
490
|
-
// ...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
|
|
491
|
-
// }
|
|
492
|
-
// },
|
|
493
|
-
// {
|
|
494
|
-
// projection: { _id: 1 }
|
|
495
|
-
// }
|
|
496
|
-
// )
|
|
497
|
-
// .lean<{ _id: ObjectId }>()
|
|
498
|
-
// .exec();
|
|
499
|
-
// if (doc === null) {
|
|
500
|
-
// throw new factory.errors.NotFound(
|
|
501
|
-
// this.transactionModel.modelName,
|
|
502
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
503
|
-
// );
|
|
504
|
-
// }
|
|
505
|
-
// }
|
|
506
|
-
// /**
|
|
507
|
-
// * 取引を確定する
|
|
508
|
-
// */
|
|
509
|
-
// // public async confirmNoPlaceOrder<
|
|
510
|
-
// public async confirmMoneyTransfer(params: {
|
|
511
|
-
// typeOf: factory.transactionType.MoneyTransfer;
|
|
512
|
-
// id: string;
|
|
513
|
-
// result: factory.transaction.IResult<factory.transactionType.MoneyTransfer>;
|
|
514
|
-
// potentialActions: factory.transaction.IPotentialActions<factory.transactionType.MoneyTransfer>;
|
|
515
|
-
// }): Promise<void> {
|
|
516
|
-
// const endDate = new Date();
|
|
517
|
-
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
518
|
-
// {
|
|
519
|
-
// _id: { $eq: params.id },
|
|
520
|
-
// typeOf: { $eq: params.typeOf },
|
|
521
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
522
|
-
// expires: { $gt: endDate } // add expires(2025-02-27~)
|
|
523
|
-
// },
|
|
524
|
-
// {
|
|
525
|
-
// status: factory.transactionStatusType.Confirmed, // ステータス変更
|
|
526
|
-
// endDate,
|
|
527
|
-
// // 'object.authorizeActions': params.authorizeActions,
|
|
528
|
-
// result: params.result, // resultを更新
|
|
529
|
-
// potentialActions: params.potentialActions // resultを更新
|
|
530
|
-
// },
|
|
531
|
-
// {
|
|
532
|
-
// new: true,
|
|
533
|
-
// projection: { _id: 1 }
|
|
534
|
-
// }
|
|
535
|
-
// )
|
|
536
|
-
// .lean<{ _id: ObjectId }>()
|
|
537
|
-
// .exec();
|
|
538
|
-
// // NotFoundであれば取引状態確認
|
|
539
|
-
// if (doc === null) {
|
|
540
|
-
// const { expires, status } = <Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'expires' | 'status'>>
|
|
541
|
-
// await this.findMoneyTransferById({ typeOf: params.typeOf, id: params.id }, ['expires', 'status']);
|
|
542
|
-
// if (status === factory.transactionStatusType.Confirmed) {
|
|
543
|
-
// // すでに確定済の場合スルー
|
|
544
|
-
// } else if (status === factory.transactionStatusType.Expired) {
|
|
545
|
-
// throw new factory.errors.Argument('Transaction id', 'Already expired');
|
|
546
|
-
// } else if (status === factory.transactionStatusType.Canceled) {
|
|
547
|
-
// throw new factory.errors.Argument('Transaction id', 'Already canceled');
|
|
548
|
-
// } else {
|
|
549
|
-
// if (moment(expires)
|
|
550
|
-
// .isSameOrBefore(moment(endDate))) {
|
|
551
|
-
// throw new factory.errors.Argument('Transaction id', 'potentially expired');
|
|
552
|
-
// }
|
|
553
|
-
// throw new factory.errors.NotFound(
|
|
554
|
-
// this.transactionModel.modelName,
|
|
555
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
556
|
-
// );
|
|
557
|
-
// }
|
|
558
|
-
// }
|
|
559
|
-
// transactionEventEmitter.emitTransactionStatusChanged({
|
|
560
|
-
// id: params.id,
|
|
561
|
-
// typeOf: params.typeOf,
|
|
562
|
-
// status: factory.transactionStatusType.Confirmed
|
|
563
|
-
// });
|
|
564
|
-
// }
|
|
565
20
|
async countPotentiallyExportTasks(params) {
|
|
566
21
|
const { endDate, limit } = params;
|
|
567
22
|
const endDateLt = endDate?.$lt;
|
|
@@ -646,56 +101,6 @@ class TransactionRepo {
|
|
|
646
101
|
.exec()
|
|
647
102
|
.then((doc) => (doc === null) ? null : doc);
|
|
648
103
|
}
|
|
649
|
-
// discontinue(2025-03-10~)
|
|
650
|
-
// public async reexportTasksByExportAction(params: {
|
|
651
|
-
// intervalInMinutes: number;
|
|
652
|
-
// limit: number;
|
|
653
|
-
// }): Promise<void> {
|
|
654
|
-
// const reexportingTransactions: Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'status' | 'typeOf'>[] =
|
|
655
|
-
// await this.transactionModel.find(
|
|
656
|
-
// {
|
|
657
|
-
// 'tasksExportAction.actionStatus': {
|
|
658
|
-
// $exists: true,
|
|
659
|
-
// $eq: factory.actionStatusType.ActiveActionStatus
|
|
660
|
-
// },
|
|
661
|
-
// 'tasksExportAction.startDate': {
|
|
662
|
-
// $exists: true,
|
|
663
|
-
// $lt: moment()
|
|
664
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
665
|
-
// .toDate()
|
|
666
|
-
// }
|
|
667
|
-
// },
|
|
668
|
-
// { _id: 1, typeOf: 1, status: 1 }
|
|
669
|
-
// )
|
|
670
|
-
// .limit(params.limit)
|
|
671
|
-
// .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
672
|
-
// .exec();
|
|
673
|
-
// if (reexportingTransactions.length > 0) {
|
|
674
|
-
// for (const reexportingTransaction of reexportingTransactions) {
|
|
675
|
-
// await this.transactionModel.updateOne(
|
|
676
|
-
// {
|
|
677
|
-
// _id: { $eq: reexportingTransaction.id },
|
|
678
|
-
// 'tasksExportAction.actionStatus': {
|
|
679
|
-
// $exists: true,
|
|
680
|
-
// $eq: factory.actionStatusType.ActiveActionStatus
|
|
681
|
-
// }
|
|
682
|
-
// },
|
|
683
|
-
// {
|
|
684
|
-
// tasksExportAction: {
|
|
685
|
-
// actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
686
|
-
// }
|
|
687
|
-
// // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
|
|
688
|
-
// }
|
|
689
|
-
// )
|
|
690
|
-
// .exec();
|
|
691
|
-
// transactionEventEmitter.emitTransactionStatusChanged({
|
|
692
|
-
// id: reexportingTransaction.id,
|
|
693
|
-
// typeOf: reexportingTransaction.typeOf,
|
|
694
|
-
// status: reexportingTransaction.status
|
|
695
|
-
// });
|
|
696
|
-
// }
|
|
697
|
-
// }
|
|
698
|
-
// }
|
|
699
104
|
/**
|
|
700
105
|
* tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
|
|
701
106
|
* PotentialActionStatusに変更する
|
|
@@ -884,187 +289,6 @@ class TransactionRepo {
|
|
|
884
289
|
}
|
|
885
290
|
return expiringTransactions;
|
|
886
291
|
}
|
|
887
|
-
// /**
|
|
888
|
-
// * 取引を中止する
|
|
889
|
-
// */
|
|
890
|
-
// public async cancelMoneyTransfer(params: {
|
|
891
|
-
// typeOf: factory.transactionType.MoneyTransfer;
|
|
892
|
-
// id: string;
|
|
893
|
-
// }): Promise<void> {
|
|
894
|
-
// const endDate = new Date();
|
|
895
|
-
// // 進行中ステータスの取引を中止する
|
|
896
|
-
// const doc = await this.transactionModel.findOneAndUpdate(
|
|
897
|
-
// {
|
|
898
|
-
// typeOf: params.typeOf,
|
|
899
|
-
// _id: params.id,
|
|
900
|
-
// status: factory.transactionStatusType.InProgress
|
|
901
|
-
// },
|
|
902
|
-
// {
|
|
903
|
-
// status: factory.transactionStatusType.Canceled,
|
|
904
|
-
// endDate: endDate
|
|
905
|
-
// },
|
|
906
|
-
// {
|
|
907
|
-
// new: true,
|
|
908
|
-
// projection: { _id: 1 }
|
|
909
|
-
// }
|
|
910
|
-
// )
|
|
911
|
-
// .lean<{ _id: ObjectId }>()
|
|
912
|
-
// .exec();
|
|
913
|
-
// // NotFoundであれば取引状態確認
|
|
914
|
-
// if (doc === null) {
|
|
915
|
-
// const { status } = <Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'status'>>
|
|
916
|
-
// await this.findMoneyTransferById(params, ['status']);
|
|
917
|
-
// if (status === factory.transactionStatusType.Canceled) {
|
|
918
|
-
// // すでに中止済の場合スルー
|
|
919
|
-
// } else if (status === factory.transactionStatusType.Expired) {
|
|
920
|
-
// throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
|
|
921
|
-
// } else if (status === factory.transactionStatusType.Confirmed) {
|
|
922
|
-
// throw new factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
|
|
923
|
-
// } else {
|
|
924
|
-
// throw new factory.errors.NotFound(
|
|
925
|
-
// this.transactionModel.modelName,
|
|
926
|
-
// `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`
|
|
927
|
-
// );
|
|
928
|
-
// }
|
|
929
|
-
// }
|
|
930
|
-
// transactionEventEmitter.emitTransactionStatusChanged({
|
|
931
|
-
// id: params.id,
|
|
932
|
-
// typeOf: params.typeOf,
|
|
933
|
-
// status: factory.transactionStatusType.Canceled
|
|
934
|
-
// });
|
|
935
|
-
// }
|
|
936
|
-
// public async countMoneyTransfer<
|
|
937
|
-
// // T extends factory.transactionType
|
|
938
|
-
// T extends factory.transactionType.MoneyTransfer
|
|
939
|
-
// >(params: factory.transaction.ISearchConditions<T>): Promise<{ count: number }> {
|
|
940
|
-
// const { limit } = params;
|
|
941
|
-
// const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
942
|
-
// const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
943
|
-
// if (typeof limit === 'number' && limit >= 0) {
|
|
944
|
-
// query.limit(limit);
|
|
945
|
-
// }
|
|
946
|
-
// const count = await query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
947
|
-
// .exec();
|
|
948
|
-
// return { count };
|
|
949
|
-
// }
|
|
950
|
-
// /**
|
|
951
|
-
// * 取引を検索する
|
|
952
|
-
// */
|
|
953
|
-
// public async findMoneyTransferTransactions<
|
|
954
|
-
// // T extends factory.transactionType,
|
|
955
|
-
// T extends factory.transactionType.MoneyTransfer,
|
|
956
|
-
// F extends IKeyOfProjection
|
|
957
|
-
// >(
|
|
958
|
-
// params: factory.transaction.ISearchConditions<T> & {
|
|
959
|
-
// inclusion: F[];
|
|
960
|
-
// }
|
|
961
|
-
// ): Promise<(Pick<factory.transaction.ITransaction<T>, F> & { id: string })[]> {
|
|
962
|
-
// const { inclusion } = params;
|
|
963
|
-
// const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
964
|
-
// let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
|
|
965
|
-
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
966
|
-
// positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(<F>key));
|
|
967
|
-
// }
|
|
968
|
-
// const projection: ProjectionType<factory.transaction.ITransaction<T>> = {
|
|
969
|
-
// _id: 0,
|
|
970
|
-
// id: { $toString: '$_id' },
|
|
971
|
-
// ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
|
|
972
|
-
// };
|
|
973
|
-
// // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
|
|
974
|
-
// // if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
975
|
-
// // params.inclusion.forEach((field) => {
|
|
976
|
-
// // projection[field] = 1;
|
|
977
|
-
// // });
|
|
978
|
-
// // } else {
|
|
979
|
-
// // projection = {
|
|
980
|
-
// // __v: 0,
|
|
981
|
-
// // createdAt: 0,
|
|
982
|
-
// // updatedAt: 0
|
|
983
|
-
// // };
|
|
984
|
-
// // }
|
|
985
|
-
// const query = this.transactionModel.find(
|
|
986
|
-
// (conditions.length > 0) ? { $and: conditions } : {}
|
|
987
|
-
// )
|
|
988
|
-
// .select(projection);
|
|
989
|
-
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
990
|
-
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
991
|
-
// query.limit(params.limit)
|
|
992
|
-
// .skip(params.limit * (page - 1));
|
|
993
|
-
// }
|
|
994
|
-
// if (params.sort?.startDate !== undefined) {
|
|
995
|
-
// query.sort({ startDate: params.sort.startDate });
|
|
996
|
-
// }
|
|
997
|
-
// // const explainResult = await (<any>query).explain();
|
|
998
|
-
// // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
999
|
-
// return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
1000
|
-
// .lean<(Pick<factory.transaction.ITransaction<T>, F> & { id: string })[]>()
|
|
1001
|
-
// .exec();
|
|
1002
|
-
// }
|
|
1003
|
-
// /**
|
|
1004
|
-
// * 特定の進行中取引を更新する(汎用)
|
|
1005
|
-
// */
|
|
1006
|
-
// public async findByIdAndUpdateInProgress(params: {
|
|
1007
|
-
// id: string;
|
|
1008
|
-
// update: {
|
|
1009
|
-
// $set?: { 'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl };
|
|
1010
|
-
// // $unset?: any;
|
|
1011
|
-
// // $pull?: any;
|
|
1012
|
-
// // $push?: any;
|
|
1013
|
-
// };
|
|
1014
|
-
// }): Promise<void> {
|
|
1015
|
-
// await this.transactionModel.findOneAndUpdate(
|
|
1016
|
-
// {
|
|
1017
|
-
// _id: { $eq: params.id },
|
|
1018
|
-
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
1019
|
-
// },
|
|
1020
|
-
// params.update,
|
|
1021
|
-
// {
|
|
1022
|
-
// // new: true,
|
|
1023
|
-
// projection: { _id: 1 }
|
|
1024
|
-
// }
|
|
1025
|
-
// )
|
|
1026
|
-
// .lean<{ _id: ObjectId }>()
|
|
1027
|
-
// .exec()
|
|
1028
|
-
// .then((doc) => {
|
|
1029
|
-
// if (doc === null) {
|
|
1030
|
-
// throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
1031
|
-
// }
|
|
1032
|
-
// });
|
|
1033
|
-
// }
|
|
1034
|
-
// /**
|
|
1035
|
-
// * 進行中取引のobjectに注文番号を保管する
|
|
1036
|
-
// */
|
|
1037
|
-
// public async saveOrderNumberIfNotExist(params: {
|
|
1038
|
-
// id: string;
|
|
1039
|
-
// orderNumber: string;
|
|
1040
|
-
// }): Promise<{ modifiedCount: number }> {
|
|
1041
|
-
// const result = await this.transactionModel.updateOne(
|
|
1042
|
-
// {
|
|
1043
|
-
// _id: { $eq: params.id },
|
|
1044
|
-
// status: { $eq: factory.transactionStatusType.InProgress },
|
|
1045
|
-
// 'object.orderNumber': { $exists: false }
|
|
1046
|
-
// },
|
|
1047
|
-
// { $set: { 'object.orderNumber': params.orderNumber } }
|
|
1048
|
-
// )
|
|
1049
|
-
// .exec();
|
|
1050
|
-
// return { modifiedCount: result.modifiedCount };
|
|
1051
|
-
// }
|
|
1052
|
-
// public async saveConfirmationNumberIfNotExist(params: {
|
|
1053
|
-
// id: string;
|
|
1054
|
-
// status: { $in: factory.transactionStatusType[] };
|
|
1055
|
-
// confirmationNumber: string;
|
|
1056
|
-
// }): Promise<void> {
|
|
1057
|
-
// await this.transactionModel.updateOne(
|
|
1058
|
-
// {
|
|
1059
|
-
// _id: { $eq: params.id },
|
|
1060
|
-
// // status: { $eq: factory.transactionStatusType.InProgress },
|
|
1061
|
-
// status: { $in: params.status.$in },
|
|
1062
|
-
// 'object.confirmationNumber': { $exists: false }
|
|
1063
|
-
// },
|
|
1064
|
-
// { $set: { 'object.confirmationNumber': params.confirmationNumber } }
|
|
1065
|
-
// )
|
|
1066
|
-
// .exec();
|
|
1067
|
-
// }
|
|
1068
292
|
async findByIdAndDelete(params) {
|
|
1069
293
|
await this.transactionModel.findByIdAndDelete(params.id)
|
|
1070
294
|
.exec();
|
package/lib/chevre/service/order/{findPlaceOrderTransaction.d.ts → findConfirmedPlaceOrder.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
|
|
2
2
|
import { factory } from '../../factory';
|
|
3
3
|
type ITransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'potentialActions' | 'project' | 'typeOf'>;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function findConfirmedPlaceOrder(params: {
|
|
5
5
|
project: {
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
package/lib/chevre/service/order/{findPlaceOrderTransaction.js → findConfirmedPlaceOrder.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.findConfirmedPlaceOrder = findConfirmedPlaceOrder;
|
|
4
4
|
const factory_1 = require("../../factory");
|
|
5
|
-
function
|
|
5
|
+
function findConfirmedPlaceOrder(params) {
|
|
6
6
|
return async (repos) => {
|
|
7
7
|
const placeOrderTransactions = await repos.placeOrder.findPlaceOrderTransactions({
|
|
8
8
|
limit: 1,
|
|
@@ -10,12 +10,17 @@ function findPlaceOrderTransaction(params) {
|
|
|
10
10
|
project: { id: { $eq: params.project.id } },
|
|
11
11
|
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
12
12
|
statuses: [factory_1.factory.transactionStatusType.Confirmed],
|
|
13
|
-
result
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
// resultではなくobjectで参照するように変更(2026-06-16~)
|
|
14
|
+
object: {
|
|
15
|
+
confirmationNumber: { $eq: params.confirmationNumber },
|
|
16
|
+
orderNumber: { $eq: params.orderNumber },
|
|
18
17
|
},
|
|
18
|
+
// result: {
|
|
19
|
+
// order: {
|
|
20
|
+
// confirmationNumber: { $eq: params.confirmationNumber },
|
|
21
|
+
// orderNumbers: [params.orderNumber]
|
|
22
|
+
// }
|
|
23
|
+
// },
|
|
19
24
|
inclusion: ['potentialActions', 'project', 'typeOf']
|
|
20
25
|
});
|
|
21
26
|
const placeOrderTransaction = placeOrderTransactions.shift();
|
package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onPayTransactionCanceled = onPayTransactionCanceled;
|
|
4
|
-
const
|
|
4
|
+
const findConfirmedPlaceOrder_1 = require("../findConfirmedPlaceOrder");
|
|
5
5
|
const onOrderStatusChanged_1 = require("../onOrderStatusChanged");
|
|
6
6
|
const factory_1 = require("../../../factory");
|
|
7
7
|
function onPayTransactionCanceled(params) {
|
|
@@ -35,7 +35,7 @@ function cancelOrderIfExist(params) {
|
|
|
35
35
|
}, { inclusion: ['confirmationNumber', 'orderNumber'] });
|
|
36
36
|
const orderByPaymentMethodId = ordersByPaymentMethodId.shift();
|
|
37
37
|
if (orderByPaymentMethodId !== undefined) {
|
|
38
|
-
const placeOrderTransaction = await (0,
|
|
38
|
+
const placeOrderTransaction = await (0, findConfirmedPlaceOrder_1.findConfirmedPlaceOrder)({
|
|
39
39
|
project: { id: params.project.id },
|
|
40
40
|
confirmationNumber: orderByPaymentMethodId.confirmationNumber,
|
|
41
41
|
orderNumber: orderByPaymentMethodId.orderNumber
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.paymentDue2Processing = paymentDue2Processing;
|
|
7
7
|
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const
|
|
8
|
+
const findConfirmedPlaceOrder_1 = require("../findConfirmedPlaceOrder");
|
|
9
9
|
const onOrderStatusChanged_1 = require("../onOrderStatusChanged");
|
|
10
10
|
const factory_1 = require("../../../factory");
|
|
11
11
|
const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
@@ -14,16 +14,11 @@ const debug = (0, debug_1.default)('chevre-domain:service:order');
|
|
|
14
14
|
*/
|
|
15
15
|
function paymentDue2Processing(params) {
|
|
16
16
|
return async (repos, settings) => {
|
|
17
|
-
const placeOrderTransaction = await (0,
|
|
17
|
+
const placeOrderTransaction = await (0, findConfirmedPlaceOrder_1.findConfirmedPlaceOrder)({
|
|
18
18
|
project: { id: params.project.id },
|
|
19
19
|
confirmationNumber: params.confirmationNumber,
|
|
20
20
|
orderNumber: params.orderNumber
|
|
21
21
|
})(repos);
|
|
22
|
-
// const existingOrder: Pick<factory.order.IOrder, 'project'> = await repos.order.projectFieldsByOrderNumber({
|
|
23
|
-
// orderNumber: params.orderNumber,
|
|
24
|
-
// project: { id: params.project.id },
|
|
25
|
-
// inclusion: ['project']
|
|
26
|
-
// });
|
|
27
22
|
let order;
|
|
28
23
|
try {
|
|
29
24
|
order = await repos.order.changeStatus({
|
|
@@ -13,18 +13,27 @@ function createPlacingOrderFromExistingTransaction(params) {
|
|
|
13
13
|
project: { id: { $eq: params.project.id } },
|
|
14
14
|
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
15
15
|
statuses: [factory_1.factory.transactionStatusType.Confirmed],
|
|
16
|
-
result
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
orderNumbers: [orderNumber]
|
|
20
|
-
}
|
|
16
|
+
// resultではなくobjectで参照するように変更(2026-06-16~)
|
|
17
|
+
object: {
|
|
18
|
+
orderNumber: { $eq: orderNumber },
|
|
21
19
|
},
|
|
22
|
-
|
|
20
|
+
// result: {
|
|
21
|
+
// order: {
|
|
22
|
+
// confirmationNumber: { $eq: confirmationNumber },
|
|
23
|
+
// orderNumbers: [orderNumber]
|
|
24
|
+
// }
|
|
25
|
+
// },
|
|
26
|
+
inclusion: ['project', 'typeOf', 'result', 'object', 'seller']
|
|
23
27
|
});
|
|
24
28
|
const placeOrderTransactionWithResult = placeOrderTransactions.shift();
|
|
25
29
|
if (placeOrderTransactionWithResult === undefined) {
|
|
26
30
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
|
|
27
31
|
}
|
|
32
|
+
// 参照時の条件に含まれないので、確認番号はここで検証(2026-06-16~)
|
|
33
|
+
if (typeof placeOrderTransactionWithResult.object.confirmationNumber !== 'string'
|
|
34
|
+
|| placeOrderTransactionWithResult.object.confirmationNumber !== confirmationNumber) {
|
|
35
|
+
throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder, `${factory_1.factory.transactionType.PlaceOrder} not found with the confirmationNumber`);
|
|
36
|
+
}
|
|
28
37
|
let authorizePaymentActions = [];
|
|
29
38
|
let authorizeOfferActionsWithInstrument = [];
|
|
30
39
|
const authorizeActionsAsResult = placeOrderTransactionWithResult.result?.authorizeActions;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "9.0.0-alpha.
|
|
14
|
+
"@chevre/factory": "9.0.0-alpha.1",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "24.1.0-alpha.
|
|
94
|
+
"version": "24.1.0-alpha.62"
|
|
95
95
|
}
|