@chevre/domain 21.29.0-alpha.18 → 21.29.0-alpha.19
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/migrateCancelReservationObject.ts +71 -0
- package/example/src/chevre/searchAssetTransactions.ts +5 -5
- package/lib/chevre/repo/assetTransaction.d.ts +6 -5
- package/lib/chevre/repo/assetTransaction.js +14 -5
- package/lib/chevre/repo/productModel.d.ts +10 -5
- package/lib/chevre/repo/productModel.js +40 -2
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +26 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +9 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +61 -0
- package/lib/chevre/service/task/onResourceUpdated.js +11 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +25 -3
- package/lib/chevre/settings.d.ts +0 -4
- package/lib/chevre/settings.js +1 -8
- package/package.json +1 -1
- package/example/src/chevre/migrateScreeningEventSeriesOffers.ts +0 -87
|
@@ -0,0 +1,71 @@
|
|
|
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 assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.CancelReservation }
|
|
15
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
16
|
+
},
|
|
17
|
+
{}
|
|
18
|
+
);
|
|
19
|
+
console.log('assetTransactions found');
|
|
20
|
+
|
|
21
|
+
let i = 0;
|
|
22
|
+
let updateCount = 0;
|
|
23
|
+
await cursor.eachAsync(async (doc) => {
|
|
24
|
+
i += 1;
|
|
25
|
+
const assetTransaction: chevre.factory.assetTransaction.cancelReservation.ITransaction = doc.toObject();
|
|
26
|
+
|
|
27
|
+
const alreadyMigrated = assetTransaction.object.typeOf === chevre.factory.reservationType.ReservationPackage
|
|
28
|
+
&& typeof assetTransaction.object.reservationNumber === 'string'
|
|
29
|
+
&& assetTransaction.object.reservationNumber.length > 0;
|
|
30
|
+
|
|
31
|
+
if (alreadyMigrated) {
|
|
32
|
+
console.log(
|
|
33
|
+
'already migrated.',
|
|
34
|
+
assetTransaction.project.id, assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
|
|
35
|
+
} else {
|
|
36
|
+
let reservationNumber: string | undefined;
|
|
37
|
+
if (typeof assetTransaction.object.transaction?.transactionNumber === 'string') {
|
|
38
|
+
reservationNumber = assetTransaction.object.transaction.transactionNumber;
|
|
39
|
+
} else if (typeof assetTransaction.object.reservations?.[0].reservationNumber === 'string') {
|
|
40
|
+
reservationNumber = assetTransaction.object.reservations[0].reservationNumber;
|
|
41
|
+
}
|
|
42
|
+
if (typeof reservationNumber !== 'string') {
|
|
43
|
+
console.error(
|
|
44
|
+
'reservationNumber not found.',
|
|
45
|
+
assetTransaction.project.id,
|
|
46
|
+
assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
|
|
47
|
+
throw new Error('reservationNumber not found');
|
|
48
|
+
}
|
|
49
|
+
console.log(
|
|
50
|
+
'updating assetTransaction...',
|
|
51
|
+
assetTransaction.project.id,
|
|
52
|
+
assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, reservationNumber, i);
|
|
53
|
+
await assetTransactionRepo.migrateObjectReservationNumber({
|
|
54
|
+
id: assetTransaction.id,
|
|
55
|
+
object: { reservationNumber }
|
|
56
|
+
});
|
|
57
|
+
updateCount += 1;
|
|
58
|
+
console.log(
|
|
59
|
+
'updated.',
|
|
60
|
+
assetTransaction.project.id,
|
|
61
|
+
assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log(i, 'assetTransactions checked');
|
|
66
|
+
console.log(updateCount, 'assetTransactions updated');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main()
|
|
70
|
+
.then()
|
|
71
|
+
.catch(console.error);
|
|
@@ -19,17 +19,17 @@ async function main() {
|
|
|
19
19
|
|
|
20
20
|
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
21
21
|
|
|
22
|
-
const assetTransactions = await assetTransactionRepo.search<chevre.factory.assetTransactionType.
|
|
22
|
+
const assetTransactions = await assetTransactionRepo.search<chevre.factory.assetTransactionType.CancelReservation>(
|
|
23
23
|
{
|
|
24
24
|
limit: 10,
|
|
25
25
|
project: { id: { $eq: project.id } },
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
object: { reservationNumber: { $in: ['792955671389309', '439371836213743'] } },
|
|
27
|
+
typeOf: chevre.factory.assetTransactionType.CancelReservation
|
|
28
28
|
},
|
|
29
|
-
['
|
|
29
|
+
['transactionNumber'],
|
|
30
30
|
[]
|
|
31
31
|
);
|
|
32
|
-
console.log('assetTransactions found', assetTransactions
|
|
32
|
+
console.log('assetTransactions found', assetTransactions);
|
|
33
33
|
console.log(assetTransactions.length, 'assetTransactions found');
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -195,12 +195,13 @@ export declare class MongoRepository {
|
|
|
195
195
|
id: string;
|
|
196
196
|
update: any;
|
|
197
197
|
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
/**
|
|
199
|
+
* 互換性維持対応
|
|
200
|
+
*/
|
|
201
|
+
migrateObjectReservationNumber(params: {
|
|
202
|
+
id: string;
|
|
200
203
|
object: {
|
|
201
|
-
|
|
202
|
-
identifier: string;
|
|
203
|
-
};
|
|
204
|
+
reservationNumber: string;
|
|
204
205
|
};
|
|
205
206
|
}): Promise<any>;
|
|
206
207
|
/**
|
|
@@ -726,19 +726,28 @@ class MongoRepository {
|
|
|
726
726
|
});
|
|
727
727
|
});
|
|
728
728
|
}
|
|
729
|
-
|
|
729
|
+
/**
|
|
730
|
+
* 互換性維持対応
|
|
731
|
+
*/
|
|
732
|
+
migrateObjectReservationNumber(params) {
|
|
730
733
|
return __awaiter(this, void 0, void 0, function* () {
|
|
731
734
|
return this.transactionModel.findOneAndUpdate({
|
|
732
|
-
typeOf: { $eq: factory.assetTransactionType.
|
|
733
|
-
|
|
734
|
-
}, {
|
|
735
|
+
typeOf: { $eq: factory.assetTransactionType.CancelReservation },
|
|
736
|
+
_id: { $eq: params.id }
|
|
737
|
+
}, {
|
|
738
|
+
$set: {
|
|
739
|
+
'object.reservationNumber': params.object.reservationNumber,
|
|
740
|
+
'object.typeOf': factory.reservationType.ReservationPackage
|
|
741
|
+
}
|
|
742
|
+
}, {
|
|
743
|
+
timestamps: false,
|
|
735
744
|
new: true,
|
|
736
745
|
projection: { _id: 1 }
|
|
737
746
|
})
|
|
738
747
|
.exec()
|
|
739
748
|
.then((doc) => {
|
|
740
749
|
if (doc === null) {
|
|
741
|
-
throw new factory.errors.
|
|
750
|
+
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
742
751
|
}
|
|
743
752
|
return doc.toObject();
|
|
744
753
|
});
|
|
@@ -52,10 +52,15 @@ export declare class MongoRepository {
|
|
|
52
52
|
}): Promise<{
|
|
53
53
|
id: string;
|
|
54
54
|
}>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
/**
|
|
56
|
+
* 区分から同期する
|
|
57
|
+
*/
|
|
58
|
+
upsertByCategory(params: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet' | 'name' | 'project'>): Promise<{
|
|
59
|
+
id: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* 区分から削除する
|
|
63
|
+
*/
|
|
64
|
+
deleteByCategory(params: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet' | 'project'>): Promise<void>;
|
|
60
65
|
}
|
|
61
66
|
export {};
|
|
@@ -126,10 +126,48 @@ class MongoRepository {
|
|
|
126
126
|
return doc.toObject();
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
/**
|
|
130
|
+
* 区分から同期する
|
|
131
|
+
*/
|
|
132
|
+
upsertByCategory(params) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const upsertingProductModel = {
|
|
135
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
136
|
+
typeOf: 'ProductModel',
|
|
137
|
+
category: {
|
|
138
|
+
codeValue: params.codeValue,
|
|
139
|
+
inCodeSet: params.inCodeSet
|
|
140
|
+
},
|
|
141
|
+
name: params.name,
|
|
142
|
+
offers: [{
|
|
143
|
+
typeOf: factory.offerType.Offer
|
|
144
|
+
}]
|
|
145
|
+
};
|
|
146
|
+
const { id, project, typeOf, offers, category } = upsertingProductModel, setFields = __rest(upsertingProductModel, ["id", "project", "typeOf", "offers", "category"]);
|
|
147
|
+
const doc = yield this.productModelModel.findOneAndUpdate({
|
|
148
|
+
'project.id': { $eq: upsertingProductModel.project.id },
|
|
149
|
+
'category.codeValue': { $exists: true, $eq: upsertingProductModel.category.codeValue },
|
|
150
|
+
'category.inCodeSet.identifier': { $exists: true, $eq: upsertingProductModel.category.inCodeSet.identifier }
|
|
151
|
+
}, {
|
|
152
|
+
$setOnInsert: { project, typeOf, offers, category },
|
|
153
|
+
$set: setFields
|
|
154
|
+
}, { new: true, upsert: true, projection: { _id: 1 } })
|
|
155
|
+
.exec();
|
|
156
|
+
if (doc === null) {
|
|
157
|
+
throw new factory.errors.NotFound(this.productModelModel.modelName);
|
|
158
|
+
}
|
|
159
|
+
return doc.toObject();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 区分から削除する
|
|
164
|
+
*/
|
|
165
|
+
deleteByCategory(params) {
|
|
130
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
167
|
yield this.productModelModel.deleteMany({
|
|
132
|
-
'project.id': { $eq: params.project.id }
|
|
168
|
+
'project.id': { $eq: params.project.id },
|
|
169
|
+
'category.codeValue': { $exists: true, $eq: params.codeValue },
|
|
170
|
+
'category.inCodeSet.identifier': { $exists: true, $eq: params.inCodeSet.identifier }
|
|
133
171
|
})
|
|
134
172
|
.exec();
|
|
135
173
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
2
|
+
import type { MongoRepository as ProductModelRepo } from '../../../repo/productModel';
|
|
3
|
+
/**
|
|
4
|
+
* 区分変更時処理
|
|
5
|
+
*/
|
|
6
|
+
export declare function onCategoryCodeUpdated(params: {
|
|
7
|
+
project: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
ids: string[];
|
|
11
|
+
isDeleted: boolean;
|
|
12
|
+
}): (repos: {
|
|
13
|
+
categoryCode: CategoryCodeRepo;
|
|
14
|
+
productModel: ProductModelRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.onCategoryCodeUpdated = void 0;
|
|
13
|
+
const syncCategoryCode_1 = require("./syncCategoryCode");
|
|
14
|
+
/**
|
|
15
|
+
* 区分変更時処理
|
|
16
|
+
*/
|
|
17
|
+
function onCategoryCodeUpdated(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
yield (0, syncCategoryCode_1.syncCategoryCode)({
|
|
20
|
+
project: { id: params.project.id },
|
|
21
|
+
ids: params.ids,
|
|
22
|
+
isDeleted: false
|
|
23
|
+
})(repos);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.onCategoryCodeUpdated = onCategoryCodeUpdated;
|
|
@@ -14,6 +14,7 @@ import type { MongoRepository as HasPOSRepo } from '../../../repo/place/hasPOS';
|
|
|
14
14
|
import type { MongoRepository as MovieTheaterRepo } from '../../../repo/place/movieTheater';
|
|
15
15
|
import type { MongoRepository as ScreeningRoomRepo } from '../../../repo/place/screeningRoom';
|
|
16
16
|
import type { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
17
|
+
import type { MongoRepository as ProductModelRepo } from '../../../repo/productModel';
|
|
17
18
|
import type { MongoRepository as ProductOfferRepo } from '../../../repo/productOffer';
|
|
18
19
|
import type { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
19
20
|
export declare function onResourceDeleted(params: factory.task.onResourceUpdated.IData): (repos: {
|
|
@@ -32,6 +33,7 @@ export declare function onResourceDeleted(params: factory.task.onResourceUpdated
|
|
|
32
33
|
offerCatalogItem: OfferCatalogItemRepo;
|
|
33
34
|
screeningRoom: ScreeningRoomRepo;
|
|
34
35
|
product: ProductRepo;
|
|
36
|
+
productModel: ProductModelRepo;
|
|
35
37
|
productOffer: ProductOfferRepo;
|
|
36
38
|
task: TaskRepo;
|
|
37
39
|
}) => Promise<void>;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.onResourceDeleted = void 0;
|
|
13
13
|
const factory = require("../../../factory");
|
|
14
14
|
const onHasPOSUpdated_1 = require("./onHasPOSUpdated");
|
|
15
|
+
const syncCategoryCode_1 = require("./syncCategoryCode");
|
|
15
16
|
const syncOfferCatalog_1 = require("./syncOfferCatalog");
|
|
16
17
|
// tslint:disable-next-line:max-func-body-length
|
|
17
18
|
function onResourceDeleted(params) {
|
|
@@ -89,6 +90,14 @@ function onResourceDeleted(params) {
|
|
|
89
90
|
typeOf: params.typeOf
|
|
90
91
|
})(repos);
|
|
91
92
|
break;
|
|
93
|
+
// 区分削除に対応(2024-04-18~)
|
|
94
|
+
case 'CategoryCode':
|
|
95
|
+
yield (0, syncCategoryCode_1.syncCategoryCode)({
|
|
96
|
+
project: { id: params.project.id },
|
|
97
|
+
ids: params.id,
|
|
98
|
+
isDeleted: true
|
|
99
|
+
})(repos);
|
|
100
|
+
break;
|
|
92
101
|
default:
|
|
93
102
|
// no op
|
|
94
103
|
throw new factory.errors.NotImplemented(`${params.typeOf} onDeleted not implemented`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
2
|
+
import type { MongoRepository as ProductModelRepo } from '../../../repo/productModel';
|
|
3
|
+
/**
|
|
4
|
+
* 区分を他リソースへ同期する
|
|
5
|
+
*/
|
|
6
|
+
export declare function syncCategoryCode(params: {
|
|
7
|
+
project: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
ids: string[];
|
|
11
|
+
isDeleted: boolean;
|
|
12
|
+
}): (repos: {
|
|
13
|
+
categoryCode: CategoryCodeRepo;
|
|
14
|
+
productModel: ProductModelRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.syncCategoryCode = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
/**
|
|
15
|
+
* 区分を他リソースへ同期する
|
|
16
|
+
*/
|
|
17
|
+
function syncCategoryCode(params) {
|
|
18
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
if (params.isDeleted) {
|
|
20
|
+
for (const categoryCodeId of params.ids) {
|
|
21
|
+
const syncingCategoryCode = (yield repos.categoryCode.search({
|
|
22
|
+
limit: 1,
|
|
23
|
+
page: 1,
|
|
24
|
+
project: { id: { $eq: params.project.id } },
|
|
25
|
+
id: { $eq: categoryCodeId }
|
|
26
|
+
}, ['codeValue', 'inCodeSet', 'project'], [])).shift();
|
|
27
|
+
if (syncingCategoryCode !== undefined) {
|
|
28
|
+
switch (syncingCategoryCode.inCodeSet.identifier) {
|
|
29
|
+
case factory.categoryCode.CategorySetIdentifier.SeatingType:
|
|
30
|
+
// プロダクトモデルを削除
|
|
31
|
+
yield repos.productModel.deleteByCategory(syncingCategoryCode);
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
// no op
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
for (const categoryCodeId of params.ids) {
|
|
41
|
+
const syncingCategoryCode = (yield repos.categoryCode.search({
|
|
42
|
+
limit: 1,
|
|
43
|
+
page: 1,
|
|
44
|
+
project: { id: { $eq: params.project.id } },
|
|
45
|
+
id: { $eq: categoryCodeId }
|
|
46
|
+
}, ['codeValue', 'inCodeSet', 'name', 'project'], [])).shift();
|
|
47
|
+
if (syncingCategoryCode !== undefined) {
|
|
48
|
+
switch (syncingCategoryCode.inCodeSet.identifier) {
|
|
49
|
+
case factory.categoryCode.CategorySetIdentifier.SeatingType:
|
|
50
|
+
// プロダクトモデルへ同期
|
|
51
|
+
yield repos.productModel.upsertByCategory(syncingCategoryCode);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
// no op
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.syncCategoryCode = syncCategoryCode;
|
|
@@ -27,9 +27,11 @@ const hasPOS_1 = require("../../repo/place/hasPOS");
|
|
|
27
27
|
const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
28
28
|
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
29
29
|
const product_1 = require("../../repo/product");
|
|
30
|
+
const productModel_1 = require("../../repo/productModel");
|
|
30
31
|
const productOffer_1 = require("../../repo/productOffer");
|
|
31
32
|
const task_1 = require("../../repo/task");
|
|
32
33
|
const onAggregateOfferUpdated_1 = require("./onResourceUpdated/onAggregateOfferUpdated");
|
|
34
|
+
const onCategoryCodeUpdated_1 = require("./onResourceUpdated/onCategoryCodeUpdated");
|
|
33
35
|
const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
|
|
34
36
|
const onOfferCatalogUpdated_1 = require("./onResourceUpdated/onOfferCatalogUpdated");
|
|
35
37
|
const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
|
|
@@ -57,6 +59,7 @@ function call(data) {
|
|
|
57
59
|
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(connection),
|
|
58
60
|
screeningRoom: new screeningRoom_1.MongoRepository(connection),
|
|
59
61
|
product: new product_1.MongoRepository(connection),
|
|
62
|
+
productModel: new productModel_1.MongoRepository(connection),
|
|
60
63
|
productOffer: new productOffer_1.MongoRepository(connection),
|
|
61
64
|
task: new task_1.MongoRepository(connection)
|
|
62
65
|
});
|
|
@@ -162,6 +165,14 @@ function onResourceUpdated(params) {
|
|
|
162
165
|
isOfferCatalogItem: params.isOfferCatalogItem === true
|
|
163
166
|
})(repos);
|
|
164
167
|
break;
|
|
168
|
+
// 区分に対応(2024-04-18~)
|
|
169
|
+
case 'CategoryCode':
|
|
170
|
+
yield (0, onCategoryCodeUpdated_1.onCategoryCodeUpdated)({
|
|
171
|
+
project: { id: params.project.id },
|
|
172
|
+
ids: params.id,
|
|
173
|
+
isDeleted: false
|
|
174
|
+
})(repos);
|
|
175
|
+
break;
|
|
165
176
|
default:
|
|
166
177
|
// no op
|
|
167
178
|
}
|
|
@@ -151,6 +151,7 @@ function deleteTransactionById(params) {
|
|
|
151
151
|
let payTransactionNumbers = [];
|
|
152
152
|
let deleteReservationsResult;
|
|
153
153
|
let deleteReserveTransactionResult;
|
|
154
|
+
let deleteCancelReservationTransactionResult;
|
|
154
155
|
let deletedReservationNumbers = [];
|
|
155
156
|
let deleteActionResult;
|
|
156
157
|
const action = yield repos.action.start(actionAttributes);
|
|
@@ -192,6 +193,8 @@ function deleteTransactionById(params) {
|
|
|
192
193
|
const deleteReservationsByPlaceOrderResult = yield deleteReservationsByPlaceOrder({ authorizeActions, transaction })(repos);
|
|
193
194
|
deleteReservationsResult = deleteReservationsByPlaceOrderResult.deleteResult;
|
|
194
195
|
deleteReserveTransactionResult = deleteReservationsByPlaceOrderResult.deleteReserveTransactionResult;
|
|
196
|
+
deleteCancelReservationTransactionResult =
|
|
197
|
+
deleteReservationsByPlaceOrderResult.deleteCancelReservationTransactionResult;
|
|
195
198
|
deletedReservationNumbers = deleteReservationsByPlaceOrderResult.reserveTransactionNumbers;
|
|
196
199
|
// アクション削除(2023-05-19~)
|
|
197
200
|
deleteActionResult = yield repos.action.deleteByPurpose({
|
|
@@ -239,6 +242,7 @@ function deleteTransactionById(params) {
|
|
|
239
242
|
payTransactionNumbers,
|
|
240
243
|
deleteReservationsResult,
|
|
241
244
|
deleteReserveTransactionResult,
|
|
245
|
+
deleteCancelReservationTransactionResult,
|
|
242
246
|
deletedReservationNumbers,
|
|
243
247
|
deleteActionResult
|
|
244
248
|
};
|
|
@@ -249,6 +253,7 @@ function deleteReservationsByPlaceOrder(params) {
|
|
|
249
253
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
250
254
|
let deleteResult;
|
|
251
255
|
let deleteReserveTransactionResult;
|
|
256
|
+
let deleteCancelReservationTransactionResult;
|
|
252
257
|
const authorizeActions = params.authorizeActions;
|
|
253
258
|
// 予約取引番号を抽出
|
|
254
259
|
const authorizeReservationOfferActions = authorizeActions
|
|
@@ -283,10 +288,27 @@ function deleteReservationsByPlaceOrder(params) {
|
|
|
283
288
|
ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
|
|
284
289
|
deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
|
|
285
290
|
};
|
|
286
|
-
//
|
|
287
|
-
|
|
291
|
+
// 予約番号で予約取消取引を検索
|
|
292
|
+
const deletingCancelReservationTransactions = yield repos.assetTransaction.search({
|
|
293
|
+
project: { id: { $eq: params.transaction.project.id } },
|
|
294
|
+
object: { reservationNumber: { $in: reserveTransactionNumbers } },
|
|
295
|
+
typeOf: factory.assetTransactionType.CancelReservation
|
|
296
|
+
}, ['transactionNumber'], []);
|
|
297
|
+
if (deletingCancelReservationTransactions.length > 0) {
|
|
298
|
+
// 予約取消取引も削除(2024-04-18~)
|
|
299
|
+
const deleteCancelReservationResult = yield repos.assetTransaction.deleteByTransactionNumber({
|
|
300
|
+
project: { id: params.transaction.project.id },
|
|
301
|
+
transactionNumbers: deletingCancelReservationTransactions.map(({ transactionNumber }) => String(transactionNumber)),
|
|
302
|
+
typeOf: factory.assetTransactionType.CancelReservation
|
|
303
|
+
});
|
|
304
|
+
deleteCancelReservationTransactionResult = {
|
|
305
|
+
n: deleteCancelReservationResult === null || deleteCancelReservationResult === void 0 ? void 0 : deleteCancelReservationResult.n,
|
|
306
|
+
ok: deleteCancelReservationResult === null || deleteCancelReservationResult === void 0 ? void 0 : deleteCancelReservationResult.ok,
|
|
307
|
+
deletedCount: deleteCancelReservationResult === null || deleteCancelReservationResult === void 0 ? void 0 : deleteCancelReservationResult.deletedCount
|
|
308
|
+
};
|
|
309
|
+
}
|
|
288
310
|
}
|
|
289
|
-
return { deleteResult, deleteReserveTransactionResult, reserveTransactionNumbers };
|
|
311
|
+
return { deleteResult, deleteReserveTransactionResult, deleteCancelReservationTransactionResult, reserveTransactionNumbers };
|
|
290
312
|
});
|
|
291
313
|
}
|
|
292
314
|
function deletePayTransactionsByPlaceOrder(params) {
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
|
4
4
|
export declare const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS: number;
|
|
5
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
6
6
|
export declare const MAX_NUM_CREDIT_CARD_PAYMENT_METHOD: number;
|
|
7
|
-
/**
|
|
8
|
-
* 資産取引保管期間
|
|
9
|
-
*/
|
|
10
|
-
export declare const ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS: number;
|
|
11
7
|
/**
|
|
12
8
|
* 取引保管期間(Confirmed)
|
|
13
9
|
*/
|
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.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = 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.
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = 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.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -35,13 +35,6 @@ exports.ABORTED_TASKS_WITHOUT_REPORT = (typeof process.env.ABORTED_TASKS_WITHOUT
|
|
|
35
35
|
exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = (typeof process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'string')
|
|
36
36
|
? Number(process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD)
|
|
37
37
|
: 1;
|
|
38
|
-
/**
|
|
39
|
-
* 資産取引保管期間
|
|
40
|
-
*/
|
|
41
|
-
exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = (typeof process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS === 'string')
|
|
42
|
-
? Number(process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS)
|
|
43
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
-
: 500;
|
|
45
38
|
/**
|
|
46
39
|
* 取引保管期間(Confirmed)
|
|
47
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,87 +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
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
19
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
21
|
-
// 'offers.availabilityEnds': { $exists: true }
|
|
22
|
-
},
|
|
23
|
-
{}
|
|
24
|
-
);
|
|
25
|
-
console.log('events found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
const projectIds: string[] = [];
|
|
30
|
-
let createdAtLatest: Date | undefined;
|
|
31
|
-
let updatedAtLatest: Date | undefined;
|
|
32
|
-
await cursor.eachAsync(async (doc) => {
|
|
33
|
-
i += 1;
|
|
34
|
-
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
35
|
-
|
|
36
|
-
const unacceptedPaymentMethod = event.offers?.unacceptedPaymentMethod;
|
|
37
|
-
const alreadyMigrated =
|
|
38
|
-
(!Array.isArray(unacceptedPaymentMethod))
|
|
39
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 0)
|
|
40
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 1 && unacceptedPaymentMethod[0] === 'MovieTicket');
|
|
41
|
-
|
|
42
|
-
if (alreadyMigrated) {
|
|
43
|
-
console.log(
|
|
44
|
-
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
45
|
-
} else {
|
|
46
|
-
projectIds.push(event.project.id);
|
|
47
|
-
if (createdAtLatest instanceof Date) {
|
|
48
|
-
if (moment(createdAtLatest)
|
|
49
|
-
.isBefore(moment((<any>event).createdAt))) {
|
|
50
|
-
createdAtLatest = (<any>event).createdAt;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
createdAtLatest = (<any>event).createdAt;
|
|
54
|
-
}
|
|
55
|
-
if (updatedAtLatest instanceof Date) {
|
|
56
|
-
if (moment(updatedAtLatest)
|
|
57
|
-
.isBefore(moment((<any>event).updatedAt))) {
|
|
58
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
62
|
-
}
|
|
63
|
-
console.log(
|
|
64
|
-
'updating event...', event.project.id, event.id, event.startDate, unacceptedPaymentMethod,
|
|
65
|
-
(<any>event).createdAt,
|
|
66
|
-
(<any>event).updatedAt,
|
|
67
|
-
i
|
|
68
|
-
);
|
|
69
|
-
// await creativeWorkRepo.saveMovie(<any>{
|
|
70
|
-
// id: String(movie.id),
|
|
71
|
-
// 'offers.availabilityStarts': availabilityStarts
|
|
72
|
-
// });
|
|
73
|
-
updateCount += 1;
|
|
74
|
-
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
console.log(i, 'events checked');
|
|
79
|
-
console.log(updateCount, 'events updated');
|
|
80
|
-
console.log('projectIds:', [...new Set(projectIds)]);
|
|
81
|
-
console.log('createdAtLatest:', createdAtLatest);
|
|
82
|
-
console.log('updatedAtLatest:', updatedAtLatest);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main()
|
|
86
|
-
.then()
|
|
87
|
-
.catch(console.error);
|