@chevre/domain 21.9.0-alpha.4 → 21.9.0-alpha.6

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.
@@ -61,6 +61,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
61
61
  description?: any;
62
62
  itemOffered?: any;
63
63
  dateSynced?: Date | undefined;
64
+ relatedOffer?: any;
64
65
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
65
66
  typeOf: string;
66
67
  additionalProperty: any[];
@@ -72,6 +73,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
72
73
  description?: any;
73
74
  itemOffered?: any;
74
75
  dateSynced?: Date | undefined;
76
+ relatedOffer?: any;
75
77
  }>> & Omit<import("mongoose").FlatRecord<{
76
78
  typeOf: string;
77
79
  additionalProperty: any[];
@@ -83,6 +85,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
83
85
  description?: any;
84
86
  itemOffered?: any;
85
87
  dateSynced?: Date | undefined;
88
+ relatedOffer?: any;
86
89
  }> & {
87
90
  _id: import("mongoose").Types.ObjectId;
88
91
  }, never>>;
@@ -10,7 +10,6 @@ exports.modelName = modelName;
10
10
  */
11
11
  const schema = new mongoose_1.Schema({
12
12
  project: mongoose_1.SchemaTypes.Mixed,
13
- // _id: String,
14
13
  identifier: {
15
14
  type: String,
16
15
  required: true
@@ -25,7 +24,8 @@ const schema = new mongoose_1.Schema({
25
24
  itemListElement: [mongoose_1.SchemaTypes.Mixed],
26
25
  itemOffered: mongoose_1.SchemaTypes.Mixed,
27
26
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
28
- dateSynced: Date
27
+ dateSynced: Date,
28
+ relatedOffer: mongoose_1.SchemaTypes.Mixed
29
29
  }, {
30
30
  collection: 'offerCatalogItems',
31
31
  id: true,
@@ -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) {
@@ -142,6 +151,7 @@ class MongoRepository {
142
151
  identifier: '$identifier',
143
152
  itemOffered: '$itemOffered',
144
153
  additionalProperty: '$additionalProperty',
154
+ relatedOffer: '$relatedOffer',
145
155
  numberOfItems: {
146
156
  $cond: {
147
157
  if: { $isArray: '$itemListElement' },
@@ -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
- deleteResult = { deleteEventResult, deleteProductResult, updateOfferResult };
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>;
@@ -41,16 +41,32 @@ function syncOfferCatalog(params) {
41
41
  }
42
42
  else {
43
43
  for (const offerCatalogId of params.ids) {
44
- const offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
44
+ let offerCatalogs = [];
45
+ if (params.isOfferCatalogItem) {
46
+ offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } });
47
+ }
48
+ else {
49
+ offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
50
+ }
45
51
  const itemListElementTypeOf = (_b = offerCatalogs.shift()) === null || _b === void 0 ? void 0 : _b.itemListElementTypeOf;
46
52
  switch (itemListElementTypeOf) {
47
53
  case factory.offerType.Offer:
48
54
  // 集計オファーIDリストを検索
49
- const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
50
- id: offerCatalogId,
51
- project: { id: params.project.id }
52
- });
53
- const aggregateOfferIds = itemListElement.map((element) => element.id);
55
+ let aggregateOfferIds;
56
+ if (params.isOfferCatalogItem) {
57
+ const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
58
+ id: offerCatalogId,
59
+ project: { id: params.project.id }
60
+ });
61
+ aggregateOfferIds = itemListElement.map((element) => element.id);
62
+ }
63
+ else {
64
+ const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
65
+ id: offerCatalogId,
66
+ project: { id: params.project.id }
67
+ });
68
+ aggregateOfferIds = itemListElement.map((element) => element.id);
69
+ }
54
70
  // カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
55
71
  yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
56
72
  includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
@@ -66,7 +82,12 @@ function syncOfferCatalog(params) {
66
82
  });
67
83
  }
68
84
  // 同期済記録を補完
69
- yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
85
+ if (params.isOfferCatalogItem) {
86
+ yield repos.offerCatalogItem.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
87
+ }
88
+ else {
89
+ yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
90
+ }
70
91
  break;
71
92
  default:
72
93
  // 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.329.0",
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.4"
120
+ "version": "21.9.0-alpha.6"
121
121
  }