@chevre/domain 20.10.0-alpha.0 → 20.11.0-alpha.0
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/importCategoryCodesFromCOA.ts +35 -0
- package/lib/chevre/repo/categoryCode.d.ts +4 -0
- package/lib/chevre/repo/categoryCode.js +33 -0
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +12 -0
- package/lib/chevre/service/offer/event/importFromCOA.js +70 -1
- package/lib/chevre/service/offer/event.d.ts +2 -2
- package/lib/chevre/service/offer/event.js +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +4 -1
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.js +63 -16
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA.js +20 -8
- package/package.json +2 -2
|
@@ -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:
|
|
10
|
+
acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
|
|
10
11
|
event: {
|
|
11
12
|
id: string;
|
|
12
13
|
};
|
|
@@ -15,6 +16,8 @@ declare function validateAcceptedOffers(params: {
|
|
|
15
16
|
id: string;
|
|
16
17
|
};
|
|
17
18
|
availablePaymentMethodTypes: factory.categoryCode.ICategoryCode[];
|
|
19
|
+
screeningEvent: Pick<factory.event.screeningEvent.IEvent, 'id' | 'superEvent'>;
|
|
20
|
+
seatingTypes: factory.categoryCode.ICategoryCode[];
|
|
18
21
|
}): (repos: {
|
|
19
22
|
offer: OfferRepo;
|
|
20
23
|
}) => Promise<{
|
|
@@ -50,7 +50,7 @@ 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;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
54
54
|
const acceptedOffer = params.acceptedOffer;
|
|
55
55
|
const availableUnitPriceOffer = params.availableUnitPriceOffer;
|
|
56
56
|
const { name, ticketInfo } = acceptedOffer;
|
|
@@ -130,29 +130,55 @@ 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;
|
|
133
134
|
categoryCodeChargeSpecs.push({
|
|
134
135
|
name: {
|
|
135
|
-
en:
|
|
136
|
-
|
|
136
|
+
en: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunNameEng) === 'string')
|
|
137
|
+
? kbnJoueihousiki.kubunNameEng
|
|
138
|
+
: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
|
|
139
|
+
ja: (typeof (kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunName) === 'string')
|
|
140
|
+
? `${kbnJoueihousiki.kubunName}加算料金`
|
|
141
|
+
: '加算単価'
|
|
137
142
|
},
|
|
138
143
|
price: ticketInfo.addPrice,
|
|
139
144
|
priceCurrency: factory.priceCurrency.JPY,
|
|
140
145
|
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
141
|
-
appliesToCategoryCode: [
|
|
146
|
+
appliesToCategoryCode: [{
|
|
147
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
148
|
+
typeOf: 'CategoryCode',
|
|
149
|
+
codeValue: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
|
|
150
|
+
inCodeSet: {
|
|
151
|
+
typeOf: 'CategoryCodeSet',
|
|
152
|
+
identifier: factory.categoryCode.CategorySetIdentifier.VideoFormatType
|
|
153
|
+
}
|
|
154
|
+
}],
|
|
142
155
|
valueAddedTaxIncluded: true
|
|
143
156
|
});
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
159
|
if (ticketInfo.spseatAdd1 > 0) {
|
|
160
|
+
const existingSeatingType = params.seatingTypes.find((seatingType) => seatingType.codeValue === ticketInfo.spseatKbn);
|
|
147
161
|
categoryCodeChargeSpecs.push({
|
|
148
162
|
name: {
|
|
149
|
-
en:
|
|
150
|
-
|
|
163
|
+
en: (typeof (existingSeatingType === null || existingSeatingType === void 0 ? void 0 : existingSeatingType.name.en) === 'string')
|
|
164
|
+
? `${existingSeatingType.name.en}`
|
|
165
|
+
: ticketInfo.spseatKbn,
|
|
166
|
+
ja: (typeof (existingSeatingType === null || existingSeatingType === void 0 ? void 0 : existingSeatingType.name.ja) === 'string')
|
|
167
|
+
? `${existingSeatingType.name.ja}加算料金`
|
|
168
|
+
: '特別席加算額'
|
|
151
169
|
},
|
|
152
170
|
price: ticketInfo.spseatAdd1,
|
|
153
171
|
priceCurrency: factory.priceCurrency.JPY,
|
|
154
172
|
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
155
|
-
appliesToCategoryCode: [
|
|
173
|
+
appliesToCategoryCode: [{
|
|
174
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
175
|
+
typeOf: 'CategoryCode',
|
|
176
|
+
codeValue: ticketInfo.spseatKbn,
|
|
177
|
+
inCodeSet: {
|
|
178
|
+
typeOf: 'CategoryCodeSet',
|
|
179
|
+
identifier: factory.categoryCode.CategorySetIdentifier.SeatingType
|
|
180
|
+
}
|
|
181
|
+
}],
|
|
156
182
|
valueAddedTaxIncluded: true
|
|
157
183
|
});
|
|
158
184
|
}
|
|
@@ -237,25 +263,46 @@ function validateAcceptedOffers(params) {
|
|
|
237
263
|
var _a, _b, _c, _d, _e, _f;
|
|
238
264
|
const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
|
|
239
265
|
if (availableUnitPriceOffer === undefined) {
|
|
240
|
-
throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.
|
|
241
|
-
}
|
|
242
|
-
const { additionalProperty, itemOffered, name, price, priceSpecification, ticketInfo } = acceptedOffer;
|
|
243
|
-
if (priceSpecification === undefined) {
|
|
244
|
-
throw new factory.errors.NotFound('priceSpecification');
|
|
266
|
+
throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.id} not found`);
|
|
245
267
|
}
|
|
268
|
+
const { additionalProperty, itemOffered, name, ticketInfo } = acceptedOffer;
|
|
269
|
+
// if (priceSpecification === undefined) {
|
|
270
|
+
// throw new factory.errors.NotFound('priceSpecification');
|
|
271
|
+
// }
|
|
246
272
|
// priceComponentを再生成(2023-03-14~)
|
|
247
273
|
const { priceComponent, eligibleMonetaryAmount } = createPriceComponent({
|
|
274
|
+
project: { id: params.project.id },
|
|
248
275
|
availablePaymentMethodTypes: params.availablePaymentMethodTypes,
|
|
276
|
+
seatingTypes: params.seatingTypes,
|
|
249
277
|
acceptedOffer,
|
|
250
|
-
availableUnitPriceOffer
|
|
278
|
+
availableUnitPriceOffer,
|
|
279
|
+
screeningEvent: params.screeningEvent
|
|
251
280
|
});
|
|
252
|
-
priceSpecification
|
|
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);
|
|
253
300
|
return Object.assign(Object.assign({ additionalProperty,
|
|
254
301
|
itemOffered,
|
|
255
302
|
name,
|
|
256
303
|
price,
|
|
257
|
-
priceSpecification,
|
|
258
|
-
|
|
304
|
+
priceSpecification, ticketInfo: Object.assign(Object.assign({}, ticketInfo), { salePrice // COAに渡す販売金額を上書き(2023-03-20~)
|
|
305
|
+
}),
|
|
259
306
|
// 以下属性については単価オファーから読む(2023-03-09~)
|
|
260
307
|
priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
|
|
261
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 {
|
|
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:
|
|
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:
|
|
77
|
+
acceptedOffer: IAcceptedOfferBeforeAuthorize4COA[];
|
|
78
78
|
event: {
|
|
79
79
|
id: string;
|
|
80
80
|
};
|
|
@@ -36,13 +36,19 @@ 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
|
+
});
|
|
39
43
|
// COA仮予約後にリクエストが来る前提
|
|
40
44
|
// validate acceptedOffer(2023-03-09~)
|
|
41
45
|
// const acceptedOffer = params.object.acceptedOffer;
|
|
42
46
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
43
47
|
object: params.object,
|
|
44
48
|
project: { id: transaction.project.id },
|
|
45
|
-
availablePaymentMethodTypes
|
|
49
|
+
availablePaymentMethodTypes,
|
|
50
|
+
screeningEvent,
|
|
51
|
+
seatingTypes
|
|
46
52
|
})(repos);
|
|
47
53
|
const updTmpReserveSeatArgs = params.result.requestBody;
|
|
48
54
|
const updTmpReserveSeatResult = params.result.responseBody;
|
|
@@ -148,19 +154,19 @@ function changeOffers(params) {
|
|
|
148
154
|
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
149
155
|
}
|
|
150
156
|
validate4changeOffer({ action: authorizeAction, object: params.object });
|
|
151
|
-
// 座席情報に関しては元のacceptedOffersで自動補完する(
|
|
157
|
+
// 座席情報に関しては元のacceptedOffersで自動補完する(リクエストでは正しく指定されないので注意)(2023-03-20~)
|
|
152
158
|
params.object.acceptedOffer = params.object.acceptedOffer.map((offer) => {
|
|
153
|
-
const
|
|
159
|
+
const originalAcceptedOfferBySeatNumber = authorizeAction.object.acceptedOffer.find((originalOffer) => {
|
|
154
160
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
155
|
-
return ((_d = (_c = (_b = (_a =
|
|
161
|
+
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)
|
|
156
162
|
=== ((_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)
|
|
157
|
-
&& ((_k = (_j = (_h =
|
|
163
|
+
&& ((_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)
|
|
158
164
|
=== ((_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);
|
|
159
165
|
});
|
|
160
|
-
if (
|
|
166
|
+
if (originalAcceptedOfferBySeatNumber === undefined) {
|
|
161
167
|
throw new factory.errors.Argument('offers', 'seatSection or seatNumber not matched.');
|
|
162
168
|
}
|
|
163
|
-
return Object.assign(Object.assign({}, offer), { ticketInfo: Object.assign(Object.assign({}, offer.ticketInfo), { spseatAdd1:
|
|
169
|
+
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 }) });
|
|
164
170
|
});
|
|
165
171
|
// イベント取得属性最適化(2023-01-23~)
|
|
166
172
|
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
@@ -170,13 +176,19 @@ function changeOffers(params) {
|
|
|
170
176
|
project: { id: { $eq: transaction.project.id } },
|
|
171
177
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
172
178
|
});
|
|
179
|
+
const seatingTypes = yield repos.categoryCode.search({
|
|
180
|
+
project: { id: { $eq: transaction.project.id } },
|
|
181
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
182
|
+
});
|
|
173
183
|
// COA仮予約後にリクエストが来る前提
|
|
174
184
|
// validate acceptedOffer(2023-03-09~)
|
|
175
185
|
// const acceptedOffer = params.object.acceptedOffer;
|
|
176
186
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
177
187
|
object: params.object,
|
|
178
188
|
project: { id: transaction.project.id },
|
|
179
|
-
availablePaymentMethodTypes
|
|
189
|
+
availablePaymentMethodTypes,
|
|
190
|
+
screeningEvent,
|
|
191
|
+
seatingTypes
|
|
180
192
|
})(repos);
|
|
181
193
|
// 供給情報と価格を変更してからDB更新
|
|
182
194
|
authorizeAction.object.acceptedOffer = acceptedOffers;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
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.
|
|
123
|
+
"version": "20.11.0-alpha.0"
|
|
124
124
|
}
|