@chevre/domain 21.8.0-alpha.36 → 21.8.0-alpha.38
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/lib/chevre/repo/offer.js
CHANGED
|
@@ -853,7 +853,7 @@ class MongoRepository {
|
|
|
853
853
|
});
|
|
854
854
|
const unitPriceOffer = offers.shift();
|
|
855
855
|
if (unitPriceOffer === undefined) {
|
|
856
|
-
throw new factory.errors.NotFound(
|
|
856
|
+
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
857
857
|
}
|
|
858
858
|
return unitPriceOffer;
|
|
859
859
|
});
|
|
@@ -1010,7 +1010,7 @@ class MongoRepository {
|
|
|
1010
1010
|
.exec();
|
|
1011
1011
|
}
|
|
1012
1012
|
if (doc === null) {
|
|
1013
|
-
throw new factory.errors.NotFound(
|
|
1013
|
+
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
1014
1014
|
}
|
|
1015
1015
|
// 同期タスク作成(2023-09-03~)
|
|
1016
1016
|
if (typeof doc._id === 'string') {
|
|
@@ -1030,54 +1030,111 @@ class MongoRepository {
|
|
|
1030
1030
|
/**
|
|
1031
1031
|
* sskts専用オファー保管
|
|
1032
1032
|
*/
|
|
1033
|
+
// tslint:disable-next-line:max-func-body-length
|
|
1033
1034
|
saveManyByIdentifier(params) {
|
|
1034
1035
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1035
|
-
//
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
$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 }
|
|
1053
1054
|
},
|
|
1054
|
-
|
|
1055
|
-
$
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
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
|
+
});
|
|
1067
1079
|
});
|
|
1068
|
-
}
|
|
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
|
+
}
|
|
1069
1094
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
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
|
+
}
|
|
1081
1138
|
}
|
|
1082
1139
|
});
|
|
1083
1140
|
}
|
|
@@ -1326,7 +1383,26 @@ class MongoRepository {
|
|
|
1326
1383
|
.exec();
|
|
1327
1384
|
}
|
|
1328
1385
|
if (Array.isArray(identifierIn) && identifierIn.length > 0) {
|
|
1329
|
-
|
|
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();
|
|
1330
1406
|
}
|
|
1331
1407
|
const bulkWriteOps = [];
|
|
1332
1408
|
if (aggregateOffers.length > 0) {
|
|
@@ -301,44 +301,40 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
301
301
|
transaction: params.transaction
|
|
302
302
|
});
|
|
303
303
|
const acceptedAppliesToMovieTicket = (_a = offerWithoutDetail.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
304
|
-
// let movieTicketIdentifire: string | undefined;
|
|
305
|
-
// if (Array.isArray(acceptedAppliesToMovieTicket)) {
|
|
306
|
-
// // throw new factory.errors.NotImplemented('multiple appliesToMovieTicket not implemented');
|
|
307
|
-
// // no op
|
|
308
|
-
// } else if (typeof acceptedAppliesToMovieTicket?.identifier === 'string') {
|
|
309
|
-
// movieTicketIdentifire = acceptedAppliesToMovieTicket.identifier;
|
|
310
|
-
// }
|
|
311
304
|
// 承認アクションオブジェクトのacceptedOfferにappliesToMovieTicketを連携する(2022-08-02~)
|
|
312
305
|
const priceSpecification = Object.assign(Object.assign({}, offer.priceSpecification), (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
|
|
313
306
|
? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
|
|
314
307
|
: undefined);
|
|
308
|
+
const acceptedAddOns = (Array.isArray(offerWithoutDetail.addOn))
|
|
309
|
+
? offerWithoutDetail.addOn.map((acceptedAddOnOffer) => {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
if (typeof acceptedAddOnOffer.id !== 'string' || acceptedAddOnOffer.id.length === 0) {
|
|
312
|
+
throw new factory.errors.ArgumentNull('object.acceptedOffer.addOn.id');
|
|
313
|
+
}
|
|
314
|
+
const addOnOfferReferenceQuantityValue = (_b = (_a = acceptedAddOnOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
315
|
+
return Object.assign({
|
|
316
|
+
// typeOf: <factory.offerType.Offer>factory.offerType.Offer,
|
|
317
|
+
id: acceptedAddOnOffer.id }, (typeof addOnOfferReferenceQuantityValue === 'number')
|
|
318
|
+
? { priceSpecification: { referenceQuantity: { value: addOnOfferReferenceQuantityValue } } }
|
|
319
|
+
: undefined);
|
|
320
|
+
})
|
|
321
|
+
: [];
|
|
315
322
|
const acceptedOffer = {
|
|
316
323
|
// オファーの中身を最適化する(必要最低限の情報のみに)
|
|
317
324
|
id: String(offer.id),
|
|
318
325
|
identifier: offer.identifier,
|
|
319
326
|
priceSpecification,
|
|
320
|
-
// project: offer.project,
|
|
321
327
|
typeOf: offer.typeOf,
|
|
322
328
|
priceCurrency: offer.priceCurrency,
|
|
323
329
|
itemOffered: Object.assign({ typeOf: factory.product.ProductType.EventService, serviceOutput: (offerWithoutDetail.itemOffered !== undefined && offerWithoutDetail.itemOffered !== null)
|
|
324
330
|
? offerWithoutDetail.itemOffered.serviceOutput
|
|
325
331
|
: undefined }, (pointAward !== undefined) ? { pointAward } : undefined),
|
|
326
|
-
addOn:
|
|
327
|
-
? offerWithoutDetail.addOn.map((a) => {
|
|
328
|
-
return {
|
|
329
|
-
typeOf: factory.offerType.Offer,
|
|
330
|
-
id: String(a.id),
|
|
331
|
-
priceCurrency: offer.priceCurrency
|
|
332
|
-
};
|
|
333
|
-
})
|
|
334
|
-
: [],
|
|
332
|
+
addOn: acceptedAddOns,
|
|
335
333
|
// 追加属性をマージ
|
|
336
334
|
additionalProperty: [
|
|
337
335
|
...(Array.isArray(offerWithoutDetail.additionalProperty)) ? offerWithoutDetail.additionalProperty : [],
|
|
338
336
|
...(Array.isArray(offer.additionalProperty)) ? offer.additionalProperty : []
|
|
339
337
|
]
|
|
340
|
-
// movieTicketIdentifireの不要を確認後に廃止(2022-09-09以降)(2022-11-02+)
|
|
341
|
-
// ...(typeof movieTicketIdentifire === 'string') ? { movieTicketIdentifire } : undefined
|
|
342
338
|
};
|
|
343
339
|
let offeredThrough = (_b = params.event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
|
|
344
340
|
if (typeof (offeredThrough === null || offeredThrough === void 0 ? void 0 : offeredThrough.typeOf) !== 'string') {
|
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
|
|
12
|
+
"@chevre/factory": "4.329.0-alpha.8",
|
|
13
|
+
"@cinerino/sdk": "3.166.0",
|
|
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.38"
|
|
121
121
|
}
|