@chevre/domain 25.0.0-alpha.17 → 25.0.0-alpha.18
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/orderInTransaction.d.ts +5 -0
- package/lib/chevre/repo/orderInTransaction.js +4 -3
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.js +16 -9
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +1 -1
- package/package.json +1 -1
|
@@ -72,6 +72,11 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
72
72
|
project: {
|
|
73
73
|
id: string;
|
|
74
74
|
};
|
|
75
|
+
}, options: {
|
|
76
|
+
/**
|
|
77
|
+
* 注文取引タイプのドキュメントのみを参照対象にするかどうか
|
|
78
|
+
*/
|
|
79
|
+
onlyPlaceOrder: boolean;
|
|
75
80
|
}): Promise<string>;
|
|
76
81
|
/**
|
|
77
82
|
* 注文取引からcustomerを参照する
|
|
@@ -49,12 +49,13 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
49
49
|
* 注文取引から注文番号を参照する
|
|
50
50
|
* 存在しなければNotFoundError
|
|
51
51
|
*/
|
|
52
|
-
async findOrderNumberByIdentifier(params) {
|
|
52
|
+
async findOrderNumberByIdentifier(params, options) {
|
|
53
53
|
const { project, identifier } = params;
|
|
54
|
+
const onlyPlaceOrder = options.onlyPlaceOrder === true;
|
|
54
55
|
const doc = await this.orderModel.findOne({
|
|
55
56
|
identifier: { $eq: identifier },
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
'project.id': { $eq: project.id },
|
|
58
|
+
...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
|
|
58
59
|
}, {
|
|
59
60
|
_id: 0,
|
|
60
61
|
orderNumber: 1
|
|
@@ -28,7 +28,7 @@ function authorize(params, options) {
|
|
|
28
28
|
const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
29
29
|
identifier: transaction.id,
|
|
30
30
|
project: { id: params.project.id },
|
|
31
|
-
});
|
|
31
|
+
}, { onlyPlaceOrder: true });
|
|
32
32
|
// まず取引番号発行
|
|
33
33
|
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: now });
|
|
34
34
|
const actionAttributes = (0, factory_2.createAuthorizeSeatReservationActionAttributes)({
|
|
@@ -20,7 +20,7 @@ function fixOrderAsNeeded(params) {
|
|
|
20
20
|
const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
21
21
|
identifier: params.purpose.id,
|
|
22
22
|
project: { id: params.project.id },
|
|
23
|
-
});
|
|
23
|
+
}, { onlyPlaceOrder: true });
|
|
24
24
|
return { confirmationNumber, orderNumber };
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -19,16 +19,17 @@ const debug = (0, debug_1.default)('chevre-domain:service:transaction');
|
|
|
19
19
|
/**
|
|
20
20
|
* 進行中でない取引を処理する
|
|
21
21
|
*/
|
|
22
|
-
function processTransactionNotInProgress(
|
|
22
|
+
function processTransactionNotInProgress(params) {
|
|
23
23
|
return async (repos) => {
|
|
24
|
+
const { transaction, orderNumber } = params;
|
|
24
25
|
if (transaction.status === factory_1.factory.transactionStatusType.Confirmed) {
|
|
25
26
|
const resultCustomer = await repos.orderInTransaction.findCustomerByOrderNumber({
|
|
26
|
-
orderNumber: { $eq:
|
|
27
|
+
orderNumber: { $eq: orderNumber }
|
|
27
28
|
});
|
|
28
29
|
// if (resultCustomer === undefined) {
|
|
29
30
|
// throw new factory.errors.Internal('resultCustomer undefined'); // impossible process
|
|
30
31
|
// }
|
|
31
|
-
const { confirmationNumber
|
|
32
|
+
const { confirmationNumber } = transaction.object;
|
|
32
33
|
// Confirmedの取引であればobjectには必ず存在するはず
|
|
33
34
|
if (typeof confirmationNumber !== 'string' || typeof orderNumber !== 'string'
|
|
34
35
|
|| confirmationNumber === '' || orderNumber === '') {
|
|
@@ -62,18 +63,24 @@ function confirm(params, options) {
|
|
|
62
63
|
object: { orderDate: params.result.order.orderDate }
|
|
63
64
|
})(repos);
|
|
64
65
|
const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
|
|
65
|
-
|
|
66
|
+
// 注文ドキュメントから注文番号を参照(取引開始時に発行済の前提)(2026-06-26~)
|
|
67
|
+
const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
68
|
+
identifier: params.id,
|
|
69
|
+
project: { id: transaction.project.id }
|
|
70
|
+
}, { onlyPlaceOrder: false } // すでに取引確定済かもしれないのでfalse
|
|
71
|
+
);
|
|
72
|
+
const confirmResult = await processTransactionNotInProgress({ transaction, orderNumber })(repos);
|
|
66
73
|
if (confirmResult !== undefined) {
|
|
67
74
|
return confirmResult;
|
|
68
75
|
}
|
|
69
76
|
if (typeof params.agent?.id === 'string' && transaction.agent.id !== params.agent.id) {
|
|
70
77
|
throw new factory_1.factory.errors.Forbidden('Transaction not yours');
|
|
71
78
|
}
|
|
72
|
-
// 注文番号は興行オファー承認時に発行済のはず(2026-06-16~)
|
|
73
|
-
const orderNumber = transaction.object.orderNumber;
|
|
74
|
-
if (typeof orderNumber !== 'string' || orderNumber === '') {
|
|
75
|
-
|
|
76
|
-
}
|
|
79
|
+
// // 注文番号は興行オファー承認時に発行済のはず(2026-06-16~)
|
|
80
|
+
// const orderNumber = transaction.object.orderNumber;
|
|
81
|
+
// if (typeof orderNumber !== 'string' || orderNumber === '') {
|
|
82
|
+
// throw new factory.errors.Argument('transactionId', 'orderNumber not issued');
|
|
83
|
+
// }
|
|
77
84
|
// 取引に対する全ての承認アクションをマージ
|
|
78
85
|
const completedAuthorizeActions = await searchAuthorizeActions(params)(repos);
|
|
79
86
|
let acceptPayActions = [];
|
|
@@ -77,7 +77,7 @@ function updateAgent(params) {
|
|
|
77
77
|
const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
78
78
|
identifier: params.id,
|
|
79
79
|
project: { id: transaction.project.id },
|
|
80
|
-
});
|
|
80
|
+
}, { onlyPlaceOrder: true });
|
|
81
81
|
const customerName = (typeof customer.name === 'string' && customer.name !== '')
|
|
82
82
|
? customer.name
|
|
83
83
|
: (typeof customer.givenName === 'string' && typeof customer.familyName === 'string'
|
package/package.json
CHANGED