@chevre/domain 24.1.0-alpha.60 → 24.1.0-alpha.61
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 +3 -0
- package/lib/chevre/repo/transaction/placeOrder.js +1 -1
- 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;
|
|
@@ -126,6 +126,9 @@ export declare class PlaceOrderRepo {
|
|
|
126
126
|
confirmPlaceOrder(params: {
|
|
127
127
|
typeOf: factory.transactionType.PlaceOrder;
|
|
128
128
|
id: string;
|
|
129
|
+
object: {
|
|
130
|
+
orderDate: Date;
|
|
131
|
+
};
|
|
129
132
|
result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
|
|
130
133
|
potentialActions: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
|
|
131
134
|
}): Promise<void>;
|
|
@@ -425,7 +425,7 @@ class PlaceOrderRepo {
|
|
|
425
425
|
}, {
|
|
426
426
|
status: factory_1.factory.transactionStatusType.Confirmed, // ステータス変更
|
|
427
427
|
endDate,
|
|
428
|
-
|
|
428
|
+
'object.orderDate': params.object.orderDate, // add(2026-06-15~)
|
|
429
429
|
result: params.result, // resultを更新
|
|
430
430
|
potentialActions: params.potentialActions // resultを更新
|
|
431
431
|
}, {
|
|
@@ -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.0",
|
|
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.61"
|
|
95
95
|
}
|