@chevre/domain 21.10.0 → 21.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/offer/searchAllByIdsAndOfferCatalogId.ts +31 -0
- package/example/src/chevre/{searchEventTicketOffers.ts → offer/searchEventTicketOffers.ts} +2 -1
- package/example/src/chevre/{searchOffersByCatalog.ts → offer/searchOffersByCatalog.ts} +2 -3
- package/lib/chevre/repo/offer.d.ts +9 -7
- package/lib/chevre/repo/offer.js +59 -24
- package/lib/chevre/service/assetTransaction/registerService.js +1 -0
- package/lib/chevre/service/assetTransaction/reserve.js +2 -1
- package/lib/chevre/service/offer/event/authorize.js +1 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +25 -14
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +3 -0
- package/lib/chevre/service/offer/product/searchProductOffers.js +20 -10
- package/lib/chevre/service/offer/product.d.ts +3 -0
- package/lib/chevre/service/offer/product.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const offers = await offerRepo.searchAllByIdsAndOfferCatalogId({
|
|
13
|
+
ids: ['xx', 'xxx', '1001', '901'],
|
|
14
|
+
includedInDataCatalog: {
|
|
15
|
+
id: ['0001'],
|
|
16
|
+
isOfferCatalogItem: false
|
|
17
|
+
// id: ['6509262f69b07dde13c708eb', '6509262f69b07dde13c708ec', '6508dd91584bb60769914d2b', '651360e04df434b49114e4bb'],
|
|
18
|
+
// isOfferCatalogItem: true
|
|
19
|
+
},
|
|
20
|
+
excludeAppliesToMovieTicket: false
|
|
21
|
+
});
|
|
22
|
+
// console.log(offers);
|
|
23
|
+
console.log(offers.map((offer) => {
|
|
24
|
+
return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${offer.offerIndex}`;
|
|
25
|
+
}));
|
|
26
|
+
console.log(offers.length);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main()
|
|
30
|
+
.then(console.log)
|
|
31
|
+
.catch(console.error);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
import * as redis from 'redis';
|
|
4
4
|
|
|
5
|
-
import { chevre } from '
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
7
|
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
8
8
|
|
|
@@ -28,6 +28,7 @@ async function main() {
|
|
|
28
28
|
const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
|
|
29
29
|
event: { id: 'ale6qiedq' },
|
|
30
30
|
onlyValid: true,
|
|
31
|
+
includedInDataCatalog: { id: '' },
|
|
31
32
|
priceSpecification: {},
|
|
32
33
|
validateOfferRateLimit: true,
|
|
33
34
|
addSortIndex: true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// import * as redis from 'redis';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
|
-
import { chevre } from '
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
7
|
async function main() {
|
|
8
8
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
@@ -13,7 +13,7 @@ async function main() {
|
|
|
13
13
|
limit: 10,
|
|
14
14
|
page: 1,
|
|
15
15
|
// ids: ['xx', 'xxx', '1001', '901'],
|
|
16
|
-
|
|
16
|
+
offerCatalog: {
|
|
17
17
|
id: '0001',
|
|
18
18
|
isOfferCatalogItem: false
|
|
19
19
|
},
|
|
@@ -33,7 +33,6 @@ async function main() {
|
|
|
33
33
|
return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${offer.offerIndex} ${sortIndex}`;
|
|
34
34
|
}));
|
|
35
35
|
console.log(offers.length);
|
|
36
|
-
console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
main()
|
|
@@ -48,11 +48,11 @@ export declare class MongoRepository {
|
|
|
48
48
|
* 指定したIDの単価オファーだけ取得
|
|
49
49
|
*/
|
|
50
50
|
ids: string[];
|
|
51
|
-
|
|
51
|
+
includedInDataCatalog: {
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* オファー記載のカタログID(複数対応)
|
|
54
54
|
*/
|
|
55
|
-
id: string;
|
|
55
|
+
id: string[];
|
|
56
56
|
isOfferCatalogItem: boolean;
|
|
57
57
|
};
|
|
58
58
|
availableAtOrFrom?: {
|
|
@@ -62,15 +62,13 @@ export declare class MongoRepository {
|
|
|
62
62
|
excludeAppliesToMovieTicket: boolean;
|
|
63
63
|
onlyValid?: boolean;
|
|
64
64
|
projection?: IProjection;
|
|
65
|
-
}): Promise<
|
|
66
|
-
offers: IUnitPriceOfferFromAggregateOffer[];
|
|
67
|
-
}>;
|
|
65
|
+
}): Promise<IUnitPriceOfferFromAggregateOffer[]>;
|
|
68
66
|
/**
|
|
69
67
|
* カタログに含まれるオファーを検索する(カタログ内ソートは保証しない)
|
|
70
68
|
* カタログ内ソートインデックスはsortedOfferIdsで判断する
|
|
71
69
|
*/
|
|
72
70
|
searchByOfferCatalogIdWithSortIndex(params: {
|
|
73
|
-
|
|
71
|
+
offerCatalog: {
|
|
74
72
|
/**
|
|
75
73
|
* サブカタログID
|
|
76
74
|
*/
|
|
@@ -166,5 +164,9 @@ export declare class MongoRepository {
|
|
|
166
164
|
* サブカタログから集計オファーIDリストを検索する
|
|
167
165
|
*/
|
|
168
166
|
private searchAggregateOfferIdsBySubOfferCatalog;
|
|
167
|
+
/**
|
|
168
|
+
* 複数サブカタログから集計オファーIDリストを検索する
|
|
169
|
+
*/
|
|
170
|
+
private searchAggregateOfferIdsBySubOfferCatalogs;
|
|
169
171
|
}
|
|
170
172
|
export {};
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -492,17 +492,17 @@ class MongoRepository {
|
|
|
492
492
|
if (aggregateOfferIds.length === 0) {
|
|
493
493
|
throw new factory.errors.NotFound(factory.offerType.AggregateOffer);
|
|
494
494
|
}
|
|
495
|
-
const
|
|
496
|
-
id: params.
|
|
497
|
-
isOfferCatalogItem: params.
|
|
495
|
+
const aggregateOfferIdsInDataCatalog = yield this.searchAggregateOfferIdsBySubOfferCatalogs({
|
|
496
|
+
id: params.includedInDataCatalog.id,
|
|
497
|
+
isOfferCatalogItem: params.includedInDataCatalog.isOfferCatalogItem,
|
|
498
498
|
itemListElementIds: aggregateOfferIds
|
|
499
499
|
});
|
|
500
500
|
let offers = [];
|
|
501
|
-
if (
|
|
502
|
-
debug('searchAllByIdsAndOfferCatalogId:searching offers...,
|
|
501
|
+
if (aggregateOfferIdsInDataCatalog.length > 0) {
|
|
502
|
+
debug('searchAllByIdsAndOfferCatalogId:searching offers...,aggregateOfferIdsInDataCatalog:', aggregateOfferIdsInDataCatalog, 'ids:', params.ids);
|
|
503
503
|
const searchOffersConditions = Object.assign({
|
|
504
504
|
// aggregateOffer.idで検索する(2023-09-09~)
|
|
505
|
-
parentOffer: { id: { $in:
|
|
505
|
+
parentOffer: { id: { $in: aggregateOfferIdsInDataCatalog } }, id: { $in: params.ids }, priceSpecification: {
|
|
506
506
|
appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
507
507
|
? {
|
|
508
508
|
serviceOutput: {
|
|
@@ -516,17 +516,10 @@ class MongoRepository {
|
|
|
516
516
|
: undefined)
|
|
517
517
|
}, onlyValid: params.onlyValid === true }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
518
518
|
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
|
|
519
|
-
: undefined
|
|
520
|
-
// ...(typeof params.limit === 'number' && typeof params.page === 'number')
|
|
521
|
-
// // 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
|
|
522
|
-
// ? { sort: { identifier: factory.sortType.Ascending } }
|
|
523
|
-
// : undefined,
|
|
524
|
-
// ...(typeof params.limit === 'number') ? { limit: params.limit } : undefined,
|
|
525
|
-
// ...(typeof params.page === 'number') ? { page: params.page } : undefined
|
|
526
|
-
);
|
|
519
|
+
: undefined);
|
|
527
520
|
offers = yield this.search(searchOffersConditions, params.projection);
|
|
528
521
|
}
|
|
529
|
-
return
|
|
522
|
+
return offers;
|
|
530
523
|
});
|
|
531
524
|
}
|
|
532
525
|
/**
|
|
@@ -537,8 +530,8 @@ class MongoRepository {
|
|
|
537
530
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
538
531
|
return __awaiter(this, void 0, void 0, function* () {
|
|
539
532
|
const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
|
|
540
|
-
id: params.
|
|
541
|
-
isOfferCatalogItem: params.
|
|
533
|
+
id: params.offerCatalog.id,
|
|
534
|
+
isOfferCatalogItem: params.offerCatalog.isOfferCatalogItem
|
|
542
535
|
});
|
|
543
536
|
let offers = [];
|
|
544
537
|
if (sortedOfferIds.length > 0) {
|
|
@@ -562,7 +555,7 @@ class MongoRepository {
|
|
|
562
555
|
: undefined)
|
|
563
556
|
};
|
|
564
557
|
const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ priceSpecification: priceSpecificationConditions, onlyValid: params.onlyValid === true }, (params.useIncludeInDataCatalog)
|
|
565
|
-
? { includedInDataCatalog: { id: { $in: [params.
|
|
558
|
+
? { includedInDataCatalog: { id: { $in: [params.offerCatalog.id] } } }
|
|
566
559
|
: { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_h = params.availableAtOrFrom) === null || _h === void 0 ? void 0 : _h.id) === 'string')
|
|
567
560
|
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
|
|
568
561
|
: undefined), (typeof params.limit === 'number' && typeof params.page === 'number')
|
|
@@ -891,9 +884,6 @@ class MongoRepository {
|
|
|
891
884
|
let itemListElements;
|
|
892
885
|
if (params.isOfferCatalogItem) {
|
|
893
886
|
const matchStages = [{ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id) } } }]; // ObjectIdなので注意
|
|
894
|
-
if (Array.isArray(params.itemListElementIds)) {
|
|
895
|
-
matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
|
|
896
|
-
}
|
|
897
887
|
itemListElements = yield this.offerCatalogItemModel.aggregate([
|
|
898
888
|
{ $unwind: '$itemListElement' },
|
|
899
889
|
...matchStages,
|
|
@@ -908,9 +898,6 @@ class MongoRepository {
|
|
|
908
898
|
}
|
|
909
899
|
else {
|
|
910
900
|
const matchStages = [{ $match: { _id: { $eq: params.id } } }];
|
|
911
|
-
if (Array.isArray(params.itemListElementIds)) {
|
|
912
|
-
matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
|
|
913
|
-
}
|
|
914
901
|
itemListElements = yield this.offerCatalogModel.aggregate([
|
|
915
902
|
{ $unwind: '$itemListElement' },
|
|
916
903
|
...matchStages,
|
|
@@ -928,5 +915,53 @@ class MongoRepository {
|
|
|
928
915
|
: [];
|
|
929
916
|
});
|
|
930
917
|
}
|
|
918
|
+
/**
|
|
919
|
+
* 複数サブカタログから集計オファーIDリストを検索する
|
|
920
|
+
*/
|
|
921
|
+
searchAggregateOfferIdsBySubOfferCatalogs(params) {
|
|
922
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
923
|
+
if (!Array.isArray(params.itemListElementIds) || params.itemListElementIds.length === 0) {
|
|
924
|
+
throw new factory.errors.ArgumentNull('itemListElementIds');
|
|
925
|
+
}
|
|
926
|
+
let itemListElements;
|
|
927
|
+
if (params.isOfferCatalogItem) {
|
|
928
|
+
const matchStages = [
|
|
929
|
+
{ $match: { _id: { $in: params.id.map((id) => new mongoose_1.Types.ObjectId(id)) } } },
|
|
930
|
+
{ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } }
|
|
931
|
+
];
|
|
932
|
+
itemListElements = yield this.offerCatalogItemModel.aggregate([
|
|
933
|
+
{ $unwind: '$itemListElement' },
|
|
934
|
+
...matchStages,
|
|
935
|
+
{
|
|
936
|
+
$group: { _id: '$itemListElement.id' }
|
|
937
|
+
}
|
|
938
|
+
])
|
|
939
|
+
.exec();
|
|
940
|
+
}
|
|
941
|
+
else {
|
|
942
|
+
// 1カタログしかありえないはず
|
|
943
|
+
if (params.id.length !== 1) {
|
|
944
|
+
throw new factory.errors.Argument('id', 'length must be 1');
|
|
945
|
+
}
|
|
946
|
+
const matchStages = [
|
|
947
|
+
{ $match: { _id: { $in: params.id } } },
|
|
948
|
+
{ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } }
|
|
949
|
+
];
|
|
950
|
+
itemListElements = yield this.offerCatalogModel.aggregate([
|
|
951
|
+
{ $unwind: '$itemListElement' },
|
|
952
|
+
...matchStages,
|
|
953
|
+
{
|
|
954
|
+
$project: {
|
|
955
|
+
_id: '$itemListElement.id'
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
])
|
|
959
|
+
.exec();
|
|
960
|
+
}
|
|
961
|
+
return (Array.isArray(itemListElements))
|
|
962
|
+
? itemListElements.map((element) => element._id)
|
|
963
|
+
: [];
|
|
964
|
+
});
|
|
965
|
+
}
|
|
931
966
|
}
|
|
932
967
|
exports.MongoRepository = MongoRepository;
|
|
@@ -94,6 +94,7 @@ function createTransactionObject(params) {
|
|
|
94
94
|
ids: params.acceptedOffers.map((o) => o.id),
|
|
95
95
|
itemOffered: { id: String(params.product.id) },
|
|
96
96
|
onlyValid: true,
|
|
97
|
+
includedInDataCatalog: { id: '' },
|
|
97
98
|
addSortIndex: false,
|
|
98
99
|
useIncludeInDataCatalog: false
|
|
99
100
|
})(repos);
|
|
@@ -119,6 +119,7 @@ function addReservations(params) {
|
|
|
119
119
|
// 対応アプリケーション条件追加(2023-01-27~)
|
|
120
120
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
|
|
121
121
|
priceSpecification: {},
|
|
122
|
+
includedInDataCatalog: { id: '' },
|
|
122
123
|
onlyValid: true,
|
|
123
124
|
addSortIndex: false,
|
|
124
125
|
validateOfferRateLimit: true,
|
|
@@ -478,7 +479,7 @@ function searchAvailableAddOns(params) {
|
|
|
478
479
|
if (Array.isArray(params.ticketOffer.addOn)) {
|
|
479
480
|
const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
|
|
480
481
|
for (const addOnProductId of addOnProductIds) {
|
|
481
|
-
const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
482
|
+
const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, includedInDataCatalog: { id: '' }, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
482
483
|
? { availableAt: { id: params.availableAtOrFrom.id } }
|
|
483
484
|
: undefined))(repos);
|
|
484
485
|
availableAddOns.push(...offers.map((o) => {
|
|
@@ -41,6 +41,9 @@ declare function searchEventTicketOffers(params: {
|
|
|
41
41
|
*/
|
|
42
42
|
onlyValid: boolean;
|
|
43
43
|
priceSpecification: Pick<factory.unitPriceOffer.IPriceSpecificationSearchConditions, 'appliesToMovieTicket'>;
|
|
44
|
+
includedInDataCatalog: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
44
47
|
limit?: number;
|
|
45
48
|
page?: number;
|
|
46
49
|
addSortIndex: boolean;
|
|
@@ -16,12 +16,11 @@ const factory_1 = require("../factory");
|
|
|
16
16
|
function searchTicketOffersByItemOffered(params) {
|
|
17
17
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
var _a, _b, _c, _d, _e;
|
|
19
|
+
let eventService;
|
|
19
20
|
let catalogId;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
catalogId = eventService.hasOfferCatalog.id;
|
|
24
|
-
}
|
|
21
|
+
eventService = yield repos.product.findById({ id: (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id }, ['hasOfferCatalog', 'project'], []);
|
|
22
|
+
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
23
|
+
catalogId = eventService.hasOfferCatalog.id;
|
|
25
24
|
}
|
|
26
25
|
if (typeof catalogId !== 'string') {
|
|
27
26
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
@@ -39,9 +38,12 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
39
38
|
if (Array.isArray(params.ids)) {
|
|
40
39
|
throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
41
40
|
}
|
|
41
|
+
// 明示的にカタログ指定可能にする
|
|
42
|
+
if (typeof ((_c = params.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
|
|
43
|
+
subOfferCatalogId = params.includedInDataCatalog.id;
|
|
44
|
+
}
|
|
42
45
|
const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
43
|
-
|
|
44
|
-
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
46
|
+
offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
45
47
|
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
46
48
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
47
49
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
@@ -54,21 +56,28 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
54
56
|
return { availableOffers: offers, sortedOfferIds };
|
|
55
57
|
}
|
|
56
58
|
else {
|
|
57
|
-
//
|
|
59
|
+
// id指定必須(2023-09-13~)
|
|
58
60
|
if (!Array.isArray(params.ids)) {
|
|
59
61
|
throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
let includedInDataCatalogIds = [subOfferCatalogId];
|
|
64
|
+
if (isOfferCatalogItem) {
|
|
65
|
+
// 複数カタログ対応(2023-09-27~)
|
|
66
|
+
const offerCatalogItems = yield repos.offerCatalog.findItemListElementById({
|
|
67
|
+
id: catalogId,
|
|
68
|
+
project: { id: eventService.project.id }
|
|
69
|
+
});
|
|
70
|
+
includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
|
|
71
|
+
}
|
|
72
|
+
const availableOffers = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
62
73
|
ids: params.ids,
|
|
63
|
-
|
|
74
|
+
includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
|
|
64
75
|
availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
|
|
65
76
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
66
77
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
67
78
|
onlyValid: params.onlyValid === true
|
|
68
|
-
// limit: params.limit,
|
|
69
|
-
// page: params.page
|
|
70
79
|
});
|
|
71
|
-
return { availableOffers
|
|
80
|
+
return { availableOffers };
|
|
72
81
|
}
|
|
73
82
|
});
|
|
74
83
|
}
|
|
@@ -108,12 +117,13 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
108
117
|
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
109
118
|
const eventOffers = event.offers;
|
|
110
119
|
const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
|
|
111
|
-
itemOffered: { id: (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id },
|
|
120
|
+
itemOffered: { id: String((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) },
|
|
112
121
|
ids: params.ids,
|
|
113
122
|
store: params.store,
|
|
114
123
|
limit: params.limit,
|
|
115
124
|
page: params.page,
|
|
116
125
|
onlyValid: params.onlyValid,
|
|
126
|
+
includedInDataCatalog: params.includedInDataCatalog,
|
|
117
127
|
unacceptedPaymentMethod,
|
|
118
128
|
excludeAppliesToMovieTicket,
|
|
119
129
|
priceSpecification: params.priceSpecification,
|
|
@@ -279,6 +289,7 @@ function searchEventTicketOffers(params) {
|
|
|
279
289
|
event,
|
|
280
290
|
store: params.store,
|
|
281
291
|
priceSpecification: params.priceSpecification,
|
|
292
|
+
includedInDataCatalog: params.includedInDataCatalog,
|
|
282
293
|
limit: params.limit,
|
|
283
294
|
page: params.page,
|
|
284
295
|
addSortIndex: params.addSortIndex,
|
|
@@ -15,12 +15,12 @@ const settings_1 = require("../../../settings");
|
|
|
15
15
|
/**
|
|
16
16
|
* プロダクトオファーを検索する
|
|
17
17
|
*/
|
|
18
|
-
// tslint:disable-next-line:max-func-body-length
|
|
19
18
|
function searchProductOffers(params) {
|
|
19
|
+
// tslint:disable-next-line:max-func-body-length
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
22
22
|
// プロダクト検索
|
|
23
|
-
const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id }, ['hasOfferCatalog'], []);
|
|
23
|
+
const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id }, ['hasOfferCatalog', 'project'], []);
|
|
24
24
|
const offerCatalogId = (_a = productWithOffers.hasOfferCatalog) === null || _a === void 0 ? void 0 : _a.id;
|
|
25
25
|
if (typeof offerCatalogId !== 'string') {
|
|
26
26
|
return [];
|
|
@@ -40,9 +40,12 @@ function searchProductOffers(params) {
|
|
|
40
40
|
if (Array.isArray(params.ids)) {
|
|
41
41
|
throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
42
42
|
}
|
|
43
|
+
// 明示的にカタログ指定可能にする
|
|
44
|
+
if (typeof ((_b = params.includedInDataCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
|
|
45
|
+
subOfferCatalogId = params.includedInDataCatalog.id;
|
|
46
|
+
}
|
|
43
47
|
const searchByOfferCatalogIdResult = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
44
|
-
|
|
45
|
-
subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
48
|
+
offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
46
49
|
excludeAppliesToMovieTicket: false,
|
|
47
50
|
priceSpecification: {},
|
|
48
51
|
limit: params.limit,
|
|
@@ -55,20 +58,27 @@ function searchProductOffers(params) {
|
|
|
55
58
|
sortedOfferIds = searchByOfferCatalogIdResult.sortedOfferIds;
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
|
-
//
|
|
61
|
+
// id指定必須(2023-09-13~)
|
|
59
62
|
if (!Array.isArray(params.ids)) {
|
|
60
63
|
throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
|
|
61
64
|
}
|
|
65
|
+
let includedInDataCatalogIds = [subOfferCatalogId];
|
|
66
|
+
if (isOfferCatalogItem) {
|
|
67
|
+
// 複数カタログ対応(2023-09-27~)
|
|
68
|
+
const offerCatalogItems = yield repos.offerCatalog.findItemListElementById({
|
|
69
|
+
id: offerCatalogId,
|
|
70
|
+
project: { id: productWithOffers.project.id }
|
|
71
|
+
});
|
|
72
|
+
includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
|
|
73
|
+
}
|
|
62
74
|
const searchByOfferCatalogIdResult = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
63
75
|
ids: params.ids,
|
|
64
|
-
|
|
76
|
+
includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
|
|
65
77
|
excludeAppliesToMovieTicket: false,
|
|
66
|
-
// limit: params.limit,
|
|
67
|
-
// page: params.page,
|
|
68
78
|
onlyValid: params.onlyValid === true,
|
|
69
79
|
availableAtOrFrom: params.availableAt
|
|
70
80
|
});
|
|
71
|
-
offers = searchByOfferCatalogIdResult
|
|
81
|
+
offers = searchByOfferCatalogIdResult;
|
|
72
82
|
}
|
|
73
83
|
return offers.map((o) => {
|
|
74
84
|
var _a;
|
|
@@ -64,6 +64,7 @@ function search(params) {
|
|
|
64
64
|
itemOffered: { id: params.itemOffered.id },
|
|
65
65
|
availableAt: params.availableAt,
|
|
66
66
|
onlyValid: params.onlyValid,
|
|
67
|
+
includedInDataCatalog: params.includedInDataCatalog,
|
|
67
68
|
addSortIndex: params.addSortIndex,
|
|
68
69
|
useIncludeInDataCatalog: params.useIncludeInDataCatalog,
|
|
69
70
|
limit: params.limit,
|
|
@@ -185,7 +186,7 @@ function fixProductAndOffers(params) {
|
|
|
185
186
|
if (product === undefined) {
|
|
186
187
|
throw new factory.errors.NotFound('Product');
|
|
187
188
|
}
|
|
188
|
-
const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
|
|
189
|
+
const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, includedInDataCatalog: { id: '' }, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
|
|
189
190
|
return { product, availableOffers: offers };
|
|
190
191
|
});
|
|
191
192
|
}
|
package/package.json
CHANGED