@chevre/domain 21.8.0-alpha.31 → 21.8.0-alpha.32
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.
|
@@ -5,144 +5,154 @@ import { chevre } from '../../../lib/index';
|
|
|
5
5
|
|
|
6
6
|
// tslint:disable-next-line:max-func-body-length
|
|
7
7
|
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
9
9
|
|
|
10
10
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
11
|
|
|
12
|
-
const offers = await offerRepo.searchFromAggregateOffer(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const offers = await offerRepo.searchFromAggregateOffer(
|
|
13
|
+
{
|
|
14
|
+
limit: 5,
|
|
15
|
+
page: 1,
|
|
16
|
+
sort: { 'priceSpecification.price': 1 },
|
|
17
|
+
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
18
|
+
availability: { $eq: chevre.factory.itemAvailability.InStock },
|
|
19
|
+
addOn: {
|
|
20
|
+
itemOffered: {
|
|
21
|
+
/**
|
|
22
|
+
* アドオンプロダクトID
|
|
23
|
+
*/
|
|
24
|
+
id: {
|
|
25
|
+
// $eq: ''
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
availableAtOrFrom: {
|
|
30
|
+
id: {
|
|
31
|
+
// $eq: ''
|
|
32
|
+
// $in: string[]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
eligibleMembershipType: {
|
|
20
36
|
/**
|
|
21
|
-
*
|
|
37
|
+
* 適用メンバーシップ区分
|
|
22
38
|
*/
|
|
39
|
+
codeValue: {
|
|
40
|
+
// $eq: 'Permit'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
eligibleMonetaryAmount: {
|
|
44
|
+
/**
|
|
45
|
+
* 適用通貨区分
|
|
46
|
+
*/
|
|
47
|
+
currency: {
|
|
48
|
+
// $eq: 'Point'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
eligibleSeatingType: {
|
|
52
|
+
/**
|
|
53
|
+
* 適用座席区分
|
|
54
|
+
*/
|
|
55
|
+
codeValue: {
|
|
56
|
+
// $eq: ''
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
hasMerchantReturnPolicy: {
|
|
23
60
|
id: {
|
|
24
61
|
// $eq: ''
|
|
25
62
|
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
availableAtOrFrom: {
|
|
29
|
-
id: {
|
|
30
|
-
// $eq: ''
|
|
31
|
-
// $in: string[]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
eligibleMembershipType: {
|
|
35
|
-
/**
|
|
36
|
-
* 適用メンバーシップ区分
|
|
37
|
-
*/
|
|
38
|
-
codeValue: {
|
|
39
|
-
// $eq: 'Permit'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
eligibleMonetaryAmount: {
|
|
43
|
-
/**
|
|
44
|
-
* 適用通貨区分
|
|
45
|
-
*/
|
|
46
|
-
currency: {
|
|
47
|
-
// $eq: 'Point'
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
eligibleSeatingType: {
|
|
51
|
-
/**
|
|
52
|
-
* 適用座席区分
|
|
53
|
-
*/
|
|
54
|
-
codeValue: {
|
|
55
|
-
// $eq: ''
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
hasMerchantReturnPolicy: {
|
|
63
|
+
},
|
|
59
64
|
id: {
|
|
60
|
-
// $eq: ''
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// $regex: ''
|
|
74
|
-
},
|
|
75
|
-
priceSpecification: {
|
|
76
|
-
appliesToMovieTicket: {
|
|
77
|
-
/**
|
|
78
|
-
* 適用決済カード区分
|
|
79
|
-
*/
|
|
80
|
-
serviceType: {
|
|
65
|
+
// $eq: '1001'
|
|
66
|
+
// $in: string[];
|
|
67
|
+
},
|
|
68
|
+
identifier: {
|
|
69
|
+
// $eq: '1001'
|
|
70
|
+
// $in: string[];
|
|
71
|
+
// $regex: '003'
|
|
72
|
+
},
|
|
73
|
+
name: {
|
|
74
|
+
// $regex: ''
|
|
75
|
+
},
|
|
76
|
+
priceSpecification: {
|
|
77
|
+
appliesToMovieTicket: {
|
|
81
78
|
/**
|
|
82
|
-
*
|
|
79
|
+
* 適用決済カード区分
|
|
83
80
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
serviceType: {
|
|
82
|
+
/**
|
|
83
|
+
* 適用決済カード区分が存在するかどうか
|
|
84
|
+
*/
|
|
85
|
+
// $exists: boolean;
|
|
86
|
+
// $eq: '01'
|
|
87
|
+
},
|
|
88
|
+
serviceOutput: {
|
|
89
|
+
/**
|
|
90
|
+
* 適用決済方法タイプ
|
|
91
|
+
*/
|
|
92
|
+
typeOf: {
|
|
93
|
+
// $eq: ''
|
|
94
|
+
// $nin: string[];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
86
97
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// $
|
|
98
|
+
price: {
|
|
99
|
+
// $gte: 100,
|
|
100
|
+
// $lte: 500
|
|
101
|
+
},
|
|
102
|
+
referenceQuantity: {
|
|
103
|
+
value: {
|
|
104
|
+
// $eq: 2
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
accounting: {
|
|
108
|
+
accountsReceivable: {
|
|
109
|
+
// $gte: 1800,
|
|
110
|
+
// $lte: 100
|
|
111
|
+
},
|
|
112
|
+
operatingRevenue: {
|
|
113
|
+
codeValue: {
|
|
114
|
+
// $eq: ''
|
|
115
|
+
// $in: string[];
|
|
116
|
+
}
|
|
94
117
|
}
|
|
95
118
|
}
|
|
96
119
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
category: {
|
|
121
|
+
codeValue: {
|
|
122
|
+
// $in: ['1']
|
|
123
|
+
}
|
|
100
124
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// $eq:
|
|
125
|
+
itemOffered: {
|
|
126
|
+
typeOf: {
|
|
127
|
+
// $eq: chevre.factory.product.ProductType.Product
|
|
104
128
|
}
|
|
105
129
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
/**
|
|
131
|
+
* 有効期間設定がない、あるいは、有効期間内
|
|
132
|
+
*/
|
|
133
|
+
// onlyValid: true
|
|
134
|
+
additionalProperty: {
|
|
135
|
+
$all: [
|
|
136
|
+
{
|
|
137
|
+
$elemMatch: {
|
|
138
|
+
// name: { $eq: 'nameForPrinting' },
|
|
139
|
+
// value: { $in: ['General'] }
|
|
140
|
+
}
|
|
115
141
|
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
category: {
|
|
120
|
-
codeValue: {
|
|
121
|
-
// $in: ['1']
|
|
142
|
+
]
|
|
122
143
|
}
|
|
123
144
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* 有効期間設定がない、あるいは、有効期間内
|
|
131
|
-
*/
|
|
132
|
-
// onlyValid: true
|
|
133
|
-
additionalProperty: {
|
|
134
|
-
$all: [
|
|
135
|
-
{
|
|
136
|
-
$elemMatch: {
|
|
137
|
-
// name: { $eq: 'nameForPrinting' },
|
|
138
|
-
// value: { $in: ['General'] }
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
]
|
|
145
|
+
{
|
|
146
|
+
id: 1,
|
|
147
|
+
identifier: 1,
|
|
148
|
+
name: 1,
|
|
149
|
+
alternateName: 1,
|
|
150
|
+
priceSpecification: 1
|
|
142
151
|
}
|
|
143
|
-
|
|
152
|
+
);
|
|
153
|
+
console.log(offers);
|
|
144
154
|
console.log(offers.map((offer) => {
|
|
145
|
-
return `${offer.project
|
|
155
|
+
return `${offer.project?.id} ${offer.id} ${offer.identifier} ${offer.name?.ja} ${offer.priceSpecification?.price}`;
|
|
146
156
|
}));
|
|
147
157
|
console.log(offers.length);
|
|
148
158
|
}
|
|
@@ -52,3 +52,125 @@ schema.index({ 'offers.identifier': 1, 'project.id': 1 }, {
|
|
|
52
52
|
name: 'uniqueOfferIdentifier',
|
|
53
53
|
unique: true
|
|
54
54
|
});
|
|
55
|
+
schema.index({ 'offers.availability': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersAvailability' });
|
|
56
|
+
schema.index({ 'offers.itemOffered.typeOf': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersItemOfferedTypeOf' });
|
|
57
|
+
schema.index({ 'offers.identifier': 1, 'offers.priceSpecification.price': 1 }, {
|
|
58
|
+
name: 'searchByOffersIdentifier',
|
|
59
|
+
partialFilterExpression: {
|
|
60
|
+
'offers.identifier': { $exists: true }
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
schema.index({ 'offers.priceSpecification.referenceQuantity.value': 1, 'offers.priceSpecification.price': 1 }, {
|
|
64
|
+
name: 'searchByOffersPriceSpecificationReferenceQuantityValue',
|
|
65
|
+
partialFilterExpression: {
|
|
66
|
+
'offers.priceSpecification.referenceQuantity.value': { $exists: true }
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
schema.index({ 'offers.priceSpecification.accounting.accountsReceivable': 1, 'offers.priceSpecification.price': 1 }, {
|
|
70
|
+
name: 'searchByOffersPriceSpecificationAccountingAccountsReceivable',
|
|
71
|
+
partialFilterExpression: {
|
|
72
|
+
'offers.priceSpecification.accounting.accountsReceivable': { $exists: true }
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
schema.index({ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
|
|
76
|
+
name: 'searchByOffersPriceSpecificationAccountingOperatingRevenueCodeValue',
|
|
77
|
+
partialFilterExpression: {
|
|
78
|
+
'offers.priceSpecification.accounting.operatingRevenue.codeValue': { $exists: true }
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceType': 1, 'offers.priceSpecification.price': 1 }, {
|
|
82
|
+
name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceType',
|
|
83
|
+
partialFilterExpression: {
|
|
84
|
+
'offers.priceSpecification.appliesToMovieTicket.serviceType': { $exists: true }
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': 1, 'offers.priceSpecification.price': 1 }, {
|
|
88
|
+
name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceOutputTypeOf',
|
|
89
|
+
partialFilterExpression: {
|
|
90
|
+
'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': { $exists: true }
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
schema.index({ 'offers.name.ja': 1, 'offers.priceSpecification.price': 1 }, {
|
|
94
|
+
name: 'searchByOffersNameJa',
|
|
95
|
+
partialFilterExpression: {
|
|
96
|
+
'offers.name.ja': { $exists: true }
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
schema.index({ 'offers.name.en': 1, 'offers.priceSpecification.price': 1 }, {
|
|
100
|
+
name: 'searchByOffersNameEn',
|
|
101
|
+
partialFilterExpression: {
|
|
102
|
+
'offers.name.en': { $exists: true }
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
schema.index({ 'offers.alternateName': 1, 'offers.priceSpecification.price': 1 }, {
|
|
106
|
+
name: 'searchByOffersAlternateName',
|
|
107
|
+
partialFilterExpression: {
|
|
108
|
+
'offers.alternateName': { $exists: true }
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
schema.index({ 'offers.category.id': 1, 'offers.priceSpecification.price': 1 }, {
|
|
112
|
+
name: 'searchOffersCategoryId',
|
|
113
|
+
partialFilterExpression: {
|
|
114
|
+
'offers.category.id': { $exists: true }
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
schema.index({ 'offers.category.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
|
|
118
|
+
name: 'searchByOffersCategoryCodeValue',
|
|
119
|
+
partialFilterExpression: {
|
|
120
|
+
'offers.category.codeValue': { $exists: true }
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
schema.index({ 'offers.availableAtOrFrom.id': 1, 'offers.priceSpecification.price': 1 }, {
|
|
124
|
+
name: 'searchByOffersAvailableAtOrFromId',
|
|
125
|
+
partialFilterExpression: {
|
|
126
|
+
'offers.availableAtOrFrom.id': { $exists: true }
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
schema.index({ 'offers.eligibleMembershipType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
|
|
130
|
+
name: 'searchByOffersEligibleMembershipTypeCodeValue',
|
|
131
|
+
partialFilterExpression: {
|
|
132
|
+
'offers.eligibleMembershipType.codeValue': { $exists: true }
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
schema.index({ 'offers.eligibleMonetaryAmount.currency': 1, 'offers.priceSpecification.price': 1 }, {
|
|
136
|
+
name: 'searchByOffersEligibleMonetaryAmountCurrency',
|
|
137
|
+
partialFilterExpression: {
|
|
138
|
+
'offers.eligibleMonetaryAmount.currency': { $exists: true }
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
schema.index({ 'offers.eligibleSeatingType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
|
|
142
|
+
name: 'searchByOffersEligibleSeatingTypeCodeValue',
|
|
143
|
+
partialFilterExpression: {
|
|
144
|
+
'offers.eligibleSeatingType.codeValue': { $exists: true }
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
schema.index({ 'offers.addOn.itemOffered.id': 1, 'offers.priceSpecification.price': 1 }, {
|
|
148
|
+
name: 'searchByOffersAddOnItemOfferedId',
|
|
149
|
+
partialFilterExpression: {
|
|
150
|
+
'offers.addOn.itemOffered.id': { $exists: true }
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
schema.index({ 'offers.hasMerchantReturnPolicy.id': 1, 'offers.priceSpecification.price': 1 }, {
|
|
154
|
+
name: 'searchByOffersHasMerchantReturnPolicyId',
|
|
155
|
+
partialFilterExpression: {
|
|
156
|
+
'offers.hasMerchantReturnPolicy.id': { $exists: true }
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
schema.index({ 'offers.additionalProperty': 1, 'offers.priceSpecification.price': 1 }, {
|
|
160
|
+
name: 'searchByOffersAdditionalProperty',
|
|
161
|
+
partialFilterExpression: {
|
|
162
|
+
'offers.additionalProperty': { $exists: true }
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
schema.index({ 'offers.validFrom': 1, 'offers.priceSpecification.price': 1 }, {
|
|
166
|
+
name: 'searchByOffersValidFrom',
|
|
167
|
+
partialFilterExpression: {
|
|
168
|
+
'offers.validFrom': { $exists: true }
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
schema.index({ 'offers.validThrough': 1, 'offers.priceSpecification.price': 1 }, {
|
|
172
|
+
name: 'searchByOffersValidThrough',
|
|
173
|
+
partialFilterExpression: {
|
|
174
|
+
'offers.validThrough': { $exists: true }
|
|
175
|
+
}
|
|
176
|
+
});
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
26
|
-
import { Connection, PipelineStage } from 'mongoose';
|
|
26
|
+
import { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
|
+
type IMatchStage = PipelineStage.Match;
|
|
28
29
|
interface IProjection {
|
|
29
30
|
[key: string]: 0 | 1;
|
|
30
31
|
}
|
|
@@ -38,7 +39,10 @@ export declare class MongoRepository {
|
|
|
38
39
|
private readonly taskModel;
|
|
39
40
|
constructor(connection: Connection);
|
|
40
41
|
static CREATE_OFFER_MONGO_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): any[];
|
|
41
|
-
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions):
|
|
42
|
+
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
|
|
43
|
+
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
|
|
44
|
+
[field: string]: AnyExpression;
|
|
45
|
+
};
|
|
42
46
|
/**
|
|
43
47
|
* カタログに含まれるオファーを検索する
|
|
44
48
|
* カタログに登録されたオファーの順序は保証される
|
|
@@ -65,6 +69,9 @@ export declare class MongoRepository {
|
|
|
65
69
|
sortedOfferIds: string[];
|
|
66
70
|
}>;
|
|
67
71
|
findById(params: {
|
|
72
|
+
project: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
68
75
|
id: string;
|
|
69
76
|
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
70
77
|
findAggregateOfferById(params: {
|
|
@@ -75,7 +82,7 @@ export declare class MongoRepository {
|
|
|
75
82
|
}): Promise<factory.aggregateOffer.IAggregateOffer>;
|
|
76
83
|
count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
|
|
77
84
|
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
78
|
-
searchFromAggregateOffer(params: factory.unitPriceOffer.ISearchConditions,
|
|
85
|
+
searchFromAggregateOffer(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
79
86
|
save(params: factory.unitPriceOffer.IUnitPriceOffer): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
80
87
|
/**
|
|
81
88
|
* sskts専用オファー保管
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -712,6 +712,60 @@ class MongoRepository {
|
|
|
712
712
|
}
|
|
713
713
|
return matchStages;
|
|
714
714
|
}
|
|
715
|
+
static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
|
|
716
|
+
let projectStage = {
|
|
717
|
+
_id: 0,
|
|
718
|
+
typeOf: '$offers.typeOf',
|
|
719
|
+
project: '$project',
|
|
720
|
+
id: '$offers.id',
|
|
721
|
+
identifier: '$offers.identifier',
|
|
722
|
+
name: '$offers.name',
|
|
723
|
+
description: '$offers.description',
|
|
724
|
+
category: '$offers.category',
|
|
725
|
+
color: '$offers.color',
|
|
726
|
+
additionalProperty: '$offers.additionalProperty',
|
|
727
|
+
advanceBookingRequirement: '$offers.advanceBookingRequirement',
|
|
728
|
+
alternateName: '$offers.alternateName',
|
|
729
|
+
addOn: '$offers.addOn',
|
|
730
|
+
availability: '$offers.availability',
|
|
731
|
+
availableAtOrFrom: '$offers.availableAtOrFrom',
|
|
732
|
+
hasMerchantReturnPolicy: '$offers.hasMerchantReturnPolicy',
|
|
733
|
+
itemOffered: '$offers.itemOffered',
|
|
734
|
+
priceCurrency: '$offers.priceCurrency',
|
|
735
|
+
priceSpecification: '$offers.priceSpecification',
|
|
736
|
+
eligibleCustomerType: '$offers.eligibleCustomerType',
|
|
737
|
+
eligibleDuration: '$offers.eligibleDuration',
|
|
738
|
+
eligibleMembershipType: '$offers.eligibleMembershipType',
|
|
739
|
+
eligibleMonetaryAmount: '$offers.eligibleMonetaryAmount',
|
|
740
|
+
eligibleQuantity: '$offers.eligibleQuantity',
|
|
741
|
+
eligibleRegion: '$offers.eligibleRegion',
|
|
742
|
+
eligibleSeatingType: '$offers.eligibleSeatingType',
|
|
743
|
+
eligibleSubReservation: '$offers.eligibleSubReservation',
|
|
744
|
+
settings: '$offers.settings',
|
|
745
|
+
validFrom: '$offers.validFrom',
|
|
746
|
+
validThrough: '$offers.validThrough',
|
|
747
|
+
validRateLimit: '$offers.validRateLimit'
|
|
748
|
+
};
|
|
749
|
+
const positiveProjectionFields = Object.keys(params)
|
|
750
|
+
.filter((key) => params[key] !== 0);
|
|
751
|
+
const negativeProjectionFields = Object.keys(params)
|
|
752
|
+
.filter((key) => params[key] === 0);
|
|
753
|
+
if (positiveProjectionFields.length > 0) {
|
|
754
|
+
projectStage = { _id: 0 };
|
|
755
|
+
positiveProjectionFields.forEach((field) => {
|
|
756
|
+
projectStage[field] = `$offers.${field}`;
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
else if (negativeProjectionFields.length > 0) {
|
|
760
|
+
negativeProjectionFields.forEach((field) => {
|
|
761
|
+
if (typeof projectStage[field] === 'string') {
|
|
762
|
+
// tslint:disable-next-line:no-dynamic-delete
|
|
763
|
+
delete projectStage[field];
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return projectStage;
|
|
768
|
+
}
|
|
715
769
|
/**
|
|
716
770
|
* カタログに含まれるオファーを検索する
|
|
717
771
|
* カタログに登録されたオファーの順序は保証される
|
|
@@ -771,17 +825,17 @@ class MongoRepository {
|
|
|
771
825
|
}
|
|
772
826
|
findById(params) {
|
|
773
827
|
return __awaiter(this, void 0, void 0, function* () {
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
})
|
|
780
|
-
|
|
781
|
-
if (
|
|
828
|
+
const offers = yield this.search({
|
|
829
|
+
limit: 1,
|
|
830
|
+
page: 1,
|
|
831
|
+
project: { id: { $eq: params.project.id } },
|
|
832
|
+
id: { $eq: params.id }
|
|
833
|
+
});
|
|
834
|
+
const unitPriceOffer = offers.shift();
|
|
835
|
+
if (unitPriceOffer === undefined) {
|
|
782
836
|
throw new factory.errors.NotFound(this.offerModel.modelName);
|
|
783
837
|
}
|
|
784
|
-
return
|
|
838
|
+
return unitPriceOffer;
|
|
785
839
|
});
|
|
786
840
|
}
|
|
787
841
|
findAggregateOfferById(params) {
|
|
@@ -836,69 +890,18 @@ class MongoRepository {
|
|
|
836
890
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
837
891
|
});
|
|
838
892
|
}
|
|
839
|
-
|
|
840
|
-
searchFromAggregateOffer(params, __) {
|
|
893
|
+
searchFromAggregateOffer(params, projection) {
|
|
841
894
|
var _a;
|
|
842
895
|
return __awaiter(this, void 0, void 0, function* () {
|
|
843
896
|
const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
|
|
844
|
-
|
|
845
|
-
// TODO implement projection
|
|
846
|
-
// const positiveProjectionExists: boolean = (projection !== undefined && projection !== null)
|
|
847
|
-
// ? Object.values(projection)
|
|
848
|
-
// .some((value) => value !== 0)
|
|
849
|
-
// : false;
|
|
897
|
+
const projectStage = MongoRepository.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
|
|
850
898
|
const aggregate = this.aggregateOfferModel.aggregate([
|
|
851
899
|
{ $unwind: '$offers' },
|
|
852
900
|
...matchStages,
|
|
853
|
-
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'])
|
|
901
|
+
...(typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number')
|
|
854
902
|
? [{ $sort: { 'offers.priceSpecification.price': params.sort['priceSpecification.price'] } }]
|
|
855
903
|
: [],
|
|
856
|
-
{
|
|
857
|
-
$project: {
|
|
858
|
-
_id: 0,
|
|
859
|
-
typeOf: '$offers.typeOf',
|
|
860
|
-
project: '$project',
|
|
861
|
-
id: '$offers.id',
|
|
862
|
-
identifier: '$offers.identifier',
|
|
863
|
-
name: '$offers.name',
|
|
864
|
-
description: '$offers.description',
|
|
865
|
-
category: '$offers.category',
|
|
866
|
-
color: '$offers.color',
|
|
867
|
-
additionalProperty: '$offers.additionalProperty',
|
|
868
|
-
advanceBookingRequirement: '$offers.advanceBookingRequirement',
|
|
869
|
-
alternateName: '$offers.alternateName',
|
|
870
|
-
addOn: '$offers.addOn',
|
|
871
|
-
availability: '$offers.availability',
|
|
872
|
-
availableAtOrFrom: '$offers.availableAtOrFrom',
|
|
873
|
-
hasMerchantReturnPolicy: '$offers.hasMerchantReturnPolicy',
|
|
874
|
-
itemOffered: '$offers.itemOffered',
|
|
875
|
-
priceCurrency: '$offers.priceCurrency',
|
|
876
|
-
priceSpecification: '$offers.priceSpecification',
|
|
877
|
-
eligibleCustomerType: '$offers.eligibleCustomerType',
|
|
878
|
-
eligibleDuration: '$offers.eligibleDuration',
|
|
879
|
-
eligibleMembershipType: '$offers.eligibleMembershipType',
|
|
880
|
-
eligibleMonetaryAmount: '$offers.eligibleMonetaryAmount',
|
|
881
|
-
eligibleQuantity: '$offers.eligibleQuantity',
|
|
882
|
-
eligibleRegion: '$offers.eligibleRegion',
|
|
883
|
-
eligibleSeatingType: '$offers.eligibleSeatingType',
|
|
884
|
-
eligibleSubReservation: '$offers.eligibleSubReservation',
|
|
885
|
-
settings: '$offers.settings',
|
|
886
|
-
validFrom: '$offers.validFrom',
|
|
887
|
-
validThrough: '$offers.validThrough',
|
|
888
|
-
validRateLimit: '$offers.validRateLimit'
|
|
889
|
-
// ...(searchConditions.$projection?.seatCount === 1)
|
|
890
|
-
// ? {
|
|
891
|
-
// seatCount: {
|
|
892
|
-
// $cond: {
|
|
893
|
-
// if: { $isArray: '$containsPlace.containsPlace' },
|
|
894
|
-
// then: { $size: '$containsPlace.containsPlace' },
|
|
895
|
-
// else: 0
|
|
896
|
-
// }
|
|
897
|
-
// }
|
|
898
|
-
// }
|
|
899
|
-
// : undefined
|
|
900
|
-
}
|
|
901
|
-
}
|
|
904
|
+
{ $project: projectStage }
|
|
902
905
|
]);
|
|
903
906
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
904
907
|
/* istanbul ignore else */
|
package/package.json
CHANGED