@chevre/domain 21.13.0-alpha.7 → 21.13.0-alpha.8
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/lib/chevre/service/event.d.ts +1 -0
- package/lib/chevre/service/event.js +7 -3
- package/lib/chevre/settings.d.ts +0 -1
- package/lib/chevre/settings.js +1 -5
- package/package.json +2 -2
- package/example/src/chevre/assetTransaction/searchGMOTrade.ts +0 -27
- package/example/src/chevre/countDelayedTasks.ts +0 -22
- package/example/src/chevre/countDelayedTransactions.ts +0 -60
- package/example/src/chevre/countMoneyTransferTransaction.ts +0 -36
- package/example/src/chevre/countOffers.ts +0 -32
- package/example/src/chevre/createDeleteTransactionTasks.ts +0 -108
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +0 -98
- package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +0 -126
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -365
- package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +0 -31
- package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +0 -32
- package/example/src/chevre/offer/searchAllByIdsAndOfferCatalogId.ts +0 -34
- package/example/src/chevre/offer/searchEventTicketOffers.ts +0 -54
- package/example/src/chevre/offer/searchOffersByCatalog.ts +0 -40
- package/example/src/chevre/processPay.ts +0 -90
- package/example/src/chevre/processRegisterMembership.ts +0 -110
- package/example/src/chevre/processRegisterPaymentCard.ts +0 -98
- package/example/src/chevre/processReserve.ts +0 -114
- package/example/src/chevre/publishConfirmationNumber.ts +0 -27
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +0 -56
- package/example/src/chevre/reIndex.ts +0 -25
- package/example/src/chevre/redisConfig.ts +0 -32
- package/example/src/chevre/saveTasks.ts +0 -41
- package/example/src/chevre/searchAbortedTasks.ts +0 -34
- package/example/src/chevre/searchAcceptedOfferIds.ts +0 -23
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +0 -168
- package/example/src/chevre/searchOrdersWithUnwoundOffers.ts +0 -35
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +0 -58
- package/example/src/chevre/task/executeTasks.ts +0 -26
- package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +0 -41
- package/example/src/chevre/updateOfferCatalogs.ts +0 -40
- package/example/src/chevre/updateTransaction.ts +0 -38
- package/example/src/playOnMoment.ts +0 -24
|
@@ -24,7 +24,6 @@ const factory = require("../factory");
|
|
|
24
24
|
const createEvent_1 = require("./event/createEvent");
|
|
25
25
|
Object.defineProperty(exports, "createEvent", { enumerable: true, get: function () { return createEvent_1.createEvent; } });
|
|
26
26
|
const offer_1 = require("./offer");
|
|
27
|
-
const settings_1 = require("../settings");
|
|
28
27
|
const debug = createDebug('chevre-domain:service:event');
|
|
29
28
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
30
29
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
@@ -139,6 +138,7 @@ function importFromCOA(params) {
|
|
|
139
138
|
movieTheater,
|
|
140
139
|
project: project,
|
|
141
140
|
saveScreeningEventSeries: params.saveScreeningEventSeries,
|
|
141
|
+
saveScreeningEventSeriesPeriodInMonth: params.saveScreeningEventSeriesPeriodInMonth,
|
|
142
142
|
seller: { id: seller.id }
|
|
143
143
|
})(repos);
|
|
144
144
|
savedScreeningEventSeriesCount = savedEventsCount;
|
|
@@ -199,6 +199,7 @@ function importFromCOA(params) {
|
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
exports.importFromCOA = importFromCOA;
|
|
202
|
+
// tslint:disable-next-line:max-func-body-length
|
|
202
203
|
function saveScreeningEventSeries(params) {
|
|
203
204
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
204
205
|
const project = params.project;
|
|
@@ -245,13 +246,16 @@ function saveScreeningEventSeries(params) {
|
|
|
245
246
|
seller: params.seller
|
|
246
247
|
});
|
|
247
248
|
});
|
|
249
|
+
const COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH = (typeof params.saveScreeningEventSeriesPeriodInMonth === 'number')
|
|
250
|
+
? params.saveScreeningEventSeriesPeriodInMonth
|
|
251
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
252
|
+
: 3;
|
|
248
253
|
let savedEventsCount = 0;
|
|
249
254
|
// saveScreeningEventSeries:trueの場合のみ保管(2022-10-10~)
|
|
250
255
|
if (params.saveScreeningEventSeries === true) {
|
|
251
256
|
// 更新対象が無限に増えるのを防ぐためにstartDateでフィルター
|
|
252
257
|
const someMonthsAgo = moment()
|
|
253
|
-
|
|
254
|
-
.add(-settings_1.COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH, 'months'); // to settings(2023-10-18~)
|
|
258
|
+
.add(-COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH, 'months');
|
|
255
259
|
const saveParams = screeningEventSerieses
|
|
256
260
|
.filter((screeningEventSeries) => {
|
|
257
261
|
return moment(screeningEventSeries.startDate)
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -45,7 +45,6 @@ export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
|
|
|
45
45
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
46
46
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
47
47
|
export declare const MONGO_AUTO_INDEX: boolean;
|
|
48
|
-
export declare const COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH: number;
|
|
49
48
|
/**
|
|
50
49
|
* グローバル設定
|
|
51
50
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.
|
|
3
|
+
exports.settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -76,10 +76,6 @@ exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 's
|
|
|
76
76
|
? process.env.MONGO_READ_PREFERENCE
|
|
77
77
|
: 'primaryPreferred';
|
|
78
78
|
exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
|
|
79
|
-
exports.COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH = (typeof process.env.COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH === 'string')
|
|
80
|
-
? Number(process.env.COA_IMPORT_SCREENING_EVENT_SERIES_PERIOD_IN_MONTH)
|
|
81
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
82
|
-
: 3;
|
|
83
79
|
/**
|
|
84
80
|
* グローバル設定
|
|
85
81
|
*/
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.335.0",
|
|
13
13
|
"@cinerino/sdk": "4.0.0-alpha.1",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "21.13.0-alpha.
|
|
118
|
+
"version": "21.13.0-alpha.8"
|
|
119
119
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
11
|
-
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
12
|
-
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const result = await chevre.service.assetTransaction.pay.searchGMOTrade({
|
|
15
|
-
transactionNumber: '020518441863622'
|
|
16
|
-
})({
|
|
17
|
-
product: productRepo,
|
|
18
|
-
seller: sellerRepo,
|
|
19
|
-
assetTransaction: assetTransactionRepo
|
|
20
|
-
});
|
|
21
|
-
console.log(result);
|
|
22
|
-
// return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
main()
|
|
26
|
-
.then(console.log)
|
|
27
|
-
.catch(console.error);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
export async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
-
|
|
9
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
10
|
-
|
|
11
|
-
const count = await taskRepo.countDelayedTasks({
|
|
12
|
-
delayInSeconds: 60,
|
|
13
|
-
name: {
|
|
14
|
-
$nin: [<any>'orderProgramMembership']
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
console.log('count:', count);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
main()
|
|
21
|
-
.then()
|
|
22
|
-
.catch(console.error);
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
export async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
8
|
-
|
|
9
|
-
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
10
|
-
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
for (const typeOf of [
|
|
13
|
-
chevre.factory.transactionType.PlaceOrder,
|
|
14
|
-
chevre.factory.transactionType.ReturnOrder,
|
|
15
|
-
chevre.factory.transactionType.MoneyTransfer
|
|
16
|
-
]) {
|
|
17
|
-
const count = await transactionRepo.count({
|
|
18
|
-
typeOf,
|
|
19
|
-
statuses: [
|
|
20
|
-
chevre.factory.transactionStatusType.Canceled,
|
|
21
|
-
chevre.factory.transactionStatusType.Confirmed,
|
|
22
|
-
chevre.factory.transactionStatusType.Expired
|
|
23
|
-
],
|
|
24
|
-
tasksExportationStatuses: [
|
|
25
|
-
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
26
|
-
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
27
|
-
],
|
|
28
|
-
endThrough: new Date()
|
|
29
|
-
});
|
|
30
|
-
console.log('count:', count, typeOf);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
for (const typeOf of [
|
|
34
|
-
chevre.factory.assetTransactionType.CancelReservation,
|
|
35
|
-
chevre.factory.assetTransactionType.MoneyTransfer,
|
|
36
|
-
chevre.factory.assetTransactionType.Pay,
|
|
37
|
-
chevre.factory.assetTransactionType.Refund,
|
|
38
|
-
chevre.factory.assetTransactionType.RegisterService,
|
|
39
|
-
chevre.factory.assetTransactionType.Reserve
|
|
40
|
-
]) {
|
|
41
|
-
const count = await assetTransactionRepo.count({
|
|
42
|
-
typeOf,
|
|
43
|
-
statuses: [
|
|
44
|
-
chevre.factory.transactionStatusType.Canceled,
|
|
45
|
-
chevre.factory.transactionStatusType.Confirmed,
|
|
46
|
-
chevre.factory.transactionStatusType.Expired
|
|
47
|
-
],
|
|
48
|
-
tasksExportationStatuses: [
|
|
49
|
-
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
50
|
-
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
51
|
-
],
|
|
52
|
-
endThrough: new Date()
|
|
53
|
-
});
|
|
54
|
-
console.log('count:', count, typeOf);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
main()
|
|
59
|
-
.then()
|
|
60
|
-
.catch(console.error);
|
|
@@ -1,36 +0,0 @@
|
|
|
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 project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
export async function main() {
|
|
11
|
-
const now = new Date();
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const transactions = await transactionRepo.search<chevre.factory.transactionType.MoneyTransfer>(
|
|
17
|
-
{
|
|
18
|
-
project: { id: { $eq: project.id } },
|
|
19
|
-
typeOf: chevre.factory.transactionType.MoneyTransfer,
|
|
20
|
-
statuses: [chevre.factory.transactionStatusType.Confirmed],
|
|
21
|
-
startFrom: moment(now)
|
|
22
|
-
.add(-1, 'year')
|
|
23
|
-
.toDate(),
|
|
24
|
-
startThrough: now,
|
|
25
|
-
inclusion: ['_id', 'startDate', 'typeOf', 'object'],
|
|
26
|
-
exclusion: []
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
const count = transactions.filter((t) => t.object.description === '受け取り')
|
|
30
|
-
.length;
|
|
31
|
-
console.log('transactions found', count);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
main()
|
|
35
|
-
.then()
|
|
36
|
-
.catch(console.error);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
// tslint:disable-next-line:max-func-body-length
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
const result = await offerRepo.count(
|
|
13
|
-
{
|
|
14
|
-
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
15
|
-
availability: { $eq: chevre.factory.itemAvailability.InStock },
|
|
16
|
-
id: {
|
|
17
|
-
// $eq: '1001'
|
|
18
|
-
// $in: string[];
|
|
19
|
-
},
|
|
20
|
-
identifier: {
|
|
21
|
-
// $eq: '1001'
|
|
22
|
-
// $in: string[];
|
|
23
|
-
// $regex: '003'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
console.log(result);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main()
|
|
31
|
-
.then(console.log)
|
|
32
|
-
.catch(console.error);
|
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const now = new Date();
|
|
14
|
-
const endDateLt: Date = moment(now)
|
|
15
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
16
|
-
.add(-ONE_YEAR_IN_DAYS, 'days')
|
|
17
|
-
.toDate();
|
|
18
|
-
const startDateLt: Date = moment('2022-01-01T00:00:00Z')
|
|
19
|
-
.toDate();
|
|
20
|
-
|
|
21
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
22
|
-
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
23
|
-
|
|
24
|
-
const cursor = transactionRepo.getCursor(
|
|
25
|
-
{
|
|
26
|
-
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
27
|
-
startDate: {
|
|
28
|
-
$lt: startDateLt
|
|
29
|
-
}
|
|
30
|
-
// endDate: {
|
|
31
|
-
// $exists: true,
|
|
32
|
-
// $lt: moment(now)
|
|
33
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
34
|
-
// .add(-365, 'days')
|
|
35
|
-
// .toDate()
|
|
36
|
-
// }
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
_id: 1,
|
|
40
|
-
typeOf: 1,
|
|
41
|
-
project: 1,
|
|
42
|
-
startDate: 1,
|
|
43
|
-
endDate: 1,
|
|
44
|
-
object: 1
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
console.log('transactions found');
|
|
48
|
-
|
|
49
|
-
let i = 0;
|
|
50
|
-
let updateCount = 0;
|
|
51
|
-
await cursor.eachAsync(async (doc) => {
|
|
52
|
-
i += 1;
|
|
53
|
-
const transaction: Pick<
|
|
54
|
-
chevre.factory.transaction.placeOrder.ITransaction,
|
|
55
|
-
'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
|
|
56
|
-
> = doc.toObject();
|
|
57
|
-
console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
58
|
-
|
|
59
|
-
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
60
|
-
.isBefore(endDateLt);
|
|
61
|
-
if (isEndDateBefore) {
|
|
62
|
-
const runsAt: Date = moment(transaction.endDate)
|
|
63
|
-
.add(ONE_YEAR_IN_DAYS, 'days')
|
|
64
|
-
.toDate();
|
|
65
|
-
|
|
66
|
-
updateCount += 1;
|
|
67
|
-
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
68
|
-
project: transaction.project,
|
|
69
|
-
name: chevre.factory.taskName.DeleteTransaction,
|
|
70
|
-
status: chevre.factory.taskStatus.Ready,
|
|
71
|
-
runsAt,
|
|
72
|
-
remainingNumberOfTries: 3,
|
|
73
|
-
numberOfTried: 0,
|
|
74
|
-
executionResults: [],
|
|
75
|
-
data: {
|
|
76
|
-
object: {
|
|
77
|
-
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
78
|
-
endDate: transaction.endDate,
|
|
79
|
-
id: transaction.id,
|
|
80
|
-
object: {
|
|
81
|
-
...(typeof transaction.object.confirmationNumber === 'string')
|
|
82
|
-
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
83
|
-
: undefined,
|
|
84
|
-
...(typeof transaction.object.orderNumber === 'string')
|
|
85
|
-
? { orderNumber: transaction.object.orderNumber }
|
|
86
|
-
: undefined
|
|
87
|
-
},
|
|
88
|
-
project: transaction.project,
|
|
89
|
-
startDate: transaction.startDate,
|
|
90
|
-
typeOf: transaction.typeOf
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
console.log(
|
|
95
|
-
'saving task...',
|
|
96
|
-
deleteTransactionTask, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
97
|
-
await taskRepo.saveMany([deleteTransactionTask], { emitImmediately: false });
|
|
98
|
-
console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
console.log(i, 'transactions checked');
|
|
103
|
-
console.log(updateCount, 'transactions updated');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
main()
|
|
107
|
-
.then()
|
|
108
|
-
.catch(console.error);
|
|
@@ -1,98 +0,0 @@
|
|
|
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);
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const now = new Date();
|
|
14
|
-
|
|
15
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
16
|
-
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
17
|
-
const personRepo = new chevre.repository.Person({ userPoolId: USERPOOL_ID_NEW });
|
|
18
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
-
|
|
20
|
-
const cursor = orderRepo.getCursor(
|
|
21
|
-
{
|
|
22
|
-
'project.id': { $eq: project.id },
|
|
23
|
-
'customer.typeOf': { $eq: chevre.factory.personType.Person },
|
|
24
|
-
'acceptedOffers.itemOffered.typeOf': { $exists: true.valueOf, $eq: chevre.factory.reservationType.EventReservation }
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
_id: 1,
|
|
28
|
-
project: 1,
|
|
29
|
-
orderNumber: 1,
|
|
30
|
-
orderDate: 1,
|
|
31
|
-
customer: 1
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
console.log('orders found');
|
|
35
|
-
|
|
36
|
-
let i = 0;
|
|
37
|
-
let updateCount = 0;
|
|
38
|
-
await cursor.eachAsync(async (doc) => {
|
|
39
|
-
i += 1;
|
|
40
|
-
const order = <Pick<chevre.factory.order.IOrder, 'id' | 'orderDate' | 'orderNumber' | 'customer' | 'project'>>doc.toObject();
|
|
41
|
-
|
|
42
|
-
// person検索
|
|
43
|
-
console.log('seaching person....', order.project.id, order.orderNumber, order.orderDate, order.customer.id, i);
|
|
44
|
-
const people = await personRepo.search({ id: String(order.customer.id) });
|
|
45
|
-
const person = people.shift();
|
|
46
|
-
const activePerson = (<any>person).Enabled === true;
|
|
47
|
-
if (activePerson) {
|
|
48
|
-
// activeであれば何もしない
|
|
49
|
-
console.log(
|
|
50
|
-
'person found', order.project.id, order.orderNumber, order.orderDate,
|
|
51
|
-
person?.memberOf?.membershipNumber,
|
|
52
|
-
(<any>person).Enabled, i);
|
|
53
|
-
} else {
|
|
54
|
-
// migrateアクション検索
|
|
55
|
-
const deletePersonActions = <chevre.factory.action.update.deleteAction.member.IAction[]>await actionRepo.search(
|
|
56
|
-
{
|
|
57
|
-
limit: 1,
|
|
58
|
-
page: 1,
|
|
59
|
-
project: { id: { $eq: order.project.id } },
|
|
60
|
-
actionStatus: { $in: [chevre.factory.actionStatusType.CompletedActionStatus] },
|
|
61
|
-
typeOf: { $eq: chevre.factory.actionType.DeleteAction },
|
|
62
|
-
object: {
|
|
63
|
-
id: { $eq: order.customer.id },
|
|
64
|
-
typeOf: { $eq: chevre.factory.personType.Person }
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
[],
|
|
68
|
-
[]
|
|
69
|
-
);
|
|
70
|
-
const deletePersonAction = deletePersonActions.shift();
|
|
71
|
-
if (deletePersonAction !== undefined) {
|
|
72
|
-
// migrateアクションがあれば何もしない
|
|
73
|
-
const migratedUser: boolean = deletePersonAction.object.migrate === true;
|
|
74
|
-
console.log('migratedUser:', migratedUser);
|
|
75
|
-
if (migratedUser) {
|
|
76
|
-
console.log(
|
|
77
|
-
'person migrated', order.project.id, order.orderNumber, order.orderDate,
|
|
78
|
-
person?.memberOf?.membershipNumber, i);
|
|
79
|
-
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(
|
|
85
|
-
'creating task...', order.project.id, order.orderNumber, order.orderDate,
|
|
86
|
-
person?.memberOf?.membershipNumber, i);
|
|
87
|
-
// task作成
|
|
88
|
-
const deleteTransactionTasks: chevre.factory.task.deleteTransaction.IAttributes[] = [
|
|
89
|
-
chevre.factory.transactionType.MoneyTransfer,
|
|
90
|
-
chevre.factory.transactionType.PlaceOrder,
|
|
91
|
-
chevre.factory.transactionType.ReturnOrder
|
|
92
|
-
].map((transactionType) => {
|
|
93
|
-
return {
|
|
94
|
-
project: { id: order.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
95
|
-
name: chevre.factory.taskName.DeleteTransaction,
|
|
96
|
-
status: chevre.factory.taskStatus.Ready,
|
|
97
|
-
runsAt: now,
|
|
98
|
-
remainingNumberOfTries: 3,
|
|
99
|
-
numberOfTried: 0,
|
|
100
|
-
executionResults: [],
|
|
101
|
-
data: {
|
|
102
|
-
object: {
|
|
103
|
-
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.AgentId,
|
|
104
|
-
agent: { id: order.customer.id },
|
|
105
|
-
project: { id: order.project.id },
|
|
106
|
-
typeOf: transactionType
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
// console.log(deleteTransactionTasks);
|
|
112
|
-
await taskRepo.saveMany(deleteTransactionTasks, { emitImmediately: false });
|
|
113
|
-
updateCount += 1;
|
|
114
|
-
console.log(
|
|
115
|
-
'task created.', order.project.id, order.orderNumber, order.orderDate,
|
|
116
|
-
person?.memberOf?.membershipNumber, i);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
console.log(i, 'orders checked');
|
|
121
|
-
console.log(updateCount, 'tasks created');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
main()
|
|
125
|
-
.then()
|
|
126
|
-
.catch(console.error);
|