@chevre/domain 25.2.0-alpha.2 → 25.2.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/action/actionProcess.js +57 -57
- package/lib/chevre/repo/action.d.ts +16 -9
- package/lib/chevre/repo/action.js +99 -180
- package/lib/chevre/repo/mongoose/schemas/action.js +67 -66
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
- package/lib/chevre/repo/order.d.ts +2 -0
- package/lib/chevre/repo/orderInTransaction.d.ts +41 -0
- package/lib/chevre/repo/orderInTransaction.js +131 -0
- package/lib/chevre/repo/transaction/placeOrder.d.ts +1 -44
- package/lib/chevre/repo/transaction/placeOrder.js +42 -82
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +5 -1
- package/lib/chevre/service/offer/event/authorize/factory.js +22 -12
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
- package/lib/chevre/service/payment/any/authorize.js +13 -37
- package/lib/chevre/service/payment/any/factory.d.ts +6 -6
- package/lib/chevre/service/payment/any/factory.js +19 -22
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +4 -66
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -16
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -2
- package/lib/chevre/service/task/voidPayTransaction.js +3 -7
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +65 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +22 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +120 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +14 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +108 -89
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +7 -0
- package/lib/chevre/service/transaction/placeOrder/confirm.js +35 -60
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
- package/package.json +2 -2
|
@@ -214,19 +214,19 @@ const indexes = [
|
|
|
214
214
|
alternateName: { $exists: true }
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
+
],
|
|
218
|
+
// add unique index(dev)(2025-03-28~)
|
|
219
|
+
// add unique index(test,prod)(2026-07-08~)
|
|
220
|
+
[
|
|
221
|
+
{ identifier: 1 },
|
|
222
|
+
{
|
|
223
|
+
unique: true,
|
|
224
|
+
name: 'uniqueIdentifier',
|
|
225
|
+
partialFilterExpression: {
|
|
226
|
+
identifier: { $exists: true }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
217
229
|
]
|
|
218
|
-
// eslint-disable-next-line no-warning-comments
|
|
219
|
-
// TODO add unique index(2025-03-28~)
|
|
220
|
-
// [
|
|
221
|
-
// { identifier: 1 },
|
|
222
|
-
// {
|
|
223
|
-
// unique: true,
|
|
224
|
-
// name: 'uniqueIdentifier',
|
|
225
|
-
// partialFilterExpression: {
|
|
226
|
-
// identifier: { $exists: true }
|
|
227
|
-
// }
|
|
228
|
-
// }
|
|
229
|
-
// ]
|
|
230
230
|
];
|
|
231
231
|
exports.indexes = indexes;
|
|
232
232
|
/**
|
|
@@ -135,6 +135,7 @@ export declare class OrderRepo {
|
|
|
135
135
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.order.IOrder, "id"> & {
|
|
136
136
|
acceptedOffers?: factory.order.IAcceptedOffer[];
|
|
137
137
|
identifier?: string;
|
|
138
|
+
paymentMethodId?: string;
|
|
138
139
|
} & {
|
|
139
140
|
_id: import("mongoose").Types.ObjectId;
|
|
140
141
|
} & {
|
|
@@ -142,6 +143,7 @@ export declare class OrderRepo {
|
|
|
142
143
|
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.order.IOrder, "id"> & {
|
|
143
144
|
acceptedOffers?: factory.order.IAcceptedOffer[];
|
|
144
145
|
identifier?: string;
|
|
146
|
+
paymentMethodId?: string;
|
|
145
147
|
} & {
|
|
146
148
|
_id: import("mongoose").Types.ObjectId;
|
|
147
149
|
} & {
|
|
@@ -11,6 +11,7 @@ export type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'pr
|
|
|
11
11
|
acceptedOffers: factory.order.IAcceptedOffer[];
|
|
12
12
|
customer?: factory.order.ICustomer;
|
|
13
13
|
seller?: factory.order.ISeller;
|
|
14
|
+
confirmationNumber?: string;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* typeOf: Orderへドキュメント変換時の編集フィールド
|
|
@@ -61,6 +62,7 @@ export type IMinimizedAcceptedOffer = Pick<factory.order.IOptimizedAcceptedOffer
|
|
|
61
62
|
*/
|
|
62
63
|
export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
63
64
|
private readonly orderModel;
|
|
65
|
+
private readonly transactionModel;
|
|
64
66
|
constructor(connection: Connection);
|
|
65
67
|
createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker' | 'seller' | 'customer'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
66
68
|
/**
|
|
@@ -127,6 +129,45 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
127
129
|
setCustomerByIdentifier(params: Pick<IOrderInTransaction, 'project' | 'identifier'> & {
|
|
128
130
|
customer: factory.order.ICustomer;
|
|
129
131
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
132
|
+
/**
|
|
133
|
+
* 確認番号を参照する
|
|
134
|
+
*/
|
|
135
|
+
findConfirmationNumberByIdentifier(params: {
|
|
136
|
+
identifier: string;
|
|
137
|
+
}): Promise<string | undefined>;
|
|
138
|
+
/**
|
|
139
|
+
* 注文ドキュメントに確認番号を保管する
|
|
140
|
+
* 確認番号未発行の場合のみ保管される
|
|
141
|
+
*/
|
|
142
|
+
saveConfirmationNumberIfNotExist(params: {
|
|
143
|
+
identifier: string;
|
|
144
|
+
confirmationNumber: string;
|
|
145
|
+
}, options: {
|
|
146
|
+
/**
|
|
147
|
+
* 注文取引タイプのドキュメントのみを参照対象にするかどうか
|
|
148
|
+
*/
|
|
149
|
+
onlyPlaceOrder: boolean;
|
|
150
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
151
|
+
/**
|
|
152
|
+
* 特定の進行中取引の決済方法IDを保管する
|
|
153
|
+
* transactionsへの保管としてひとまず定義(2026-07-11~)
|
|
154
|
+
*/
|
|
155
|
+
savePaymentMethodId(params: {
|
|
156
|
+
id: string;
|
|
157
|
+
paymentMethod: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
158
|
+
}): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* 進行中取引に保管された採用済決済方法を検索する
|
|
161
|
+
*/
|
|
162
|
+
findInProgressPaymentMethodId(params: {
|
|
163
|
+
id: string;
|
|
164
|
+
}): Promise<string | undefined>;
|
|
165
|
+
/**
|
|
166
|
+
* 保管された採用済決済方法を検索する
|
|
167
|
+
*/
|
|
168
|
+
findPaymentMethodId(params: {
|
|
169
|
+
id: string;
|
|
170
|
+
}): Promise<string | undefined>;
|
|
130
171
|
deleteByIdentifier(params: {
|
|
131
172
|
identifier: string;
|
|
132
173
|
}): Promise<import("mongodb").DeleteResult>;
|
|
@@ -5,6 +5,7 @@ exports.OrderInTransactionRepo = void 0;
|
|
|
5
5
|
const errorHandler_1 = require("../errorHandler");
|
|
6
6
|
const factory_1 = require("../factory");
|
|
7
7
|
const order_1 = require("./mongoose/schemas/order");
|
|
8
|
+
const transaction_1 = require("./mongoose/schemas/transaction");
|
|
8
9
|
const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
|
|
9
10
|
// const debug = createDebug('chevre-domain:repo:orderInTransaction');
|
|
10
11
|
/**
|
|
@@ -12,9 +13,11 @@ const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
|
|
|
12
13
|
*/
|
|
13
14
|
class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInReserveRepo {
|
|
14
15
|
orderModel;
|
|
16
|
+
transactionModel;
|
|
15
17
|
constructor(connection) {
|
|
16
18
|
super(connection);
|
|
17
19
|
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
20
|
+
this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
|
|
18
21
|
}
|
|
19
22
|
async createPlaceOrderIfNotExists(params) {
|
|
20
23
|
const { orderNumber, project, identifier, broker, seller, customer } = params;
|
|
@@ -241,6 +244,134 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
241
244
|
}
|
|
242
245
|
return result;
|
|
243
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* 確認番号を参照する
|
|
249
|
+
*/
|
|
250
|
+
async findConfirmationNumberByIdentifier(params) {
|
|
251
|
+
const { identifier } = params;
|
|
252
|
+
const doc = await this.orderModel.findOne({
|
|
253
|
+
identifier: { $eq: identifier },
|
|
254
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder }, // 取引確定の冪等性確保のためtypeOfを検証しない
|
|
255
|
+
}, { confirmationNumber: 1 })
|
|
256
|
+
.lean()
|
|
257
|
+
.exec();
|
|
258
|
+
if (doc === null) {
|
|
259
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
260
|
+
}
|
|
261
|
+
return doc.confirmationNumber;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 注文ドキュメントに確認番号を保管する
|
|
265
|
+
* 確認番号未発行の場合のみ保管される
|
|
266
|
+
*/
|
|
267
|
+
async saveConfirmationNumberIfNotExist(params, options) {
|
|
268
|
+
const { identifier, confirmationNumber } = params;
|
|
269
|
+
const onlyPlaceOrder = options.onlyPlaceOrder === true;
|
|
270
|
+
if (typeof confirmationNumber !== 'string' || confirmationNumber === '') {
|
|
271
|
+
throw new factory_1.factory.errors.ArgumentNull('confirmationNumber');
|
|
272
|
+
}
|
|
273
|
+
return this.orderModel.updateOne({
|
|
274
|
+
identifier: { $eq: identifier },
|
|
275
|
+
confirmationNumber: { $exists: false },
|
|
276
|
+
...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
|
|
277
|
+
}, { $set: { confirmationNumber } })
|
|
278
|
+
.exec();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 特定の進行中取引の決済方法IDを保管する
|
|
282
|
+
* transactionsへの保管としてひとまず定義(2026-07-11~)
|
|
283
|
+
*/
|
|
284
|
+
async savePaymentMethodId(params) {
|
|
285
|
+
const { paymentMethodId } = params.paymentMethod;
|
|
286
|
+
if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
|
|
287
|
+
throw new factory_1.factory.errors.ArgumentNull('paymentMethod.paymentMethodId');
|
|
288
|
+
}
|
|
289
|
+
await this.transactionModel.findOneAndUpdate({
|
|
290
|
+
_id: { $eq: params.id },
|
|
291
|
+
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
292
|
+
}, {
|
|
293
|
+
$set: { 'object.paymentMethods': { paymentMethodId } }
|
|
294
|
+
}, {
|
|
295
|
+
projection: { _id: 1 }
|
|
296
|
+
})
|
|
297
|
+
.lean()
|
|
298
|
+
.exec()
|
|
299
|
+
.then((doc) => {
|
|
300
|
+
if (doc === null) {
|
|
301
|
+
throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
// 注文ドキュメントにも保管する(2026-07-12~)
|
|
305
|
+
await this.orderModel.findOneAndUpdate({
|
|
306
|
+
identifier: { $eq: params.id },
|
|
307
|
+
paymentMethodId: { $exists: false },
|
|
308
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
|
|
309
|
+
}, { $set: { paymentMethodId } }, { projection: { _id: 1 } })
|
|
310
|
+
.lean()
|
|
311
|
+
.exec()
|
|
312
|
+
.then((doc) => {
|
|
313
|
+
if (doc === null) {
|
|
314
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* 進行中取引に保管された採用済決済方法を検索する
|
|
320
|
+
*/
|
|
321
|
+
async findInProgressPaymentMethodId(params) {
|
|
322
|
+
const doc = await this.transactionModel.findOne({
|
|
323
|
+
_id: { $eq: params.id },
|
|
324
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
325
|
+
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
326
|
+
}, {
|
|
327
|
+
'object.paymentMethods': 1,
|
|
328
|
+
_id: 0
|
|
329
|
+
})
|
|
330
|
+
.lean()
|
|
331
|
+
.exec();
|
|
332
|
+
if (doc === null) {
|
|
333
|
+
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
334
|
+
}
|
|
335
|
+
return (typeof doc.object.paymentMethods?.paymentMethodId === 'string') ? doc.object.paymentMethods.paymentMethodId : undefined;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 保管された採用済決済方法を検索する
|
|
339
|
+
*/
|
|
340
|
+
async findPaymentMethodId(params) {
|
|
341
|
+
const doc = await this.transactionModel.findOne({
|
|
342
|
+
_id: { $eq: params.id },
|
|
343
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
|
|
344
|
+
}, {
|
|
345
|
+
'object.paymentMethods': 1,
|
|
346
|
+
_id: 0
|
|
347
|
+
})
|
|
348
|
+
.lean()
|
|
349
|
+
.exec();
|
|
350
|
+
if (doc === null) {
|
|
351
|
+
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
352
|
+
}
|
|
353
|
+
const paymentMethodId = doc.object.paymentMethods?.paymentMethodId;
|
|
354
|
+
if (typeof paymentMethodId === 'string') {
|
|
355
|
+
// 注文ドキュメントにも発行済の場合、同一性を検証(2026-07-12~)
|
|
356
|
+
const orderDoc = await this.orderModel.findOne({ identifier: { $eq: params.id } }, {
|
|
357
|
+
paymentMethodId: 1,
|
|
358
|
+
_id: 0
|
|
359
|
+
})
|
|
360
|
+
.lean()
|
|
361
|
+
.exec();
|
|
362
|
+
if (orderDoc === null) {
|
|
363
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
364
|
+
}
|
|
365
|
+
const paymentMethodIdByOrder = orderDoc.paymentMethodId;
|
|
366
|
+
if (typeof paymentMethodIdByOrder === 'string') {
|
|
367
|
+
console.log('paymentMethodId matched?', JSON.stringify(doc), JSON.stringify(orderDoc));
|
|
368
|
+
if (paymentMethodId !== paymentMethodIdByOrder) {
|
|
369
|
+
throw new factory_1.factory.errors.Internal('paymentMethodId not matched unexpectedly');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return (typeof paymentMethodId === 'string') ? paymentMethodId : undefined;
|
|
374
|
+
}
|
|
244
375
|
async deleteByIdentifier(params) {
|
|
245
376
|
return this.orderModel.deleteOne({
|
|
246
377
|
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
@@ -37,21 +37,6 @@ export declare class PlaceOrderRepo {
|
|
|
37
37
|
}): Promise<(Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, IKeyOfProjection> & {
|
|
38
38
|
id: string;
|
|
39
39
|
})[]>;
|
|
40
|
-
/**
|
|
41
|
-
* 進行中取引に保管された採用済決済方法を検索する
|
|
42
|
-
*/
|
|
43
|
-
findInProgressPaymentMethodId(params: {
|
|
44
|
-
id: string;
|
|
45
|
-
}): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
|
|
46
|
-
/**
|
|
47
|
-
* 取引の確認番号を検索する
|
|
48
|
-
*/
|
|
49
|
-
findInProgressConfirmationNumberById(params: {
|
|
50
|
-
id: string;
|
|
51
|
-
status: {
|
|
52
|
-
$in: factory.transactionStatusType[];
|
|
53
|
-
};
|
|
54
|
-
}): Promise<string | undefined>;
|
|
55
40
|
/**
|
|
56
41
|
* 取引期限変更
|
|
57
42
|
*/
|
|
@@ -60,28 +45,6 @@ export declare class PlaceOrderRepo {
|
|
|
60
45
|
id: string;
|
|
61
46
|
expires: Date;
|
|
62
47
|
}): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* 取引オブジェクトを更新
|
|
65
|
-
* 注文名称など
|
|
66
|
-
*/
|
|
67
|
-
updateObject(params: {
|
|
68
|
-
typeOf: factory.transactionType.PlaceOrder;
|
|
69
|
-
id: string;
|
|
70
|
-
object?: {
|
|
71
|
-
name?: string;
|
|
72
|
-
};
|
|
73
|
-
}): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* 特定の進行中取引を更新する(汎用)
|
|
76
|
-
*/
|
|
77
|
-
findByIdAndUpdateInProgress(params: {
|
|
78
|
-
id: string;
|
|
79
|
-
update: {
|
|
80
|
-
$set?: {
|
|
81
|
-
'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}): Promise<void>;
|
|
85
48
|
/**
|
|
86
49
|
* 進行中取引のobjectに注文番号を保管する
|
|
87
50
|
*/
|
|
@@ -91,13 +54,6 @@ export declare class PlaceOrderRepo {
|
|
|
91
54
|
}): Promise<{
|
|
92
55
|
modifiedCount: number;
|
|
93
56
|
}>;
|
|
94
|
-
saveConfirmationNumberIfNotExist(params: {
|
|
95
|
-
id: string;
|
|
96
|
-
status: {
|
|
97
|
-
$in: factory.transactionStatusType[];
|
|
98
|
-
};
|
|
99
|
-
confirmationNumber: string;
|
|
100
|
-
}): Promise<void>;
|
|
101
57
|
/**
|
|
102
58
|
* 進行中の注文取引を取得する
|
|
103
59
|
*/
|
|
@@ -125,6 +81,7 @@ export declare class PlaceOrderRepo {
|
|
|
125
81
|
object: {
|
|
126
82
|
orderDate: Date;
|
|
127
83
|
orderNumber: string;
|
|
84
|
+
confirmationNumber: string;
|
|
128
85
|
};
|
|
129
86
|
result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
|
|
130
87
|
potentialActions: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
|
|
@@ -186,22 +186,6 @@ class PlaceOrderRepo {
|
|
|
186
186
|
.lean()
|
|
187
187
|
.exec();
|
|
188
188
|
}
|
|
189
|
-
/**
|
|
190
|
-
* 進行中取引に保管された採用済決済方法を検索する
|
|
191
|
-
*/
|
|
192
|
-
async findInProgressPaymentMethodId(params) {
|
|
193
|
-
const doc = await this.transactionModel.findOne({
|
|
194
|
-
_id: { $eq: params.id },
|
|
195
|
-
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
196
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
197
|
-
}, { 'object.paymentMethods': 1 })
|
|
198
|
-
.lean() // 2024-08-26~
|
|
199
|
-
.exec();
|
|
200
|
-
if (doc === null) {
|
|
201
|
-
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
202
|
-
}
|
|
203
|
-
return doc.object.paymentMethods;
|
|
204
|
-
}
|
|
205
189
|
// /**
|
|
206
190
|
// * 取引の注文番号を検索する
|
|
207
191
|
// */
|
|
@@ -226,22 +210,31 @@ class PlaceOrderRepo {
|
|
|
226
210
|
// }
|
|
227
211
|
// return doc.object.orderNumber;
|
|
228
212
|
// }
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
async findInProgressConfirmationNumberById(params
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
213
|
+
// /**
|
|
214
|
+
// * 取引の確認番号を検索する
|
|
215
|
+
// */
|
|
216
|
+
// public async findInProgressConfirmationNumberById(params: {
|
|
217
|
+
// id: string;
|
|
218
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
219
|
+
// }): Promise<string | undefined> {
|
|
220
|
+
// const doc = await this.transactionModel.findOne(
|
|
221
|
+
// {
|
|
222
|
+
// _id: { $eq: params.id },
|
|
223
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
224
|
+
// status: { $in: params.status.$in }
|
|
225
|
+
// },
|
|
226
|
+
// { 'object.confirmationNumber': 1 }
|
|
227
|
+
// )
|
|
228
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
|
|
229
|
+
// .exec();
|
|
230
|
+
// if (doc === null) {
|
|
231
|
+
// throw new factory.errors.NotFound(
|
|
232
|
+
// this.transactionModel.modelName,
|
|
233
|
+
// `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
|
|
234
|
+
// );
|
|
235
|
+
// }
|
|
236
|
+
// return doc.object.confirmationNumber;
|
|
237
|
+
// }
|
|
245
238
|
/**
|
|
246
239
|
* 取引期限変更
|
|
247
240
|
*/
|
|
@@ -263,47 +256,6 @@ class PlaceOrderRepo {
|
|
|
263
256
|
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
264
257
|
}
|
|
265
258
|
}
|
|
266
|
-
/**
|
|
267
|
-
* 取引オブジェクトを更新
|
|
268
|
-
* 注文名称など
|
|
269
|
-
*/
|
|
270
|
-
async updateObject(params) {
|
|
271
|
-
const doc = await this.transactionModel.findOneAndUpdate({
|
|
272
|
-
_id: { $eq: params.id },
|
|
273
|
-
typeOf: { $eq: params.typeOf },
|
|
274
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
275
|
-
}, {
|
|
276
|
-
$set: {
|
|
277
|
-
...(typeof params.object?.name === 'string') ? { 'object.name': params.object.name } : undefined
|
|
278
|
-
}
|
|
279
|
-
}, {
|
|
280
|
-
projection: { _id: 1 }
|
|
281
|
-
})
|
|
282
|
-
.lean()
|
|
283
|
-
.exec();
|
|
284
|
-
if (doc === null) {
|
|
285
|
-
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* 特定の進行中取引を更新する(汎用)
|
|
290
|
-
*/
|
|
291
|
-
async findByIdAndUpdateInProgress(params) {
|
|
292
|
-
await this.transactionModel.findOneAndUpdate({
|
|
293
|
-
_id: { $eq: params.id },
|
|
294
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
295
|
-
}, params.update, {
|
|
296
|
-
// new: true,
|
|
297
|
-
projection: { _id: 1 }
|
|
298
|
-
})
|
|
299
|
-
.lean()
|
|
300
|
-
.exec()
|
|
301
|
-
.then((doc) => {
|
|
302
|
-
if (doc === null) {
|
|
303
|
-
throw new factory_1.factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
259
|
/**
|
|
308
260
|
* 進行中取引のobjectに注文番号を保管する
|
|
309
261
|
*/
|
|
@@ -316,15 +268,22 @@ class PlaceOrderRepo {
|
|
|
316
268
|
.exec();
|
|
317
269
|
return { modifiedCount: result.modifiedCount };
|
|
318
270
|
}
|
|
319
|
-
async saveConfirmationNumberIfNotExist(params
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
271
|
+
// public async saveConfirmationNumberIfNotExist(params: {
|
|
272
|
+
// id: string;
|
|
273
|
+
// status: { $in: factory.transactionStatusType[] };
|
|
274
|
+
// confirmationNumber: string;
|
|
275
|
+
// }): Promise<void> {
|
|
276
|
+
// await this.transactionModel.updateOne(
|
|
277
|
+
// {
|
|
278
|
+
// _id: { $eq: params.id },
|
|
279
|
+
// // status: { $eq: factory.transactionStatusType.InProgress },
|
|
280
|
+
// status: { $in: params.status.$in },
|
|
281
|
+
// 'object.confirmationNumber': { $exists: false }
|
|
282
|
+
// },
|
|
283
|
+
// { $set: { 'object.confirmationNumber': params.confirmationNumber } }
|
|
284
|
+
// )
|
|
285
|
+
// .exec();
|
|
286
|
+
// }
|
|
328
287
|
/**
|
|
329
288
|
* 進行中の注文取引を取得する
|
|
330
289
|
*/
|
|
@@ -441,6 +400,7 @@ class PlaceOrderRepo {
|
|
|
441
400
|
endDate,
|
|
442
401
|
'object.orderDate': params.object.orderDate, // add(2026-06-15~)
|
|
443
402
|
'object.orderNumber': params.object.orderNumber, // add(2026-06-27~)
|
|
403
|
+
'object.confirmationNumber': params.object.confirmationNumber, // add(2026-07-08~)
|
|
444
404
|
result: params.result, // resultを更新
|
|
445
405
|
potentialActions: params.potentialActions // resultを更新
|
|
446
406
|
}, {
|
|
@@ -82,7 +82,8 @@ function createStartParams(params, options) {
|
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
default:
|
|
85
|
-
|
|
85
|
+
// no op
|
|
86
|
+
throw new factory_1.factory.errors.NotImplemented(`paymentServiceType: ${params.paymentServiceType} not implemented`);
|
|
86
87
|
}
|
|
87
88
|
// const informPaymentParams = createInformPaymentParams({
|
|
88
89
|
// paymentService: <factory.service.paymentService.IService | undefined>params.paymentService
|
|
@@ -122,12 +123,10 @@ function createStartParams(params, options) {
|
|
|
122
123
|
: paymentMethodType,
|
|
123
124
|
amount: paymentMethodAmount, // MonetaryAmount対応(2023-08-14~)
|
|
124
125
|
identifier: paymentMethodType, // 追加(2023-08-29~)
|
|
126
|
+
totalPaymentDue,
|
|
125
127
|
...(typeof params.object.paymentMethod?.description === 'string')
|
|
126
128
|
? { description: params.object.paymentMethod?.description }
|
|
127
129
|
: undefined,
|
|
128
|
-
...(totalPaymentDue !== undefined)
|
|
129
|
-
? { totalPaymentDue: totalPaymentDue }
|
|
130
|
-
: undefined,
|
|
131
130
|
...(typeof accountId === 'string') ? { accountId: accountId } : undefined,
|
|
132
131
|
...(typeof params.object.paymentMethod?.method === 'string')
|
|
133
132
|
? { method: params.object.paymentMethod?.method }
|
|
@@ -31,7 +31,11 @@ declare function acceptedOffers2authorizeResult(params: {
|
|
|
31
31
|
acceptedOffers4result: IResultAcceptedOffer[];
|
|
32
32
|
noOfferSpecified: boolean;
|
|
33
33
|
ticketOffers: factory.product.ITicketOffer[];
|
|
34
|
-
}
|
|
34
|
+
}, options: {
|
|
35
|
+
useLegacyAuthorizeOfferResult: boolean;
|
|
36
|
+
}): factory.action.authorize.offer.eventService.IResult & {
|
|
37
|
+
onlyPrice?: boolean;
|
|
38
|
+
};
|
|
35
39
|
type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
|
|
36
40
|
export type IResultAcceptedOffer = Omit<factory.order.IOptimizedAcceptedOffer, 'priceSpecification'> & {
|
|
37
41
|
itemOffered: factory.order.IEventReservation;
|
|
@@ -172,9 +172,10 @@ function acceptedOffers2programMembershipUsed(params) {
|
|
|
172
172
|
});
|
|
173
173
|
return programMembershipUsed;
|
|
174
174
|
}
|
|
175
|
-
function acceptedOffers2authorizeResult(params) {
|
|
175
|
+
function acceptedOffers2authorizeResult(params, options) {
|
|
176
|
+
const { useLegacyAuthorizeOfferResult } = options;
|
|
176
177
|
const { acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
|
|
177
|
-
const priceCurrency =
|
|
178
|
+
// const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
|
|
178
179
|
let offers;
|
|
179
180
|
let price;
|
|
180
181
|
let programMembershipUsed = [];
|
|
@@ -211,16 +212,25 @@ function acceptedOffers2authorizeResult(params) {
|
|
|
211
212
|
};
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
if (useLegacyAuthorizeOfferResult) {
|
|
216
|
+
return {
|
|
217
|
+
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
218
|
+
// priceCurrency, // discontinue(2026-07-06~)
|
|
219
|
+
// amount: [], // discontinue(2026-07-06~)
|
|
220
|
+
itemOffered: {
|
|
221
|
+
serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
|
|
222
|
+
},
|
|
223
|
+
...(typeof price === 'number') ? { price } : undefined,
|
|
224
|
+
...(Array.isArray(offers)) ? { offers } : undefined
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
return {
|
|
229
|
+
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
230
|
+
onlyPrice: true,
|
|
231
|
+
...(typeof price === 'number') ? { price } : undefined,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
224
234
|
}
|
|
225
235
|
function responseBody2acceptedOffers4result(params) {
|
|
226
236
|
let acceptedOffers4result = [];
|
|
@@ -78,7 +78,7 @@ function authorize(params, options) {
|
|
|
78
78
|
}
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
|
-
const result = (0, factory_2.acceptedOffers2authorizeResult)({ acceptedOffers4result, noOfferSpecified, ticketOffers });
|
|
81
|
+
const result = (0, factory_2.acceptedOffers2authorizeResult)({ acceptedOffers4result, noOfferSpecified, ticketOffers }, options);
|
|
82
82
|
await repos.authorizeOfferAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
83
83
|
return { id: action.id, result };
|
|
84
84
|
};
|
|
@@ -109,8 +109,8 @@ function authorize(params, options) {
|
|
|
109
109
|
result = {
|
|
110
110
|
typeOf: factory_2.factory.offerType.AggregateOffer, // add(2024-06-18~)
|
|
111
111
|
price: price,
|
|
112
|
-
priceCurrency:
|
|
113
|
-
amount: []
|
|
112
|
+
// priceCurrency: factory.priceCurrency.JPY, // discontinue(2026-07-06~)
|
|
113
|
+
// amount: [] // discontinue(2026-07-06~)
|
|
114
114
|
};
|
|
115
115
|
await (0, any_1.acceptOffer)({
|
|
116
116
|
project: transaction.project,
|
|
@@ -133,7 +133,7 @@ function changeOffers(params) {
|
|
|
133
133
|
const actionResult = {
|
|
134
134
|
...authorizeAction.result,
|
|
135
135
|
price: price,
|
|
136
|
-
amount: []
|
|
136
|
+
// amount: [] // discontinue(2026-07-06~)
|
|
137
137
|
};
|
|
138
138
|
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
139
139
|
await repos.action.reStart({ id: authorizeAction.id, typeOf: authorizeAction.typeOf });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
2
2
|
import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
|
+
import type { IDeleteActionResult, ActionRepo } from '../../repo/action';
|
|
3
4
|
import type { NoteRepo } from '../../repo/note';
|
|
4
5
|
import type { OrderRepo } from '../../repo/order';
|
|
5
6
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
@@ -17,8 +18,11 @@ declare function deleteOrder(params: {
|
|
|
17
18
|
}): (repos: {
|
|
18
19
|
acceptedOffer: AcceptedOfferRepo;
|
|
19
20
|
accountingReport: AccountingReportRepo;
|
|
21
|
+
action: ActionRepo;
|
|
20
22
|
note: NoteRepo;
|
|
21
23
|
order: OrderRepo;
|
|
22
24
|
reservation: ReservationRepo;
|
|
23
|
-
}) => Promise<
|
|
25
|
+
}) => Promise<{
|
|
26
|
+
deleteActionsResult: IDeleteActionResult[];
|
|
27
|
+
}>;
|
|
24
28
|
export { deleteOrder };
|