@chevre/domain 21.26.0-alpha.2 → 21.26.0-alpha.4
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/example/src/chevre/migrateOrderSeller.ts +65 -0
- package/example/src/chevre/validateOrder.ts +4 -2
- package/example/src/mvtkMessage.ts +11 -0
- package/lib/chevre/errorHandler.d.ts +1 -0
- package/lib/chevre/errorHandler.js +3 -2
- package/lib/chevre/service/notification/factory.js +29 -18
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +23 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +18 -8
- package/lib/chevre/service/task/checkResource.d.ts +7 -0
- package/lib/chevre/service/task/checkResource.js +64 -0
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = orderRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
orderDate: {
|
|
18
|
+
$gte: moment()
|
|
19
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
20
|
+
.add(-12, 'months')
|
|
21
|
+
.toDate()
|
|
22
|
+
// $lte: moment()
|
|
23
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
// .add(-6, 'months')
|
|
25
|
+
// .toDate()
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
orderDate: 1,
|
|
30
|
+
orderNumber: 1,
|
|
31
|
+
project: 1,
|
|
32
|
+
seller: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('orders found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
let updateCount = 0;
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const order: Pick<
|
|
42
|
+
chevre.factory.order.IOrder,
|
|
43
|
+
'orderDate' | 'orderNumber' | 'project' | 'seller'
|
|
44
|
+
> = doc.toObject();
|
|
45
|
+
console.log(order);
|
|
46
|
+
|
|
47
|
+
const alreadyMigrated = (<any>order.seller).telephone === undefined
|
|
48
|
+
&& (<any>order.seller).url === undefined;
|
|
49
|
+
|
|
50
|
+
if (alreadyMigrated) {
|
|
51
|
+
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
52
|
+
} else {
|
|
53
|
+
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
54
|
+
updateCount += 1;
|
|
55
|
+
console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log(i, 'orders checked');
|
|
60
|
+
console.log(updateCount, 'orders updated');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main()
|
|
64
|
+
.then()
|
|
65
|
+
.catch(console.error);
|
|
@@ -22,7 +22,7 @@ async function main() {
|
|
|
22
22
|
orderDate: {
|
|
23
23
|
$gte: moment()
|
|
24
24
|
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
-
.add(-
|
|
25
|
+
.add(-365, 'days')
|
|
26
26
|
.toDate()
|
|
27
27
|
}
|
|
28
28
|
},
|
|
@@ -41,12 +41,13 @@ async function main() {
|
|
|
41
41
|
const unexpextedprojectIds: string[] = [];
|
|
42
42
|
|
|
43
43
|
let i = 0;
|
|
44
|
+
let unexpextedOrderCount = 0;
|
|
44
45
|
await cursor.eachAsync(async (doc) => {
|
|
45
46
|
i += 1;
|
|
46
47
|
const order: Pick<chevre.factory.order.IOrder, 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> = doc.toObject();
|
|
47
48
|
|
|
48
49
|
try {
|
|
49
|
-
console.log('validating order...', order.project.id, order.typeOf, order.orderNumber, order.orderDate, i);
|
|
50
|
+
console.log('validating order...', order.project.id, order.typeOf, order.orderNumber, order.orderDate, i, unexpextedOrderCount);
|
|
50
51
|
const result = await validateOrder({
|
|
51
52
|
orderNumber: order.orderNumber,
|
|
52
53
|
project: { id: order.project.id }
|
|
@@ -58,6 +59,7 @@ async function main() {
|
|
|
58
59
|
console.log(result);
|
|
59
60
|
} catch (error) {
|
|
60
61
|
console.error(error);
|
|
62
|
+
unexpextedOrderCount += 1;
|
|
61
63
|
unexpextedOrders.push({
|
|
62
64
|
orderDate: order.orderDate,
|
|
63
65
|
orderNumber: order.orderNumber,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
|
|
3
|
+
const paymentMethodId = '792943638208219';
|
|
4
|
+
const message = `{\"message\":\"bookingNo:\\\"${paymentMethodId}\\\" が見つかりません。\"}`;
|
|
5
|
+
console.log(JSON.parse(message));
|
|
6
|
+
|
|
7
|
+
const error = { message: `bookingNo:"${paymentMethodId}" が見つかりません。` };
|
|
8
|
+
const expectedMessage4surfrockNotFound = JSON.stringify(error);
|
|
9
|
+
console.log(expectedMessage4surfrockNotFound);
|
|
10
|
+
|
|
11
|
+
console.log(expectedMessage4surfrockNotFound === message);
|
|
@@ -14,6 +14,7 @@ export declare function handleCOAError(error: any): Error;
|
|
|
14
14
|
* 可能であればChevreエラーへ変換します
|
|
15
15
|
*/
|
|
16
16
|
export declare function handlePecorinoError(error: any): Error;
|
|
17
|
+
export declare const MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = "MovieticketReserveRequestError";
|
|
17
18
|
/**
|
|
18
19
|
* ムビチケ着券サービスエラーをハンドリングする
|
|
19
20
|
* 可能であればChevreエラーへ変換します
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.handleAWSError = exports.handleMvtkReserveError = exports.handlePecorinoError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
12
|
+
exports.handleAWSError = exports.handleMvtkReserveError = exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = exports.handlePecorinoError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* エラーハンドラー
|
|
15
15
|
* 外部サービスと連携している場合に、サービス(API)のエラーを本ドメインのエラーに変換する責任を担います。
|
|
@@ -115,6 +115,7 @@ function handlePecorinoError(error) {
|
|
|
115
115
|
return handledError;
|
|
116
116
|
}
|
|
117
117
|
exports.handlePecorinoError = handlePecorinoError;
|
|
118
|
+
exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = 'MovieticketReserveRequestError';
|
|
118
119
|
/**
|
|
119
120
|
* ムビチケ着券サービスエラーをハンドリングする
|
|
120
121
|
* 可能であればChevreエラーへ変換します
|
|
@@ -122,7 +123,7 @@ exports.handlePecorinoError = handlePecorinoError;
|
|
|
122
123
|
// tslint:disable-next-line:no-any
|
|
123
124
|
function handleMvtkReserveError(error) {
|
|
124
125
|
let handledError = error;
|
|
125
|
-
if (error.name ===
|
|
126
|
+
if (error.name === exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME) {
|
|
126
127
|
// ムビチケAPIのステータスコード4xxをハンドリング
|
|
127
128
|
// ムビチケAPIのレスポンスステータスコードが4xxであればクライアントエラー
|
|
128
129
|
const message = `${error.name}:${error.message}`;
|
|
@@ -32,26 +32,37 @@ lastMessage:${lastMessage}`;
|
|
|
32
32
|
exports.task2lineNotify = task2lineNotify;
|
|
33
33
|
const MAX_LAST_MESSAGE_LENGTH = 20;
|
|
34
34
|
function tasks2lineNotify(params) {
|
|
35
|
-
|
|
36
|
-
content =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
const subject = `${params.tasks.length} ${exports.ABORT_REPORT_SUBJECT}`;
|
|
36
|
+
let content = subject;
|
|
37
|
+
// あまりに通知タスク数が多いケースに対応
|
|
38
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
39
|
+
if (params.tasks.length > 10) {
|
|
40
|
+
content = params.tasks.map((task) => {
|
|
41
|
+
return `project:${task.project.id}
|
|
42
|
+
id:${task.id}
|
|
43
|
+
name:${task.name}`;
|
|
44
|
+
})
|
|
45
|
+
.join('\n');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
49
|
+
const maxLastMessageLength = (params.tasks.length <= 5) ? 80 : MAX_LAST_MESSAGE_LENGTH; // 通知タスク数に応じてメッセージ長を調整
|
|
50
|
+
content = params.tasks.map((task) => {
|
|
51
|
+
const lastExecutionResult = (task.executionResults.length > 0) ? task.executionResults.slice(-1)[0] : undefined;
|
|
52
|
+
let lastError = lastExecutionResult === null || lastExecutionResult === void 0 ? void 0 : lastExecutionResult.error;
|
|
53
|
+
if (typeof lastError === 'string') {
|
|
54
|
+
lastError = { message: lastError, name: 'Error' };
|
|
55
|
+
}
|
|
56
|
+
const lastMessage = `${String(lastError === null || lastError === void 0 ? void 0 : lastError.name)} ${String(lastError === null || lastError === void 0 ? void 0 : lastError.message)}`;
|
|
57
|
+
return `project:${task.project.id}
|
|
45
58
|
id:${task.id}
|
|
46
59
|
name:${task.name}
|
|
47
60
|
runsAt:${moment(task.runsAt)
|
|
48
|
-
|
|
49
|
-
lastMessage:${lastMessage.slice(0,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
content: content
|
|
55
|
-
};
|
|
61
|
+
.toISOString()}
|
|
62
|
+
lastMessage:${lastMessage.slice(0, maxLastMessageLength)}...`;
|
|
63
|
+
})
|
|
64
|
+
.join('\n');
|
|
65
|
+
}
|
|
66
|
+
return { subject, content };
|
|
56
67
|
}
|
|
57
68
|
exports.tasks2lineNotify = tasks2lineNotify;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
|
-
type IAcceptedOffer = Pick<factory.order.IAcceptedOffer<factory.order.IItemOffered>, 'itemOffered' | 'offeredThrough'>;
|
|
3
2
|
type IProcessingOrder = factory.order.IOrder & {
|
|
4
3
|
numAcceptedOffers: number;
|
|
5
4
|
orderStatus: factory.orderStatus.OrderProcessing;
|
|
@@ -16,4 +15,5 @@ declare function createConfirmReservationActionObject4COAByOrder(params: {
|
|
|
16
15
|
};
|
|
17
16
|
}): factory.task.confirmReserveTransaction.IObject4COAOptimized[];
|
|
18
17
|
type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
|
|
19
|
-
|
|
18
|
+
declare function createCheckResourceTask(order: IProcessingOrder): factory.task.checkResource.IAttributes;
|
|
19
|
+
export { IExternalOrder, createInformTasks, createCheckResourceTask, createConfirmReservationActionObject4ChevreByOrder, createConfirmReservationActionObject4COAByOrder };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = void 0;
|
|
4
|
+
exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createCheckResourceTask = exports.createInformTasks = void 0;
|
|
5
5
|
const factory = require("../../../../factory");
|
|
6
6
|
const reservedAgentIdentifireNames_1 = require("../../../../factory/reservedAgentIdentifireNames");
|
|
7
7
|
const settings_1 = require("../../../../settings");
|
|
@@ -104,3 +104,25 @@ function createConfirmReservationActionObject4COAByOrder(params) {
|
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
exports.createConfirmReservationActionObject4COAByOrder = createConfirmReservationActionObject4COAByOrder;
|
|
107
|
+
function createCheckResourceTask(order) {
|
|
108
|
+
const taskRunsAt = new Date();
|
|
109
|
+
const data = {
|
|
110
|
+
object: {
|
|
111
|
+
orderNumber: order.orderNumber,
|
|
112
|
+
typeOf: order.typeOf
|
|
113
|
+
},
|
|
114
|
+
project: order.project,
|
|
115
|
+
typeOf: factory.actionType.CheckAction
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
project: order.project,
|
|
119
|
+
name: factory.taskName.CheckResource,
|
|
120
|
+
status: factory.taskStatus.Ready,
|
|
121
|
+
runsAt: taskRunsAt,
|
|
122
|
+
remainingNumberOfTries: 10,
|
|
123
|
+
numberOfTried: 0,
|
|
124
|
+
executionResults: [],
|
|
125
|
+
data
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
exports.createCheckResourceTask = createCheckResourceTask;
|
|
@@ -16,7 +16,6 @@ exports.onOrderProcessing = void 0;
|
|
|
16
16
|
const createDebug = require("debug");
|
|
17
17
|
const util = require("util");
|
|
18
18
|
const factory = require("../../../factory");
|
|
19
|
-
// import { createMaskedCustomer } from '../../../factory/order';
|
|
20
19
|
const settings_1 = require("../../../settings");
|
|
21
20
|
const createSendEmailMessageTaskIfNotExist_1 = require("./onOrderProcessing/createSendEmailMessageTaskIfNotExist");
|
|
22
21
|
const factory_1 = require("./onOrderProcessing/factory");
|
|
@@ -44,7 +43,8 @@ function onOrderProcessing(params) {
|
|
|
44
43
|
switch (params.order.orderStatus) {
|
|
45
44
|
case factory.orderStatus.OrderProcessing:
|
|
46
45
|
tasks = [
|
|
47
|
-
...(0, factory_1.createInformTasks)(params.order)
|
|
46
|
+
...(0, factory_1.createInformTasks)(params.order),
|
|
47
|
+
...(settings_1.USE_CHECK_RESOURCE_TASK) ? [(0, factory_1.createCheckResourceTask)(params.order)] : [] // リソース検証タスクを追加(2024-03-13~)
|
|
48
48
|
];
|
|
49
49
|
break;
|
|
50
50
|
default:
|
|
@@ -14,6 +14,7 @@ exports.voidTransaction = exports.refundMovieTicket = exports.payMovieTicket = e
|
|
|
14
14
|
* 決済サービス
|
|
15
15
|
*/
|
|
16
16
|
const surfrock = require("@surfrock/sdk");
|
|
17
|
+
const http_status_1 = require("http-status");
|
|
17
18
|
const credentials_1 = require("../../credentials");
|
|
18
19
|
const factory = require("../../factory");
|
|
19
20
|
const checkByIdentifier_1 = require("./movieTicket/checkByIdentifier");
|
|
@@ -23,6 +24,12 @@ const validation_1 = require("./movieTicket/validation");
|
|
|
23
24
|
const errorHandler_1 = require("../../errorHandler");
|
|
24
25
|
const onPaid_1 = require("./any/onPaid");
|
|
25
26
|
const onRefund_1 = require("./any/onRefund");
|
|
27
|
+
var MovieticketReserveRequestErrorMessage;
|
|
28
|
+
(function (MovieticketReserveRequestErrorMessage) {
|
|
29
|
+
MovieticketReserveRequestErrorMessage["AlreadyPaid"] = "\u65E2\u306B\u5B58\u5728\u3059\u308B\u8208\u884C\u30B7\u30B9\u30C6\u30E0\u5EA7\u5E2D\u4E88\u7D04\u756A\u53F7\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F\u3002";
|
|
30
|
+
MovieticketReserveRequestErrorMessage["NotFound"] = "\u5B58\u5728\u3057\u306A\u3044\u8208\u884C\u4F1A\u793E\u30B7\u30B9\u30C6\u30E0\u5EA7\u5E2D\u4E88\u7D04\u756A\u53F7\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F\u3002";
|
|
31
|
+
MovieticketReserveRequestErrorMessage["ReservationResult19"] = "ReservationResult 19";
|
|
32
|
+
})(MovieticketReserveRequestErrorMessage || (MovieticketReserveRequestErrorMessage = {}));
|
|
26
33
|
/**
|
|
27
34
|
* MovieTicket認証
|
|
28
35
|
*/
|
|
@@ -250,9 +257,8 @@ function payMovieTicket(params) {
|
|
|
250
257
|
catch (error) {
|
|
251
258
|
let throwsError = true;
|
|
252
259
|
// 「既に存在する興行システム座席予約番号が入力されました」の場合、着券済なのでok
|
|
253
|
-
if (error.name ===
|
|
254
|
-
|
|
255
|
-
if (error.code === 400 && error.message === '既に存在する興行システム座席予約番号が入力されました。') {
|
|
260
|
+
if (error.name === errorHandler_1.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME) {
|
|
261
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === MovieticketReserveRequestErrorMessage.AlreadyPaid) {
|
|
256
262
|
seatInfoSyncResult = error;
|
|
257
263
|
throwsError = false;
|
|
258
264
|
}
|
|
@@ -366,15 +372,19 @@ function refundMovieTicket(params) {
|
|
|
366
372
|
catch (error) {
|
|
367
373
|
let throwsError = true;
|
|
368
374
|
// 「存在しない興行会社システム座席予約番号が入力されました」の場合、取消済なのでok
|
|
369
|
-
if (error.name ===
|
|
370
|
-
|
|
371
|
-
if (error.code === 400 && error.message === '存在しない興行会社システム座席予約番号が入力されました。') {
|
|
375
|
+
if (error.name === errorHandler_1.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME) {
|
|
376
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === MovieticketReserveRequestErrorMessage.NotFound) {
|
|
372
377
|
seatInfoSyncResult = error;
|
|
373
378
|
throwsError = false;
|
|
374
379
|
}
|
|
375
380
|
// ReservationResult 19の内容が不明だがリトライする意味はおそらくないパターン
|
|
376
|
-
|
|
377
|
-
|
|
381
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === MovieticketReserveRequestErrorMessage.ReservationResult19) {
|
|
382
|
+
seatInfoSyncResult = error;
|
|
383
|
+
throwsError = false;
|
|
384
|
+
}
|
|
385
|
+
// surfrock: bookingNoが存在しないケースをハンドル(2024-03-13~)
|
|
386
|
+
const expectedMessage4surfrockNotFound = JSON.stringify({ message: `bookingNo:"${paymentMethodId}" が見つかりません。` });
|
|
387
|
+
if (error.code === http_status_1.BAD_REQUEST && error.message === expectedMessage4surfrockNotFound) {
|
|
378
388
|
seatInfoSyncResult = error;
|
|
379
389
|
throwsError = false;
|
|
380
390
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.checkResource.IData): IOperation<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const acceptedOffer_1 = require("../../repo/acceptedOffer");
|
|
15
|
+
const action_1 = require("../../repo/action");
|
|
16
|
+
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
17
|
+
const order_1 = require("../../repo/order");
|
|
18
|
+
const validateOrder_1 = require("../validation/validateOrder");
|
|
19
|
+
/**
|
|
20
|
+
* タスク実行関数
|
|
21
|
+
*/
|
|
22
|
+
function call(data) {
|
|
23
|
+
return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const acceptedOfferRepo = new acceptedOffer_1.MongoRepository(connection);
|
|
25
|
+
const actionRepo = new action_1.MongoRepository(connection);
|
|
26
|
+
const assetTransactionRepo = new assetTransaction_1.MongoRepository(connection);
|
|
27
|
+
const orderRepo = new order_1.MongoRepository(connection);
|
|
28
|
+
const actionAttributes = {
|
|
29
|
+
agent: { id: data.project.id, typeOf: factory.organizationType.Project },
|
|
30
|
+
object: data.object,
|
|
31
|
+
project: { id: data.project.id, typeOf: factory.organizationType.Project },
|
|
32
|
+
typeOf: factory.actionType.CheckAction
|
|
33
|
+
};
|
|
34
|
+
const action = yield actionRepo.start(actionAttributes);
|
|
35
|
+
try {
|
|
36
|
+
switch (data.object.typeOf) {
|
|
37
|
+
case factory.order.OrderType.Order:
|
|
38
|
+
yield (0, validateOrder_1.validateOrder)({
|
|
39
|
+
orderNumber: data.object.orderNumber,
|
|
40
|
+
project: { id: data.project.id }
|
|
41
|
+
})({
|
|
42
|
+
acceptedOffer: acceptedOfferRepo,
|
|
43
|
+
assetTransaction: assetTransactionRepo,
|
|
44
|
+
order: orderRepo
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
throw new factory.errors.NotImplemented(`${data.object.typeOf} not implemented`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
try {
|
|
53
|
+
yield actionRepo.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
54
|
+
}
|
|
55
|
+
catch (__) {
|
|
56
|
+
// 失敗したら仕方ない
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
const actionResult = {};
|
|
61
|
+
yield actionRepo.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.call = call;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
|
|
|
43
43
|
export declare const USE_MINIMIZED_PAY_TASK: boolean;
|
|
44
44
|
export declare const USE_VALIDATE_PROJECT_MAKES_OFFER: boolean;
|
|
45
45
|
export declare const USE_OWNERSHIP_INFO_BY_WEB_APPLICATION: boolean;
|
|
46
|
+
export declare const USE_CHECK_RESOURCE_TASK: boolean;
|
|
46
47
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
47
48
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
48
49
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_VALIDATE_PROJECT_MAKES_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -67,6 +67,7 @@ exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = process.env.USE_SEND_EMAIL_
|
|
|
67
67
|
exports.USE_MINIMIZED_PAY_TASK = process.env.USE_MINIMIZED_PAY_TASK === '1';
|
|
68
68
|
exports.USE_VALIDATE_PROJECT_MAKES_OFFER = process.env.USE_VALIDATE_PROJECT_MAKES_OFFER === '1';
|
|
69
69
|
exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = process.env.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION === '1';
|
|
70
|
+
exports.USE_CHECK_RESOURCE_TASK = process.env.USE_CHECK_RESOURCE_TASK === '1';
|
|
70
71
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
71
72
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
72
73
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.362.0-alpha.
|
|
14
|
-
"@cinerino/sdk": "5.14.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.362.0-alpha.3",
|
|
14
|
+
"@cinerino/sdk": "5.14.0-alpha.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.26.0-alpha.
|
|
113
|
+
"version": "21.26.0-alpha.4"
|
|
114
114
|
}
|