@chevre/domain 21.7.0-alpha.11 → 21.7.0-alpha.13
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 +103 -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 -3
- package/lib/chevre/repo/task.d.ts +2 -2
- package/lib/chevre/repo/task.js +1 -1
- package/lib/chevre/repo/transaction.d.ts +25 -0
- package/lib/chevre/repo/transaction.js +5 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +14 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +176 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged.js +10 -114
- package/lib/chevre/service/order/placeOrder.d.ts +0 -1
- package/lib/chevre/service/order/placeOrder.js +3 -3
- package/lib/chevre/service/order/sendOrder.d.ts +0 -1
- package/lib/chevre/service/order/sendOrder.js +6 -68
- 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/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);
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const endDateLt: Date = moment(now)
|
|
13
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
14
|
+
.add(-365, 'days')
|
|
15
|
+
.toDate();
|
|
16
|
+
const startDateLt: Date = moment('2021-09-01T00:00:00Z')
|
|
17
|
+
.toDate();
|
|
18
|
+
|
|
19
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
20
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
21
|
+
|
|
22
|
+
const cursor = transactionRepo.getCursor(
|
|
23
|
+
{
|
|
24
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
25
|
+
startDate: {
|
|
26
|
+
// $exists: true,
|
|
27
|
+
$lt: startDateLt
|
|
28
|
+
}
|
|
29
|
+
// endDate: {
|
|
30
|
+
// $exists: true,
|
|
31
|
+
// $lt: moment(now)
|
|
32
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
33
|
+
// .add(-365, 'days')
|
|
34
|
+
// .toDate()
|
|
35
|
+
// }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
_id: 1,
|
|
39
|
+
typeOf: 1,
|
|
40
|
+
project: 1,
|
|
41
|
+
startDate: 1,
|
|
42
|
+
endDate: 1,
|
|
43
|
+
object: 1
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
console.log('transactions found');
|
|
47
|
+
|
|
48
|
+
let i = 0;
|
|
49
|
+
let updateCount = 0;
|
|
50
|
+
await cursor.eachAsync(async (doc) => {
|
|
51
|
+
i += 1;
|
|
52
|
+
const transaction: Pick<
|
|
53
|
+
chevre.factory.transaction.placeOrder.ITransaction,
|
|
54
|
+
'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
|
|
55
|
+
> = doc.toObject();
|
|
56
|
+
console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
57
|
+
|
|
58
|
+
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
59
|
+
.isBefore(endDateLt);
|
|
60
|
+
if (isEndDateBefore) {
|
|
61
|
+
updateCount += 1;
|
|
62
|
+
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
63
|
+
project: transaction.project,
|
|
64
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
65
|
+
status: chevre.factory.taskStatus.Ready,
|
|
66
|
+
runsAt: now,
|
|
67
|
+
remainingNumberOfTries: 3,
|
|
68
|
+
numberOfTried: 0,
|
|
69
|
+
executionResults: [],
|
|
70
|
+
data: {
|
|
71
|
+
object: {
|
|
72
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
73
|
+
endDate: transaction.endDate,
|
|
74
|
+
id: transaction.id,
|
|
75
|
+
object: {
|
|
76
|
+
...(typeof transaction.object.confirmationNumber === 'string')
|
|
77
|
+
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
78
|
+
: undefined,
|
|
79
|
+
...(typeof transaction.object.orderNumber === 'string')
|
|
80
|
+
? { orderNumber: transaction.object.orderNumber }
|
|
81
|
+
: undefined
|
|
82
|
+
},
|
|
83
|
+
project: transaction.project,
|
|
84
|
+
startDate: transaction.startDate,
|
|
85
|
+
typeOf: transaction.typeOf
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
console.log(
|
|
90
|
+
'saving task...',
|
|
91
|
+
deleteTransactionTask, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
92
|
+
await taskRepo.saveMany([deleteTransactionTask], { emitImmediately: false });
|
|
93
|
+
console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log(i, 'transactions checked');
|
|
98
|
+
console.log(updateCount, 'transactions updated');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main()
|
|
102
|
+
.then()
|
|
103
|
+
.catch(console.error);
|
|
@@ -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
|
|
|
@@ -18,10 +18,8 @@ async function main() {
|
|
|
18
18
|
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
19
19
|
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
20
20
|
startDate: {
|
|
21
|
-
$lte: moment('2023-
|
|
21
|
+
$lte: moment('2023-08-16T07:26:00Z')
|
|
22
22
|
.toDate()
|
|
23
|
-
// $lte: moment('2023-08-16T07:26:00Z')
|
|
24
|
-
// .toDate()
|
|
25
23
|
},
|
|
26
24
|
'object.authorizeActions': { $exists: true }
|
|
27
25
|
},
|
|
@@ -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
|
})
|
|
@@ -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 {
|
|
@@ -193,6 +217,7 @@ export declare class MongoRepository {
|
|
|
193
217
|
filter: any;
|
|
194
218
|
$unset: any;
|
|
195
219
|
}): Promise<import("mongodb").UpdateResult>;
|
|
220
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
196
221
|
aggregatePlaceOrder(params: {
|
|
197
222
|
project?: {
|
|
198
223
|
id?: {
|
|
@@ -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([
|
|
@@ -20,4 +20,18 @@ 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)[];
|
|
23
37
|
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.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,178 @@ 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 sendOrderTask = {
|
|
342
|
+
project: potentialActions.sendOrder.project,
|
|
343
|
+
name: factory.taskName.SendOrder,
|
|
344
|
+
status: factory.taskStatus.Ready,
|
|
345
|
+
runsAt: now,
|
|
346
|
+
remainingNumberOfTries: 10,
|
|
347
|
+
numberOfTried: 0,
|
|
348
|
+
executionResults: [],
|
|
349
|
+
data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
|
|
350
|
+
? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
351
|
+
: undefined)
|
|
352
|
+
};
|
|
353
|
+
taskAttributes.push(sendOrderTask);
|
|
354
|
+
}
|
|
355
|
+
// ポイント付与
|
|
356
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
357
|
+
/* istanbul ignore else */
|
|
358
|
+
if (Array.isArray(potentialActions.givePointAward)) {
|
|
359
|
+
taskAttributes.push(...potentialActions.givePointAward.map((a) => {
|
|
360
|
+
return {
|
|
361
|
+
project: a.project,
|
|
362
|
+
name: factory.taskName.GivePointAward,
|
|
363
|
+
status: factory.taskStatus.Ready,
|
|
364
|
+
runsAt: now,
|
|
365
|
+
remainingNumberOfTries: 10,
|
|
366
|
+
numberOfTried: 0,
|
|
367
|
+
executionResults: [],
|
|
368
|
+
data: a
|
|
369
|
+
};
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return taskAttributes;
|
|
374
|
+
}
|
|
375
|
+
exports.createOnPlaceOrderTasksByTransaction = createOnPlaceOrderTasksByTransaction;
|
|
376
|
+
/**
|
|
377
|
+
* 注文配送後のアクション
|
|
378
|
+
*/
|
|
379
|
+
function createOnOrderSentTasksByTransaction(params) {
|
|
380
|
+
const potentialActions = params.potentialActions;
|
|
381
|
+
const now = new Date();
|
|
382
|
+
const taskAttributes = [];
|
|
383
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
384
|
+
/* istanbul ignore else */
|
|
385
|
+
if (potentialActions !== undefined) {
|
|
386
|
+
if (Array.isArray(potentialActions.registerService)) {
|
|
387
|
+
taskAttributes.push(...potentialActions.registerService.map((a) => {
|
|
388
|
+
return {
|
|
389
|
+
project: a.project,
|
|
390
|
+
name: factory.taskName.ConfirmRegisterService,
|
|
391
|
+
status: factory.taskStatus.Ready,
|
|
392
|
+
runsAt: now,
|
|
393
|
+
remainingNumberOfTries: 10,
|
|
394
|
+
numberOfTried: 0,
|
|
395
|
+
executionResults: [],
|
|
396
|
+
data: a
|
|
397
|
+
};
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
// 通貨転送
|
|
401
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
402
|
+
/* istanbul ignore else */
|
|
403
|
+
if (Array.isArray(potentialActions.moneyTransfer)) {
|
|
404
|
+
taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
405
|
+
return {
|
|
406
|
+
project: a.project,
|
|
407
|
+
name: factory.taskName.ConfirmMoneyTransfer,
|
|
408
|
+
status: factory.taskStatus.Ready,
|
|
409
|
+
runsAt: now,
|
|
410
|
+
remainingNumberOfTries: 10,
|
|
411
|
+
numberOfTried: 0,
|
|
412
|
+
executionResults: [],
|
|
413
|
+
data: a
|
|
414
|
+
};
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
418
|
+
/* istanbul ignore else */
|
|
419
|
+
if (Array.isArray(potentialActions.sendEmailMessage)) {
|
|
420
|
+
potentialActions.sendEmailMessage.forEach((s) => {
|
|
421
|
+
const sendEmailMessageTask = {
|
|
422
|
+
project: s.project,
|
|
423
|
+
name: factory.taskName.SendEmailMessage,
|
|
424
|
+
status: factory.taskStatus.Ready,
|
|
425
|
+
runsAt: now,
|
|
426
|
+
remainingNumberOfTries: 3,
|
|
427
|
+
numberOfTried: 0,
|
|
428
|
+
executionResults: [],
|
|
429
|
+
data: {
|
|
430
|
+
actionAttributes: s
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
taskAttributes.push(sendEmailMessageTask);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return taskAttributes;
|
|
438
|
+
}
|
|
439
|
+
exports.createOnOrderSentTasksByTransaction = createOnOrderSentTasksByTransaction;
|
|
@@ -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,5 +12,4 @@ export declare function onOrderStatusChanged(params: {
|
|
|
11
12
|
registerActionInProgress: RegisterServiceInProgressRepo;
|
|
12
13
|
task: TaskRepo;
|
|
13
14
|
}) => Promise<void>;
|
|
14
|
-
export
|
|
15
|
-
export {};
|
|
15
|
+
export { IExternalOrder };
|
|
@@ -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;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
27
27
|
let tasks = [];
|
|
28
28
|
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
29
29
|
const simpleOrder = {
|
|
@@ -41,7 +41,13 @@ function onOrderStatusChanged(params) {
|
|
|
41
41
|
};
|
|
42
42
|
switch (params.order.orderStatus) {
|
|
43
43
|
case factory.orderStatus.OrderDelivered:
|
|
44
|
-
tasks =
|
|
44
|
+
tasks = [
|
|
45
|
+
...(0, factory_1.createInformTasks)(params.order),
|
|
46
|
+
// 取引のpotentialActionsを適用(2023-08-17~)
|
|
47
|
+
...(0, factory_1.createOnOrderSentTasksByTransaction)({
|
|
48
|
+
potentialActions: (_e = (_d = (_c = (_b = (_a = params.placeOrderTransaction) === null || _a === void 0 ? void 0 : _a.potentialActions) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.potentialActions) === null || _d === void 0 ? void 0 : _d.sendOrder) === null || _e === void 0 ? void 0 : _e.potentialActions
|
|
49
|
+
})
|
|
50
|
+
];
|
|
45
51
|
// プロダクト登録プロセスロック解除
|
|
46
52
|
try {
|
|
47
53
|
const placeOrderTransaction = params.placeOrderTransaction;
|
|
@@ -79,10 +85,10 @@ function onOrderStatusChanged(params) {
|
|
|
79
85
|
...yield createConfirmReserveTransactionTasks(params.order, simpleOrder)(repos),
|
|
80
86
|
...yield createConfirmRegisterServiceTransactionTasks(params.order, simpleOrder)(repos),
|
|
81
87
|
// 取引のpotentialActionsを適用(2023-08-17~)
|
|
82
|
-
...createOnPlaceOrderTasksByTransaction({
|
|
88
|
+
...(0, factory_1.createOnPlaceOrderTasksByTransaction)({
|
|
83
89
|
object: params.order,
|
|
84
90
|
// potentialActions: params.potentialActions
|
|
85
|
-
potentialActions: (
|
|
91
|
+
potentialActions: (_h = (_g = (_f = params.placeOrderTransaction) === null || _f === void 0 ? void 0 : _f.potentialActions) === null || _g === void 0 ? void 0 : _g.order) === null || _h === void 0 ? void 0 : _h.potentialActions
|
|
86
92
|
})
|
|
87
93
|
];
|
|
88
94
|
break;
|
|
@@ -370,113 +376,3 @@ function createReturnPayTransactionTasks(order, __, returnOrderTransaction) {
|
|
|
370
376
|
return tasks;
|
|
371
377
|
});
|
|
372
378
|
}
|
|
373
|
-
/**
|
|
374
|
-
* 注文作成後のアクション
|
|
375
|
-
*/
|
|
376
|
-
// export function onPlaceOrder(params: {
|
|
377
|
-
// object: factory.order.IOrder | IExternalOrder;
|
|
378
|
-
// potentialActions?: factory.action.trade.order.IPotentialActions;
|
|
379
|
-
// }) {
|
|
380
|
-
// return async (repos: {
|
|
381
|
-
// task: TaskRepo;
|
|
382
|
-
// }) => {
|
|
383
|
-
// const potentialActions = params.potentialActions;
|
|
384
|
-
// const now = new Date();
|
|
385
|
-
// // potentialActionsのためのタスクを生成
|
|
386
|
-
// const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
|
|
387
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
388
|
-
// /* istanbul ignore else */
|
|
389
|
-
// if (potentialActions !== undefined) {
|
|
390
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
391
|
-
// /* istanbul ignore else */
|
|
392
|
-
// if (potentialActions.sendOrder !== undefined) {
|
|
393
|
-
// const sendOrderTask: factory.task.IAttributes<factory.taskName.SendOrder> = {
|
|
394
|
-
// project: potentialActions.sendOrder.project,
|
|
395
|
-
// name: factory.taskName.SendOrder,
|
|
396
|
-
// status: factory.taskStatus.Ready,
|
|
397
|
-
// runsAt: now, // なるはやで実行
|
|
398
|
-
// remainingNumberOfTries: 10,
|
|
399
|
-
// numberOfTried: 0,
|
|
400
|
-
// executionResults: [],
|
|
401
|
-
// // data: potentialActions.sendOrder
|
|
402
|
-
// data: {
|
|
403
|
-
// project: potentialActions.sendOrder.project,
|
|
404
|
-
// object: {
|
|
405
|
-
// ...potentialActions.sendOrder.object,
|
|
406
|
-
// confirmationNumber: params.object.confirmationNumber
|
|
407
|
-
// },
|
|
408
|
-
// ...(potentialActions.sendOrder.potentialActions !== undefined)
|
|
409
|
-
// ? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
410
|
-
// : undefined
|
|
411
|
-
// }
|
|
412
|
-
// };
|
|
413
|
-
// taskAttributes.push(sendOrderTask);
|
|
414
|
-
// }
|
|
415
|
-
// // ポイント付与
|
|
416
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
417
|
-
// /* istanbul ignore else */
|
|
418
|
-
// if (Array.isArray(potentialActions.givePointAward)) {
|
|
419
|
-
// taskAttributes.push(...potentialActions.givePointAward.map(
|
|
420
|
-
// (a): factory.task.IAttributes<factory.taskName.GivePointAward> => {
|
|
421
|
-
// return {
|
|
422
|
-
// project: a.project,
|
|
423
|
-
// name: factory.taskName.GivePointAward,
|
|
424
|
-
// status: factory.taskStatus.Ready,
|
|
425
|
-
// runsAt: now, // なるはやで実行
|
|
426
|
-
// remainingNumberOfTries: 10,
|
|
427
|
-
// numberOfTried: 0,
|
|
428
|
-
// executionResults: [],
|
|
429
|
-
// data: a
|
|
430
|
-
// };
|
|
431
|
-
// }));
|
|
432
|
-
// }
|
|
433
|
-
// }
|
|
434
|
-
// // タスク保管
|
|
435
|
-
// await repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
436
|
-
// };
|
|
437
|
-
// }
|
|
438
|
-
function createOnPlaceOrderTasksByTransaction(params) {
|
|
439
|
-
const potentialActions = params.potentialActions;
|
|
440
|
-
const now = new Date();
|
|
441
|
-
// potentialActionsのためのタスクを生成
|
|
442
|
-
const taskAttributes = [];
|
|
443
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
444
|
-
/* istanbul ignore else */
|
|
445
|
-
if (potentialActions !== undefined) {
|
|
446
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
447
|
-
/* istanbul ignore else */
|
|
448
|
-
if (potentialActions.sendOrder !== undefined) {
|
|
449
|
-
const sendOrderTask = {
|
|
450
|
-
project: potentialActions.sendOrder.project,
|
|
451
|
-
name: factory.taskName.SendOrder,
|
|
452
|
-
status: factory.taskStatus.Ready,
|
|
453
|
-
runsAt: now,
|
|
454
|
-
remainingNumberOfTries: 10,
|
|
455
|
-
numberOfTried: 0,
|
|
456
|
-
executionResults: [],
|
|
457
|
-
data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
|
|
458
|
-
? { potentialActions: potentialActions.sendOrder.potentialActions }
|
|
459
|
-
: undefined)
|
|
460
|
-
};
|
|
461
|
-
taskAttributes.push(sendOrderTask);
|
|
462
|
-
}
|
|
463
|
-
// ポイント付与
|
|
464
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
465
|
-
/* istanbul ignore else */
|
|
466
|
-
if (Array.isArray(potentialActions.givePointAward)) {
|
|
467
|
-
taskAttributes.push(...potentialActions.givePointAward.map((a) => {
|
|
468
|
-
return {
|
|
469
|
-
project: a.project,
|
|
470
|
-
name: factory.taskName.GivePointAward,
|
|
471
|
-
status: factory.taskStatus.Ready,
|
|
472
|
-
runsAt: now,
|
|
473
|
-
remainingNumberOfTries: 10,
|
|
474
|
-
numberOfTried: 0,
|
|
475
|
-
executionResults: [],
|
|
476
|
-
data: a
|
|
477
|
-
};
|
|
478
|
-
}));
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return taskAttributes;
|
|
482
|
-
}
|