@chevre/domain 21.9.0-alpha.5 → 21.9.0-alpha.7
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/repo/offerCatalogItem.js +10 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +8 -2
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +3 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +39 -24
- package/lib/chevre/service/task/onResourceUpdated.js +4 -1
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ class MongoRepository {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
37
37
|
// MongoDB検索条件
|
|
38
38
|
const andConditions = [];
|
|
39
39
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -92,6 +92,15 @@ class MongoRepository {
|
|
|
92
92
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
93
93
|
andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
|
|
94
94
|
}
|
|
95
|
+
const appliesToMovieTicketServiceOutputTypeOfIn = (_z = (_y = (_x = (_w = (_v = params.relatedOffer) === null || _v === void 0 ? void 0 : _v.priceSpecification) === null || _w === void 0 ? void 0 : _w.appliesToMovieTicket) === null || _x === void 0 ? void 0 : _x.serviceOutput) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
|
|
96
|
+
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfIn)) {
|
|
97
|
+
andConditions.push({
|
|
98
|
+
'relatedOffer.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
99
|
+
$exists: true,
|
|
100
|
+
$in: appliesToMovieTicketServiceOutputTypeOfIn
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
95
104
|
return andConditions;
|
|
96
105
|
}
|
|
97
106
|
save(params) {
|
|
@@ -8,6 +8,7 @@ import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
|
8
8
|
import { MongoRepository as MemberRepo } from '../../../repo/member';
|
|
9
9
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
10
10
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
11
|
+
import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
11
12
|
import { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
12
13
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
13
14
|
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
@@ -24,6 +25,7 @@ export declare function onResourceDeleted(params: factory.task.onResourceUpdated
|
|
|
24
25
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
25
26
|
offer: OfferRepo;
|
|
26
27
|
offerCatalog: OfferCatalogRepo;
|
|
28
|
+
offerCatalogItem: OfferCatalogItemRepo;
|
|
27
29
|
place: PlaceRepo;
|
|
28
30
|
product: ProductRepo;
|
|
29
31
|
productOffer: ProductOfferRepo;
|
|
@@ -57,7 +57,8 @@ function onResourceDeleted(params) {
|
|
|
57
57
|
project: { id: params.project.id },
|
|
58
58
|
ids: params.id,
|
|
59
59
|
typeOf: params.typeOf,
|
|
60
|
-
isDeleted: true
|
|
60
|
+
isDeleted: true,
|
|
61
|
+
isOfferCatalogItem: params.isOfferCatalogItem === true
|
|
61
62
|
})(repos);
|
|
62
63
|
break;
|
|
63
64
|
case factory.product.ProductType.EventService:
|
|
@@ -333,7 +334,12 @@ function deleteResourcesByOfferCatalog(params) {
|
|
|
333
334
|
project: { id: params.project.id },
|
|
334
335
|
hasOfferCatalog: { id: catalogId }
|
|
335
336
|
});
|
|
336
|
-
|
|
337
|
+
// カタログからpullItemListElement(サブカタログ対応)
|
|
338
|
+
const updateCatalogResult = yield repos.offerCatalog.pullItemListElement({
|
|
339
|
+
project: { id: params.project.id },
|
|
340
|
+
$pull: { itemListElement: { $elemMatch: { id: { $in: [catalogId] } } } }
|
|
341
|
+
});
|
|
342
|
+
deleteResult = { deleteEventResult, deleteProductResult, updateOfferResult, updateCatalogResult };
|
|
337
343
|
}
|
|
338
344
|
catch (error) {
|
|
339
345
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import { MongoRepository as AggregateOfferRepo } from '../../../repo/aggregateOffer';
|
|
3
3
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
4
|
+
import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
4
5
|
/**
|
|
5
6
|
* カタログのitemListElementを集計オファーへ同期する
|
|
6
7
|
*/
|
|
@@ -11,7 +12,9 @@ export declare function syncOfferCatalog(params: {
|
|
|
11
12
|
ids: string[];
|
|
12
13
|
typeOf: factory.task.onResourceUpdated.OfferCatalogType;
|
|
13
14
|
isDeleted: boolean;
|
|
15
|
+
isOfferCatalogItem: boolean;
|
|
14
16
|
}): (repos: {
|
|
15
17
|
aggregateOffer: AggregateOfferRepo;
|
|
16
18
|
offerCatalog: OfferCatalogRepo;
|
|
19
|
+
offerCatalogItem: OfferCatalogItemRepo;
|
|
17
20
|
}) => Promise<void>;
|
|
@@ -19,38 +19,48 @@ function syncOfferCatalog(params) {
|
|
|
19
19
|
// if (params.ids.length !== 1) {
|
|
20
20
|
// throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
21
21
|
// }
|
|
22
|
-
var _a
|
|
22
|
+
var _a;
|
|
23
23
|
if (params.isDeleted) {
|
|
24
24
|
for (const offerCatalogId of params.ids) {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
// no op
|
|
39
|
-
}
|
|
25
|
+
// 検索しても存在しない
|
|
26
|
+
// const offerCatalogs = await repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
27
|
+
// カタログを含む全集計オファーからカタログを除外
|
|
28
|
+
yield repos.aggregateOffer.pullIncludedInDataCatalog({
|
|
29
|
+
project: { id: params.project.id },
|
|
30
|
+
$pull: {
|
|
31
|
+
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
else {
|
|
43
37
|
for (const offerCatalogId of params.ids) {
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
let offerCatalogs = [];
|
|
39
|
+
if (params.isOfferCatalogItem) {
|
|
40
|
+
offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
|
|
44
|
+
}
|
|
45
|
+
const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
|
|
46
46
|
switch (itemListElementTypeOf) {
|
|
47
47
|
case factory.offerType.Offer:
|
|
48
48
|
// 集計オファーIDリストを検索
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
let aggregateOfferIds;
|
|
50
|
+
if (params.isOfferCatalogItem) {
|
|
51
|
+
const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
|
|
52
|
+
id: offerCatalogId,
|
|
53
|
+
project: { id: params.project.id }
|
|
54
|
+
});
|
|
55
|
+
aggregateOfferIds = itemListElement.map((element) => element.id);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
|
|
59
|
+
id: offerCatalogId,
|
|
60
|
+
project: { id: params.project.id }
|
|
61
|
+
});
|
|
62
|
+
aggregateOfferIds = itemListElement.map((element) => element.id);
|
|
63
|
+
}
|
|
54
64
|
// カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
|
|
55
65
|
yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
|
|
56
66
|
includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
|
|
@@ -66,7 +76,12 @@ function syncOfferCatalog(params) {
|
|
|
66
76
|
});
|
|
67
77
|
}
|
|
68
78
|
// 同期済記録を補完
|
|
69
|
-
|
|
79
|
+
if (params.isOfferCatalogItem) {
|
|
80
|
+
yield repos.offerCatalogItem.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
|
|
84
|
+
}
|
|
70
85
|
break;
|
|
71
86
|
default:
|
|
72
87
|
// no op
|
|
@@ -20,6 +20,7 @@ const event_1 = require("../../repo/event");
|
|
|
20
20
|
const member_1 = require("../../repo/member");
|
|
21
21
|
const offer_1 = require("../../repo/offer");
|
|
22
22
|
const offerCatalog_1 = require("../../repo/offerCatalog");
|
|
23
|
+
const offerCatalogItem_1 = require("../../repo/offerCatalogItem");
|
|
23
24
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
24
25
|
const place_1 = require("../../repo/place");
|
|
25
26
|
const product_1 = require("../../repo/product");
|
|
@@ -44,6 +45,7 @@ function call(data) {
|
|
|
44
45
|
member: new member_1.MongoRepository(connectionSettings.connection),
|
|
45
46
|
offer: new offer_1.MongoRepository(connectionSettings.connection),
|
|
46
47
|
offerCatalog: new offerCatalog_1.MongoRepository(connectionSettings.connection),
|
|
48
|
+
offerCatalogItem: new offerCatalogItem_1.MongoRepository(connectionSettings.connection),
|
|
47
49
|
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(connectionSettings.connection),
|
|
48
50
|
place: new place_1.MongoRepository(connectionSettings.connection),
|
|
49
51
|
product: new product_1.MongoRepository(connectionSettings.connection),
|
|
@@ -116,7 +118,8 @@ function onResourceUpdated(params) {
|
|
|
116
118
|
project: { id: params.project.id },
|
|
117
119
|
ids: params.id,
|
|
118
120
|
typeOf: params.typeOf,
|
|
119
|
-
isDeleted: false
|
|
121
|
+
isDeleted: false,
|
|
122
|
+
isOfferCatalogItem: params.isOfferCatalogItem === true
|
|
120
123
|
})(repos);
|
|
121
124
|
break;
|
|
122
125
|
default:
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.330.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.330.0-alpha.1",
|
|
13
13
|
"@cinerino/sdk": "3.167.0-alpha.9",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.9.0-alpha.
|
|
120
|
+
"version": "21.9.0-alpha.7"
|
|
121
121
|
}
|