@chevre/domain 21.8.0-alpha.0 → 21.8.0-alpha.10

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.
@@ -0,0 +1,22 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ const KILO_BYTES = 1024;
5
+ async function main() {
6
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
7
+
8
+ const stats = await mongoose.connection.db.collection('tasks')
9
+ .stats({
10
+ scale: KILO_BYTES * KILO_BYTES
11
+ });
12
+ console.log('scaleFactor:', stats.scaleFactor);
13
+ console.log('avgObjSize:', stats.avgObjSize);
14
+ console.log('count:', stats.count);
15
+ console.log('size:', stats.size);
16
+ }
17
+
18
+ main()
19
+ .then(() => {
20
+ console.log('success!');
21
+ })
22
+ .catch(console.error);
@@ -0,0 +1,31 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
10
+
11
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
12
+
13
+ const tasks = await taskRepo.search(
14
+ {
15
+ limit: 1,
16
+ project: { id: { $eq: project.id } },
17
+ name: { $in: [chevre.factory.taskName.SendOrder] },
18
+ data: {
19
+ object: {
20
+ orderNumber: { $eq: 'xxx' }
21
+ }
22
+ }
23
+ }
24
+ );
25
+ console.log('tasks found', tasks);
26
+ console.log(tasks.length, 'tasks found');
27
+ }
28
+
29
+ main()
30
+ .then()
31
+ .catch(console.error);
@@ -83,6 +83,12 @@ schema.index({ 'data.object.itemOffered.membershipFor.id': 1, runsAt: -1 }, {
83
83
  'data.object.itemOffered.membershipFor.id': { $exists: true }
84
84
  }
85
85
  });
86
+ schema.index({ 'data.object.orderNumber': 1, runsAt: -1 }, {
87
+ name: 'searchByDataObjectOrderNumber',
88
+ partialFilterExpression: {
89
+ 'data.object.orderNumber': { $exists: true }
90
+ }
91
+ });
86
92
  schema.index({ 'data.object.transactionNumber': 1, runsAt: -1 }, {
87
93
  name: 'searchByDataObjectTransactionNumber',
88
94
  partialFilterExpression: {
@@ -35,6 +35,9 @@ export declare class MongoRepository {
35
35
  * 取引削除タスク冪等作成
36
36
  */
37
37
  createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
38
+ createConfirmReserveTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.ConfirmReserveTransaction>, options: IOptionOnCreate): Promise<void>;
39
+ createSendOrderTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.SendOrder>, options: IOptionOnCreate): Promise<void>;
40
+ createOnOrderPaymentCompletedTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.OnOrderPaymentCompleted>, options: IOptionOnCreate): Promise<void>;
38
41
  executeById(params: {
39
42
  id: string;
40
43
  executor: {
@@ -67,7 +70,7 @@ export declare class MongoRepository {
67
70
  */
68
71
  $nin?: factory.taskName[];
69
72
  };
70
- }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
73
+ }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
71
74
  retry(params: {
72
75
  intervalInMinutes: number;
73
76
  }): Promise<void>;
@@ -31,7 +31,7 @@ class MongoRepository {
31
31
  }
32
32
  // tslint:disable-next-line:max-func-body-length
33
33
  static CREATE_MONGO_CONDITIONS(params) {
34
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
34
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
35
35
  const andConditions = [];
36
36
  const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
37
37
  if (typeof idEq === 'string') {
@@ -115,32 +115,21 @@ class MongoRepository {
115
115
  }
116
116
  const objectIdEq = (_k = (_j = (_h = params.data) === null || _h === void 0 ? void 0 : _h.object) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
117
117
  if (typeof objectIdEq === 'string') {
118
- andConditions.push({
119
- 'data.object.id': {
120
- $exists: true,
121
- $eq: objectIdEq
122
- }
123
- });
118
+ andConditions.push({ 'data.object.id': { $exists: true, $eq: objectIdEq } });
124
119
  }
125
- const objectTransactionNumberEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.object) === null || _m === void 0 ? void 0 : _m.transactionNumber) === null || _o === void 0 ? void 0 : _o.$eq;
120
+ const objectOrderNumberEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.object) === null || _m === void 0 ? void 0 : _m.orderNumber) === null || _o === void 0 ? void 0 : _o.$eq;
121
+ if (typeof objectOrderNumberEq === 'string') {
122
+ andConditions.push({ 'data.object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
123
+ }
124
+ const objectTransactionNumberEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.object) === null || _q === void 0 ? void 0 : _q.transactionNumber) === null || _r === void 0 ? void 0 : _r.$eq;
126
125
  if (typeof objectTransactionNumberEq === 'string') {
127
- andConditions.push({
128
- 'data.object.transactionNumber': {
129
- $exists: true,
130
- $eq: objectTransactionNumberEq
131
- }
132
- });
126
+ andConditions.push({ 'data.object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
133
127
  }
134
- const objectPurposeIdEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.purpose) === null || _q === void 0 ? void 0 : _q.id) === null || _r === void 0 ? void 0 : _r.$eq;
128
+ const objectPurposeIdEq = (_u = (_t = (_s = params.data) === null || _s === void 0 ? void 0 : _s.purpose) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
135
129
  if (typeof objectPurposeIdEq === 'string') {
136
- andConditions.push({
137
- 'data.purpose.id': {
138
- $exists: true,
139
- $eq: objectPurposeIdEq
140
- }
141
- });
130
+ andConditions.push({ 'data.purpose.id': { $exists: true, $eq: objectPurposeIdEq } });
142
131
  }
143
- const objectPurposeOrderNumberEq = (_u = (_t = (_s = params.data) === null || _s === void 0 ? void 0 : _s.purpose) === null || _t === void 0 ? void 0 : _t.orderNumber) === null || _u === void 0 ? void 0 : _u.$eq;
132
+ const objectPurposeOrderNumberEq = (_x = (_w = (_v = params.data) === null || _v === void 0 ? void 0 : _v.purpose) === null || _w === void 0 ? void 0 : _w.orderNumber) === null || _x === void 0 ? void 0 : _x.$eq;
144
133
  if (typeof objectPurposeOrderNumberEq === 'string') {
145
134
  andConditions.push({
146
135
  'data.purpose.orderNumber': {
@@ -230,6 +219,73 @@ class MongoRepository {
230
219
  }
231
220
  });
232
221
  }
222
+ createConfirmReserveTransactionTaskIfNotExist(params, options) {
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ const createdTask = yield this.taskModel.findOneAndUpdate({
225
+ 'project.id': { $eq: params.project.id },
226
+ name: { $eq: params.name },
227
+ 'data.object.transactionNumber': {
228
+ $exists: true,
229
+ $eq: String(params.data.object.transactionNumber)
230
+ },
231
+ 'data.purpose.orderNumber': {
232
+ $exists: true,
233
+ $eq: String(params.data.purpose.orderNumber)
234
+ }
235
+ }, { $setOnInsert: params }, { new: true, upsert: true })
236
+ .select({ _id: 1 })
237
+ .exec();
238
+ if (options.emitImmediately) {
239
+ task_2.taskEventEmitter.emitTaskStatusChanged({
240
+ id: createdTask.id,
241
+ name: params.name,
242
+ status: factory.taskStatus.Ready
243
+ });
244
+ }
245
+ });
246
+ }
247
+ createSendOrderTaskIfNotExist(params, options) {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ const createdTask = yield this.taskModel.findOneAndUpdate({
250
+ 'project.id': { $eq: params.project.id },
251
+ name: { $eq: params.name },
252
+ 'data.object.orderNumber': {
253
+ $exists: true,
254
+ $eq: String(params.data.object.orderNumber)
255
+ }
256
+ }, { $setOnInsert: params }, { new: true, upsert: true })
257
+ .select({ _id: 1 })
258
+ .exec();
259
+ if (options.emitImmediately) {
260
+ task_2.taskEventEmitter.emitTaskStatusChanged({
261
+ id: createdTask.id,
262
+ name: params.name,
263
+ status: factory.taskStatus.Ready
264
+ });
265
+ }
266
+ });
267
+ }
268
+ createOnOrderPaymentCompletedTaskIfNotExist(params, options) {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ const createdTask = yield this.taskModel.findOneAndUpdate({
271
+ 'project.id': { $eq: params.project.id },
272
+ name: { $eq: params.name },
273
+ 'data.object.orderNumber': {
274
+ $exists: true,
275
+ $eq: String(params.data.object.orderNumber)
276
+ }
277
+ }, { $setOnInsert: params }, { new: true, upsert: true })
278
+ .select({ _id: 1 })
279
+ .exec();
280
+ if (options.emitImmediately) {
281
+ task_2.taskEventEmitter.emitTaskStatusChanged({
282
+ id: createdTask.id,
283
+ name: params.name,
284
+ status: factory.taskStatus.Ready
285
+ });
286
+ }
287
+ });
288
+ }
233
289
  executeById(params) {
234
290
  return __awaiter(this, void 0, void 0, function* () {
235
291
  const doc = yield this.taskModel.findOneAndUpdate({
@@ -29,6 +29,23 @@ const accountTransactionIdentifier_1 = require("../factory/accountTransactionIde
29
29
  */
30
30
  function givePointAward(params) {
31
31
  return (repos) => __awaiter(this, void 0, void 0, function* () {
32
+ // 入金識別子が存在する場合、冪等性の確保(2023-08-24~)
33
+ const pendingTransactionIdentifier = params.object.identifier;
34
+ if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
35
+ // すでにConfirmedのMoneyTransfer取引が存在すれば何もしない
36
+ const assetTransactions = yield repos.assetTransaction.search({
37
+ limit: 1,
38
+ project: { id: { $eq: params.project.id } },
39
+ typeOf: factory.assetTransactionType.MoneyTransfer,
40
+ statuses: [factory.transactionStatusType.Confirmed],
41
+ object: {
42
+ pendingTransaction: { identifier: { $eq: pendingTransactionIdentifier } }
43
+ }
44
+ }, ['_id']);
45
+ if (assetTransactions.length > 0) {
46
+ return;
47
+ }
48
+ }
32
49
  // アクション開始
33
50
  const action = yield repos.action.start(params);
34
51
  try {
@@ -0,0 +1,26 @@
1
+ import * as factory from '../../factory';
2
+ import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
3
+ import { MongoRepository as ActionRepo } from '../../repo/action';
4
+ import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
5
+ import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
6
+ import { MongoRepository as EventRepo } from '../../repo/event';
7
+ import { MongoRepository as OrderRepo } from '../../repo/order';
8
+ import { MongoRepository as ProductRepo } from '../../repo/product';
9
+ import { MongoRepository as ProjectRepo } from '../../repo/project';
10
+ import { MongoRepository as SellerRepo } from '../../repo/seller';
11
+ import { MongoRepository as TaskRepo } from '../../repo/task';
12
+ import { MongoRepository as TransactionRepo } from '../../repo/transaction';
13
+ declare function confirmPayTransaction(data: factory.task.IData<factory.taskName.ConfirmPayTransaction>): (repos: {
14
+ action: ActionRepo;
15
+ assetTransaction: AssetTransactionRepo;
16
+ order: OrderRepo;
17
+ accountingReport: AccountingReportRepo;
18
+ event: EventRepo;
19
+ product: ProductRepo;
20
+ project: ProjectRepo;
21
+ seller: SellerRepo;
22
+ task: TaskRepo;
23
+ transaction: TransactionRepo;
24
+ registerServiceInProgress: RegisterServiceInProgressRepo;
25
+ }) => Promise<void>;
26
+ export { confirmPayTransaction };
@@ -0,0 +1,124 @@
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.confirmPayTransaction = void 0;
13
+ const createDebug = require("debug");
14
+ const factory = require("../../factory");
15
+ const PayTransactionService = require("../assetTransaction/pay");
16
+ const debug = createDebug('chevre-domain:service:order');
17
+ function confirmPayTransaction(data) {
18
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ // アクション開始
20
+ const action = yield repos.action.start(data);
21
+ try {
22
+ for (const confirmingTransaction of data.object) {
23
+ yield PayTransactionService.confirm({
24
+ transactionNumber: confirmingTransaction.transactionNumber,
25
+ potentialActions: {
26
+ pay: {
27
+ purpose: {
28
+ typeOf: data.purpose.typeOf,
29
+ confirmationNumber: data.purpose.confirmationNumber,
30
+ orderNumber: data.purpose.orderNumber
31
+ }
32
+ }
33
+ }
34
+ })({
35
+ action: repos.action,
36
+ accountingReport: repos.accountingReport,
37
+ assetTransaction: repos.assetTransaction,
38
+ event: repos.event,
39
+ order: repos.order,
40
+ product: repos.product,
41
+ project: repos.project,
42
+ seller: repos.seller,
43
+ task: repos.task
44
+ });
45
+ }
46
+ }
47
+ catch (error) {
48
+ // actionにエラー結果を追加
49
+ try {
50
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
51
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
52
+ }
53
+ catch (__) {
54
+ // 失敗したら仕方ない
55
+ }
56
+ throw error;
57
+ }
58
+ // アクション完了
59
+ const actionResult = {};
60
+ yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
61
+ // processOrder連携(2023-08-23~)
62
+ yield onConfirmed(data)({
63
+ assetTransaction: repos.assetTransaction,
64
+ order: repos.order,
65
+ registerActionInProgress: repos.registerServiceInProgress,
66
+ task: repos.task,
67
+ transaction: repos.transaction
68
+ });
69
+ });
70
+ }
71
+ exports.confirmPayTransaction = confirmPayTransaction;
72
+ function onConfirmed(params) {
73
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
74
+ if (params.processOrder === true) {
75
+ // 注文のpaymentMethodIdを取得
76
+ const order = yield repos.order.findByOrderNumber({
77
+ orderNumber: params.purpose.orderNumber,
78
+ project: { id: params.project.id },
79
+ inclusion: ['paymentMethods'],
80
+ exclusion: []
81
+ });
82
+ // PayTransactionのステータス検証
83
+ let allPayTransactionConfirmed = false;
84
+ const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
85
+ .map((invoice) => invoice.paymentMethodId);
86
+ if (paymentMethodIds.length > 0) {
87
+ debug('checking allPayTransactionConfirmed...', 'orderNumber:', params.purpose.orderNumber);
88
+ const referencedPayTransactions = yield repos.assetTransaction.search({
89
+ project: { id: { $eq: params.project.id } },
90
+ typeOf: factory.assetTransactionType.Pay,
91
+ transactionNumber: { $in: paymentMethodIds }
92
+ }, ['status']);
93
+ allPayTransactionConfirmed =
94
+ referencedPayTransactions.every((payTransation) => payTransation.status === factory.transactionStatusType.Confirmed);
95
+ debug('allPayTransactionConfirmed?:', allPayTransactionConfirmed, 'referencedPayTransactions:', JSON.stringify(referencedPayTransactions), 'orderNumber:', params.purpose.orderNumber);
96
+ }
97
+ else {
98
+ allPayTransactionConfirmed = true;
99
+ }
100
+ if (allPayTransactionConfirmed) {
101
+ // onOrderPaymentCompletedタスク冪等作成
102
+ const onPaymentCompletedTaskData = {
103
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
104
+ object: {
105
+ confirmationNumber: params.purpose.confirmationNumber,
106
+ orderNumber: params.purpose.orderNumber
107
+ },
108
+ useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
109
+ };
110
+ const onPaymentCompletedTaskAttributes = {
111
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
112
+ name: factory.taskName.OnOrderPaymentCompleted,
113
+ status: factory.taskStatus.Ready,
114
+ runsAt: new Date(),
115
+ remainingNumberOfTries: 10,
116
+ numberOfTried: 0,
117
+ executionResults: [],
118
+ data: onPaymentCompletedTaskData
119
+ };
120
+ yield repos.task.createOnOrderPaymentCompletedTaskIfNotExist(onPaymentCompletedTaskAttributes, { emitImmediately: true });
121
+ }
122
+ }
123
+ });
124
+ }
@@ -21,9 +21,6 @@ export declare function createConfirmRegisterServiceActionObjectByOrder(params:
21
21
  order: factory.order.IOrder;
22
22
  }): factory.action.interact.confirm.registerService.IObject[];
23
23
  export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | 'seller' | 'customer' | 'confirmationNumber' | 'orderNumber' | 'price' | 'priceCurrency' | 'orderDate' | 'name' | 'orderStatus' | 'orderedItem' | 'paymentMethods'>;
24
- /**
25
- * 注文作成後のアクション
26
- */
27
24
  export declare function createOnPlaceOrderTasksByTransaction(params: {
28
25
  object: factory.order.IOrder | IExternalOrder;
29
26
  potentialActions?: factory.action.trade.order.IPotentialActions;
@@ -33,11 +30,11 @@ export declare function createOnPlaceOrderTasksByTransaction(params: {
33
30
  */
34
31
  export declare function createOnOrderSentTasksByTransaction(params: {
35
32
  potentialActions?: factory.action.transfer.send.order.IPotentialActions;
36
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
33
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
37
34
  /**
38
35
  * 注文返品後のアクション
39
36
  */
40
37
  export declare function createOnOrderReturnedTasksByTransaction(params: {
41
38
  potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
42
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
39
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
43
40
  export {};
@@ -262,71 +262,6 @@ function createConfirmRegisterServiceActionObjectByOrder(params) {
262
262
  });
263
263
  }
264
264
  exports.createConfirmRegisterServiceActionObjectByOrder = createConfirmRegisterServiceActionObjectByOrder;
265
- /**
266
- * 注文作成後のアクション
267
- */
268
- // export function onPlaceOrder(params: {
269
- // object: factory.order.IOrder | IExternalOrder;
270
- // potentialActions?: factory.action.trade.order.IPotentialActions;
271
- // }) {
272
- // return async (repos: {
273
- // task: TaskRepo;
274
- // }) => {
275
- // const potentialActions = params.potentialActions;
276
- // const now = new Date();
277
- // // potentialActionsのためのタスクを生成
278
- // const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
279
- // // tslint:disable-next-line:no-single-line-block-comment
280
- // /* istanbul ignore else */
281
- // if (potentialActions !== undefined) {
282
- // // tslint:disable-next-line:no-single-line-block-comment
283
- // /* istanbul ignore else */
284
- // if (potentialActions.sendOrder !== undefined) {
285
- // const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
286
- // project: potentialActions.sendOrder.project,
287
- // name: factory.taskName.SendOrder,
288
- // status: factory.taskStatus.Ready,
289
- // runsAt: now, // なるはやで実行
290
- // remainingNumberOfTries: 10,
291
- // numberOfTried: 0,
292
- // executionResults: [],
293
- // // data: potentialActions.sendOrder
294
- // data: {
295
- // project: potentialActions.sendOrder.project,
296
- // object: {
297
- // ...potentialActions.sendOrder.object,
298
- // confirmationNumber: params.object.confirmationNumber
299
- // },
300
- // ...(potentialActions.sendOrder.potentialActions !== undefined)
301
- // ? { potentialActions: potentialActions.sendOrder.potentialActions }
302
- // : undefined
303
- // }
304
- // };
305
- // taskAttributes.push(sendOrderTask);
306
- // }
307
- // // ポイント付与
308
- // // tslint:disable-next-line:no-single-line-block-comment
309
- // /* istanbul ignore else */
310
- // if (Array.isArray(potentialActions.givePointAward)) {
311
- // taskAttributes.push(...potentialActions.givePointAward.map(
312
- // (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
313
- // return {
314
- // project: a.project,
315
- // name: factory.taskName.GivePointAward,
316
- // status: factory.taskStatus.Ready,
317
- // runsAt: now, // なるはやで実行
318
- // remainingNumberOfTries: 10,
319
- // numberOfTried: 0,
320
- // executionResults: [],
321
- // data: a
322
- // };
323
- // }));
324
- // }
325
- // }
326
- // // タスク保管
327
- // await repos.task.saveMany(taskAttributes, { emitImmediately: true });
328
- // };
329
- // }
330
265
  function createOnPlaceOrderTasksByTransaction(params) {
331
266
  const potentialActions = params.potentialActions;
332
267
  const now = new Date();
@@ -335,29 +270,33 @@ function createOnPlaceOrderTasksByTransaction(params) {
335
270
  // tslint:disable-next-line:no-single-line-block-comment
336
271
  /* istanbul ignore else */
337
272
  if (potentialActions !== undefined) {
273
+ // 冗長なsendOrderタスク作成を回避(createSendOrderTransactionTaskIfNotExistへ移行)(2023-08-25~)
338
274
  // tslint:disable-next-line:no-single-line-block-comment
339
275
  /* istanbul ignore else */
340
- if (potentialActions.sendOrder !== undefined) {
341
- const sendOrderTaskData = {
342
- project: potentialActions.sendOrder.project,
343
- object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber })
344
- // 廃止(2023-08-21~)
345
- // ...(potentialActions.sendOrder.potentialActions !== undefined)
346
- // ? { potentialActions: potentialActions.sendOrder.potentialActions }
347
- // : undefined
348
- };
349
- const sendOrderTask = {
350
- project: potentialActions.sendOrder.project,
351
- name: factory.taskName.SendOrder,
352
- status: factory.taskStatus.Ready,
353
- runsAt: now,
354
- remainingNumberOfTries: 10,
355
- numberOfTried: 0,
356
- executionResults: [],
357
- data: sendOrderTaskData
358
- };
359
- taskAttributes.push(sendOrderTask);
360
- }
276
+ // if (potentialActions.sendOrder !== undefined) {
277
+ // const sendOrderTaskData: factory.task.IData<factory.taskName.SendOrder> = {
278
+ // project: potentialActions.sendOrder.project,
279
+ // object: {
280
+ // ...potentialActions.sendOrder.object,
281
+ // confirmationNumber: params.object.confirmationNumber
282
+ // }
283
+ // // 廃止(2023-08-21~)
284
+ // // ...(potentialActions.sendOrder.potentialActions !== undefined)
285
+ // // ? { potentialActions: potentialActions.sendOrder.potentialActions }
286
+ // // : undefined
287
+ // };
288
+ // const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
289
+ // project: potentialActions.sendOrder.project,
290
+ // name: factory.taskName.SendOrder,
291
+ // status: factory.taskStatus.Ready,
292
+ // runsAt: now, // なるはやで実行
293
+ // remainingNumberOfTries: 10,
294
+ // numberOfTried: 0,
295
+ // executionResults: [],
296
+ // data: sendOrderTaskData
297
+ // };
298
+ // taskAttributes.push(sendOrderTask);
299
+ // }
361
300
  // ポイント付与
362
301
  // tslint:disable-next-line:no-single-line-block-comment
363
302
  /* istanbul ignore else */
@@ -13,18 +13,20 @@ exports.onOrderStatusChanged = void 0;
13
13
  /**
14
14
  * 注文ステータス変更時処理
15
15
  */
16
+ const createDebug = require("debug");
16
17
  const google_libphonenumber_1 = require("google-libphonenumber");
17
- const moment = require("moment");
18
18
  const factory = require("../../factory");
19
19
  const order_1 = require("../../factory/order");
20
20
  const product_1 = require("../offer/product");
21
21
  const factory_1 = require("./onOrderStatusChanged/factory");
22
+ const debug = createDebug('chevre-domain:service:order');
22
23
  const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTER_SERVICE_TRANSACTION === '1';
23
24
  const TOKEN_EXPIRES_IN = 604800;
24
25
  function onOrderStatusChanged(params) {
25
26
  // tslint:disable-next-line:max-func-body-length
26
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
29
+ debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
28
30
  let tasks = [];
29
31
  const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
30
32
  const simpleOrder = {
@@ -89,7 +91,8 @@ function onOrderStatusChanged(params) {
89
91
  // 注文作成時のみトークン付加
90
92
  ...(0, factory_1.createInformTasks)(orderWithToken),
91
93
  ...yield createConfirmPayTransactionTasks(params.order, simpleOrder)(repos),
92
- ...yield createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
94
+ // createConfirmReserveTransactionTasksIfNotExistへ移行(2023-08-25~)
95
+ // ...await createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
93
96
  ...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
94
97
  // 取引のpotentialActionsを適用(2023-08-17~)
95
98
  ...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
@@ -115,21 +118,30 @@ function onOrderStatusChanged(params) {
115
118
  default:
116
119
  }
117
120
  yield repos.task.saveMany(tasks, { emitImmediately: true });
121
+ switch (params.order.orderStatus) {
122
+ case factory.orderStatus.OrderProcessing:
123
+ // 冗長なconfirmReserveTransactionタスク作成を回避(2023-08-25~)
124
+ yield createConfirmReserveTransactionTasksIfNotExist(params.order, simpleOrder)(repos);
125
+ // 冗長なsendOrderタスク作成を回避(2023-08-25~)
126
+ yield createSendOrderTransactionTaskIfNotExist({
127
+ object: params.order,
128
+ potentialActions: (_q = (_p = (_o = params.placeOrderTransaction) === null || _o === void 0 ? void 0 : _o.potentialActions) === null || _p === void 0 ? void 0 : _p.order) === null || _q === void 0 ? void 0 : _q.potentialActions
129
+ })(repos);
130
+ break;
131
+ default:
132
+ }
118
133
  });
119
134
  }
120
135
  exports.onOrderStatusChanged = onOrderStatusChanged;
121
136
  function createConfirmPayTransactionTasks(order, simpleOrder) {
122
137
  return (repos) => __awaiter(this, void 0, void 0, function* () {
123
- const taskRunsAt = moment(order.orderDate)
124
- .toDate();
138
+ const taskRunsAt = new Date();
125
139
  const tasks = [];
126
140
  yield Promise.all(order.paymentMethods.map((invoice) => __awaiter(this, void 0, void 0, function* () {
127
- // tslint:disable-next-line:no-suspicious-comment
128
- // TODO 注文にpaymentStatusを保証した後に実装する
129
- // PaymentAutomaticallyAppliedであれば、自動決済処理を実行
130
- // if (invoice.paymentStatus !== factory.paymentStatusType.PaymentAutomaticallyApplied) {
131
- // return;
132
- // }
141
+ // PaymentAutomaticallyAppliedであれば、自動決済処理を実行(2023-08-24~)
142
+ if (invoice.paymentStatus !== factory.paymentStatusType.PaymentAutomaticallyApplied) {
143
+ return;
144
+ }
133
145
  // 冗長なタスク作成を回避
134
146
  const existingTasks = yield repos.task.search({
135
147
  limit: 1,
@@ -173,69 +185,49 @@ function createConfirmPayTransactionTasks(order, simpleOrder) {
173
185
  return tasks;
174
186
  });
175
187
  }
176
- const COA_TASK_DELAY_IN_SECONDS = 0;
177
- function createConfirmReserveTransactionTasks(order, simpleOrder) {
188
+ // const COA_TASK_DELAY_IN_SECONDS = 0;
189
+ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder) {
178
190
  return (repos) => __awaiter(this, void 0, void 0, function* () {
179
- const taskRunsAt = moment(order.orderDate)
180
- .toDate();
181
- const taskRunsAt4coa = moment(order.orderDate)
182
- .add(COA_TASK_DELAY_IN_SECONDS, 'seconds')
183
- .toDate();
191
+ const taskRunsAt = new Date();
192
+ const taskRunsAt4coa = new Date();
193
+ // const taskRunsAt4coa = moment(order.orderDate)
194
+ // .add(COA_TASK_DELAY_IN_SECONDS, 'seconds')
195
+ // .toDate();
184
196
  const confirmObjects = [
185
197
  ...(0, factory_1.createConfirmReservationActionObject4ChevreByOrder)({ order }),
186
198
  ...(0, factory_1.createConfirmReservationActionObject4COAByOrder)({ order })
187
199
  ];
188
- const tasks = [];
189
200
  yield Promise.all(confirmObjects.map((confirmObject) => __awaiter(this, void 0, void 0, function* () {
190
- // 冗長なタスク作成を回避
191
- const existingTasks = yield repos.task.search({
192
- limit: 1,
193
- page: 1,
194
- project: { id: { $eq: order.project.id } },
195
- name: factory.taskName.ConfirmReserveTransaction,
196
- data: {
197
- object: { transactionNumber: { $eq: confirmObject.transactionNumber } },
198
- purpose: { orderNumber: { $eq: order.orderNumber } }
201
+ const data = {
202
+ project: order.project,
203
+ typeOf: factory.actionType.ConfirmAction,
204
+ object: confirmObject,
205
+ agent: order.project,
206
+ purpose: simpleOrder,
207
+ instrument: {
208
+ typeOf: 'WebAPI',
209
+ identifier: (confirmObject.typeOf === 'COAReserveTransaction')
210
+ ? factory.service.webAPI.Identifier.COA
211
+ : factory.service.webAPI.Identifier.Chevre
199
212
  }
200
- }, {
201
- data: 0, executionResults: 0, name: 0, numberOfTried: 0,
202
- remainingNumberOfTries: 0, runsAt: 0, status: 0
203
- });
204
- if (existingTasks.length === 0) {
205
- const data = {
206
- project: order.project,
207
- typeOf: factory.actionType.ConfirmAction,
208
- object: confirmObject,
209
- agent: order.project,
210
- purpose: simpleOrder,
211
- instrument: {
212
- typeOf: 'WebAPI',
213
- identifier: (confirmObject.typeOf === 'COAReserveTransaction')
214
- ? factory.service.webAPI.Identifier.COA
215
- : factory.service.webAPI.Identifier.Chevre
216
- }
217
- };
218
- tasks.push({
219
- project: order.project,
220
- name: factory.taskName.ConfirmReserveTransaction,
221
- status: factory.taskStatus.Ready,
222
- runsAt: (confirmObject.typeOf === 'COAReserveTransaction')
223
- ? taskRunsAt4coa
224
- : taskRunsAt,
225
- remainingNumberOfTries: 10,
226
- numberOfTried: 0,
227
- executionResults: [],
228
- data
229
- });
230
- }
213
+ };
214
+ const confirmReserveTransactionTask = {
215
+ project: order.project,
216
+ name: factory.taskName.ConfirmReserveTransaction,
217
+ status: factory.taskStatus.Ready,
218
+ runsAt: (confirmObject.typeOf === 'COAReserveTransaction') ? taskRunsAt4coa : taskRunsAt,
219
+ remainingNumberOfTries: 10,
220
+ numberOfTried: 0,
221
+ executionResults: [],
222
+ data
223
+ };
224
+ yield repos.task.createConfirmReserveTransactionTaskIfNotExist(confirmReserveTransactionTask, { emitImmediately: true });
231
225
  })));
232
- return tasks;
233
226
  });
234
227
  }
235
228
  function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
236
229
  return (repos) => __awaiter(this, void 0, void 0, function* () {
237
- const taskRunsAt = moment(order.orderDate)
238
- .toDate();
230
+ const taskRunsAt = new Date();
239
231
  if (USE_CONFIRM_REGISTER_SERVICE_TRANSACTION) {
240
232
  const confirmObjects = (0, factory_1.createConfirmRegisterServiceActionObjectByOrder)({ order });
241
233
  const tasks = [];
@@ -285,14 +277,38 @@ function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
285
277
  }
286
278
  });
287
279
  }
288
- const RETURN_COA_TASK_DELAY_IN_SECONDS = 0;
280
+ function createSendOrderTransactionTaskIfNotExist(params) {
281
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
282
+ var _a;
283
+ const now = new Date();
284
+ const sendOrderByTransaction = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.sendOrder;
285
+ if (sendOrderByTransaction !== undefined) {
286
+ const sendOrderTaskData = {
287
+ project: sendOrderByTransaction.project,
288
+ object: Object.assign(Object.assign({}, sendOrderByTransaction.object), { confirmationNumber: params.object.confirmationNumber })
289
+ };
290
+ const sendOrderTask = {
291
+ project: sendOrderByTransaction.project,
292
+ name: factory.taskName.SendOrder,
293
+ status: factory.taskStatus.Ready,
294
+ runsAt: now,
295
+ remainingNumberOfTries: 10,
296
+ numberOfTried: 0,
297
+ executionResults: [],
298
+ data: sendOrderTaskData
299
+ };
300
+ yield repos.task.createSendOrderTaskIfNotExist(sendOrderTask, { emitImmediately: true });
301
+ }
302
+ });
303
+ }
304
+ // const RETURN_COA_TASK_DELAY_IN_SECONDS = 0;
289
305
  function createReturnReserveTransactionTasks(order, simpleOrder) {
290
306
  var _a, _b;
291
- const taskRunsAt = moment(order.dateReturned)
292
- .toDate();
293
- const taskRunsAt4coa = moment(order.dateReturned)
294
- .add(RETURN_COA_TASK_DELAY_IN_SECONDS, 'seconds')
295
- .toDate();
307
+ const taskRunsAt = new Date();
308
+ const taskRunsAt4coa = new Date();
309
+ // const taskRunsAt4coa = moment(order.dateReturned)
310
+ // .add(RETURN_COA_TASK_DELAY_IN_SECONDS, 'seconds')
311
+ // .toDate();
296
312
  const tasks = [];
297
313
  const returnActionRecipient = {
298
314
  typeOf: order.seller.typeOf,
@@ -367,12 +383,13 @@ function createReturnReserveTransactionTasks(order, simpleOrder) {
367
383
  }
368
384
  return tasks;
369
385
  }
370
- const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
386
+ // const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
371
387
  function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
372
388
  var _a, _b;
373
- const taskRunsAt = moment(order.dateReturned)
374
- .add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
375
- .toDate();
389
+ const taskRunsAt = new Date();
390
+ // const taskRunsAt = moment(order.dateReturned)
391
+ // .add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
392
+ // .toDate();
376
393
  const tasks = [];
377
394
  const returnOrderPotentialActions = (_b = (_a = returnOrderTransaction === null || returnOrderTransaction === void 0 ? void 0 : returnOrderTransaction.potentialActions) === null || _a === void 0 ? void 0 : _a.returnOrder.find((action) => action.object.orderNumber === order.orderNumber)) === null || _b === void 0 ? void 0 : _b.potentialActions;
378
395
  const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions === null || returnOrderPotentialActions === void 0 ? void 0 : returnOrderPotentialActions.returnPaymentMethod;
@@ -2,19 +2,11 @@ import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/act
2
2
  import { MongoRepository as OrderRepo } from '../../repo/order';
3
3
  import { MongoRepository as TaskRepo } from '../../repo/task';
4
4
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
5
+ import * as factory from '../../factory';
5
6
  /**
6
7
  * 注文を決済する
7
8
  */
8
- declare function payOrder(params: {
9
- project: {
10
- id: string;
11
- };
12
- object: {
13
- confirmationNumber: string;
14
- orderNumber: string;
15
- };
16
- useOnOrderStatusChanged: boolean;
17
- }): (repos: {
9
+ declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): (repos: {
18
10
  order: OrderRepo;
19
11
  registerActionInProgress: RegisterServiceInProgressRepo;
20
12
  task: TaskRepo;
@@ -38,8 +38,8 @@ function payOrder(params) {
38
38
  order = yield repos.order.changeStatus({
39
39
  project: { id: order.project.id },
40
40
  orderNumber,
41
- orderStatus: factory.orderStatus.OrderPaymentDue,
42
- previousOrderStatus: factory.orderStatus.OrderProcessing
41
+ orderStatus: factory.orderStatus.OrderProcessing,
42
+ previousOrderStatus: factory.orderStatus.OrderPaymentDue
43
43
  });
44
44
  }
45
45
  catch (error) {
@@ -42,5 +42,7 @@ declare function placeOrder(params: {
42
42
  registerActionInProgress: RegisterServiceInProgressRepo;
43
43
  task: TaskRepo;
44
44
  transaction: TransactionRepo;
45
- }) => Promise<void>;
45
+ }) => Promise<{
46
+ order: factory.order.IOrder;
47
+ }>;
46
48
  export { placeOrder, placeOrderWithoutTransaction };
@@ -15,7 +15,6 @@ const order_1 = require("../../factory/order");
15
15
  const createAccountingReportIfNotExist_1 = require("./createAccountingReportIfNotExist");
16
16
  const findPlaceOrderTransaction_1 = require("./findPlaceOrderTransaction");
17
17
  const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
18
- const payOrder_1 = require("./payOrder");
19
18
  const factory = require("../../factory");
20
19
  function createOrder(params) {
21
20
  // 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
@@ -233,14 +232,41 @@ function placeOrder(params) {
233
232
  }
234
233
  else if (order.orderStatus === factory.orderStatus.OrderProcessing) {
235
234
  // OrderPaymentDueをスキップしてOrderProcessingから開始する場合(2023-08-23~)
236
- yield (0, payOrder_1.payOrder)({
237
- project: { id: order.project.id },
235
+ // OrderPaymentDueに対する処理をまず強制的に実行する(2023-08-24~)
236
+ yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({
237
+ order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderPaymentDue }),
238
+ placeOrderTransaction
239
+ })({
240
+ registerActionInProgress: repos.registerActionInProgress,
241
+ task: repos.task
242
+ });
243
+ }
244
+ else {
245
+ throw new factory.errors.NotImplemented(`placing an order on the status '${order.orderStatus}' not implemented`);
246
+ }
247
+ // paymentMethods.length: 0の場合を考慮(2023-08-24~)
248
+ if (order.paymentMethods.length === 0) {
249
+ // paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpayOrderを実行する必要がある
250
+ // onOrderPaymentCompletedタスク作成
251
+ const onPaymentCompletedTaskData = {
252
+ project: { id: order.project.id, typeOf: factory.organizationType.Project },
238
253
  object: {
239
254
  confirmationNumber: order.confirmationNumber,
240
255
  orderNumber: order.orderNumber
241
256
  },
242
- useOnOrderStatusChanged: params.useOnOrderStatusChanged
243
- })(repos);
257
+ useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
258
+ };
259
+ const onPaymentCompletedTaskAttributes = {
260
+ project: { id: order.project.id, typeOf: factory.organizationType.Project },
261
+ name: factory.taskName.OnOrderPaymentCompleted,
262
+ status: factory.taskStatus.Ready,
263
+ runsAt: new Date(),
264
+ remainingNumberOfTries: 10,
265
+ numberOfTried: 0,
266
+ executionResults: [],
267
+ data: onPaymentCompletedTaskData
268
+ };
269
+ yield repos.task.createOnOrderPaymentCompletedTaskIfNotExist(onPaymentCompletedTaskAttributes, { emitImmediately: true });
244
270
  }
245
271
  }
246
272
  // onOrderStatusChangedへ移行(2023-08-17~)
@@ -248,6 +274,7 @@ function placeOrder(params) {
248
274
  // object: order,
249
275
  // potentialActions: params.potentialActions
250
276
  // })(repos);
277
+ return { order };
251
278
  });
252
279
  }
253
280
  exports.placeOrder = placeOrder;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * 注文サービス
3
3
  */
4
+ import { confirmPayTransaction } from './order/confirmPayTransaction';
4
5
  import { deleteOrder } from './order/deleteOrder';
5
6
  import { onOrderStatusChanged } from './order/onOrderStatusChanged';
6
7
  import { onOrderUpdated } from './order/onOrderUpdated';
7
8
  import { placeOrder, placeOrderWithoutTransaction } from './order/placeOrder';
8
- import { returnOrder } from './order/returnOrder';
9
9
  import { sendOrder } from './order/sendOrder';
10
- export { deleteOrder, onOrderStatusChanged, onOrderUpdated, placeOrder, placeOrderWithoutTransaction, returnOrder, sendOrder };
10
+ export { confirmPayTransaction, deleteOrder, onOrderStatusChanged, onOrderUpdated, placeOrder, placeOrderWithoutTransaction, sendOrder };
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendOrder = exports.returnOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.onOrderUpdated = exports.onOrderStatusChanged = exports.deleteOrder = void 0;
3
+ exports.sendOrder = exports.placeOrderWithoutTransaction = exports.placeOrder = exports.onOrderUpdated = exports.onOrderStatusChanged = exports.deleteOrder = exports.confirmPayTransaction = void 0;
4
4
  /**
5
5
  * 注文サービス
6
6
  */
7
+ const confirmPayTransaction_1 = require("./order/confirmPayTransaction");
8
+ Object.defineProperty(exports, "confirmPayTransaction", { enumerable: true, get: function () { return confirmPayTransaction_1.confirmPayTransaction; } });
7
9
  const deleteOrder_1 = require("./order/deleteOrder");
8
10
  Object.defineProperty(exports, "deleteOrder", { enumerable: true, get: function () { return deleteOrder_1.deleteOrder; } });
9
11
  const onOrderStatusChanged_1 = require("./order/onOrderStatusChanged");
@@ -13,7 +15,6 @@ Object.defineProperty(exports, "onOrderUpdated", { enumerable: true, get: functi
13
15
  const placeOrder_1 = require("./order/placeOrder");
14
16
  Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return placeOrder_1.placeOrder; } });
15
17
  Object.defineProperty(exports, "placeOrderWithoutTransaction", { enumerable: true, get: function () { return placeOrder_1.placeOrderWithoutTransaction; } });
16
- const returnOrder_1 = require("./order/returnOrder");
17
- Object.defineProperty(exports, "returnOrder", { enumerable: true, get: function () { return returnOrder_1.returnOrder; } });
18
+ // import { returnOrder } from './order/returnOrder';
18
19
  const sendOrder_1 = require("./order/sendOrder");
19
20
  Object.defineProperty(exports, "sendOrder", { enumerable: true, get: function () { return sendOrder_1.sendOrder; } });
@@ -22,8 +22,7 @@ const project_1 = require("../../repo/project");
22
22
  const seller_1 = require("../../repo/seller");
23
23
  const task_1 = require("../../repo/task");
24
24
  const transaction_1 = require("../../repo/transaction");
25
- const PayTransactionService = require("../assetTransaction/pay");
26
- const payOrder_1 = require("../order/payOrder");
25
+ const confirmPayTransaction_1 = require("../order/confirmPayTransaction");
27
26
  /**
28
27
  * タスク実行関数
29
28
  */
@@ -32,106 +31,19 @@ function call(data) {
32
31
  if (settings.redisClient === undefined) {
33
32
  throw new factory.errors.Argument('settings', 'redisClient required');
34
33
  }
35
- const actionRepo = new action_1.MongoRepository(settings.connection);
36
- const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
37
- const orderRepo = new order_1.MongoRepository(settings.connection);
38
- const accountingReportRepo = new accountingReport_1.MongoRepository(settings.connection);
39
- const eventRepo = new event_1.MongoRepository(settings.connection);
40
- const productRepo = new product_1.MongoRepository(settings.connection);
41
- const projectRepo = new project_1.MongoRepository(settings.connection);
42
- const sellerRepo = new seller_1.MongoRepository(settings.connection);
43
- const taskRepo = new task_1.MongoRepository(settings.connection);
44
- const transactionRepo = new transaction_1.MongoRepository(settings.connection);
45
- const registerServiceInProgressRepo = new registerServiceInProgress_1.RedisRepository(settings.redisClient);
46
- // アクション開始
47
- const action = yield actionRepo.start(data);
48
- try {
49
- for (const confirmingTransaction of data.object) {
50
- yield PayTransactionService.confirm({
51
- transactionNumber: confirmingTransaction.transactionNumber,
52
- potentialActions: {
53
- pay: {
54
- purpose: {
55
- typeOf: data.purpose.typeOf,
56
- confirmationNumber: data.purpose.confirmationNumber,
57
- orderNumber: data.purpose.orderNumber
58
- }
59
- }
60
- }
61
- })({
62
- action: actionRepo,
63
- accountingReport: accountingReportRepo,
64
- assetTransaction: assetTransactionRepo,
65
- event: eventRepo,
66
- order: orderRepo,
67
- product: productRepo,
68
- project: projectRepo,
69
- seller: sellerRepo,
70
- task: taskRepo
71
- });
72
- }
73
- }
74
- catch (error) {
75
- // actionにエラー結果を追加
76
- try {
77
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
78
- yield actionRepo.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
79
- }
80
- catch (__) {
81
- // 失敗したら仕方ない
82
- }
83
- throw error;
84
- }
85
- // アクション完了
86
- const actionResult = {};
87
- yield actionRepo.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
88
- // processOrder連携(2023-08-23~)
89
- yield onConfirmed(data)({
90
- assetTransaction: assetTransactionRepo,
91
- order: orderRepo,
92
- registerActionInProgress: registerServiceInProgressRepo,
93
- task: taskRepo,
94
- transaction: transactionRepo
34
+ yield (0, confirmPayTransaction_1.confirmPayTransaction)(data)({
35
+ action: new action_1.MongoRepository(settings.connection),
36
+ assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
37
+ order: new order_1.MongoRepository(settings.connection),
38
+ accountingReport: new accountingReport_1.MongoRepository(settings.connection),
39
+ event: new event_1.MongoRepository(settings.connection),
40
+ product: new product_1.MongoRepository(settings.connection),
41
+ project: new project_1.MongoRepository(settings.connection),
42
+ seller: new seller_1.MongoRepository(settings.connection),
43
+ task: new task_1.MongoRepository(settings.connection),
44
+ transaction: new transaction_1.MongoRepository(settings.connection),
45
+ registerServiceInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient)
95
46
  });
96
47
  });
97
48
  }
98
49
  exports.call = call;
99
- function onConfirmed(params) {
100
- return (repos) => __awaiter(this, void 0, void 0, function* () {
101
- if (params.processOrder === true) {
102
- // 注文のpaymentMethodIdを取得
103
- const order = yield repos.order.findByOrderNumber({
104
- orderNumber: params.purpose.orderNumber,
105
- project: { id: params.project.id },
106
- inclusion: ['paymentMethods'],
107
- exclusion: []
108
- });
109
- // PayTransactionのステータス検証
110
- let allPayTransactionConfirmed = false;
111
- const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
112
- .map((invoice) => invoice.paymentMethodId);
113
- if (paymentMethodIds.length > 0) {
114
- const referencedPayTransactions = yield repos.assetTransaction.search({
115
- project: { id: { $eq: params.project.id } },
116
- typeOf: factory.assetTransactionType.Pay,
117
- transactionNumber: { $in: paymentMethodIds }
118
- }, ['status']);
119
- allPayTransactionConfirmed =
120
- referencedPayTransactions.every((payTransation) => payTransation.status === factory.transactionStatusType.Confirmed);
121
- }
122
- else {
123
- allPayTransactionConfirmed = true;
124
- }
125
- if (allPayTransactionConfirmed) {
126
- yield (0, payOrder_1.payOrder)({
127
- project: { id: params.project.id },
128
- object: {
129
- confirmationNumber: params.purpose.confirmationNumber,
130
- orderNumber: params.purpose.orderNumber
131
- },
132
- useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
133
- })(repos);
134
- }
135
- }
136
- });
137
- }
@@ -0,0 +1,6 @@
1
+ import { IOperation } from '../task';
2
+ import * as factory from '../../factory';
3
+ /**
4
+ * タスク実行関数
5
+ */
6
+ export declare function call(data: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): IOperation<void>;
@@ -0,0 +1,35 @@
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 registerServiceInProgress_1 = require("../../repo/action/registerServiceInProgress");
15
+ const order_1 = require("../../repo/order");
16
+ const task_1 = require("../../repo/task");
17
+ const transaction_1 = require("../../repo/transaction");
18
+ const payOrder_1 = require("../order/payOrder");
19
+ /**
20
+ * タスク実行関数
21
+ */
22
+ function call(data) {
23
+ return (settings) => __awaiter(this, void 0, void 0, function* () {
24
+ if (settings.redisClient === undefined) {
25
+ throw new factory.errors.Argument('settings', 'redisClient required');
26
+ }
27
+ yield (0, payOrder_1.payOrder)(data)({
28
+ order: new order_1.MongoRepository(settings.connection),
29
+ registerActionInProgress: new registerServiceInProgress_1.RedisRepository(settings.redisClient),
30
+ task: new task_1.MongoRepository(settings.connection),
31
+ transaction: new transaction_1.MongoRepository(settings.connection)
32
+ });
33
+ });
34
+ }
35
+ exports.call = call;
@@ -17,7 +17,7 @@ const order_1 = require("../../repo/order");
17
17
  const ownershipInfo_1 = require("../../repo/ownershipInfo");
18
18
  const task_1 = require("../../repo/task");
19
19
  const transaction_1 = require("../../repo/transaction");
20
- const OrderService = require("../order");
20
+ const returnOrder_1 = require("../order/returnOrder");
21
21
  /**
22
22
  * タスク実行関数
23
23
  */
@@ -32,7 +32,7 @@ function call(data) {
32
32
  const taskRepo = new task_1.MongoRepository(settings.connection);
33
33
  const transactionRepo = new transaction_1.MongoRepository(settings.connection);
34
34
  const registerServiceInProgressRepo = new registerServiceInProgress_1.RedisRepository(settings.redisClient);
35
- yield OrderService.returnOrder(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
35
+ yield (0, returnOrder_1.returnOrder)(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
36
36
  action: actionRepo,
37
37
  order: orderRepo,
38
38
  ownershipInfo: ownershipInfoRepo,
@@ -22,6 +22,7 @@ const validation_1 = require("./placeOrderInProgress/validation");
22
22
  const validateSeller_1 = require("./placeOrderInProgress/validation/validateSeller");
23
23
  const validation_2 = require("./validation");
24
24
  const errorHandler_1 = require("../../errorHandler");
25
+ const settings_1 = require("../../settings");
25
26
  exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
26
27
  /**
27
28
  * 取引開始
@@ -226,7 +227,9 @@ function createResult(params) {
226
227
  orderNumber: params.orderNumber,
227
228
  transaction: transaction,
228
229
  orderDate: params.result.order.orderDate,
229
- orderStatus: factory.orderStatus.OrderProcessing,
230
+ // OrderPaymentDueオプションを追加(2023-08-25~)
231
+ // 注文作成時のステータスとなる
232
+ orderStatus: (settings_1.USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
230
233
  isGift: false,
231
234
  authorizeActions: params.authorizeActions
232
235
  });
@@ -42,6 +42,7 @@ export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
42
42
  export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
43
43
  export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
44
44
  export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
45
+ export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
45
46
  export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
46
47
  export declare const MONGO_MAX_TIME_MS: number;
47
48
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = 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.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = 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.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -74,6 +74,7 @@ exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIR
74
74
  exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
75
75
  exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
76
76
  exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
77
+ exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
77
78
  exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
78
79
  ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
79
80
  : 0;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.327.0-alpha.1",
12
+ "@chevre/factory": "4.327.0-alpha.3",
13
13
  "@cinerino/sdk": "3.165.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.0"
120
+ "version": "21.8.0-alpha.10"
121
121
  }