@chevre/domain 21.8.0-alpha.35 → 21.8.0-alpha.37
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.
|
@@ -11,9 +11,12 @@ async function main() {
|
|
|
11
11
|
|
|
12
12
|
const offers = await offerRepo.search(
|
|
13
13
|
{
|
|
14
|
-
limit:
|
|
14
|
+
limit: 10,
|
|
15
15
|
page: 1,
|
|
16
|
-
sort: {
|
|
16
|
+
sort: {
|
|
17
|
+
'priceSpecification.price': 1,
|
|
18
|
+
identifier: 1
|
|
19
|
+
},
|
|
17
20
|
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
18
21
|
availability: { $eq: chevre.factory.itemAvailability.InStock },
|
|
19
22
|
itemOffered: {
|
|
@@ -101,8 +104,8 @@ async function main() {
|
|
|
101
104
|
}
|
|
102
105
|
},
|
|
103
106
|
price: {
|
|
104
|
-
// $gte:
|
|
105
|
-
// $lte:
|
|
107
|
+
// $gte: 2000,
|
|
108
|
+
// $lte: 2000
|
|
106
109
|
},
|
|
107
110
|
referenceQuantity: {
|
|
108
111
|
value: {
|
|
@@ -147,14 +150,16 @@ async function main() {
|
|
|
147
150
|
identifier: 1,
|
|
148
151
|
name: 1,
|
|
149
152
|
alternateName: 1,
|
|
150
|
-
priceSpecification: 1
|
|
153
|
+
priceSpecification: 1,
|
|
154
|
+
project: 1
|
|
151
155
|
}
|
|
152
156
|
);
|
|
153
157
|
console.log(offers);
|
|
154
158
|
console.log(offers.map((offer) => {
|
|
155
|
-
return `${offer.project?.id} ${offer.
|
|
159
|
+
return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id}`;
|
|
156
160
|
}));
|
|
157
161
|
console.log(offers.length);
|
|
162
|
+
console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
main()
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -48,7 +48,7 @@ class MongoRepository {
|
|
|
48
48
|
}
|
|
49
49
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
50
50
|
static CREATE_OFFER_MONGO_CONDITIONS(params) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36;
|
|
52
52
|
// MongoDB検索条件
|
|
53
53
|
const andConditions = [];
|
|
54
54
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -303,13 +303,16 @@ class MongoRepository {
|
|
|
303
303
|
const addOnItemOfferedIdEq = (_29 = (_28 = (_27 = params.addOn) === null || _27 === void 0 ? void 0 : _27.itemOffered) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$eq;
|
|
304
304
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
305
305
|
andConditions.push({
|
|
306
|
-
'addOn.itemOffered.id': {
|
|
307
|
-
$exists: true,
|
|
308
|
-
$eq: addOnItemOfferedIdEq
|
|
309
|
-
}
|
|
306
|
+
'addOn.itemOffered.id': { $exists: true, $eq: addOnItemOfferedIdEq }
|
|
310
307
|
});
|
|
311
308
|
}
|
|
312
|
-
const
|
|
309
|
+
const addOnItemOfferedIdIn = (_32 = (_31 = (_30 = params.addOn) === null || _30 === void 0 ? void 0 : _30.itemOffered) === null || _31 === void 0 ? void 0 : _31.id) === null || _32 === void 0 ? void 0 : _32.$in;
|
|
310
|
+
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
311
|
+
andConditions.push({
|
|
312
|
+
'addOn.itemOffered.id': { $exists: true, $in: addOnItemOfferedIdIn }
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
const hasMerchantReturnPolicyIdEq = (_34 = (_33 = params.hasMerchantReturnPolicy) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
|
|
313
316
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
314
317
|
andConditions.push({
|
|
315
318
|
'hasMerchantReturnPolicy.id': {
|
|
@@ -318,7 +321,7 @@ class MongoRepository {
|
|
|
318
321
|
}
|
|
319
322
|
});
|
|
320
323
|
}
|
|
321
|
-
const additionalPropertyAll = (
|
|
324
|
+
const additionalPropertyAll = (_35 = params.additionalProperty) === null || _35 === void 0 ? void 0 : _35.$all;
|
|
322
325
|
if (Array.isArray(additionalPropertyAll)) {
|
|
323
326
|
andConditions.push({
|
|
324
327
|
additionalProperty: {
|
|
@@ -327,7 +330,7 @@ class MongoRepository {
|
|
|
327
330
|
}
|
|
328
331
|
});
|
|
329
332
|
}
|
|
330
|
-
const additionalPropertyElemMatch = (
|
|
333
|
+
const additionalPropertyElemMatch = (_36 = params.additionalProperty) === null || _36 === void 0 ? void 0 : _36.$elemMatch;
|
|
331
334
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
332
335
|
andConditions.push({
|
|
333
336
|
additionalProperty: {
|
|
@@ -354,7 +357,7 @@ class MongoRepository {
|
|
|
354
357
|
}
|
|
355
358
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
356
359
|
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
|
|
357
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
|
|
360
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36;
|
|
358
361
|
const matchStages = [];
|
|
359
362
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
360
363
|
if (typeof projectIdEq === 'string') {
|
|
@@ -659,14 +662,19 @@ class MongoRepository {
|
|
|
659
662
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
660
663
|
matchStages.push({
|
|
661
664
|
$match: {
|
|
662
|
-
'offers.addOn.itemOffered.id': {
|
|
663
|
-
$exists: true,
|
|
664
|
-
$eq: addOnItemOfferedIdEq
|
|
665
|
-
}
|
|
665
|
+
'offers.addOn.itemOffered.id': { $exists: true, $eq: addOnItemOfferedIdEq }
|
|
666
666
|
}
|
|
667
667
|
});
|
|
668
668
|
}
|
|
669
|
-
const
|
|
669
|
+
const addOnItemOfferedIdIn = (_32 = (_31 = (_30 = params.addOn) === null || _30 === void 0 ? void 0 : _30.itemOffered) === null || _31 === void 0 ? void 0 : _31.id) === null || _32 === void 0 ? void 0 : _32.$in;
|
|
670
|
+
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
671
|
+
matchStages.push({
|
|
672
|
+
$match: {
|
|
673
|
+
'offers.addOn.itemOffered.id': { $exists: true, $in: addOnItemOfferedIdIn }
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
const hasMerchantReturnPolicyIdEq = (_34 = (_33 = params.hasMerchantReturnPolicy) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
|
|
670
678
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
671
679
|
matchStages.push({
|
|
672
680
|
$match: {
|
|
@@ -677,7 +685,7 @@ class MongoRepository {
|
|
|
677
685
|
}
|
|
678
686
|
});
|
|
679
687
|
}
|
|
680
|
-
const additionalPropertyAll = (
|
|
688
|
+
const additionalPropertyAll = (_35 = params.additionalProperty) === null || _35 === void 0 ? void 0 : _35.$all;
|
|
681
689
|
if (Array.isArray(additionalPropertyAll)) {
|
|
682
690
|
matchStages.push({
|
|
683
691
|
$match: {
|
|
@@ -688,7 +696,7 @@ class MongoRepository {
|
|
|
688
696
|
}
|
|
689
697
|
});
|
|
690
698
|
}
|
|
691
|
-
const additionalPropertyElemMatch = (
|
|
699
|
+
const additionalPropertyElemMatch = (_36 = params.additionalProperty) === null || _36 === void 0 ? void 0 : _36.$elemMatch;
|
|
692
700
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
693
701
|
matchStages.push({
|
|
694
702
|
$match: {
|
|
@@ -824,8 +832,8 @@ class MongoRepository {
|
|
|
824
832
|
}, onlyValid: params.onlyValid === true }), (typeof params.limit === 'number' && typeof params.page === 'number')
|
|
825
833
|
? { sort: { _id: factory.sortType.Ascending } }
|
|
826
834
|
: undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
|
|
827
|
-
//
|
|
828
|
-
offers = yield this.search(searchOffersConditions, params.projection, settings_1.
|
|
835
|
+
// USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG対応(2023-09-06~)
|
|
836
|
+
offers = yield this.search(searchOffersConditions, params.projection, settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG);
|
|
829
837
|
// 完全廃止(基本的にsortedOfferIdsと合わせて利用する想定)(2023-09-04~)
|
|
830
838
|
// if (params.sort) {
|
|
831
839
|
// // sorting
|
|
@@ -845,7 +853,7 @@ class MongoRepository {
|
|
|
845
853
|
});
|
|
846
854
|
const unitPriceOffer = offers.shift();
|
|
847
855
|
if (unitPriceOffer === undefined) {
|
|
848
|
-
throw new factory.errors.NotFound(
|
|
856
|
+
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
849
857
|
}
|
|
850
858
|
return unitPriceOffer;
|
|
851
859
|
});
|
|
@@ -897,7 +905,7 @@ class MongoRepository {
|
|
|
897
905
|
* 強制的にoffersコレクションを使用する
|
|
898
906
|
*/
|
|
899
907
|
useOffersAsPrimary) {
|
|
900
|
-
var _a;
|
|
908
|
+
var _a, _b;
|
|
901
909
|
return __awaiter(this, void 0, void 0, function* () {
|
|
902
910
|
// primaryコレクションをコントロール(2023-09-05~)
|
|
903
911
|
const useAggregateOfferAsPrimary = settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY && (useOffersAsPrimary !== true);
|
|
@@ -920,8 +928,10 @@ class MongoRepository {
|
|
|
920
928
|
}
|
|
921
929
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
922
930
|
/* istanbul ignore else */
|
|
923
|
-
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'])
|
|
924
|
-
query.sort({ 'priceSpecification.price': params.sort['priceSpecification.price'] })
|
|
931
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number') {
|
|
932
|
+
query.sort(Object.assign({ 'priceSpecification.price': params.sort['priceSpecification.price'] }, (typeof ((_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier) === 'number')
|
|
933
|
+
? { identifier: params.sort.identifier }
|
|
934
|
+
: undefined));
|
|
925
935
|
}
|
|
926
936
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
927
937
|
.exec()
|
|
@@ -1000,7 +1010,7 @@ class MongoRepository {
|
|
|
1000
1010
|
.exec();
|
|
1001
1011
|
}
|
|
1002
1012
|
if (doc === null) {
|
|
1003
|
-
throw new factory.errors.NotFound(
|
|
1013
|
+
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
1004
1014
|
}
|
|
1005
1015
|
// 同期タスク作成(2023-09-03~)
|
|
1006
1016
|
if (typeof doc._id === 'string') {
|
|
@@ -1020,54 +1030,111 @@ class MongoRepository {
|
|
|
1020
1030
|
/**
|
|
1021
1031
|
* sskts専用オファー保管
|
|
1022
1032
|
*/
|
|
1033
|
+
// tslint:disable-next-line:max-func-body-length
|
|
1023
1034
|
saveManyByIdentifier(params) {
|
|
1024
1035
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1025
|
-
//
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
$eq: p.attributes.
|
|
1036
|
+
// USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-06~)
|
|
1037
|
+
if (settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY) {
|
|
1038
|
+
const insertBulkWriteOps = [];
|
|
1039
|
+
const updateBulkWriteOps = [];
|
|
1040
|
+
if (Array.isArray(params)) {
|
|
1041
|
+
params.forEach((p) => {
|
|
1042
|
+
const newOfferId = uniqid();
|
|
1043
|
+
const unitPriceOffer = Object.assign(Object.assign({}, p.attributes), { id: newOfferId });
|
|
1044
|
+
const aggregateOffer = {
|
|
1045
|
+
project: p.attributes.project,
|
|
1046
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
1047
|
+
offers: [unitPriceOffer]
|
|
1048
|
+
};
|
|
1049
|
+
insertBulkWriteOps.push({
|
|
1050
|
+
updateOne: {
|
|
1051
|
+
filter: {
|
|
1052
|
+
'project.id': { $eq: p.attributes.project.id },
|
|
1053
|
+
'offers.identifier': { $exists: true, $eq: p.attributes.identifier }
|
|
1043
1054
|
},
|
|
1044
|
-
|
|
1045
|
-
$
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1055
|
+
update: {
|
|
1056
|
+
$setOnInsert: Object.assign(Object.assign({}, aggregateOffer), { _id: newOfferId })
|
|
1057
|
+
},
|
|
1058
|
+
upsert: true
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
const { id } = unitPriceOffer, $set = __rest(unitPriceOffer, ["id"]);
|
|
1062
|
+
updateBulkWriteOps.push({
|
|
1063
|
+
updateOne: {
|
|
1064
|
+
filter: {
|
|
1065
|
+
'project.id': { $eq: unitPriceOffer.project.id },
|
|
1066
|
+
'offers.identifier': { $exists: true, $eq: unitPriceOffer.identifier }
|
|
1067
|
+
},
|
|
1068
|
+
update: {
|
|
1069
|
+
// 特定の属性のみ更新する(IDを上書きできないので)
|
|
1070
|
+
$set: Object.assign(Object.assign({ 'offers.0.name': $set.name, 'offers.0.description': $set.description, 'offers.0.alternateName': $set.alternateName, 'offers.0.priceSpecification': $set.priceSpecification, 'offers.0.additionalProperty': $set.additionalProperty }, (Array.isArray($set.eligibleMembershipType))
|
|
1071
|
+
? { 'offers.0.eligibleMembershipType': $set.eligibleMembershipType }
|
|
1072
|
+
: undefined), (Array.isArray($set.eligibleMonetaryAmount))
|
|
1073
|
+
? { 'offers.0.eligibleMonetaryAmount': $set.eligibleMonetaryAmount }
|
|
1074
|
+
: undefined)
|
|
1075
|
+
},
|
|
1076
|
+
upsert: false
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1057
1079
|
});
|
|
1058
|
-
}
|
|
1080
|
+
}
|
|
1081
|
+
if (insertBulkWriteOps.length > 0) {
|
|
1082
|
+
yield this.aggregateOfferModel.bulkWrite(insertBulkWriteOps, { ordered: false });
|
|
1083
|
+
yield this.aggregateOfferModel.bulkWrite(updateBulkWriteOps, { ordered: false });
|
|
1084
|
+
// 同期タスク作成(2023-09-03~)
|
|
1085
|
+
yield this.saveSyncTask({
|
|
1086
|
+
project: { id: params[0].attributes.project.id },
|
|
1087
|
+
id: { $in: [] },
|
|
1088
|
+
identifier: { $in: params.map((savingOffer) => savingOffer.attributes.identifier) },
|
|
1089
|
+
isDeleted: false,
|
|
1090
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
1091
|
+
options: { emitImmediately: true }
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1059
1094
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1095
|
+
else {
|
|
1096
|
+
const bulkWriteOps = [];
|
|
1097
|
+
if (Array.isArray(params)) {
|
|
1098
|
+
params.forEach((p) => {
|
|
1099
|
+
const id = uniqid();
|
|
1100
|
+
const $set = Object.assign({}, p.attributes);
|
|
1101
|
+
if (typeof $set.id === 'string') {
|
|
1102
|
+
delete $set.id;
|
|
1103
|
+
}
|
|
1104
|
+
bulkWriteOps.push({
|
|
1105
|
+
updateOne: {
|
|
1106
|
+
filter: {
|
|
1107
|
+
'project.id': {
|
|
1108
|
+
$eq: p.attributes.project.id
|
|
1109
|
+
},
|
|
1110
|
+
identifier: {
|
|
1111
|
+
$exists: true,
|
|
1112
|
+
$eq: p.attributes.identifier
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
update: {
|
|
1116
|
+
$set: $set,
|
|
1117
|
+
$setOnInsert: {
|
|
1118
|
+
_id: id
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
if (bulkWriteOps.length > 0) {
|
|
1127
|
+
yield this.offerModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
1128
|
+
// 同期タスク作成(2023-09-03~)
|
|
1129
|
+
yield this.saveSyncTask({
|
|
1130
|
+
project: { id: params[0].attributes.project.id },
|
|
1131
|
+
id: { $in: [] },
|
|
1132
|
+
identifier: { $in: params.map((savingOffer) => savingOffer.attributes.identifier) },
|
|
1133
|
+
isDeleted: false,
|
|
1134
|
+
typeOf: factory.offerType.Offer,
|
|
1135
|
+
options: { emitImmediately: true }
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1071
1138
|
}
|
|
1072
1139
|
});
|
|
1073
1140
|
}
|
|
@@ -1079,44 +1146,36 @@ class MongoRepository {
|
|
|
1079
1146
|
if (params.addOn.itemOffered.id.$in.length === 0) {
|
|
1080
1147
|
return;
|
|
1081
1148
|
}
|
|
1082
|
-
//
|
|
1083
|
-
// TODO USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
1149
|
+
// USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
1084
1150
|
if (settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
//
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
// identifier: { $in: [] },
|
|
1114
|
-
// isDeleted: false,
|
|
1115
|
-
// typeOf: factory.offerType.AggregateOffer,
|
|
1116
|
-
// options: { emitImmediately: true }
|
|
1117
|
-
// });
|
|
1118
|
-
// }
|
|
1119
|
-
// return result;
|
|
1151
|
+
const conditions = {
|
|
1152
|
+
'project.id': { $eq: params.project.id },
|
|
1153
|
+
'offers.addOn.itemOffered.id': { $exists: true, $in: params.addOn.itemOffered.id.$in }
|
|
1154
|
+
};
|
|
1155
|
+
const updatingOffers = yield this.searchFromAggregateOffer({
|
|
1156
|
+
project: { id: { $eq: params.project.id } },
|
|
1157
|
+
addOn: { itemOffered: { id: { $in: params.addOn.itemOffered.id.$in } } }
|
|
1158
|
+
}, { id: 1 });
|
|
1159
|
+
const result = yield this.aggregateOfferModel.updateMany(conditions, {
|
|
1160
|
+
$pull: {
|
|
1161
|
+
'offers.addOn': {
|
|
1162
|
+
'itemOffered.id': { $in: params.addOn.itemOffered.id.$in }
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
})
|
|
1166
|
+
.exec();
|
|
1167
|
+
// 同期タスク作成(2023-09-05~)
|
|
1168
|
+
if (updatingOffers.length > 0) {
|
|
1169
|
+
yield this.saveSyncTask({
|
|
1170
|
+
project: { id: params.project.id },
|
|
1171
|
+
id: { $in: updatingOffers.map((offer) => String(offer.id)) },
|
|
1172
|
+
identifier: { $in: [] },
|
|
1173
|
+
isDeleted: false,
|
|
1174
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
1175
|
+
options: { emitImmediately: true }
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
return result;
|
|
1120
1179
|
}
|
|
1121
1180
|
else {
|
|
1122
1181
|
const conditions = {
|
|
@@ -1324,7 +1383,26 @@ class MongoRepository {
|
|
|
1324
1383
|
.exec();
|
|
1325
1384
|
}
|
|
1326
1385
|
if (Array.isArray(identifierIn) && identifierIn.length > 0) {
|
|
1327
|
-
|
|
1386
|
+
aggregateOffers = yield this.aggregateOfferModel.aggregate([
|
|
1387
|
+
{
|
|
1388
|
+
$unwind: {
|
|
1389
|
+
path: '$offers'
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
$match: {
|
|
1394
|
+
'project.id': { $eq: params.project.id },
|
|
1395
|
+
'offers.identifier': { $exists: true, $in: identifierIn }
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
$project: {
|
|
1400
|
+
_id: 0,
|
|
1401
|
+
offer: '$offers'
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
])
|
|
1405
|
+
.exec();
|
|
1328
1406
|
}
|
|
1329
1407
|
const bulkWriteOps = [];
|
|
1330
1408
|
if (aggregateOffers.length > 0) {
|
|
@@ -1393,7 +1471,7 @@ class MongoRepository {
|
|
|
1393
1471
|
});
|
|
1394
1472
|
}
|
|
1395
1473
|
searchFromAggregateOffer(params, projection) {
|
|
1396
|
-
var _a;
|
|
1474
|
+
var _a, _b;
|
|
1397
1475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1398
1476
|
const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
|
|
1399
1477
|
const projectStage = MongoRepository.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
|
|
@@ -1406,7 +1484,13 @@ class MongoRepository {
|
|
|
1406
1484
|
},
|
|
1407
1485
|
...matchStages,
|
|
1408
1486
|
...(typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number')
|
|
1409
|
-
? [
|
|
1487
|
+
? [
|
|
1488
|
+
{
|
|
1489
|
+
$sort: Object.assign({ 'offers.priceSpecification.price': params.sort['priceSpecification.price'] }, (typeof ((_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier) === 'number')
|
|
1490
|
+
? { 'offers.identifier': params.sort.identifier }
|
|
1491
|
+
: undefined)
|
|
1492
|
+
}
|
|
1493
|
+
]
|
|
1410
1494
|
: [],
|
|
1411
1495
|
{ $project: projectStage }
|
|
1412
1496
|
]);
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
|
|
|
44
44
|
export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
|
|
45
45
|
export declare const USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY: boolean;
|
|
46
46
|
export declare const USE_AGGREGATE_OFFERS_AS_PRIMARY: boolean;
|
|
47
|
+
export declare const USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG: boolean;
|
|
47
48
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
48
49
|
/**
|
|
49
50
|
* グローバル設定
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG = exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -76,6 +76,7 @@ exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
|
|
|
76
76
|
exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
|
|
77
77
|
exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = process.env.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY === '1';
|
|
78
78
|
exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY === '1';
|
|
79
|
+
exports.USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG = process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG === '1';
|
|
79
80
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
80
81
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
81
82
|
// tslint:disable-next-line:no-magic-numbers
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.329.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.166.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.329.0-alpha.7",
|
|
13
|
+
"@cinerino/sdk": "3.166.0-alpha.7",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.37"
|
|
121
121
|
}
|