@chevre/domain 21.20.0-alpha.26 → 21.20.0-alpha.27
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/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +2 -30
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +9 -2
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
2
1
|
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
3
3
|
type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'potentialActions'>;
|
|
4
4
|
declare function onOrderDelivered(params: {
|
|
5
5
|
order: Pick<factory.order.IOrder, 'id' | 'customer' | 'orderDate' | 'orderNumber' | 'project' | 'typeOf'> & {
|
|
@@ -14,8 +14,8 @@ exports.onOrderDelivered = void 0;
|
|
|
14
14
|
* 注文ステータス変更時処理
|
|
15
15
|
*/
|
|
16
16
|
const createDebug = require("debug");
|
|
17
|
-
const util = require("util");
|
|
18
17
|
const factory = require("../../../factory");
|
|
18
|
+
const createSendEmailMessageTaskIfNotExist_1 = require("./onOrderProcessing/createSendEmailMessageTaskIfNotExist");
|
|
19
19
|
const factory_1 = require("./onOrderDelivered/factory");
|
|
20
20
|
const debug = createDebug('chevre-domain:service:order');
|
|
21
21
|
function onOrderDelivered(params) {
|
|
@@ -39,9 +39,7 @@ function onOrderDelivered(params) {
|
|
|
39
39
|
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
40
40
|
switch (params.order.orderStatus) {
|
|
41
41
|
case factory.orderStatus.OrderDelivered:
|
|
42
|
-
yield createSendEmailMessageTaskIfNotExist({
|
|
43
|
-
potentialActions: sendOrderPotentialActions
|
|
44
|
-
})(repos);
|
|
42
|
+
yield (0, createSendEmailMessageTaskIfNotExist_1.createSendEmailMessageTaskIfNotExist)({ potentialActions: sendOrderPotentialActions })(repos);
|
|
45
43
|
break;
|
|
46
44
|
default:
|
|
47
45
|
throw new factory.errors.NotImplemented(`${params.order.orderStatus} not implemented`);
|
|
@@ -49,29 +47,3 @@ function onOrderDelivered(params) {
|
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
exports.onOrderDelivered = onOrderDelivered;
|
|
52
|
-
function createSendEmailMessageTaskIfNotExist(params) {
|
|
53
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a;
|
|
55
|
-
const sendEmailMessageActions = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.sendEmailMessage;
|
|
56
|
-
const now = new Date();
|
|
57
|
-
if (Array.isArray(sendEmailMessageActions)) {
|
|
58
|
-
yield Promise.all(sendEmailMessageActions.map((sendEmailMessageAction, index) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', sendEmailMessageAction.project.id, factory.taskName.SendEmailMessage, sendEmailMessageAction.purpose.typeOf, sendEmailMessageAction.purpose.orderNumber, factory.orderStatus.OrderDelivered, index);
|
|
60
|
-
const sendEmailMessageTask = {
|
|
61
|
-
identifier: taskIdentifier,
|
|
62
|
-
project: sendEmailMessageAction.project,
|
|
63
|
-
name: factory.taskName.SendEmailMessage,
|
|
64
|
-
status: factory.taskStatus.Ready,
|
|
65
|
-
runsAt: now,
|
|
66
|
-
remainingNumberOfTries: 10,
|
|
67
|
-
numberOfTried: 0,
|
|
68
|
-
executionResults: [],
|
|
69
|
-
data: {
|
|
70
|
-
actionAttributes: sendEmailMessageAction
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
yield repos.task.createIfNotExistByIdentifier(sendEmailMessageTask, { emitImmediately: true });
|
|
74
|
-
})));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MongoRepository as TaskRepo } from '../../../../repo/task';
|
|
2
|
+
import * as factory from '../../../../factory';
|
|
3
|
+
declare function createSendEmailMessageTaskIfNotExist(params: {
|
|
4
|
+
potentialActions?: factory.action.transfer.send.order.IPotentialActions;
|
|
5
|
+
}): (repos: {
|
|
6
|
+
task: TaskRepo;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
export { createSendEmailMessageTaskIfNotExist };
|
|
@@ -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.createSendEmailMessageTaskIfNotExist = void 0;
|
|
13
|
+
const util = require("util");
|
|
14
|
+
const factory = require("../../../../factory");
|
|
15
|
+
function createSendEmailMessageTaskIfNotExist(params) {
|
|
16
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a;
|
|
18
|
+
const sendEmailMessageActions = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.sendEmailMessage;
|
|
19
|
+
const now = new Date();
|
|
20
|
+
if (Array.isArray(sendEmailMessageActions)) {
|
|
21
|
+
yield Promise.all(sendEmailMessageActions.map((sendEmailMessageAction, index) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', sendEmailMessageAction.project.id, factory.taskName.SendEmailMessage, sendEmailMessageAction.purpose.typeOf, sendEmailMessageAction.purpose.orderNumber, factory.orderStatus.OrderProcessing, index);
|
|
23
|
+
const sendEmailMessageTask = {
|
|
24
|
+
identifier: taskIdentifier,
|
|
25
|
+
project: sendEmailMessageAction.project,
|
|
26
|
+
name: factory.taskName.SendEmailMessage,
|
|
27
|
+
status: factory.taskStatus.Ready,
|
|
28
|
+
runsAt: now,
|
|
29
|
+
remainingNumberOfTries: 10,
|
|
30
|
+
numberOfTried: 0,
|
|
31
|
+
executionResults: [],
|
|
32
|
+
data: {
|
|
33
|
+
actionAttributes: sendEmailMessageAction
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
yield repos.task.createIfNotExistByIdentifier(sendEmailMessageTask, { emitImmediately: true });
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.createSendEmailMessageTaskIfNotExist = createSendEmailMessageTaskIfNotExist;
|
|
@@ -17,14 +17,17 @@ const createDebug = require("debug");
|
|
|
17
17
|
const util = require("util");
|
|
18
18
|
const factory = require("../../../factory");
|
|
19
19
|
const order_1 = require("../../../factory/order");
|
|
20
|
+
const settings_1 = require("../../../settings");
|
|
21
|
+
const createSendEmailMessageTaskIfNotExist_1 = require("./onOrderProcessing/createSendEmailMessageTaskIfNotExist");
|
|
20
22
|
const factory_1 = require("./onOrderProcessing/factory");
|
|
21
23
|
const debug = createDebug('chevre-domain:service:order');
|
|
22
24
|
const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTER_SERVICE_TRANSACTION === '1';
|
|
23
25
|
function onOrderProcessing(params) {
|
|
24
26
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
var _a, _b, _c;
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
26
28
|
debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
|
|
27
29
|
let tasks = [];
|
|
30
|
+
const sendOrderPotentialActions = (_e = (_d = (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.potentialActions) === null || _d === void 0 ? void 0 : _d.sendOrder) === null || _e === void 0 ? void 0 : _e.potentialActions;
|
|
28
31
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
29
32
|
const simpleOrder = {
|
|
30
33
|
typeOf: params.order.typeOf,
|
|
@@ -55,8 +58,12 @@ function onOrderProcessing(params) {
|
|
|
55
58
|
// 冗長なconfirmReserveTransactionタスク作成を回避(2023-08-25~)
|
|
56
59
|
yield createConfirmReserveTransactionTasksIfNotExist(params.order, simpleOrder)(repos);
|
|
57
60
|
yield createGivePointAwardTaskIfNotExist({
|
|
58
|
-
potentialActions: (
|
|
61
|
+
potentialActions: (_h = (_g = (_f = params.placeOrderTransaction) === null || _f === void 0 ? void 0 : _f.potentialActions) === null || _g === void 0 ? void 0 : _g.order) === null || _h === void 0 ? void 0 : _h.potentialActions
|
|
59
62
|
})(repos);
|
|
63
|
+
// OrderProcessingにおけるEメール送信に対応(2024-01-17~)
|
|
64
|
+
if (settings_1.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING) {
|
|
65
|
+
yield (0, createSendEmailMessageTaskIfNotExist_1.createSendEmailMessageTaskIfNotExist)({ potentialActions: sendOrderPotentialActions })(repos);
|
|
66
|
+
}
|
|
60
67
|
break;
|
|
61
68
|
default:
|
|
62
69
|
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
|
|
|
40
40
|
export declare const USE_FETCH_API: boolean;
|
|
41
41
|
export declare const USE_INFORM_ORDER_IN_TRANSIT: boolean;
|
|
42
42
|
export declare const USE_INFORM_ACCEPTED_OFFERS_ON_ORDER_PROCESSING: boolean;
|
|
43
|
+
export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
|
|
43
44
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
44
45
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
45
46
|
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_INFORM_ACCEPTED_OFFERS_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.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_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ACCEPTED_OFFERS_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.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(' ')
|
|
@@ -64,6 +64,7 @@ exports.USE_OPTIMIZE_TICKET_OFFER = process.env.USE_OPTIMIZE_TICKET_OFFER === '1
|
|
|
64
64
|
exports.USE_FETCH_API = process.env.USE_FETCH_API === '1';
|
|
65
65
|
exports.USE_INFORM_ORDER_IN_TRANSIT = process.env.USE_INFORM_ORDER_IN_TRANSIT === '1';
|
|
66
66
|
exports.USE_INFORM_ACCEPTED_OFFERS_ON_ORDER_PROCESSING = process.env.USE_INFORM_ACCEPTED_OFFERS_ON_ORDER_PROCESSING === '1';
|
|
67
|
+
exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = process.env.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING === '1';
|
|
67
68
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
68
69
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
69
70
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED