@chevre/domain 24.1.0-alpha.60 → 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/factory/transaction/placeOrder.d.ts +2 -7
- package/lib/chevre/factory/transaction/placeOrder.js +1 -0
- package/lib/chevre/repo/transaction/placeOrder.d.ts +8 -3
- package/lib/chevre/repo/transaction/placeOrder.js +5 -1
- 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/lib/chevre/service/order/placeOrder/factory.js +25 -10
- package/lib/chevre/service/transaction/deleteTransaction.js +13 -7
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.js +15 -8
- package/package.json +2 -2
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { factory } from '../../factory';
|
|
2
|
-
export
|
|
3
|
-
export type IResultOrderParams = factory.transaction.placeOrder.IResultOrderParams & {
|
|
2
|
+
export interface IResultOrderParams {
|
|
4
3
|
/**
|
|
5
4
|
* 注文日時
|
|
6
5
|
*/
|
|
7
6
|
orderDate: Date;
|
|
8
|
-
/**
|
|
9
|
-
* 注文確認URLのカスタム指定
|
|
10
|
-
*/
|
|
11
|
-
url?: string | IOrderURLGenerator;
|
|
12
7
|
/**
|
|
13
8
|
* オファー制約
|
|
14
9
|
*/
|
|
@@ -26,7 +21,7 @@ export type IResultOrderParams = factory.transaction.placeOrder.IResultOrderPara
|
|
|
26
21
|
orderedItem: {
|
|
27
22
|
maxValue: number;
|
|
28
23
|
};
|
|
29
|
-
}
|
|
24
|
+
}
|
|
30
25
|
export type IConfirmParams = factory.transaction.placeOrder.IConfirmParams & {
|
|
31
26
|
project: {
|
|
32
27
|
id: string;
|
|
@@ -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;
|
|
@@ -126,6 +128,9 @@ export declare class PlaceOrderRepo {
|
|
|
126
128
|
confirmPlaceOrder(params: {
|
|
127
129
|
typeOf: factory.transactionType.PlaceOrder;
|
|
128
130
|
id: string;
|
|
131
|
+
object: {
|
|
132
|
+
orderDate: Date;
|
|
133
|
+
};
|
|
129
134
|
result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
|
|
130
135
|
potentialActions: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
|
|
131
136
|
}): Promise<void>;
|
|
@@ -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) {
|
|
@@ -425,7 +429,7 @@ class PlaceOrderRepo {
|
|
|
425
429
|
}, {
|
|
426
430
|
status: factory_1.factory.transactionStatusType.Confirmed, // ステータス変更
|
|
427
431
|
endDate,
|
|
428
|
-
|
|
432
|
+
'object.orderDate': params.object.orderDate, // add(2026-06-15~)
|
|
429
433
|
result: params.result, // resultを更新
|
|
430
434
|
potentialActions: params.potentialActions // resultを更新
|
|
431
435
|
}, {
|
|
@@ -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;
|
|
@@ -68,10 +68,29 @@ function createSeller(params) {
|
|
|
68
68
|
}
|
|
69
69
|
function createPlacingOrder(params) {
|
|
70
70
|
const { transaction, authorizePaymentActions } = params;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
let orderDateByTransaction;
|
|
72
|
+
const { confirmationNumber, orderDate, orderNumber } = transaction.object;
|
|
73
|
+
if (typeof confirmationNumber !== 'string') {
|
|
74
|
+
// 事前に発行済なはずなので、ありえないフロー
|
|
75
|
+
throw new factory_1.factory.errors.Internal('object.confirmationNumber undefined');
|
|
76
|
+
}
|
|
77
|
+
if (typeof orderNumber !== 'string') {
|
|
78
|
+
// 事前に発行済なはずなので、ありえないフロー
|
|
79
|
+
throw new factory_1.factory.errors.Internal('object.orderNumber undefined');
|
|
80
|
+
}
|
|
81
|
+
if (orderDate === undefined) {
|
|
82
|
+
orderDateByTransaction = transaction.result?.order?.orderDate;
|
|
74
83
|
}
|
|
84
|
+
else {
|
|
85
|
+
orderDateByTransaction = orderDate;
|
|
86
|
+
}
|
|
87
|
+
if (orderDateByTransaction === undefined) {
|
|
88
|
+
throw new factory_1.factory.errors.NotFound('orderDate in the transaction');
|
|
89
|
+
}
|
|
90
|
+
// const orderByTransaction = transaction.result?.order;
|
|
91
|
+
// if (orderByTransaction === undefined) {
|
|
92
|
+
// throw new factory.errors.NotFound('transaction.result.order');
|
|
93
|
+
// }
|
|
75
94
|
const seller = createSeller({ transaction });
|
|
76
95
|
// discontinue(2026-06-11~)
|
|
77
96
|
// const name: string | undefined =
|
|
@@ -92,21 +111,17 @@ function createPlacingOrder(params) {
|
|
|
92
111
|
const orderedItem = (0, orderedItem_1.acceptedOffers2orderedItem)({
|
|
93
112
|
eventReservationAcceptedOffers,
|
|
94
113
|
});
|
|
95
|
-
const confirmationNumber = transaction.object.confirmationNumber;
|
|
96
|
-
if (typeof confirmationNumber !== 'string') {
|
|
97
|
-
// 事前に発行済なはずなので、ありえないフロー
|
|
98
|
-
throw new factory_1.factory.errors.Internal('object.confirmationNumber undefined');
|
|
99
|
-
}
|
|
100
114
|
return {
|
|
101
|
-
...orderByTransaction,
|
|
115
|
+
// ...orderByTransaction, // transaction.result.orderへの依存廃止(2026-06-15~)
|
|
102
116
|
confirmationNumber,
|
|
117
|
+
orderNumber,
|
|
103
118
|
typeOf: factory_1.factory.order.OrderType.Order, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
104
119
|
orderStatus: factory_1.factory.orderStatus.OrderPaymentDue, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
105
120
|
seller, // 2024-06-17~
|
|
106
121
|
paymentMethods, // 2024-06-17~
|
|
107
122
|
price, // 2024-06-17~
|
|
108
123
|
priceCurrency: factory_1.factory.priceCurrency.JPY, // 取引保管を廃止するためにここで指定(2026-06-14~)
|
|
109
|
-
orderDate: (0, moment_1.default)(
|
|
124
|
+
orderDate: (0, moment_1.default)(orderDateByTransaction)
|
|
110
125
|
.toDate(),
|
|
111
126
|
orderedItem, // 2024-06-18~
|
|
112
127
|
// ...(typeof name === 'string') ? { name } : undefined, // discontinue(2026-06-11~)
|
|
@@ -133,19 +133,21 @@ function deleteTransactionById(params) {
|
|
|
133
133
|
if (typeof deletingTransactionId !== 'string' || deletingTransactionId.length === 0) {
|
|
134
134
|
throw new factory_1.factory.errors.ArgumentNull('object.id');
|
|
135
135
|
}
|
|
136
|
+
let deletingOrderNumberByTask;
|
|
136
137
|
let transaction;
|
|
137
138
|
if (params.object.typeOf === factory_1.factory.transactionType.PlaceOrder) {
|
|
138
139
|
transaction = (await repos.placeOrder.findPlaceOrderTransactions({
|
|
139
140
|
ids: [deletingTransactionId],
|
|
140
141
|
typeOf: params.object.typeOf,
|
|
141
|
-
inclusion: ['typeOf', 'project', 'status'
|
|
142
|
+
inclusion: ['typeOf', 'project', 'status']
|
|
142
143
|
})).shift();
|
|
144
|
+
deletingOrderNumberByTask = params.object.object.orderNumber;
|
|
143
145
|
}
|
|
144
146
|
else if (params.object.typeOf === factory_1.factory.transactionType.ReturnOrder) {
|
|
145
147
|
transaction = (await repos.returnOrder.findReturnOrderTransactions({
|
|
146
148
|
ids: [deletingTransactionId],
|
|
147
149
|
typeOf: params.object.typeOf,
|
|
148
|
-
inclusion: ['typeOf', 'project', 'status'
|
|
150
|
+
inclusion: ['typeOf', 'project', 'status']
|
|
149
151
|
})).shift();
|
|
150
152
|
}
|
|
151
153
|
else {
|
|
@@ -189,10 +191,16 @@ function deleteTransactionById(params) {
|
|
|
189
191
|
case factory_1.factory.transactionStatusType.Expired:
|
|
190
192
|
break;
|
|
191
193
|
case factory_1.factory.transactionStatusType.Confirmed: {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
// 削除対象の注文番号についてはタスクを参照する(2026-06-15~)
|
|
195
|
+
// const deletingOrder = transaction.result?.order;
|
|
196
|
+
// if (typeof deletingOrder?.orderNumber === 'string') {
|
|
197
|
+
// await deleteOrder({
|
|
198
|
+
// object: deletingOrder
|
|
199
|
+
// })(repos);
|
|
200
|
+
// }
|
|
201
|
+
if (typeof deletingOrderNumberByTask === 'string') {
|
|
194
202
|
await (0, deleteOrder_1.deleteOrder)({
|
|
195
|
-
object:
|
|
203
|
+
object: { orderNumber: deletingOrderNumberByTask }
|
|
196
204
|
})(repos);
|
|
197
205
|
}
|
|
198
206
|
break;
|
|
@@ -200,8 +208,6 @@ function deleteTransactionById(params) {
|
|
|
200
208
|
default:
|
|
201
209
|
throw new factory_1.factory.errors.NotImplemented(`${transaction.status} not implemented`);
|
|
202
210
|
}
|
|
203
|
-
// eslint-disable-next-line no-warning-comments
|
|
204
|
-
// TODO サービス登録取引を削除
|
|
205
211
|
// 決済取引を削除
|
|
206
212
|
const deletePayTransactionsByPlaceOrderResult = await deletePayTransactionsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
207
213
|
deletePayTransactionResult = deletePayTransactionsByPlaceOrderResult.deletePayTransactionResult;
|
|
@@ -6,7 +6,6 @@ export { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction,
|
|
|
6
6
|
* 取引が確定可能な状態かどうかをチェックする
|
|
7
7
|
*/
|
|
8
8
|
export declare function validateTransaction(transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'object'>, acceptPayActions: IAcceptPayAction[], authorizePaymentActions: IAuthorizePaymentAction[], authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[], eventReservationAcceptedOffers: Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'priceSpecification'>[], payTransactions: IPayTransaction[], customer: factory.order.ICustomer): void;
|
|
9
|
-
export type IOrderURLGenerator = (order: factory.order.IOrder) => string;
|
|
10
9
|
/**
|
|
11
10
|
* 注文オファー数検証
|
|
12
11
|
*/
|
|
@@ -43,10 +43,14 @@ interface IConfirmOptions {
|
|
|
43
43
|
* 注文における最大CreditCardIF決済方法数
|
|
44
44
|
*/
|
|
45
45
|
maxNumCreditCardPaymentMethod: number;
|
|
46
|
+
/**
|
|
47
|
+
* 取引ドキュメントのresult.orderを保管しないオプション(2026-06-15~)
|
|
48
|
+
*/
|
|
49
|
+
disableResultOrder: boolean;
|
|
46
50
|
}
|
|
47
51
|
type IConfirmParams = PlaceOrderFactory.IConfirmParams;
|
|
48
52
|
interface IConfirmResult {
|
|
49
|
-
order: factory.transaction.placeOrder.IOrderAsResult
|
|
53
|
+
order: Pick<factory.transaction.placeOrder.IOrderAsResult, 'confirmationNumber' | 'orderNumber'>;
|
|
50
54
|
customer: factory.order.ICustomer;
|
|
51
55
|
code?: string;
|
|
52
56
|
/**
|
|
@@ -29,9 +29,16 @@ function processTransactionNotInProgress(transaction) {
|
|
|
29
29
|
// if (resultCustomer === undefined) {
|
|
30
30
|
// throw new factory.errors.Internal('resultCustomer undefined'); // impossible process
|
|
31
31
|
// }
|
|
32
|
+
const { confirmationNumber, orderNumber } = transaction.object;
|
|
33
|
+
// Confirmedの取引であればobjectには必ず存在するはず
|
|
34
|
+
if (typeof confirmationNumber !== 'string' || typeof orderNumber !== 'string'
|
|
35
|
+
|| confirmationNumber === '' || orderNumber === '') {
|
|
36
|
+
throw new factory_1.factory.errors.Internal('confirmationNumber, orderNumber undefined unexpectedly');
|
|
37
|
+
}
|
|
32
38
|
// すでに確定済の場合
|
|
33
39
|
return {
|
|
34
40
|
...transaction.result,
|
|
41
|
+
order: { confirmationNumber, orderNumber },
|
|
35
42
|
customer: resultCustomer
|
|
36
43
|
};
|
|
37
44
|
}
|
|
@@ -165,6 +172,7 @@ function confirm(params, options) {
|
|
|
165
172
|
await repos.placeOrder.confirmPlaceOrder({
|
|
166
173
|
typeOf: transaction.typeOf,
|
|
167
174
|
id: transaction.id,
|
|
175
|
+
object: { orderDate: params.result.order.orderDate },
|
|
168
176
|
result: result,
|
|
169
177
|
potentialActions: potentialActions
|
|
170
178
|
});
|
|
@@ -177,9 +185,12 @@ function confirm(params, options) {
|
|
|
177
185
|
}
|
|
178
186
|
throw error;
|
|
179
187
|
}
|
|
180
|
-
const { order } = result;
|
|
188
|
+
// const { order } = result;
|
|
181
189
|
return {
|
|
182
|
-
order
|
|
190
|
+
order: {
|
|
191
|
+
confirmationNumber: placingOrder.confirmationNumber,
|
|
192
|
+
orderNumber: placingOrder.orderNumber
|
|
193
|
+
},
|
|
183
194
|
customer,
|
|
184
195
|
...(typeof code === 'string') ? { code } : undefined,
|
|
185
196
|
...(typeof eventId === 'string') ? { eventId } : undefined,
|
|
@@ -345,7 +356,6 @@ function createResult(params, options) {
|
|
|
345
356
|
const authorizeActions = [
|
|
346
357
|
...params.authorizePaymentActions.map(({ id }) => ({ id })),
|
|
347
358
|
...params.authorizeEventServiceOfferActions.map(({ id }) => ({ id })),
|
|
348
|
-
// ...params.authorizeProductOfferActions.map(({ id }) => ({ id }))
|
|
349
359
|
];
|
|
350
360
|
let eventId;
|
|
351
361
|
let reservationIds;
|
|
@@ -359,13 +369,10 @@ function createResult(params, options) {
|
|
|
359
369
|
paymentMethods,
|
|
360
370
|
placingOrder,
|
|
361
371
|
result: {
|
|
362
|
-
order: orderAsResult,
|
|
363
372
|
authorizeActions, // 追加(2024-01-17~)
|
|
364
373
|
numAcceptedOffers: params.acceptedOffers.length, // 追加(2024-01-17~)
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// },
|
|
368
|
-
...(typeof params.code === 'string') ? { code: params.code } : undefined
|
|
374
|
+
...(typeof params.code === 'string') ? { code: params.code } : undefined,
|
|
375
|
+
...((!options.disableResultOrder) && { order: orderAsResult }) // support disableResultOrder(2026-06-15~)
|
|
369
376
|
},
|
|
370
377
|
...(typeof eventId === 'string') ? { eventId } : undefined,
|
|
371
378
|
...(Array.isArray(reservationIds)) ? { reservationIds } : undefined
|
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": "
|
|
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
|
}
|