@chevre/domain 21.20.0-alpha.67 → 21.20.0-alpha.69
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/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +4 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +26 -1
- package/lib/chevre/service/order/placeOrder.js +4 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +17 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +16 -8
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
- package/package.json +2 -2
|
@@ -4,6 +4,10 @@ declare function onOrderPaymentDue(params: {
|
|
|
4
4
|
order: Pick<factory.order.IOrder, 'paymentMethods' | 'project' | 'orderNumber' | 'confirmationNumber' | 'customer' | 'orderDate' | 'seller' | 'typeOf' | 'price' | 'priceCurrency'> & {
|
|
5
5
|
orderStatus: factory.orderStatus.OrderPaymentDue;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* 注文取引に注文コードが保管されている場合に対応
|
|
9
|
+
*/
|
|
10
|
+
code?: string;
|
|
7
11
|
}): (repos: {
|
|
8
12
|
task: TaskRepo;
|
|
9
13
|
}) => Promise<void>;
|
|
@@ -40,7 +40,10 @@ function onOrderPaymentDue(params) {
|
|
|
40
40
|
case factory.orderStatus.OrderPaymentDue:
|
|
41
41
|
tasks = [
|
|
42
42
|
...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
|
|
43
|
-
...createCreateAccountingReportTask(params.order)
|
|
43
|
+
...createCreateAccountingReportTask(params.order),
|
|
44
|
+
...(typeof params.code === 'string' && params.code.length > 0)
|
|
45
|
+
? createOnAuthorizationCreatedTask(params.order, params.code)
|
|
46
|
+
: []
|
|
44
47
|
];
|
|
45
48
|
break;
|
|
46
49
|
default:
|
|
@@ -119,3 +122,25 @@ function createCreateAccountingReportTask(order) {
|
|
|
119
122
|
};
|
|
120
123
|
return [task];
|
|
121
124
|
}
|
|
125
|
+
function createOnAuthorizationCreatedTask(order,
|
|
126
|
+
/**
|
|
127
|
+
* 注文取引に注文コードが保管されている場合に対応
|
|
128
|
+
*/
|
|
129
|
+
code) {
|
|
130
|
+
const taskRunsAt = new Date();
|
|
131
|
+
const task = {
|
|
132
|
+
name: factory.taskName.OnAuthorizationCreated,
|
|
133
|
+
status: factory.taskStatus.Ready,
|
|
134
|
+
runsAt: taskRunsAt,
|
|
135
|
+
remainingNumberOfTries: 10,
|
|
136
|
+
numberOfTried: 0,
|
|
137
|
+
executionResults: [],
|
|
138
|
+
data: {
|
|
139
|
+
project: { id: order.project.id },
|
|
140
|
+
code
|
|
141
|
+
// reserveIfNotYet: USE_RESERVE_IF_NOT_YET
|
|
142
|
+
},
|
|
143
|
+
project: { id: order.project.id, typeOf: factory.organizationType.Project }
|
|
144
|
+
};
|
|
145
|
+
return [task];
|
|
146
|
+
}
|
|
@@ -264,7 +264,7 @@ function verifyAcceptedOffers(params) {
|
|
|
264
264
|
function placeOrder(params) {
|
|
265
265
|
// tslint:disable-next-line:max-func-body-length
|
|
266
266
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
267
|
-
var _a, _b, _c;
|
|
267
|
+
var _a, _b, _c, _d;
|
|
268
268
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
269
269
|
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
270
270
|
}
|
|
@@ -355,8 +355,8 @@ function placeOrder(params) {
|
|
|
355
355
|
// await createAccountingReportIfNotExist(order)({ accountingReport: repos.accountingReport });
|
|
356
356
|
// PaymentDueであればonOrderStatusChangedを実行(2023-08-23~)
|
|
357
357
|
if (order.orderStatus === factory.orderStatus.OrderPaymentDue) {
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
const orderCodeFromTransaction = (_d = placeOrderTransaction.result) === null || _d === void 0 ? void 0 : _d.code;
|
|
359
|
+
yield (0, onOrderStatusChanged_1.onOrderPaymentDue)(Object.assign({ order: {
|
|
360
360
|
paymentMethods: order.paymentMethods,
|
|
361
361
|
project: order.project,
|
|
362
362
|
orderNumber: order.orderNumber,
|
|
@@ -368,8 +368,7 @@ function placeOrder(params) {
|
|
|
368
368
|
price: order.price,
|
|
369
369
|
priceCurrency: order.priceCurrency,
|
|
370
370
|
orderStatus: order.orderStatus
|
|
371
|
-
}
|
|
372
|
-
})({
|
|
371
|
+
} }, (typeof orderCodeFromTransaction === 'string') ? { code: orderCodeFromTransaction } : undefined))({
|
|
373
372
|
task: repos.task
|
|
374
373
|
});
|
|
375
374
|
// } else if (order.orderStatus === factory.orderStatus.OrderProcessing) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
|
+
import type { MongoRepository as CodeRepo } from '../../../repo/code';
|
|
2
3
|
import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
3
4
|
import type { MongoRepository as EmailMessageRepo } from '../../../repo/emailMessage';
|
|
4
5
|
import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
|
|
@@ -8,6 +9,7 @@ import * as factory from '../../../factory';
|
|
|
8
9
|
import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
|
|
9
10
|
interface IConfirmOperationRepos {
|
|
10
11
|
action: ActionRepo;
|
|
12
|
+
authorization: CodeRepo;
|
|
11
13
|
emailMessage?: EmailMessageRepo;
|
|
12
14
|
project: ProjectRepo;
|
|
13
15
|
transaction: TransactionRepo;
|
|
@@ -25,10 +27,24 @@ type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
|
|
|
25
27
|
* 確定レスポンスに予約IDを含めるかどうか(ttts対応)
|
|
26
28
|
*/
|
|
27
29
|
expectsReservationIds: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 同期的にに注文コードを発行する場合に指定
|
|
32
|
+
*/
|
|
33
|
+
publishCodeExpiresInSeconds?: number;
|
|
28
34
|
};
|
|
29
35
|
};
|
|
30
36
|
/**
|
|
31
37
|
* 注文取引を確定する
|
|
32
38
|
*/
|
|
33
|
-
declare function confirm(params: IConfirmParams): IConfirmOperation<
|
|
39
|
+
declare function confirm(params: IConfirmParams): IConfirmOperation<{
|
|
40
|
+
order: factory.order.IOrder;
|
|
41
|
+
/**
|
|
42
|
+
* expectsReservationIdsの場合のみ
|
|
43
|
+
*/
|
|
44
|
+
eventId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* expectsReservationIdsの場合のみ
|
|
47
|
+
*/
|
|
48
|
+
reservationIds?: string[];
|
|
49
|
+
}>;
|
|
34
50
|
export { confirm };
|
|
@@ -26,6 +26,7 @@ const errorHandler_1 = require("../../../errorHandler");
|
|
|
26
26
|
const factory = require("../../../factory");
|
|
27
27
|
const settings_1 = require("../../../settings");
|
|
28
28
|
const potentialActions_1 = require("./potentialActions");
|
|
29
|
+
const publishCode_1 = require("./publishCode");
|
|
29
30
|
const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
|
|
30
31
|
const publishOrderNumberIfNotExist_1 = require("./publishOrderNumberIfNotExist");
|
|
31
32
|
const result_1 = require("./result");
|
|
@@ -34,6 +35,7 @@ const validation_1 = require("./validation");
|
|
|
34
35
|
* 注文取引を確定する
|
|
35
36
|
*/
|
|
36
37
|
function confirm(params) {
|
|
38
|
+
// tslint:disable-next-line:max-func-body-length
|
|
37
39
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
38
40
|
var _a;
|
|
39
41
|
// 確認番号を事前発行
|
|
@@ -66,7 +68,18 @@ function confirm(params) {
|
|
|
66
68
|
id: transaction.id,
|
|
67
69
|
object: { orderDate: params.result.order.orderDate }
|
|
68
70
|
})(repos);
|
|
69
|
-
|
|
71
|
+
// 必要あらば注文コード発行(2024-02-05~)
|
|
72
|
+
let code;
|
|
73
|
+
const publishCodeExpiresInSeconds = params.options.publishCodeExpiresInSeconds;
|
|
74
|
+
if (typeof publishCodeExpiresInSeconds === 'number') {
|
|
75
|
+
code = yield (0, publishCode_1.publishCode)({
|
|
76
|
+
project: { id: transaction.project.id },
|
|
77
|
+
object: { orderNumber },
|
|
78
|
+
validFrom: params.result.order.orderDate,
|
|
79
|
+
expiresInSeconds: publishCodeExpiresInSeconds
|
|
80
|
+
})(repos);
|
|
81
|
+
}
|
|
82
|
+
const { result, eventId, reservationIds } = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions, code }));
|
|
70
83
|
// デフォルトEメールメッセージを検索
|
|
71
84
|
let emailMessageOnOrderSent;
|
|
72
85
|
if (repos.emailMessage !== undefined) {
|
|
@@ -198,14 +211,9 @@ function createResult(params) {
|
|
|
198
211
|
reservationIds = reservationIdsResult.reservationIds;
|
|
199
212
|
}
|
|
200
213
|
return {
|
|
201
|
-
result: {
|
|
202
|
-
order: orderAsResult,
|
|
203
|
-
authorizeActions,
|
|
204
|
-
numAcceptedOffers: order.acceptedOffers.length,
|
|
205
|
-
options: {
|
|
214
|
+
result: Object.assign({ order: orderAsResult, authorizeActions, numAcceptedOffers: order.acceptedOffers.length, options: {
|
|
206
215
|
ignoreAccpetedOffersFromResult: ((_a = params.options) === null || _a === void 0 ? void 0 : _a.ignoreAccpetedOffersFromResult) === true
|
|
207
|
-
}
|
|
208
|
-
},
|
|
216
|
+
} }, (typeof params.code === 'string') ? { code: params.code } : undefined),
|
|
209
217
|
eventId,
|
|
210
218
|
reservationIds
|
|
211
219
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MongoRepository as CodeRepo } from '../../../repo/code';
|
|
2
|
+
declare function publishCode(params: {
|
|
3
|
+
project: {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
object: {
|
|
7
|
+
orderNumber: string;
|
|
8
|
+
};
|
|
9
|
+
validFrom: Date;
|
|
10
|
+
expiresInSeconds: number;
|
|
11
|
+
}): (repos: {
|
|
12
|
+
authorization: CodeRepo;
|
|
13
|
+
}) => Promise<string>;
|
|
14
|
+
export { publishCode };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.publishCode = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
function publishCode(params) {
|
|
15
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a;
|
|
17
|
+
const authorizationObject = {
|
|
18
|
+
typeOf: factory.order.OrderType.Order,
|
|
19
|
+
orderNumber: params.object.orderNumber
|
|
20
|
+
};
|
|
21
|
+
let authorizations;
|
|
22
|
+
try {
|
|
23
|
+
authorizations = yield repos.authorization.publish([{
|
|
24
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
25
|
+
object: authorizationObject,
|
|
26
|
+
validFrom: params.validFrom,
|
|
27
|
+
expiresInSeconds: params.expiresInSeconds
|
|
28
|
+
}]);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
const code = (_a = authorizations.shift()) === null || _a === void 0 ? void 0 : _a.code;
|
|
34
|
+
if (typeof code !== 'string') {
|
|
35
|
+
// 基本的にありえないフロー
|
|
36
|
+
throw new factory.errors.ServiceUnavailable('code not published by an unexpected reason');
|
|
37
|
+
}
|
|
38
|
+
return code;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.publishCode = publishCode;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.353.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.353.0-alpha.3",
|
|
14
14
|
"@cinerino/sdk": "5.9.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.3.0-alpha.4",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.2",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"postversion": "git push origin --tags",
|
|
112
112
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
113
113
|
},
|
|
114
|
-
"version": "21.20.0-alpha.
|
|
114
|
+
"version": "21.20.0-alpha.69"
|
|
115
115
|
}
|