@chevre/domain 21.7.0-alpha.13 → 21.7.0-alpha.15
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/createDeleteTransactionTasks.ts +9 -4
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +98 -0
- package/lib/chevre/repo/task.d.ts +4 -0
- package/lib/chevre/repo/task.js +24 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +6 -0
- 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/package.json +1 -1
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -65
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -105
|
@@ -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,98 @@
|
|
|
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 ONE_YEAR_IN_DAYS = 365;
|
|
8
|
+
type IDeletingTransaction = Pick<
|
|
9
|
+
chevre.factory.transaction.placeOrder.ITransaction,
|
|
10
|
+
'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const endDateLt: Date = moment(now)
|
|
18
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
.add(-ONE_YEAR_IN_DAYS, 'days')
|
|
20
|
+
.toDate();
|
|
21
|
+
|
|
22
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
23
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
24
|
+
|
|
25
|
+
const deletingTransactions = <IDeletingTransaction[]>await transactionRepo.search<chevre.factory.transactionType.PlaceOrder>(
|
|
26
|
+
{
|
|
27
|
+
limit: 100,
|
|
28
|
+
page: 1,
|
|
29
|
+
sort: { startDate: chevre.factory.sortType.Ascending },
|
|
30
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
31
|
+
statuses: [
|
|
32
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
33
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
34
|
+
chevre.factory.transactionStatusType.Expired
|
|
35
|
+
],
|
|
36
|
+
endThrough: endDateLt,
|
|
37
|
+
inclusion: ['_id', 'project', 'typeOf', 'startDate', 'endDate', 'object'],
|
|
38
|
+
exclusion: []
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let i = 0;
|
|
43
|
+
let updateCount = 0;
|
|
44
|
+
for (const deletingTransaction of deletingTransactions) {
|
|
45
|
+
i += 1;
|
|
46
|
+
const transaction: IDeletingTransaction = deletingTransaction;
|
|
47
|
+
console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
48
|
+
|
|
49
|
+
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
50
|
+
.isBefore(endDateLt);
|
|
51
|
+
if (isEndDateBefore) {
|
|
52
|
+
const runsAt: Date = moment(transaction.endDate)
|
|
53
|
+
.add(ONE_YEAR_IN_DAYS, 'days')
|
|
54
|
+
.toDate();
|
|
55
|
+
|
|
56
|
+
updateCount += 1;
|
|
57
|
+
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
58
|
+
project: transaction.project,
|
|
59
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
60
|
+
status: chevre.factory.taskStatus.Ready,
|
|
61
|
+
runsAt,
|
|
62
|
+
remainingNumberOfTries: 3,
|
|
63
|
+
numberOfTried: 0,
|
|
64
|
+
executionResults: [],
|
|
65
|
+
data: {
|
|
66
|
+
object: {
|
|
67
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
68
|
+
endDate: transaction.endDate,
|
|
69
|
+
id: transaction.id,
|
|
70
|
+
object: {
|
|
71
|
+
...(typeof transaction.object.confirmationNumber === 'string')
|
|
72
|
+
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
73
|
+
: undefined,
|
|
74
|
+
...(typeof transaction.object.orderNumber === 'string')
|
|
75
|
+
? { orderNumber: transaction.object.orderNumber }
|
|
76
|
+
: undefined
|
|
77
|
+
},
|
|
78
|
+
project: transaction.project,
|
|
79
|
+
startDate: transaction.startDate,
|
|
80
|
+
typeOf: transaction.typeOf
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
console.log(
|
|
85
|
+
'saving task...',
|
|
86
|
+
deleteTransactionTask.runsAt, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
87
|
+
await taskRepo.createDeleteTransactionTaskIfNotExist(deleteTransactionTask, { emitImmediately: false });
|
|
88
|
+
console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(i, 'transactions checked');
|
|
93
|
+
console.log(updateCount, 'transactions updated');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main()
|
|
97
|
+
.then()
|
|
98
|
+
.catch(console.error);
|
|
@@ -31,6 +31,10 @@ export declare class MongoRepository {
|
|
|
31
31
|
id: string;
|
|
32
32
|
}[]>;
|
|
33
33
|
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* 取引削除タスク冪等作成
|
|
36
|
+
*/
|
|
37
|
+
createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
34
38
|
executeById(params: {
|
|
35
39
|
id: string;
|
|
36
40
|
executor: {
|
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({
|
|
@@ -34,4 +34,10 @@ export declare function createOnPlaceOrderTasksByTransaction(params: {
|
|
|
34
34
|
export declare function createOnOrderSentTasksByTransaction(params: {
|
|
35
35
|
potentialActions?: factory.action.transfer.send.order.IPotentialActions;
|
|
36
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
|
-
}
|
package/package.json
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
import * as redis from 'redis';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
import { call } from '../../../../lib/chevre/service/task/orderProgramMembership';
|
|
8
|
-
|
|
9
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
-
socket: {
|
|
15
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
16
|
-
host: <string>process.env.REDIS_HOST
|
|
17
|
-
},
|
|
18
|
-
password: <string>process.env.REDIS_KEY
|
|
19
|
-
});
|
|
20
|
-
await redisClient.connect();
|
|
21
|
-
|
|
22
|
-
const result = await call(
|
|
23
|
-
{
|
|
24
|
-
agent: {
|
|
25
|
-
typeOf: chevre.factory.personType.Person,
|
|
26
|
-
id: 'b2bc2b6d-aea2-41fc-9f6e-e4ec89c11d2e',
|
|
27
|
-
identifier: [
|
|
28
|
-
{
|
|
29
|
-
name: 'iss',
|
|
30
|
-
value: String(process.env.ISS)
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
object: {
|
|
35
|
-
seller: {
|
|
36
|
-
id: '5d0abf30ac3fb200198ebb2c'
|
|
37
|
-
},
|
|
38
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
39
|
-
itemOffered: {
|
|
40
|
-
typeOf: chevre.factory.permit.PermitType.Permit,
|
|
41
|
-
name: '[development]会員ポイントプログラム',
|
|
42
|
-
issuedThrough: {
|
|
43
|
-
id: '5afff104d51e59232c7b481b',
|
|
44
|
-
typeOf: chevre.factory.product.ProductType.MembershipService
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
id: '7k9f3ht34',
|
|
48
|
-
identifier: 'AnnualPlan'
|
|
49
|
-
},
|
|
50
|
-
project: {
|
|
51
|
-
typeOf: chevre.factory.organizationType.Project,
|
|
52
|
-
id: project.id
|
|
53
|
-
},
|
|
54
|
-
typeOf: chevre.factory.actionType.OrderAction
|
|
55
|
-
}
|
|
56
|
-
)({
|
|
57
|
-
connection: mongoose.connection,
|
|
58
|
-
redisClient
|
|
59
|
-
});
|
|
60
|
-
console.log(result);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main()
|
|
64
|
-
.then(console.log)
|
|
65
|
-
.catch(console.error);
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
import * as redis from 'redis';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
import { orderProgramMembership } from '../../../../lib/chevre/service/transaction/orderProgramMembership';
|
|
8
|
-
|
|
9
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
-
socket: {
|
|
15
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
16
|
-
host: <string>process.env.REDIS_HOST
|
|
17
|
-
},
|
|
18
|
-
password: <string>process.env.REDIS_KEY
|
|
19
|
-
});
|
|
20
|
-
await redisClient.connect();
|
|
21
|
-
|
|
22
|
-
const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
|
|
23
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
24
|
-
const accountRepo = new chevre.repository.Account(mongoose.connection);
|
|
25
|
-
const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection);
|
|
26
|
-
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
27
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
28
|
-
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
29
|
-
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
30
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
31
|
-
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
32
|
-
const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
|
|
33
|
-
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
34
|
-
const serviceOutputRepo = new chevre.repository.ServiceOutput(mongoose.connection);
|
|
35
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
36
|
-
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
37
|
-
const confirmationNumberRepo = new chevre.repository.ConfirmationNumber(redisClient);
|
|
38
|
-
const orderNumberRepo = new chevre.repository.OrderNumber(redisClient);
|
|
39
|
-
const registerServiceInProgressRepo = new chevre.repository.action.RegisterServiceInProgress(redisClient);
|
|
40
|
-
const transactionNumberRepo = new chevre.repository.TransactionNumber(redisClient);
|
|
41
|
-
const serviceOutputIdentifierRepo = new chevre.repository.ServiceOutputIdentifier(redisClient);
|
|
42
|
-
|
|
43
|
-
const result = await orderProgramMembership(
|
|
44
|
-
{
|
|
45
|
-
agent: {
|
|
46
|
-
typeOf: chevre.factory.personType.Person,
|
|
47
|
-
id: 'b2bc2b6d-aea2-41fc-9f6e-e4ec89c11d2e',
|
|
48
|
-
identifier: [
|
|
49
|
-
{
|
|
50
|
-
name: 'iss',
|
|
51
|
-
value: String(process.env.ISS)
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
object: {
|
|
56
|
-
seller: {
|
|
57
|
-
id: '5d0abf30ac3fb200198ebb2c'
|
|
58
|
-
},
|
|
59
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
60
|
-
itemOffered: {
|
|
61
|
-
typeOf: chevre.factory.permit.PermitType.Permit,
|
|
62
|
-
name: '[development]会員ポイントプログラム',
|
|
63
|
-
issuedThrough: {
|
|
64
|
-
id: '5afff104d51e59232c7b481b',
|
|
65
|
-
typeOf: chevre.factory.product.ProductType.MembershipService
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
id: '7k9f3ht34',
|
|
69
|
-
identifier: 'AnnualPlan'
|
|
70
|
-
},
|
|
71
|
-
project: {
|
|
72
|
-
typeOf: chevre.factory.organizationType.Project,
|
|
73
|
-
id: project.id
|
|
74
|
-
},
|
|
75
|
-
typeOf: chevre.factory.actionType.OrderAction
|
|
76
|
-
},
|
|
77
|
-
'CreditCard'
|
|
78
|
-
)({
|
|
79
|
-
account: accountRepo,
|
|
80
|
-
accountingReport: accountingReportRepo,
|
|
81
|
-
action: actionRepo,
|
|
82
|
-
assetTransaction: assetTransactionRepo,
|
|
83
|
-
confirmationNumber: confirmationNumberRepo,
|
|
84
|
-
event: eventRepo,
|
|
85
|
-
offer: offerRepo,
|
|
86
|
-
offerCatalog: offerCatalogRepo,
|
|
87
|
-
orderNumber: orderNumberRepo,
|
|
88
|
-
ownershipInfo: ownershipInfoRepo,
|
|
89
|
-
person: personRepo,
|
|
90
|
-
product: productRepo,
|
|
91
|
-
project: projectRepo,
|
|
92
|
-
registerActionInProgress: registerServiceInProgressRepo,
|
|
93
|
-
seller: sellerRepo,
|
|
94
|
-
serviceOutput: serviceOutputRepo,
|
|
95
|
-
serviceOutputIdentifier: serviceOutputIdentifierRepo,
|
|
96
|
-
task: taskRepo,
|
|
97
|
-
transaction: transactionRepo,
|
|
98
|
-
transactionNumber: transactionNumberRepo
|
|
99
|
-
});
|
|
100
|
-
console.log(result);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
main()
|
|
104
|
-
.then(console.log)
|
|
105
|
-
.catch(console.error);
|