@chevre/domain 20.10.0 → 20.11.0-alpha.1

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.
@@ -0,0 +1,35 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
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
+ const coaAuthClient = new chevre.COA.auth.RefreshToken({
10
+ endpoint: chevre.credentials.coa.endpoint,
11
+ refreshToken: chevre.credentials.coa.refreshToken
12
+ });
13
+
14
+ async function main() {
15
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
16
+
17
+ const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
18
+ const masterService = new chevre.COA.service.Master(
19
+ {
20
+ endpoint: chevre.credentials.coa.endpoint,
21
+ auth: coaAuthClient
22
+ },
23
+ { timeout: chevre.credentials.coa.timeout }
24
+ );
25
+
26
+ await chevre.service.offer.event.importCategoryCodesFromCOA({
27
+ project,
28
+ theaterCode: '120'
29
+ })({ categoryCode: categoryCodeRepo, masterService });
30
+ console.log('imported');
31
+ }
32
+
33
+ main()
34
+ .then(console.log)
35
+ .catch(console.error);
@@ -19,6 +19,10 @@ export declare class MongoRepository {
19
19
  id?: string;
20
20
  attributes: factory.categoryCode.ICategoryCode;
21
21
  }): Promise<factory.categoryCode.ICategoryCode>;
22
+ saveManyByCodeValue(params: {
23
+ attributes: factory.categoryCode.ICategoryCode;
24
+ upsert?: boolean;
25
+ }[]): Promise<void>;
22
26
  /**
23
27
  * 削除する
24
28
  */
@@ -217,6 +217,39 @@ class MongoRepository {
217
217
  return doc.toObject();
218
218
  });
219
219
  }
220
+ saveManyByCodeValue(params) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ const bulkWriteOps = [];
223
+ if (Array.isArray(params)) {
224
+ params.forEach((p) => {
225
+ const $set = Object.assign({}, p.attributes);
226
+ if (typeof $set.id === 'string') {
227
+ delete $set.id;
228
+ }
229
+ bulkWriteOps.push({
230
+ updateOne: {
231
+ filter: {
232
+ 'project.id': { $eq: p.attributes.project.id },
233
+ codeValue: { $eq: p.attributes.codeValue },
234
+ 'inCodeSet.identifier': {
235
+ $exists: true,
236
+ $eq: p.attributes.inCodeSet.identifier
237
+ }
238
+ },
239
+ update: {
240
+ $set
241
+ // $setOnInsert: {}
242
+ },
243
+ upsert: (p.upsert !== undefined) ? p.upsert : false
244
+ }
245
+ });
246
+ });
247
+ }
248
+ if (bulkWriteOps.length > 0) {
249
+ yield this.categoryCodeModel.bulkWrite(bulkWriteOps, { ordered: false });
250
+ }
251
+ });
252
+ }
220
253
  /**
221
254
  * 削除する
222
255
  */
@@ -11,3 +11,15 @@ export declare function importFromCOA(params: {
11
11
  offer: OfferRepo;
12
12
  masterService: COA.service.Master;
13
13
  }) => Promise<void>;
14
+ /**
15
+ * 区分をインポートする
16
+ */
17
+ export declare function importCategoryCodesFromCOA(params: {
18
+ project: {
19
+ id: string;
20
+ };
21
+ theaterCode: string;
22
+ }): (repos: {
23
+ categoryCode: CategoryCodeRepo;
24
+ masterService: COA.service.Master;
25
+ }) => Promise<void>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.importFromCOA = void 0;
12
+ exports.importCategoryCodesFromCOA = exports.importFromCOA = void 0;
13
13
  const factory = require("../../../factory");
14
14
  const factory_1 = require("./factory");
15
15
  function importFromCOA(params) {
@@ -62,3 +62,72 @@ function importFromCOA(params) {
62
62
  });
63
63
  }
64
64
  exports.importFromCOA = importFromCOA;
65
+ /**
66
+ * 区分をインポートする
67
+ */
68
+ function importCategoryCodesFromCOA(params) {
69
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
70
+ try {
71
+ const joueihousikiKubuns = yield repos.masterService.kubunName({
72
+ theaterCode: params.theaterCode,
73
+ kubunClass: '045'
74
+ });
75
+ const seatKubuns = yield repos.masterService.kubunName({
76
+ theaterCode: params.theaterCode,
77
+ kubunClass: '050'
78
+ });
79
+ const saveParams = [];
80
+ joueihousikiKubuns.forEach((kubun) => {
81
+ saveParams.push({
82
+ attributes: kubun2categoryCode({
83
+ kubun,
84
+ project: params.project,
85
+ inCodeSet: { identifier: factory.categoryCode.CategorySetIdentifier.VideoFormatType }
86
+ }),
87
+ upsert: true
88
+ });
89
+ });
90
+ seatKubuns.forEach((kubun) => {
91
+ saveParams.push({
92
+ attributes: kubun2categoryCode({
93
+ kubun,
94
+ project: params.project,
95
+ inCodeSet: { identifier: factory.categoryCode.CategorySetIdentifier.SeatingType }
96
+ }),
97
+ upsert: true
98
+ });
99
+ });
100
+ yield repos.categoryCode.saveManyByCodeValue(saveParams);
101
+ }
102
+ catch (error) {
103
+ let throwsError = true;
104
+ // "name": "COAServiceError",
105
+ // "code": 500,
106
+ // "status": "",
107
+ // "message": "ESOCKETTIMEDOUT",
108
+ if (error.name === 'COAServiceError') {
109
+ if (error.message === 'ESOCKETTIMEDOUT') {
110
+ throwsError = false;
111
+ }
112
+ }
113
+ if (throwsError) {
114
+ throw error;
115
+ }
116
+ }
117
+ });
118
+ }
119
+ exports.importCategoryCodesFromCOA = importCategoryCodesFromCOA;
120
+ function kubun2categoryCode(params) {
121
+ return {
122
+ additionalProperty: [
123
+ ...(typeof params.kubun.kubunAddPrice === 'number')
124
+ ? [{ name: 'kubunAddPrice', value: String(params.kubun.kubunAddPrice) }]
125
+ : []
126
+ ],
127
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
128
+ typeOf: 'CategoryCode',
129
+ codeValue: params.kubun.kubunCode,
130
+ inCodeSet: { identifier: params.inCodeSet.identifier, typeOf: 'CategoryCodeSet' },
131
+ name: Object.assign({ ja: String(params.kubun.kubunName) }, (typeof params.kubun.kubunNameEng === 'string') ? { en: params.kubun.kubunNameEng } : undefined)
132
+ };
133
+ }
@@ -1,6 +1,6 @@
1
1
  import { authorize } from './event/authorize';
2
2
  import { cancel } from './event/cancel';
3
- import { importFromCOA } from './event/importFromCOA';
3
+ import { importCategoryCodesFromCOA, importFromCOA } from './event/importFromCOA';
4
4
  import { searchEventTicketOffers } from './event/searchEventTicketOffers';
5
5
  import { voidTransaction } from './event/voidTransaction';
6
- export { authorize, cancel, importFromCOA, voidTransaction, searchEventTicketOffers };
6
+ export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers };
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.cancel = exports.authorize = void 0;
3
+ exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
4
4
  const authorize_1 = require("./event/authorize");
5
5
  Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
6
6
  const cancel_1 = require("./event/cancel");
7
7
  Object.defineProperty(exports, "cancel", { enumerable: true, get: function () { return cancel_1.cancel; } });
8
8
  const importFromCOA_1 = require("./event/importFromCOA");
9
+ Object.defineProperty(exports, "importCategoryCodesFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importCategoryCodesFromCOA; } });
9
10
  Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importFromCOA; } });
10
11
  const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
11
12
  Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
@@ -1,12 +1,13 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
3
3
  import { IAcceptedOffer4COA } from './factory';
4
+ export declare type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.seatReservation.IAcceptedOfferBeforeAuthorize4COA;
4
5
  /**
5
6
  * 受け入れらたオファーの内容を検証
6
7
  */
7
8
  declare function validateAcceptedOffers(params: {
8
9
  object: {
9
- acceptedOffer: IAcceptedOffer4COA[];
10
+ acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
10
11
  event: {
11
12
  id: string;
12
13
  };
@@ -14,8 +15,10 @@ declare function validateAcceptedOffers(params: {
14
15
  project: {
15
16
  id: string;
16
17
  };
17
- availablePaymentMethodTypes: factory.categoryCode.ICategoryCode[];
18
18
  screeningEvent: Pick<factory.event.screeningEvent.IEvent, 'id' | 'superEvent'>;
19
+ availablePaymentMethodTypes: factory.categoryCode.ICategoryCode[];
20
+ seatingTypes: factory.categoryCode.ICategoryCode[];
21
+ videoFormatTypes: factory.categoryCode.ICategoryCode[];
19
22
  }): (repos: {
20
23
  offer: OfferRepo;
21
24
  }) => Promise<{
@@ -37,7 +37,7 @@ function createAppliesToMovieTicket(params) {
37
37
  serviceType: params.ticketInfo.mvtkKbnKensyu,
38
38
  serviceOutput: { typeOf: availablePaymentMethod }
39
39
  },
40
- appliesToVideoFormat: params.ticketInfo.kbnEisyahousiki
40
+ appliesToVideoFormat: params.appliesToVideoFormat
41
41
  };
42
42
  appliesToMovieTicket = {
43
43
  typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
@@ -50,35 +50,35 @@ function createAppliesToMovieTicket(params) {
50
50
  }
51
51
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
52
52
  function createPriceComponent(params) {
53
- var _a, _b, _c, _d, _e, _f, _g, _h;
53
+ var _a, _b, _c, _d, _e, _f;
54
54
  const acceptedOffer = params.acceptedOffer;
55
55
  const availableUnitPriceOffer = params.availableUnitPriceOffer;
56
+ const kbnJoueihousiki = (_a = params.screeningEvent.superEvent.coaInfo) === null || _a === void 0 ? void 0 : _a.kbnJoueihousiki;
57
+ const appliesToVideoFormat = (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode) === 'string')
58
+ ? kbnJoueihousiki.kubunCode
59
+ : 'Default';
56
60
  const { name, ticketInfo } = acceptedOffer;
57
61
  // appliesToMovieTicket.serviceOutput.typeOfを自動補完(2023-03-13~)
58
62
  const { appliesToMovieTicket, movieTicketTypeChargePriceSpec } = createAppliesToMovieTicket({
59
63
  ticketInfo,
60
- availablePaymentMethodTypes: params.availablePaymentMethodTypes
64
+ availablePaymentMethodTypes: params.availablePaymentMethodTypes,
65
+ appliesToVideoFormat
61
66
  });
62
67
  let surfrockChargePriceSpec;
63
68
  let appliesToMovieTicket4surfrock;
64
69
  // appliesToSurfrockの指定があれば強制的にMovieTicket決済
65
70
  let eligibleMonetaryAmount;
66
- const surfrockIdentifier = (_b = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToSurfrock) === null || _b === void 0 ? void 0 : _b.identifier;
67
- const surfrockPaymentMethodType = (_e = (_d = (_c = acceptedOffer.priceSpecification) === null || _c === void 0 ? void 0 : _c.appliesToSurfrock) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.typeOf;
71
+ const surfrockIdentifier = (_c = (_b = acceptedOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.appliesToSurfrock) === null || _c === void 0 ? void 0 : _c.identifier;
72
+ const surfrockPaymentMethodType = (_f = (_e = (_d = acceptedOffer.priceSpecification) === null || _d === void 0 ? void 0 : _d.appliesToSurfrock) === null || _e === void 0 ? void 0 : _e.serviceOutput) === null || _f === void 0 ? void 0 : _f.typeOf;
68
73
  if (typeof surfrockIdentifier === 'string' && surfrockIdentifier.length > 0
69
74
  && typeof surfrockPaymentMethodType === 'string' && surfrockPaymentMethodType.length > 0) {
70
- // serviceTypeはticketCode
71
- const serviceType = (_g = (_f = availableUnitPriceOffer.additionalProperty) === null || _f === void 0 ? void 0 : _f.find((p) => p.name === 'ticketCode')) === null || _g === void 0 ? void 0 : _g.value;
72
- if (typeof serviceType !== 'string') {
73
- throw new factory.errors.NotFound('ticketCode of unitPriceOffer');
74
- }
75
75
  surfrockChargePriceSpec = {
76
76
  appliesToMovieTicket: {
77
77
  typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
78
78
  serviceOutput: { typeOf: surfrockPaymentMethodType },
79
- serviceType
79
+ serviceType: ticketInfo.ticketCode // serviceTypeはticketCode
80
80
  },
81
- appliesToVideoFormat: 'Default',
81
+ appliesToVideoFormat,
82
82
  name,
83
83
  price: 0,
84
84
  priceCurrency: factory.priceCurrency.JPY,
@@ -89,7 +89,7 @@ function createPriceComponent(params) {
89
89
  typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
90
90
  identifier: surfrockIdentifier,
91
91
  serviceOutput: { typeOf: surfrockPaymentMethodType },
92
- serviceType
92
+ serviceType: ticketInfo.ticketCode // serviceTypeはticketCode
93
93
  };
94
94
  }
95
95
  else {
@@ -130,13 +130,14 @@ function createPriceComponent(params) {
130
130
  // movieTicketTypeChargePriceSpecにaddPriceが含まれる場合は除く
131
131
  if (movieTicketTypeChargePriceSpec === undefined) {
132
132
  if (ticketInfo.addPrice > 0) {
133
- const kbnJoueihousiki = (_h = params.screeningEvent.superEvent.coaInfo) === null || _h === void 0 ? void 0 : _h.kbnJoueihousiki;
134
133
  categoryCodeChargeSpecs.push({
135
134
  name: {
136
135
  en: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunNameEng) === 'string')
137
136
  ? kbnJoueihousiki.kubunNameEng
138
- : factory.priceSpecificationType.CategoryCodeChargeSpecification,
139
- ja: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunName) === 'string') ? kbnJoueihousiki.kubunName : '加算単価'
137
+ : String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
138
+ ja: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunName) === 'string')
139
+ ? `${kbnJoueihousiki.kubunName}加算料金`
140
+ : '加算単価'
140
141
  },
141
142
  price: ticketInfo.addPrice,
142
143
  priceCurrency: factory.priceCurrency.JPY,
@@ -155,10 +156,15 @@ function createPriceComponent(params) {
155
156
  }
156
157
  }
157
158
  if (ticketInfo.spseatAdd1 > 0) {
159
+ const existingSeatingType = params.seatingTypes.find((seatingType) => seatingType.codeValue === ticketInfo.spseatKbn);
158
160
  categoryCodeChargeSpecs.push({
159
161
  name: {
160
- en: factory.priceSpecificationType.CategoryCodeChargeSpecification,
161
- ja: '特別席加算額'
162
+ en: (typeof (existingSeatingType === null || existingSeatingType === void 0 ? void 0 : existingSeatingType.name.en) === 'string')
163
+ ? `${existingSeatingType.name.en}`
164
+ : ticketInfo.spseatKbn,
165
+ ja: (typeof (existingSeatingType === null || existingSeatingType === void 0 ? void 0 : existingSeatingType.name.ja) === 'string')
166
+ ? `${existingSeatingType.name.ja}加算料金`
167
+ : '特別席加算額'
162
168
  },
163
169
  price: ticketInfo.spseatAdd1,
164
170
  priceCurrency: factory.priceCurrency.JPY,
@@ -256,27 +262,47 @@ function validateAcceptedOffers(params) {
256
262
  var _a, _b, _c, _d, _e, _f;
257
263
  const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
258
264
  if (availableUnitPriceOffer === undefined) {
259
- throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.identifier} not found`);
260
- }
261
- const { additionalProperty, itemOffered, name, price, priceSpecification, ticketInfo } = acceptedOffer;
262
- if (priceSpecification === undefined) {
263
- throw new factory.errors.NotFound('priceSpecification');
265
+ throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.id} not found`);
264
266
  }
267
+ const { additionalProperty, itemOffered, name, ticketInfo } = acceptedOffer;
268
+ // if (priceSpecification === undefined) {
269
+ // throw new factory.errors.NotFound('priceSpecification');
270
+ // }
265
271
  // priceComponentを再生成(2023-03-14~)
266
272
  const { priceComponent, eligibleMonetaryAmount } = createPriceComponent({
267
273
  project: { id: params.project.id },
268
274
  availablePaymentMethodTypes: params.availablePaymentMethodTypes,
275
+ seatingTypes: params.seatingTypes,
276
+ videoFormatTypes: params.videoFormatTypes,
269
277
  acceptedOffer,
270
278
  availableUnitPriceOffer,
271
279
  screeningEvent: params.screeningEvent
272
280
  });
273
- priceSpecification.priceComponent = priceComponent;
281
+ const priceSpecification = {
282
+ typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
283
+ priceCurrency: factory.priceCurrency.JPY,
284
+ priceComponent,
285
+ valueAddedTaxIncluded: true
286
+ };
287
+ // 実際の発生金額を算出
288
+ const price = [
289
+ ticketInfo.salesTicketSalePrice,
290
+ ticketInfo.addGlasses,
291
+ ticketInfo.spseatAdd1,
292
+ ticketInfo.spseatAdd2
293
+ ].reduce((a, b) => a + b, 0);
294
+ // COAに渡す販売金額については、特別席加算額は興収部分のみ加算
295
+ const salePrice = [
296
+ ticketInfo.salesTicketSalePrice,
297
+ ticketInfo.addGlasses,
298
+ ticketInfo.spseatAdd1
299
+ ].reduce((a, b) => a + b, 0);
274
300
  return Object.assign(Object.assign({ additionalProperty,
275
301
  itemOffered,
276
302
  name,
277
303
  price,
278
- priceSpecification,
279
- ticketInfo,
304
+ priceSpecification, ticketInfo: Object.assign(Object.assign({}, ticketInfo), { salePrice // COAに渡す販売金額を上書き(2023-03-20~)
305
+ }),
280
306
  // 以下属性については単価オファーから読む(2023-03-09~)
281
307
  priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
282
308
  // tslint:disable-next-line:no-suspicious-comment
@@ -3,7 +3,7 @@ import { MongoRepository as CategoryCodeRepo } from '../../repo/categoryCode';
3
3
  import { MongoRepository as EventRepo } from '../../repo/event';
4
4
  import { MongoRepository as OfferRepo } from '../../repo/offer';
5
5
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
6
- import { IAcceptedOffer4COA } from './eventServiceByCOA/factory';
6
+ import { IAcceptedOfferBeforeAuthorize4COA } from './eventServiceByCOA/validateAcceptedOffers';
7
7
  import * as factory from '../../factory';
8
8
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
9
9
  interface IAuthorizeRepos {
@@ -20,7 +20,7 @@ export declare type IAuthorizeOfferAction = factory.action.authorize.offer.seatR
20
20
  */
21
21
  export declare function authorize(params: {
22
22
  object: {
23
- acceptedOffer: IAcceptedOffer4COA[];
23
+ acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
24
24
  event: {
25
25
  id: string;
26
26
  };
@@ -74,7 +74,7 @@ export declare function cancel(params: {
74
74
  export declare function changeOffers(params: {
75
75
  id: string;
76
76
  object: {
77
- acceptedOffer: IAcceptedOffer4COA[];
77
+ acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
78
78
  event: {
79
79
  id: string;
80
80
  };
@@ -36,14 +36,22 @@ function authorize(params) {
36
36
  project: { id: { $eq: transaction.project.id } },
37
37
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
38
38
  });
39
+ const seatingTypes = yield repos.categoryCode.search({
40
+ project: { id: { $eq: transaction.project.id } },
41
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
42
+ });
43
+ const videoFormatTypes = yield repos.categoryCode.search({
44
+ project: { id: { $eq: transaction.project.id } },
45
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
46
+ });
39
47
  // COA仮予約後にリクエストが来る前提
40
- // validate acceptedOffer(2023-03-09~)
41
- // const acceptedOffer = params.object.acceptedOffer;
42
48
  const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
43
49
  object: params.object,
44
50
  project: { id: transaction.project.id },
51
+ screeningEvent,
45
52
  availablePaymentMethodTypes,
46
- screeningEvent
53
+ seatingTypes,
54
+ videoFormatTypes
47
55
  })(repos);
48
56
  const updTmpReserveSeatArgs = params.result.requestBody;
49
57
  const updTmpReserveSeatResult = params.result.responseBody;
@@ -149,6 +157,20 @@ function changeOffers(params) {
149
157
  throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
150
158
  }
151
159
  validate4changeOffer({ action: authorizeAction, object: params.object });
160
+ // 座席情報に関しては元のacceptedOffersで自動補完する(リクエストでは正しく指定されないので注意)(2023-03-20~)
161
+ params.object.acceptedOffer = params.object.acceptedOffer.map((offer) => {
162
+ const originalAcceptedOfferBySeatNumber = authorizeAction.object.acceptedOffer.find((originalOffer) => {
163
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
164
+ return ((_d = (_c = (_b = (_a = originalOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat) === null || _d === void 0 ? void 0 : _d.seatSection)
165
+ === ((_g = (_f = (_e = offer.itemOffered.serviceOutput) === null || _e === void 0 ? void 0 : _e.reservedTicket) === null || _f === void 0 ? void 0 : _f.ticketedSeat) === null || _g === void 0 ? void 0 : _g.seatSection)
166
+ && ((_k = (_j = (_h = originalOffer.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservedTicket) === null || _j === void 0 ? void 0 : _j.ticketedSeat) === null || _k === void 0 ? void 0 : _k.seatNumber)
167
+ === ((_o = (_m = (_l = offer.itemOffered.serviceOutput) === null || _l === void 0 ? void 0 : _l.reservedTicket) === null || _m === void 0 ? void 0 : _m.ticketedSeat) === null || _o === void 0 ? void 0 : _o.seatNumber);
168
+ });
169
+ if (originalAcceptedOfferBySeatNumber === undefined) {
170
+ throw new factory.errors.Argument('offers', 'seatSection or seatNumber not matched.');
171
+ }
172
+ return Object.assign(Object.assign({}, offer), { ticketInfo: Object.assign(Object.assign({}, offer.ticketInfo), { spseatAdd1: originalAcceptedOfferBySeatNumber.ticketInfo.spseatAdd1, spseatAdd2: originalAcceptedOfferBySeatNumber.ticketInfo.spseatAdd2, spseatKbn: originalAcceptedOfferBySeatNumber.ticketInfo.spseatKbn }) });
173
+ });
152
174
  // イベント取得属性最適化(2023-01-23~)
153
175
  const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
154
176
  id: params.object.event.id
@@ -157,14 +179,22 @@ function changeOffers(params) {
157
179
  project: { id: { $eq: transaction.project.id } },
158
180
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
159
181
  });
182
+ const seatingTypes = yield repos.categoryCode.search({
183
+ project: { id: { $eq: transaction.project.id } },
184
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
185
+ });
186
+ const videoFormatTypes = yield repos.categoryCode.search({
187
+ project: { id: { $eq: transaction.project.id } },
188
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
189
+ });
160
190
  // COA仮予約後にリクエストが来る前提
161
- // validate acceptedOffer(2023-03-09~)
162
- // const acceptedOffer = params.object.acceptedOffer;
163
191
  const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
164
192
  object: params.object,
165
193
  project: { id: transaction.project.id },
194
+ screeningEvent,
166
195
  availablePaymentMethodTypes,
167
- screeningEvent
196
+ seatingTypes,
197
+ videoFormatTypes
168
198
  })(repos);
169
199
  // 供給情報と価格を変更してからDB更新
170
200
  authorizeAction.object.acceptedOffer = acceptedOffers;
@@ -11,9 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  var _a;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.createConfirmRegisterServiceActionObjectByOrder = exports.createConfirmReservationActionObject4COAByOrder = exports.createConfirmReservationActionObject4ChevreByOrder = exports.createDeleteTasks = exports.createInformTasks = exports.getOrderWithToken = void 0;
14
- /**
15
- * 注文ステータス変更時処理
16
- */
17
14
  const google_libphonenumber_1 = require("google-libphonenumber");
18
15
  const jwt = require("jsonwebtoken");
19
16
  const moment = require("moment");
@@ -246,10 +243,18 @@ function createConfirmReservationActionObject4COAByOrder(params) {
246
243
  throw new factory.errors.NotFound('reservedTicket.coaReserveAmount');
247
244
  }
248
245
  const listTicket = coaReservations.map((r) => {
249
- if (r.reservedTicket.coaTicketInfo === undefined) {
246
+ var _a;
247
+ if (typeof ((_a = r.reservedTicket.coaTicketInfo) === null || _a === void 0 ? void 0 : _a.ticketCode) !== 'string') {
250
248
  throw new factory.errors.NotFound('reservedTicket.coaTicketInfo');
251
249
  }
252
- return r.reservedTicket.coaTicketInfo;
250
+ // 冗長な属性を排除(2023-03-20~)
251
+ const { ticketCode, stdPrice, addPrice, spseatAdd1, spseatAdd2, disPrice, salePrice, mvtkAppPrice, ticketCount, spseatKbn, seatNum, addGlasses, kbnEisyahousiki, mvtkNum, mvtkKbnDenshiken, mvtkKbnMaeuriken, mvtkKbnKensyu, mvtkSalesPrice, kbnMgtk } = r.reservedTicket.coaTicketInfo;
252
+ return {
253
+ ticketCode, stdPrice, addPrice, spseatAdd1, spseatAdd2,
254
+ disPrice, salePrice, mvtkAppPrice, ticketCount, spseatKbn,
255
+ seatNum, addGlasses, kbnEisyahousiki, mvtkNum, mvtkKbnDenshiken,
256
+ mvtkKbnMaeuriken, mvtkKbnKensyu, mvtkSalesPrice, kbnMgtk
257
+ };
253
258
  });
254
259
  return {
255
260
  theaterCode: reservationForCOAInfo.theaterCode,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.303.0",
12
+ "@chevre/factory": "4.304.0",
13
13
  "@cinerino/sdk": "3.150.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.10.0"
123
+ "version": "20.11.0-alpha.1"
124
124
  }