@chevre/domain 21.7.0-alpha.12 → 21.7.0-alpha.14
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 +9 -4
- 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/lib/chevre/repo/task.d.ts +2 -2
- package/lib/chevre/repo/task.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +7 -1
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +61 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +106 -105
- package/lib/chevre/service/order/returnOrder.js +7 -92
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +6 -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/settings.d.ts +0 -1
- package/lib/chevre/settings.js +1 -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
|
@@ -11,7 +11,7 @@ export async function main() {
|
|
|
11
11
|
const count = await taskRepo.countDelayedTasks({
|
|
12
12
|
delayInSeconds: 60,
|
|
13
13
|
name: {
|
|
14
|
-
$nin: [
|
|
14
|
+
$nin: [<any>'orderProgramMembership']
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
console.log('count:', count);
|
|
@@ -4,6 +4,8 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
6
|
|
|
7
|
+
const ONE_YEAR_IN_DAYS = 365;
|
|
8
|
+
|
|
7
9
|
// tslint:disable-next-line:max-func-body-length
|
|
8
10
|
async function main() {
|
|
9
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
@@ -11,9 +13,9 @@ async function main() {
|
|
|
11
13
|
const now = new Date();
|
|
12
14
|
const endDateLt: Date = moment(now)
|
|
13
15
|
// tslint:disable-next-line:no-magic-numbers
|
|
14
|
-
.add(-
|
|
16
|
+
.add(-ONE_YEAR_IN_DAYS, 'days')
|
|
15
17
|
.toDate();
|
|
16
|
-
const startDateLt: Date = moment('
|
|
18
|
+
const startDateLt: Date = moment('2022-01-01T00:00:00Z')
|
|
17
19
|
.toDate();
|
|
18
20
|
|
|
19
21
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
@@ -23,7 +25,6 @@ async function main() {
|
|
|
23
25
|
{
|
|
24
26
|
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
25
27
|
startDate: {
|
|
26
|
-
// $exists: true,
|
|
27
28
|
$lt: startDateLt
|
|
28
29
|
}
|
|
29
30
|
// endDate: {
|
|
@@ -58,12 +59,16 @@ async function main() {
|
|
|
58
59
|
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
59
60
|
.isBefore(endDateLt);
|
|
60
61
|
if (isEndDateBefore) {
|
|
62
|
+
const runsAt: Date = moment(transaction.endDate)
|
|
63
|
+
.add(ONE_YEAR_IN_DAYS, 'days')
|
|
64
|
+
.toDate();
|
|
65
|
+
|
|
61
66
|
updateCount += 1;
|
|
62
67
|
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
63
68
|
project: transaction.project,
|
|
64
69
|
name: chevre.factory.taskName.DeleteTransaction,
|
|
65
70
|
status: chevre.factory.taskStatus.Ready,
|
|
66
|
-
runsAt
|
|
71
|
+
runsAt,
|
|
67
72
|
remainingNumberOfTries: 3,
|
|
68
73
|
numberOfTried: 0,
|
|
69
74
|
executionResults: [],
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const TASK_STORAGE_PERIOD_IN_DAYS = 365;
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
const now = new Date();
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const result = await taskRepo.deleteRunsAtPassedCertainPeriod({
|
|
16
|
+
runsAt: {
|
|
17
|
+
$lt: moment(now)
|
|
18
|
+
.add(-TASK_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
19
|
+
.toDate()
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('deleted', result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then()
|
|
28
|
+
.catch(console.error);
|
|
@@ -12,7 +12,7 @@ async function main() {
|
|
|
12
12
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
const result = await taskRepo.deleteByName({
|
|
15
|
-
name:
|
|
15
|
+
name: <any>'orderProgramMembership',
|
|
16
16
|
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
17
17
|
// runsAt: {
|
|
18
18
|
// $gte: moment('2023-05-20T00:00:00Z')
|
|
@@ -46,7 +46,7 @@ async function main() {
|
|
|
46
46
|
'id' | 'project' | 'result' | 'typeOf' | 'startDate' | 'actionStatus'
|
|
47
47
|
> = doc.toObject();
|
|
48
48
|
|
|
49
|
-
const oldPaymentMethodType = action.result?.paymentMethod;
|
|
49
|
+
const oldPaymentMethodType = (<any>action).result?.paymentMethod;
|
|
50
50
|
const paymentMethodType = action.result?.paymentMethodAsObject?.typeOf;
|
|
51
51
|
const alreadyMigrated = typeof paymentMethodType === 'string' && oldPaymentMethodType === paymentMethodType;
|
|
52
52
|
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
|
-
import { ISS_PREFIX, USERPOOL_ID_NEW } from './checkOrderMembershipTasks';
|
|
7
6
|
import { migrateUser } from './migrateCognitoUser';
|
|
8
7
|
|
|
8
|
+
// export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
|
|
9
|
+
export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
10
|
+
export const ISS_PREFIX = 'https://cognito-idp.ap-northeast-1.amazonaws.com/';
|
|
11
|
+
|
|
9
12
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
13
|
const PRODUCT_TYPE = chevre.factory.product.ProductType.EventService;
|
|
11
14
|
|
|
@@ -63,7 +63,7 @@ export declare class MongoRepository {
|
|
|
63
63
|
*/
|
|
64
64
|
$nin?: factory.taskName[];
|
|
65
65
|
};
|
|
66
|
-
}): 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/
|
|
66
|
+
}): 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">[]>;
|
|
67
67
|
retry(params: {
|
|
68
68
|
intervalInMinutes: number;
|
|
69
69
|
}): Promise<void>;
|
|
@@ -108,7 +108,7 @@ export declare class MongoRepository {
|
|
|
108
108
|
runsAt: {
|
|
109
109
|
$lt: Date;
|
|
110
110
|
};
|
|
111
|
-
}): Promise<
|
|
111
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
112
112
|
countDelayedTasks(params: {
|
|
113
113
|
delayInSeconds: number;
|
|
114
114
|
name: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -427,7 +427,7 @@ class MongoRepository {
|
|
|
427
427
|
*/
|
|
428
428
|
deleteRunsAtPassedCertainPeriod(params) {
|
|
429
429
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
-
|
|
430
|
+
return this.taskModel.deleteMany({
|
|
431
431
|
runsAt: { $lt: params.runsAt.$lt },
|
|
432
432
|
status: { $in: [factory.taskStatus.Aborted, factory.taskStatus.Executed] }
|
|
433
433
|
})
|
|
@@ -33,5 +33,11 @@ export declare function createOnPlaceOrderTasksByTransaction(params: {
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function createOnOrderSentTasksByTransaction(params: {
|
|
35
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/
|
|
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)[];
|
|
37
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.createOnOrderSentTasksByTransaction = exports.createOnPlaceOrderTasksByTransaction = 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");
|
|
@@ -437,3 +437,63 @@ function createOnOrderSentTasksByTransaction(params) {
|
|
|
437
437
|
return taskAttributes;
|
|
438
438
|
}
|
|
439
439
|
exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
|
|
440
|
+
/**
|
|
441
|
+
* 注文返品後のアクション
|
|
442
|
+
*/
|
|
443
|
+
function createOnOrderReturnedTasksByTransaction(params) {
|
|
444
|
+
const now = new Date();
|
|
445
|
+
const taskAttributes = [];
|
|
446
|
+
const potentialActions = params.potentialActions;
|
|
447
|
+
// 入金返却タスク
|
|
448
|
+
const returnMoneyTransferAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnMoneyTransfer;
|
|
449
|
+
if (Array.isArray(returnMoneyTransferAttributes)) {
|
|
450
|
+
taskAttributes.push(...returnMoneyTransferAttributes.map((a) => {
|
|
451
|
+
return {
|
|
452
|
+
project: a.project,
|
|
453
|
+
name: factory.taskName.ReturnMoneyTransfer,
|
|
454
|
+
status: factory.taskStatus.Ready,
|
|
455
|
+
runsAt: now,
|
|
456
|
+
remainingNumberOfTries: 10,
|
|
457
|
+
numberOfTried: 0,
|
|
458
|
+
executionResults: [],
|
|
459
|
+
data: a
|
|
460
|
+
};
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
// ポイント特典返却タスク
|
|
464
|
+
const returnPointAwardAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.returnPointAward;
|
|
465
|
+
if (Array.isArray(returnPointAwardAttributes)) {
|
|
466
|
+
taskAttributes.push(...returnPointAwardAttributes.map((a) => {
|
|
467
|
+
return {
|
|
468
|
+
project: a.project,
|
|
469
|
+
name: factory.taskName.ReturnPointAward,
|
|
470
|
+
status: factory.taskStatus.Ready,
|
|
471
|
+
runsAt: now,
|
|
472
|
+
remainingNumberOfTries: 10,
|
|
473
|
+
numberOfTried: 0,
|
|
474
|
+
executionResults: [],
|
|
475
|
+
data: a
|
|
476
|
+
};
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
const sendEmailMessageAttributes = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.sendEmailMessage;
|
|
480
|
+
if (Array.isArray(sendEmailMessageAttributes)) {
|
|
481
|
+
sendEmailMessageAttributes.forEach((s) => {
|
|
482
|
+
const sendEmailMessageTask = {
|
|
483
|
+
project: s.project,
|
|
484
|
+
name: factory.taskName.SendEmailMessage,
|
|
485
|
+
status: factory.taskStatus.Ready,
|
|
486
|
+
runsAt: now,
|
|
487
|
+
remainingNumberOfTries: 3,
|
|
488
|
+
numberOfTried: 0,
|
|
489
|
+
executionResults: [],
|
|
490
|
+
data: {
|
|
491
|
+
actionAttributes: s
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return taskAttributes;
|
|
498
|
+
}
|
|
499
|
+
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
@@ -23,7 +23,7 @@ const USE_CONFIRM_REGISTER_SERVICE_TRANSACTION = process.env.USE_CONFIRM_REGISTE
|
|
|
23
23
|
const TOKEN_EXPIRES_IN = 604800;
|
|
24
24
|
function onOrderStatusChanged(params) {
|
|
25
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
27
27
|
let tasks = [];
|
|
28
28
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
29
29
|
const simpleOrder = {
|
|
@@ -93,11 +93,16 @@ function onOrderStatusChanged(params) {
|
|
|
93
93
|
];
|
|
94
94
|
break;
|
|
95
95
|
case factory.orderStatus.OrderReturned:
|
|
96
|
+
const potentialActionsByTransaction = (_m = (_l = (_k = (_j = params.returnOrderTransaction) === null || _j === void 0 ? void 0 : _j.potentialActions) === null || _k === void 0 ? void 0 : _k.returnOrder) === null || _l === void 0 ? void 0 : _l.find((returnOrderActionByTransaction) => {
|
|
97
|
+
return returnOrderActionByTransaction.object.orderNumber === params.order.orderNumber;
|
|
98
|
+
})) === null || _m === void 0 ? void 0 : _m.potentialActions;
|
|
96
99
|
tasks = [
|
|
97
100
|
...(0, factory_1.createInformTasks)(params.order),
|
|
98
|
-
...
|
|
101
|
+
...createReturnReserveTransactionTasks(params.order, simpleOrder),
|
|
99
102
|
// 決済取引返却タスクを作成(2022-06-09~)
|
|
100
|
-
...
|
|
103
|
+
...createReturnPayTransactionTasks(params.order, simpleOrder, params.returnOrderTransaction),
|
|
104
|
+
// 取引のpotentialActionsを適用(2023-08-19~)
|
|
105
|
+
...(0, factory_1.createOnOrderReturnedTasksByTransaction)({ potentialActions: potentialActionsByTransaction })
|
|
101
106
|
];
|
|
102
107
|
break;
|
|
103
108
|
default:
|
|
@@ -267,112 +272,108 @@ function createConfirmRegisterServiceTransactionTasks(order, simpleOrder) {
|
|
|
267
272
|
}
|
|
268
273
|
const RETURN_COA_TASK_DELAY_IN_SECONDS = 0;
|
|
269
274
|
function createReturnReserveTransactionTasks(order, simpleOrder) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
tasks.push({
|
|
334
|
-
project: order.project,
|
|
335
|
-
name: factory.taskName.ReturnReserveTransaction,
|
|
336
|
-
status: factory.taskStatus.Ready,
|
|
337
|
-
runsAt: (returnReserveTransactionAction.object.typeOf === 'COAReserveTransaction')
|
|
338
|
-
? taskRunsAt4coa
|
|
339
|
-
: taskRunsAt,
|
|
340
|
-
remainingNumberOfTries: 10,
|
|
341
|
-
numberOfTried: 0,
|
|
342
|
-
executionResults: [],
|
|
343
|
-
data: returnReserveTransactionAction
|
|
344
|
-
});
|
|
345
|
-
reservationNumbers.push(reservationNumber);
|
|
275
|
+
var _a, _b;
|
|
276
|
+
const taskRunsAt = moment(order.dateReturned)
|
|
277
|
+
.toDate();
|
|
278
|
+
const taskRunsAt4coa = moment(order.dateReturned)
|
|
279
|
+
.add(RETURN_COA_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
280
|
+
.toDate();
|
|
281
|
+
const tasks = [];
|
|
282
|
+
const returnActionRecipient = {
|
|
283
|
+
typeOf: order.seller.typeOf,
|
|
284
|
+
id: order.seller.id,
|
|
285
|
+
name: order.seller.name
|
|
286
|
+
};
|
|
287
|
+
const reservationNumbers = [];
|
|
288
|
+
// 注文アイテムから返却アクションを作成する
|
|
289
|
+
const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
290
|
+
for (const acceptedOffer of acceptedOffers) {
|
|
291
|
+
if (acceptedOffer.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
292
|
+
|| acceptedOffer.itemOffered.typeOf === factory.reservationType.BusReservation) {
|
|
293
|
+
const reservation = acceptedOffer.itemOffered;
|
|
294
|
+
const reservationNumber = reservation.reservationNumber;
|
|
295
|
+
// 予約番号ごとに返却アクションを作成する
|
|
296
|
+
if (!reservationNumbers.includes(reservationNumber)) {
|
|
297
|
+
let returnReserveTransactionAction;
|
|
298
|
+
switch ((_a = acceptedOffer.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) {
|
|
299
|
+
case factory.service.webAPI.Identifier.COA:
|
|
300
|
+
const superEventLocationBranchCode = (_b = reservation.reservationFor) === null || _b === void 0 ? void 0 : _b.superEvent.location.branchCode;
|
|
301
|
+
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
|
302
|
+
const phoneNumber = phoneUtil.parse(order.customer.telephone, 'JP');
|
|
303
|
+
let telNum = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.NATIONAL);
|
|
304
|
+
// COAでは数字のみ受け付けるので数字以外を除去
|
|
305
|
+
telNum = telNum.replace(/[^\d]/g, '');
|
|
306
|
+
returnReserveTransactionAction = {
|
|
307
|
+
project: order.project,
|
|
308
|
+
typeOf: factory.actionType.ReturnAction,
|
|
309
|
+
object: {
|
|
310
|
+
theaterCode: superEventLocationBranchCode,
|
|
311
|
+
reserveNum: reservationNumber,
|
|
312
|
+
telNum: telNum,
|
|
313
|
+
typeOf: 'COAReserveTransaction'
|
|
314
|
+
},
|
|
315
|
+
agent: order.project,
|
|
316
|
+
// potentialActions: {},
|
|
317
|
+
purpose: simpleOrder,
|
|
318
|
+
instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.COA },
|
|
319
|
+
recipient: returnActionRecipient
|
|
320
|
+
};
|
|
321
|
+
break;
|
|
322
|
+
default:
|
|
323
|
+
returnReserveTransactionAction = {
|
|
324
|
+
project: order.project,
|
|
325
|
+
typeOf: factory.actionType.ReturnAction,
|
|
326
|
+
object: {
|
|
327
|
+
typeOf: factory.assetTransactionType.Reserve,
|
|
328
|
+
transactionNumber: reservationNumber
|
|
329
|
+
},
|
|
330
|
+
agent: order.project,
|
|
331
|
+
// potentialActions: {},
|
|
332
|
+
purpose: simpleOrder,
|
|
333
|
+
instrument: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre },
|
|
334
|
+
recipient: returnActionRecipient
|
|
335
|
+
};
|
|
346
336
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
|
|
353
|
-
function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
|
|
354
|
-
return (__1) => __awaiter(this, void 0, void 0, function* () {
|
|
355
|
-
var _a, _b;
|
|
356
|
-
const taskRunsAt = moment(order.dateReturned)
|
|
357
|
-
.add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
358
|
-
.toDate();
|
|
359
|
-
const tasks = [];
|
|
360
|
-
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;
|
|
361
|
-
const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions === null || returnOrderPotentialActions === void 0 ? void 0 : returnOrderPotentialActions.returnPaymentMethod;
|
|
362
|
-
if (Array.isArray(returnPayActionsByReturnOrderTransaction)) {
|
|
363
|
-
tasks.push(...returnPayActionsByReturnOrderTransaction.map((a) => {
|
|
364
|
-
return {
|
|
365
|
-
project: a.project,
|
|
366
|
-
name: factory.taskName.ReturnPayTransaction,
|
|
337
|
+
tasks.push({
|
|
338
|
+
project: order.project,
|
|
339
|
+
name: factory.taskName.ReturnReserveTransaction,
|
|
367
340
|
status: factory.taskStatus.Ready,
|
|
368
|
-
runsAt:
|
|
341
|
+
runsAt: (returnReserveTransactionAction.object.typeOf === 'COAReserveTransaction')
|
|
342
|
+
? taskRunsAt4coa
|
|
343
|
+
: taskRunsAt,
|
|
369
344
|
remainingNumberOfTries: 10,
|
|
370
345
|
numberOfTried: 0,
|
|
371
346
|
executionResults: [],
|
|
372
|
-
data:
|
|
373
|
-
};
|
|
374
|
-
|
|
347
|
+
data: returnReserveTransactionAction
|
|
348
|
+
});
|
|
349
|
+
reservationNumbers.push(reservationNumber);
|
|
350
|
+
}
|
|
375
351
|
}
|
|
376
|
-
|
|
377
|
-
|
|
352
|
+
}
|
|
353
|
+
return tasks;
|
|
354
|
+
}
|
|
355
|
+
const RETURN_PAY_TASK_DELAY_IN_SECONDS = 0;
|
|
356
|
+
function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
|
|
357
|
+
var _a, _b;
|
|
358
|
+
const taskRunsAt = moment(order.dateReturned)
|
|
359
|
+
.add(RETURN_PAY_TASK_DELAY_IN_SECONDS, 'seconds')
|
|
360
|
+
.toDate();
|
|
361
|
+
const tasks = [];
|
|
362
|
+
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;
|
|
363
|
+
const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions === null || returnOrderPotentialActions === void 0 ? void 0 : returnOrderPotentialActions.returnPaymentMethod;
|
|
364
|
+
if (Array.isArray(returnPayActionsByReturnOrderTransaction)) {
|
|
365
|
+
tasks.push(...returnPayActionsByReturnOrderTransaction.map((a) => {
|
|
366
|
+
return {
|
|
367
|
+
project: a.project,
|
|
368
|
+
name: factory.taskName.ReturnPayTransaction,
|
|
369
|
+
status: factory.taskStatus.Ready,
|
|
370
|
+
runsAt: taskRunsAt,
|
|
371
|
+
remainingNumberOfTries: 10,
|
|
372
|
+
numberOfTried: 0,
|
|
373
|
+
executionResults: [],
|
|
374
|
+
data: a
|
|
375
|
+
};
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
return tasks;
|
|
378
379
|
}
|
|
@@ -14,9 +14,12 @@ const order_1 = require("../../factory/order");
|
|
|
14
14
|
const factory_1 = require("../delivery/factory");
|
|
15
15
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
16
16
|
const factory = require("../../factory");
|
|
17
|
-
// tslint:disable-next-line:max-func-body-length
|
|
18
17
|
function returnOrder(params) {
|
|
18
|
+
// tslint:disable-next-line:max-func-body-length
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
21
|
+
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
22
|
+
}
|
|
20
23
|
const orderNumber = params.object.orderNumber;
|
|
21
24
|
const dateReturned = (params.object.dateReturned instanceof Date)
|
|
22
25
|
? params.object.dateReturned
|
|
@@ -88,14 +91,15 @@ function returnOrder(params) {
|
|
|
88
91
|
}
|
|
89
92
|
const result = returnedOwnershipInfos;
|
|
90
93
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
91
|
-
if (params.useOnOrderStatusChanged
|
|
94
|
+
if (params.useOnOrderStatusChanged) {
|
|
92
95
|
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({ order, returnOrderTransaction })({
|
|
93
96
|
registerActionInProgress: repos.registerServiceInProgress,
|
|
94
97
|
task: repos.task
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
// 潜在アクション
|
|
98
|
-
|
|
101
|
+
// onOrderStatusChangedへ移行(2023-08-19~)
|
|
102
|
+
// await onReturn(returnOrderActionAttributes)({ task: repos.task });
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
exports.returnOrder = returnOrder;
|
|
@@ -122,98 +126,9 @@ function processReturnOrder(order, dateReturned) {
|
|
|
122
126
|
return ownershipInfoByDB;
|
|
123
127
|
}
|
|
124
128
|
});
|
|
125
|
-
// const ownershipInfoReturned: IOwnershipInfo = await repos.ownershipInfo.ownershipInfoModel.findOneAndUpdate(
|
|
126
|
-
// {
|
|
127
|
-
// 'project.id': { $eq: order.project.id },
|
|
128
|
-
// identifier: String(ownershipInfo.identifier)
|
|
129
|
-
// },
|
|
130
|
-
// { ownedThrough: dateReturned },
|
|
131
|
-
// { new: true }
|
|
132
|
-
// )
|
|
133
|
-
// .select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
134
|
-
// .exec()
|
|
135
|
-
// .then((doc) => {
|
|
136
|
-
// // 存在しない場合はいったん保留
|
|
137
|
-
// if (doc === null) {
|
|
138
|
-
// return ownershipInfo;
|
|
139
|
-
// } else {
|
|
140
|
-
// return doc.toObject();
|
|
141
|
-
// }
|
|
142
|
-
// });
|
|
143
129
|
returnedOwnershipInfos.push(ownershipInfoReturned);
|
|
144
130
|
})));
|
|
145
131
|
}
|
|
146
132
|
return returnedOwnershipInfos;
|
|
147
133
|
});
|
|
148
134
|
}
|
|
149
|
-
/**
|
|
150
|
-
* 返品アクション後の処理
|
|
151
|
-
* 注文返品後に何をすべきかは返品アクションのpotentialActionsとして定義されているはずなので、それらをタスクとして登録します。
|
|
152
|
-
*/
|
|
153
|
-
function onReturn(returnActionAttributes) {
|
|
154
|
-
// tslint:disable-next-line:max-func-body-length
|
|
155
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const now = new Date();
|
|
157
|
-
const taskAttributes = [];
|
|
158
|
-
const potentialActions = returnActionAttributes.potentialActions;
|
|
159
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
160
|
-
/* istanbul ignore else */
|
|
161
|
-
if (potentialActions !== undefined) {
|
|
162
|
-
// 入金返却タスク
|
|
163
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
164
|
-
/* istanbul ignore else */
|
|
165
|
-
if (Array.isArray(potentialActions.returnMoneyTransfer)) {
|
|
166
|
-
taskAttributes.push(...potentialActions.returnMoneyTransfer.map((a) => {
|
|
167
|
-
return {
|
|
168
|
-
project: a.project,
|
|
169
|
-
name: factory.taskName.ReturnMoneyTransfer,
|
|
170
|
-
status: factory.taskStatus.Ready,
|
|
171
|
-
runsAt: now,
|
|
172
|
-
remainingNumberOfTries: 10,
|
|
173
|
-
numberOfTried: 0,
|
|
174
|
-
executionResults: [],
|
|
175
|
-
data: a
|
|
176
|
-
};
|
|
177
|
-
}));
|
|
178
|
-
}
|
|
179
|
-
// ポイントインセンティブ返却タスク
|
|
180
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
181
|
-
/* istanbul ignore else */
|
|
182
|
-
if (Array.isArray(potentialActions.returnPointAward)) {
|
|
183
|
-
taskAttributes.push(...potentialActions.returnPointAward.map((a) => {
|
|
184
|
-
return {
|
|
185
|
-
project: a.project,
|
|
186
|
-
name: factory.taskName.ReturnPointAward,
|
|
187
|
-
status: factory.taskStatus.Ready,
|
|
188
|
-
runsAt: now,
|
|
189
|
-
remainingNumberOfTries: 10,
|
|
190
|
-
numberOfTried: 0,
|
|
191
|
-
executionResults: [],
|
|
192
|
-
data: a
|
|
193
|
-
};
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
197
|
-
/* istanbul ignore else */
|
|
198
|
-
if (Array.isArray(potentialActions.sendEmailMessage)) {
|
|
199
|
-
potentialActions.sendEmailMessage.forEach((s) => {
|
|
200
|
-
const sendEmailMessageTask = {
|
|
201
|
-
project: s.project,
|
|
202
|
-
name: factory.taskName.SendEmailMessage,
|
|
203
|
-
status: factory.taskStatus.Ready,
|
|
204
|
-
runsAt: now,
|
|
205
|
-
remainingNumberOfTries: 3,
|
|
206
|
-
numberOfTried: 0,
|
|
207
|
-
executionResults: [],
|
|
208
|
-
data: {
|
|
209
|
-
actionAttributes: s
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
taskAttributes.push(sendEmailMessageTask);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// タスク保管
|
|
217
|
-
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
218
|
-
});
|
|
219
|
-
}
|
|
@@ -12,6 +12,6 @@ export declare function confirmRegisterServiceTransaction(params: factory.action
|
|
|
12
12
|
assetTransaction: AssetTransactionRepo;
|
|
13
13
|
task: TaskRepo;
|
|
14
14
|
}) => Promise<void>;
|
|
15
|
-
export declare function onRegistered(
|
|
15
|
+
export declare function onRegistered(__: factory.action.interact.confirm.registerService.IAttributes): (repos: {
|
|
16
16
|
task: TaskRepo;
|
|
17
17
|
}) => Promise<void>;
|