@chevre/domain 21.7.0-alpha.9 → 21.8.0-alpha.0
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/countDelayedTasks.ts +1 -1
- package/example/src/chevre/createDeleteTransactionTasks.ts +108 -0
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +98 -0
- package/example/src/chevre/deleteRunsAtPassedCertainPeriod.ts +28 -0
- package/example/src/chevre/deleteTasksByName.ts +1 -1
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +1 -1
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +4 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +1 -1
- package/lib/chevre/emailMessageBuilder.js +2 -1
- package/lib/chevre/repo/assetTransaction.js +22 -23
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/offer.js +5 -6
- package/lib/chevre/repo/project.d.ts +1 -0
- package/lib/chevre/repo/project.js +10 -4
- package/lib/chevre/repo/task.d.ts +6 -2
- package/lib/chevre/repo/task.js +25 -1
- package/lib/chevre/repo/transaction.d.ts +25 -1
- package/lib/chevre/repo/transaction.js +6 -1
- package/lib/chevre/service/notification.js +13 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +20 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +242 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +139 -110
- package/lib/chevre/service/order/payOrder.d.ts +23 -0
- package/lib/chevre/service/order/payOrder.js +74 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -3
- package/lib/chevre/service/order/placeOrder.js +33 -76
- package/lib/chevre/service/order/returnOrder.d.ts +1 -2
- package/lib/chevre/service/order/returnOrder.js +15 -97
- package/lib/chevre/service/order/sendOrder.d.ts +0 -1
- package/lib/chevre/service/order/sendOrder.js +6 -68
- package/lib/chevre/service/payment/any/factory.js +3 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +56 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +6 -6
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +12 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +92 -88
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -2
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +8 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +7 -4
- package/lib/chevre/service/transaction/returnOrder.js +0 -1
- package/lib/chevre/settings.d.ts +1 -1
- package/lib/chevre/settings.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/checkOrderMembershipTasks.ts +0 -127
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -65
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -105
- package/lib/chevre/service/task/orderProgramMembership.d.ts +0 -6
- package/lib/chevre/service/task/orderProgramMembership.js +0 -98
- package/lib/chevre/service/transaction/orderProgramMembership.d.ts +0 -50
- package/lib/chevre/service/transaction/orderProgramMembership.js +0 -349
package/lib/chevre/repo/task.js
CHANGED
|
@@ -206,6 +206,30 @@ class MongoRepository {
|
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* 取引削除タスク冪等作成
|
|
211
|
+
*/
|
|
212
|
+
createDeleteTransactionTaskIfNotExist(params, options) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
if (params.data.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.Id) {
|
|
215
|
+
throw new factory.errors.NotImplemented(`only ${factory.task.deleteTransaction.SpecifyingMethod.Id} implemented`);
|
|
216
|
+
}
|
|
217
|
+
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
218
|
+
'project.id': { $eq: params.project.id },
|
|
219
|
+
name: { $eq: params.name },
|
|
220
|
+
'data.object.id': { $exists: true, $eq: params.data.object.id }
|
|
221
|
+
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
222
|
+
.select({ _id: 1 })
|
|
223
|
+
.exec();
|
|
224
|
+
if (options.emitImmediately) {
|
|
225
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
226
|
+
id: createdTask.id,
|
|
227
|
+
name: params.name,
|
|
228
|
+
status: factory.taskStatus.Ready
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
209
233
|
executeById(params) {
|
|
210
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
235
|
const doc = yield this.taskModel.findOneAndUpdate({
|
|
@@ -427,7 +451,7 @@ class MongoRepository {
|
|
|
427
451
|
*/
|
|
428
452
|
deleteRunsAtPassedCertainPeriod(params) {
|
|
429
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
-
|
|
454
|
+
return this.taskModel.deleteMany({
|
|
431
455
|
runsAt: { $lt: params.runsAt.$lt },
|
|
432
456
|
status: { $in: [factory.taskStatus.Aborted, factory.taskStatus.Executed] }
|
|
433
457
|
})
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import { Connection } from 'mongoose';
|
|
2
26
|
import * as factory from '../factory';
|
|
3
27
|
interface IAggregationByStatus {
|
|
@@ -98,7 +122,6 @@ export declare class MongoRepository {
|
|
|
98
122
|
confirm<T extends factory.transactionType>(params: {
|
|
99
123
|
typeOf: T;
|
|
100
124
|
id: string;
|
|
101
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
102
125
|
result: factory.transaction.IResult<T>;
|
|
103
126
|
potentialActions: factory.transaction.IPotentialActions<T>;
|
|
104
127
|
}): Promise<void>;
|
|
@@ -194,6 +217,7 @@ export declare class MongoRepository {
|
|
|
194
217
|
filter: any;
|
|
195
218
|
$unset: any;
|
|
196
219
|
}): Promise<import("mongodb").UpdateResult>;
|
|
220
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
197
221
|
aggregatePlaceOrder(params: {
|
|
198
222
|
project?: {
|
|
199
223
|
id?: {
|
|
@@ -438,7 +438,7 @@ class MongoRepository {
|
|
|
438
438
|
}, {
|
|
439
439
|
status: factory.transactionStatusType.Confirmed,
|
|
440
440
|
endDate: new Date(),
|
|
441
|
-
'object.authorizeActions': params.authorizeActions,
|
|
441
|
+
// 'object.authorizeActions': params.authorizeActions,
|
|
442
442
|
result: params.result,
|
|
443
443
|
potentialActions: params.potentialActions // resultを更新
|
|
444
444
|
}, {
|
|
@@ -776,6 +776,11 @@ class MongoRepository {
|
|
|
776
776
|
.exec();
|
|
777
777
|
});
|
|
778
778
|
}
|
|
779
|
+
getCursor(conditions, projection) {
|
|
780
|
+
return this.transactionModel.find(conditions, projection)
|
|
781
|
+
.sort({ startDate: factory.sortType.Descending })
|
|
782
|
+
.cursor();
|
|
783
|
+
}
|
|
779
784
|
aggregatePlaceOrder(params) {
|
|
780
785
|
return __awaiter(this, void 0, void 0, function* () {
|
|
781
786
|
const statuses = yield Promise.all([
|
|
@@ -24,8 +24,9 @@ const debug = createDebug('chevre-domain:service');
|
|
|
24
24
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
25
25
|
*/
|
|
26
26
|
function sendEmailMessage(params) {
|
|
27
|
+
// tslint:disable-next-line:max-func-body-length
|
|
27
28
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b;
|
|
29
|
+
var _a, _b, _c, _d, _e;
|
|
29
30
|
const project = yield repos.project.findById({
|
|
30
31
|
id: params.project.id,
|
|
31
32
|
inclusion: ['_id', 'settings'],
|
|
@@ -45,6 +46,15 @@ function sendEmailMessage(params) {
|
|
|
45
46
|
}
|
|
46
47
|
sgMail.setApiKey(apiKey);
|
|
47
48
|
const emailMessage = params.object;
|
|
49
|
+
const emailMessageFrom = {
|
|
50
|
+
name: emailMessage.sender.name,
|
|
51
|
+
email: emailMessage.sender.email
|
|
52
|
+
};
|
|
53
|
+
// プロジェクト設定対応(2023-08-21~)
|
|
54
|
+
const senderEmailByProjectSettings = (_d = (_c = (_b = project.settings) === null || _b === void 0 ? void 0 : _b.sendEmailMessage) === null || _c === void 0 ? void 0 : _c.sender) === null || _d === void 0 ? void 0 : _d.email;
|
|
55
|
+
if (typeof senderEmailByProjectSettings === 'string' && senderEmailByProjectSettings.length > 0) {
|
|
56
|
+
emailMessageFrom.email = senderEmailByProjectSettings;
|
|
57
|
+
}
|
|
48
58
|
let subject;
|
|
49
59
|
// 互換性維持対応として、String型に対応
|
|
50
60
|
if (typeof emailMessage.about === 'string') {
|
|
@@ -52,7 +62,7 @@ function sendEmailMessage(params) {
|
|
|
52
62
|
subject = String(emailMessage.about);
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
|
-
else if (typeof ((
|
|
65
|
+
else if (typeof ((_e = emailMessage.about) === null || _e === void 0 ? void 0 : _e.name) === 'string') {
|
|
56
66
|
if (emailMessage.about.name.length > 0) {
|
|
57
67
|
subject = emailMessage.about.name;
|
|
58
68
|
}
|
|
@@ -69,10 +79,7 @@ function sendEmailMessage(params) {
|
|
|
69
79
|
name: emailMessage.toRecipient.name,
|
|
70
80
|
email: emailMessage.toRecipient.email
|
|
71
81
|
}];
|
|
72
|
-
const msg = Object.assign(Object.assign(Object.assign({ to: emailDatas, from: {
|
|
73
|
-
name: emailMessage.sender.name,
|
|
74
|
-
email: emailMessage.sender.email
|
|
75
|
-
} }, (typeof subject === 'string') ? { subject } : undefined), (String(emailMessage.text).length > 0) ? { text: String(emailMessage.text) } : undefined), {
|
|
82
|
+
const msg = Object.assign(Object.assign(Object.assign({ to: emailDatas, from: emailMessageFrom }, (typeof subject === 'string') ? { subject } : undefined), (String(emailMessage.text).length > 0) ? { text: String(emailMessage.text) } : undefined), {
|
|
76
83
|
// html: '<strong>and easy to do anywhere, even with Node.js</strong>',
|
|
77
84
|
// categories: ['Transactional', 'My category'],
|
|
78
85
|
// 送信予定を追加することもできるが、タスクの実行予定日時でコントロールする想定
|
|
@@ -20,4 +20,24 @@ export declare function createConfirmReservationActionObject4COAByOrder(params:
|
|
|
20
20
|
export declare function createConfirmRegisterServiceActionObjectByOrder(params: {
|
|
21
21
|
order: factory.order.IOrder;
|
|
22
22
|
}): factory.action.interact.confirm.registerService.IObject[];
|
|
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
|
+
export declare function createOnPlaceOrderTasksByTransaction(params: {
|
|
28
|
+
object: factory.order.IOrder | IExternalOrder;
|
|
29
|
+
potentialActions?: factory.action.trade.order.IPotentialActions;
|
|
30
|
+
}): factory.task.IAttributes<factory.taskName>[];
|
|
31
|
+
/**
|
|
32
|
+
* 注文配送後のアクション
|
|
33
|
+
*/
|
|
34
|
+
export declare function createOnOrderSentTasksByTransaction(params: {
|
|
35
|
+
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)[];
|
|
37
|
+
/**
|
|
38
|
+
* 注文返品後のアクション
|
|
39
|
+
*/
|
|
40
|
+
export declare function createOnOrderReturnedTasksByTransaction(params: {
|
|
41
|
+
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)[];
|
|
23
43
|
export {};
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
var _a;
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
|
|
13
|
+
exports.createOnOrderReturnedTasksByTransaction = exports.createOnOrderSentTasksByTransaction = exports.createOnPlaceOrderTasksByTransaction = exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createInformTasks = exports.getOrderWithToken = void 0;
|
|
14
14
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
15
15
|
const jwt = require("jsonwebtoken");
|
|
16
16
|
const util_1 = require("util");
|
|
@@ -262,3 +262,244 @@ 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
|
+
function createOnPlaceOrderTasksByTransaction(params) {
|
|
331
|
+
const potentialActions = params.potentialActions;
|
|
332
|
+
const now = new Date();
|
|
333
|
+
// potentialActionsのためのタスクを生成
|
|
334
|
+
const taskAttributes = [];
|
|
335
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
336
|
+
/* istanbul ignore else */
|
|
337
|
+
if (potentialActions !== undefined) {
|
|
338
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
339
|
+
/* 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
|
+
}
|
|
361
|
+
// ポイント付与
|
|
362
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
363
|
+
/* istanbul ignore else */
|
|
364
|
+
if (Array.isArray(potentialActions.givePointAward)) {
|
|
365
|
+
taskAttributes.push(...potentialActions.givePointAward.map((a) => {
|
|
366
|
+
return {
|
|
367
|
+
project: a.project,
|
|
368
|
+
name: factory.taskName.GivePointAward,
|
|
369
|
+
status: factory.taskStatus.Ready,
|
|
370
|
+
runsAt: now,
|
|
371
|
+
remainingNumberOfTries: 10,
|
|
372
|
+
numberOfTried: 0,
|
|
373
|
+
executionResults: [],
|
|
374
|
+
data: a
|
|
375
|
+
};
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return taskAttributes;
|
|
380
|
+
}
|
|
381
|
+
exports.createOnPlaceOrderTasksByTransaction = createOnPlaceOrderTasksByTransaction;
|
|
382
|
+
/**
|
|
383
|
+
* 注文配送後のアクション
|
|
384
|
+
*/
|
|
385
|
+
function createOnOrderSentTasksByTransaction(params) {
|
|
386
|
+
const potentialActions = params.potentialActions;
|
|
387
|
+
const now = new Date();
|
|
388
|
+
const taskAttributes = [];
|
|
389
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
390
|
+
/* istanbul ignore else */
|
|
391
|
+
if (potentialActions !== undefined) {
|
|
392
|
+
if (Array.isArray(potentialActions.registerService)) {
|
|
393
|
+
taskAttributes.push(...potentialActions.registerService.map((a) => {
|
|
394
|
+
return {
|
|
395
|
+
project: a.project,
|
|
396
|
+
name: factory.taskName.ConfirmRegisterService,
|
|
397
|
+
status: factory.taskStatus.Ready,
|
|
398
|
+
runsAt: now,
|
|
399
|
+
remainingNumberOfTries: 10,
|
|
400
|
+
numberOfTried: 0,
|
|
401
|
+
executionResults: [],
|
|
402
|
+
data: a
|
|
403
|
+
};
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
406
|
+
// 通貨転送
|
|
407
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
408
|
+
/* istanbul ignore else */
|
|
409
|
+
if (Array.isArray(potentialActions.moneyTransfer)) {
|
|
410
|
+
taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
411
|
+
return {
|
|
412
|
+
project: a.project,
|
|
413
|
+
name: factory.taskName.ConfirmMoneyTransfer,
|
|
414
|
+
status: factory.taskStatus.Ready,
|
|
415
|
+
runsAt: now,
|
|
416
|
+
remainingNumberOfTries: 10,
|
|
417
|
+
numberOfTried: 0,
|
|
418
|
+
executionResults: [],
|
|
419
|
+
data: a
|
|
420
|
+
};
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
424
|
+
/* istanbul ignore else */
|
|
425
|
+
if (Array.isArray(potentialActions.sendEmailMessage)) {
|
|
426
|
+
potentialActions.sendEmailMessage.forEach((s) => {
|
|
427
|
+
const sendEmailMessageTask = {
|
|
428
|
+
project: s.project,
|
|
429
|
+
name: factory.taskName.SendEmailMessage,
|
|
430
|
+
status: factory.taskStatus.Ready,
|
|
431
|
+
runsAt: now,
|
|
432
|
+
remainingNumberOfTries: 3,
|
|
433
|
+
numberOfTried: 0,
|
|
434
|
+
executionResults: [],
|
|
435
|
+
data: {
|
|
436
|
+
actionAttributes: s
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return taskAttributes;
|
|
444
|
+
}
|
|
445
|
+
exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
|
|
446
|
+
/**
|
|
447
|
+
* 注文返品後のアクション
|
|
448
|
+
*/
|
|
449
|
+
function createOnOrderReturnedTasksByTransaction(params) {
|
|
450
|
+
const now = new Date();
|
|
451
|
+
const taskAttributes = [];
|
|
452
|
+
const potentialActions = params.potentialActions;
|
|
453
|
+
// 入金返却タスク
|
|
454
|
+
const returnMoneyTransferAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnMoneyTransfer;
|
|
455
|
+
if (Array.isArray(returnMoneyTransferAttributes)) {
|
|
456
|
+
taskAttributes.push(...returnMoneyTransferAttributes.map((a) => {
|
|
457
|
+
return {
|
|
458
|
+
project: a.project,
|
|
459
|
+
name: factory.taskName.ReturnMoneyTransfer,
|
|
460
|
+
status: factory.taskStatus.Ready,
|
|
461
|
+
runsAt: now,
|
|
462
|
+
remainingNumberOfTries: 10,
|
|
463
|
+
numberOfTried: 0,
|
|
464
|
+
executionResults: [],
|
|
465
|
+
data: a
|
|
466
|
+
};
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
// ポイント特典返却タスク
|
|
470
|
+
const returnPointAwardAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnPointAward;
|
|
471
|
+
if (Array.isArray(returnPointAwardAttributes)) {
|
|
472
|
+
taskAttributes.push(...returnPointAwardAttributes.map((a) => {
|
|
473
|
+
return {
|
|
474
|
+
project: a.project,
|
|
475
|
+
name: factory.taskName.ReturnPointAward,
|
|
476
|
+
status: factory.taskStatus.Ready,
|
|
477
|
+
runsAt: now,
|
|
478
|
+
remainingNumberOfTries: 10,
|
|
479
|
+
numberOfTried: 0,
|
|
480
|
+
executionResults: [],
|
|
481
|
+
data: a
|
|
482
|
+
};
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
const sendEmailMessageAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.sendEmailMessage;
|
|
486
|
+
if (Array.isArray(sendEmailMessageAttributes)) {
|
|
487
|
+
sendEmailMessageAttributes.forEach((s) => {
|
|
488
|
+
const sendEmailMessageTask = {
|
|
489
|
+
project: s.project,
|
|
490
|
+
name: factory.taskName.SendEmailMessage,
|
|
491
|
+
status: factory.taskStatus.Ready,
|
|
492
|
+
runsAt: now,
|
|
493
|
+
remainingNumberOfTries: 3,
|
|
494
|
+
numberOfTried: 0,
|
|
495
|
+
executionResults: [],
|
|
496
|
+
data: {
|
|
497
|
+
actionAttributes: s
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
return taskAttributes;
|
|
504
|
+
}
|
|
505
|
+
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
|
|
2
2
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
3
3
|
import * as factory from '../../factory';
|
|
4
|
+
import { IExternalOrder } from './onOrderStatusChanged/factory';
|
|
4
5
|
type IPlaceOrderTransaction = factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
5
6
|
type IReturnOrderTransaction = factory.transaction.ITransaction<factory.transactionType.ReturnOrder>;
|
|
6
7
|
export declare function onOrderStatusChanged(params: {
|
|
@@ -11,4 +12,4 @@ export declare function onOrderStatusChanged(params: {
|
|
|
11
12
|
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
12
13
|
task: TaskRepo;
|
|
13
14
|
}) => Promise<void>;
|
|
14
|
-
export {};
|
|
15
|
+
export { IExternalOrder };
|