@pisell/pisellos 2.3.95 → 2.3.97
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/dist/model/strategy/adapter/dataVariant/evaluator.js +13 -2
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +51 -28
- package/dist/modules/SalesSummary/index.js +6 -4
- package/dist/server/index.js +14 -8
- package/dist/server/modules/products/index.d.ts +2 -2
- package/dist/server/modules/products/index.js +10 -9
- package/dist/server/utils/product.d.ts +1 -1
- package/dist/server/utils/product.js +186 -22
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +136 -41
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +12 -2
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +33 -14
- package/lib/modules/SalesSummary/index.js +3 -1
- package/lib/server/index.js +10 -6
- package/lib/server/modules/products/index.d.ts +2 -2
- package/lib/server/modules/products/index.js +5 -4
- package/lib/server/utils/product.d.ts +1 -1
- package/lib/server/utils/product.js +163 -3
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +126 -33
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -322,8 +322,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
322
322
|
if (!(appliedInfo !== null && appliedInfo !== void 0 && (_appliedInfo$appliedF = appliedInfo.appliedFields) !== null && _appliedInfo$appliedF !== void 0 && _appliedInfo$appliedF.length)) {
|
|
323
323
|
return originalItem;
|
|
324
324
|
}
|
|
325
|
+
|
|
326
|
+
// 套餐加价/减价使用配置价;仅商品原价模式跟随子商品的 Data Variant 价格。
|
|
327
|
+
var isOriginalPriceBundleItem = originalItem.price_type === 'markup' && originalItem.price_type_ext === 'product_price';
|
|
328
|
+
var appliedFields = appliedInfo.appliedFields.filter(function (field) {
|
|
329
|
+
return field !== 'price' || isOriginalPriceBundleItem;
|
|
330
|
+
});
|
|
331
|
+
if (!appliedFields.length) {
|
|
332
|
+
return originalItem;
|
|
333
|
+
}
|
|
325
334
|
var result = _objectSpread({}, originalItem);
|
|
326
|
-
var _iterator6 = _createForOfIteratorHelper(
|
|
335
|
+
var _iterator6 = _createForOfIteratorHelper(appliedFields),
|
|
327
336
|
_step6;
|
|
328
337
|
try {
|
|
329
338
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
@@ -337,7 +346,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
337
346
|
} finally {
|
|
338
347
|
_iterator6.f();
|
|
339
348
|
}
|
|
340
|
-
result._dataVariant = appliedInfo
|
|
349
|
+
result._dataVariant = _objectSpread(_objectSpread({}, appliedInfo), {}, {
|
|
350
|
+
appliedFields: appliedFields
|
|
351
|
+
});
|
|
341
352
|
return result;
|
|
342
353
|
}
|
|
343
354
|
}, {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -179,6 +179,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
179
179
|
private calculateOrderPaidPaymentTotal;
|
|
180
180
|
private getDepositAmount;
|
|
181
181
|
private normalizeDepositAmount;
|
|
182
|
+
private normalizeDepositFlag;
|
|
183
|
+
private getHistoricalDepositSnapshot;
|
|
182
184
|
private getLastOrderDepositSnapshot;
|
|
183
185
|
private getLastOrderSubmitSnapshot;
|
|
184
186
|
private applyDepositAmountToSummary;
|
|
@@ -1536,21 +1536,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1536
1536
|
return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
1537
1537
|
}
|
|
1538
1538
|
}, {
|
|
1539
|
-
key: "
|
|
1540
|
-
value: function
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1539
|
+
key: "normalizeDepositFlag",
|
|
1540
|
+
value: function normalizeDepositFlag(value) {
|
|
1541
|
+
if (value === 0 || value === '0') return 0;
|
|
1542
|
+
if (value === 1 || value === '1') return 1;
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
}, {
|
|
1546
|
+
key: "getHistoricalDepositSnapshot",
|
|
1547
|
+
value: function getHistoricalDepositSnapshot(source) {
|
|
1548
|
+
var _record$deposit_amoun, _record$summary, _this$normalizeDeposi;
|
|
1549
|
+
if (!source || _typeof(source) !== 'object') return null;
|
|
1550
|
+
var record = source;
|
|
1551
|
+
var rawDepositAmount = (_record$deposit_amoun = record.deposit_amount) !== null && _record$deposit_amoun !== void 0 ? _record$deposit_amoun : (_record$summary = record.summary) === null || _record$summary === void 0 ? void 0 : _record$summary.deposit_amount;
|
|
1545
1552
|
var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
|
|
1546
|
-
|
|
1547
|
-
var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
|
|
1548
|
-
if (!isDeposit || !hasDepositAmount) return null;
|
|
1553
|
+
if (!new Decimal(depositAmount).gt(0)) return null;
|
|
1549
1554
|
return {
|
|
1550
|
-
|
|
1555
|
+
// 兼容历史数据:旧快照缺少 is_deposit 时,沿用正定金金额的推导规则。
|
|
1556
|
+
isDeposit: (_this$normalizeDeposi = this.normalizeDepositFlag(record.is_deposit)) !== null && _this$normalizeDeposi !== void 0 ? _this$normalizeDeposi : 1,
|
|
1551
1557
|
depositAmount: depositAmount
|
|
1552
1558
|
};
|
|
1553
1559
|
}
|
|
1560
|
+
}, {
|
|
1561
|
+
key: "getLastOrderDepositSnapshot",
|
|
1562
|
+
value: function getLastOrderDepositSnapshot() {
|
|
1563
|
+
return this.getHistoricalDepositSnapshot(this.store.lastOrderInfo);
|
|
1564
|
+
}
|
|
1554
1565
|
}, {
|
|
1555
1566
|
key: "getLastOrderSubmitSnapshot",
|
|
1556
1567
|
value: function getLastOrderSubmitSnapshot() {
|
|
@@ -1597,7 +1608,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1597
1608
|
})
|
|
1598
1609
|
});
|
|
1599
1610
|
tempOrder.deposit_amount = snapshot.depositAmount;
|
|
1600
|
-
tempOrder.is_deposit =
|
|
1611
|
+
tempOrder.is_deposit = snapshot.isDeposit;
|
|
1601
1612
|
return nextSummary;
|
|
1602
1613
|
}
|
|
1603
1614
|
}, {
|
|
@@ -2307,6 +2318,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2307
2318
|
}, {
|
|
2308
2319
|
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
2309
2320
|
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
2321
|
+
var _historicalDepositSna;
|
|
2310
2322
|
// merge hydrate 的商品集合包含本地未提交行,但 summary 仍来自远端旧订单,不能复用。
|
|
2311
2323
|
if (snapshot.requiresFullSummaryRecalculation === true) return null;
|
|
2312
2324
|
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
@@ -2318,10 +2330,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2318
2330
|
}
|
|
2319
2331
|
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
2320
2332
|
var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products));
|
|
2333
|
+
var historicalDepositSnapshot = this.getHistoricalDepositSnapshot(snapshot);
|
|
2321
2334
|
if (shouldUseManualDepositOverride) {
|
|
2322
2335
|
summary = this.applyDepositAmountToSummary(tempOrder, summary, manualDepositOverride.amount);
|
|
2323
|
-
} else
|
|
2324
|
-
|
|
2336
|
+
} else {
|
|
2337
|
+
if (manualDepositOverride) {
|
|
2338
|
+
this.clearManualDepositOverride(tempOrder);
|
|
2339
|
+
}
|
|
2340
|
+
if (historicalDepositSnapshot) {
|
|
2341
|
+
summary = this.applyDepositAmountToSummary(tempOrder, summary, historicalDepositSnapshot.depositAmount);
|
|
2342
|
+
tempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
|
|
2343
|
+
}
|
|
2325
2344
|
}
|
|
2326
2345
|
var isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
2327
2346
|
if (!isPayableAmountUnchanged) return null;
|
|
@@ -2338,8 +2357,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2338
2357
|
tempOrder.surcharges = cloneDeep(snapshot.surcharges);
|
|
2339
2358
|
}
|
|
2340
2359
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
2341
|
-
tempOrder.deposit_amount = summary.deposit_amount ||
|
|
2342
|
-
tempOrder.is_deposit =
|
|
2360
|
+
tempOrder.deposit_amount = this.normalizeDepositAmount(summary.deposit_amount || 0);
|
|
2361
|
+
tempOrder.is_deposit = shouldUseManualDepositOverride ? new Decimal(tempOrder.deposit_amount).gt(0) ? 1 : 0 : (_historicalDepositSna = historicalDepositSnapshot === null || historicalDepositSnapshot === void 0 ? void 0 : historicalDepositSnapshot.isDeposit) !== null && _historicalDepositSna !== void 0 ? _historicalDepositSna : new Decimal(tempOrder.deposit_amount).gt(0) ? 1 : 0;
|
|
2343
2362
|
var previousSummary = this.store.summary;
|
|
2344
2363
|
this.store.summary = summary;
|
|
2345
2364
|
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
@@ -3000,7 +3019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3000
3019
|
var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
|
|
3001
3020
|
tempOrder.deposit_amount = depositAmount;
|
|
3002
3021
|
tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
|
|
3003
|
-
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
3022
|
+
return shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
3004
3023
|
}
|
|
3005
3024
|
}, {
|
|
3006
3025
|
key: "recalculateSummary",
|
|
@@ -6401,7 +6420,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6401
6420
|
value: (function () {
|
|
6402
6421
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(record, options) {
|
|
6403
6422
|
var _sourceRaw$_extend, _this$store$discount22;
|
|
6404
|
-
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
|
|
6423
|
+
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
|
|
6405
6424
|
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6406
6425
|
while (1) switch (_context48.prev = _context48.next) {
|
|
6407
6426
|
case 0:
|
|
@@ -6486,6 +6505,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6486
6505
|
externalSaleNumber: nextTempOrder.external_sale_number
|
|
6487
6506
|
};
|
|
6488
6507
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
6508
|
+
historicalDepositSnapshot = this.getHistoricalDepositSnapshot(sourceLastOrderInfo);
|
|
6489
6509
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
6490
6510
|
return _objectSpread({}, s || {});
|
|
6491
6511
|
}) : cloneDeep(nextTempOrder.surcharges || []);
|
|
@@ -6493,7 +6513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6493
6513
|
surcharges: summarySurcharges
|
|
6494
6514
|
});
|
|
6495
6515
|
nextTempOrder._extend = _objectSpread(_objectSpread({}, nextTempOrder._extend || {}), {}, {
|
|
6496
|
-
originalSalesSnapshot: _objectSpread({
|
|
6516
|
+
originalSalesSnapshot: _objectSpread(_objectSpread({
|
|
6497
6517
|
summary: cloneDeep(this.store.summary),
|
|
6498
6518
|
products: cloneDeep(nextTempOrder.products || []),
|
|
6499
6519
|
bookings: cloneDeep(nextTempOrder.bookings || []),
|
|
@@ -6501,7 +6521,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6501
6521
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
6502
6522
|
shop_discount: nextTempOrder.shop_discount || '0.00',
|
|
6503
6523
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
6504
|
-
},
|
|
6524
|
+
}, historicalDepositSnapshot ? {
|
|
6525
|
+
is_deposit: historicalDepositSnapshot.isDeposit,
|
|
6526
|
+
deposit_amount: historicalDepositSnapshot.depositAmount
|
|
6527
|
+
} : {}), isMergedSalesDetailHydrate ? {
|
|
6505
6528
|
requiresFullSummaryRecalculation: true
|
|
6506
6529
|
} : {})
|
|
6507
6530
|
});
|
|
@@ -6524,28 +6547,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6524
6547
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
6525
6548
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
6526
6549
|
if (shouldSkipEmptyDiscountSync) {
|
|
6527
|
-
_context48.next =
|
|
6550
|
+
_context48.next = 54;
|
|
6528
6551
|
break;
|
|
6529
6552
|
}
|
|
6530
6553
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6531
|
-
_context48.next =
|
|
6554
|
+
_context48.next = 52;
|
|
6532
6555
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList(nextDiscounts);
|
|
6533
|
-
case
|
|
6534
|
-
_context48.next =
|
|
6556
|
+
case 52:
|
|
6557
|
+
_context48.next = 54;
|
|
6535
6558
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setDiscountList(nextDiscounts);
|
|
6536
|
-
case
|
|
6559
|
+
case 54:
|
|
6537
6560
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6538
|
-
_context48.next =
|
|
6561
|
+
_context48.next = 57;
|
|
6539
6562
|
break;
|
|
6540
6563
|
}
|
|
6541
|
-
_context48.next =
|
|
6564
|
+
_context48.next = 57;
|
|
6542
6565
|
return this.recalculateSummary({
|
|
6543
6566
|
createIfMissing: false
|
|
6544
6567
|
});
|
|
6545
|
-
case
|
|
6568
|
+
case 57:
|
|
6546
6569
|
this.persistTempOrder();
|
|
6547
6570
|
return _context48.abrupt("return", nextTempOrder);
|
|
6548
|
-
case
|
|
6571
|
+
case 59:
|
|
6549
6572
|
case "end":
|
|
6550
6573
|
return _context48.stop();
|
|
6551
6574
|
}
|
|
@@ -212,8 +212,8 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
212
212
|
key: "getSummary",
|
|
213
213
|
value: function () {
|
|
214
214
|
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
215
|
-
var _this$store$surcharge, _ref;
|
|
216
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
215
|
+
var _this$otherParams2, _this$store$surcharge, _ref;
|
|
216
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
217
217
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
218
218
|
while (1) switch (_context4.prev = _context4.next) {
|
|
219
219
|
case 0:
|
|
@@ -227,7 +227,9 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
227
227
|
return this.getSurchargeList(summaryChannel);
|
|
228
228
|
case 5:
|
|
229
229
|
taxConfig = this.getTaxConfig();
|
|
230
|
-
|
|
230
|
+
fatherModuleName = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule) || this.name.replace(/_salesSummary$/, '');
|
|
231
|
+
scheduleModuleName = "".concat(fatherModuleName, "_schedule");
|
|
232
|
+
summarySchedule = this.core.getModule(scheduleModuleName);
|
|
231
233
|
needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
|
|
232
234
|
return item.available_schedule_ids;
|
|
233
235
|
})) === null || _this$store$surcharge === void 0 ? void 0 : _this$store$surcharge.flat()) || []).filter(function (id) {
|
|
@@ -264,7 +266,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
264
266
|
});
|
|
265
267
|
this.store.summary = summaryWithTaxMeta;
|
|
266
268
|
return _context4.abrupt("return", summaryWithTaxMeta);
|
|
267
|
-
case
|
|
269
|
+
case 17:
|
|
268
270
|
case "end":
|
|
269
271
|
return _context4.stop();
|
|
270
272
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -5504,29 +5504,33 @@ var Server = /*#__PURE__*/function () {
|
|
|
5504
5504
|
if (!Array.isArray(bookings)) return '';
|
|
5505
5505
|
var values = [];
|
|
5506
5506
|
var seen = new Set();
|
|
5507
|
-
var visitResource = function visitResource(resource) {
|
|
5508
|
-
var identifier = _this15.getCheckoutResourceIdentifier(resource);
|
|
5507
|
+
var visitResource = function visitResource(resource, fallbackName) {
|
|
5508
|
+
var identifier = _this15.getCheckoutResourceIdentifier(resource, fallbackName);
|
|
5509
5509
|
if (identifier && !seen.has(identifier)) {
|
|
5510
5510
|
seen.add(identifier);
|
|
5511
5511
|
values.push(identifier);
|
|
5512
5512
|
}
|
|
5513
5513
|
if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
|
|
5514
|
-
resource.children.forEach(
|
|
5514
|
+
resource.children.forEach(function (child) {
|
|
5515
|
+
return visitResource(child);
|
|
5516
|
+
});
|
|
5515
5517
|
}
|
|
5516
5518
|
};
|
|
5517
5519
|
bookings.forEach(function (booking) {
|
|
5518
5520
|
if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
|
|
5519
|
-
booking.resources.forEach(
|
|
5521
|
+
booking.resources.forEach(function (resource, index) {
|
|
5522
|
+
visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
|
|
5523
|
+
});
|
|
5520
5524
|
}
|
|
5521
5525
|
});
|
|
5522
5526
|
return values.join(',');
|
|
5523
5527
|
}
|
|
5524
5528
|
}, {
|
|
5525
5529
|
key: "getCheckoutResourceIdentifier",
|
|
5526
|
-
value: function getCheckoutResourceIdentifier(resource) {
|
|
5530
|
+
value: function getCheckoutResourceIdentifier(resource, fallbackName) {
|
|
5527
5531
|
var _resource$metadata, _resource$metadata2;
|
|
5528
5532
|
if (!resource || _typeof(resource) !== 'object') return '';
|
|
5529
|
-
var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, resource.relation_id, resource.id];
|
|
5533
|
+
var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
|
|
5530
5534
|
for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
|
|
5531
5535
|
var candidate = _candidates[_i2];
|
|
5532
5536
|
var value = this.stringifyCheckoutResourceIdentifier(candidate);
|
|
@@ -8327,16 +8331,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
8327
8331
|
}, {
|
|
8328
8332
|
key: "buildProductFormatterContext",
|
|
8329
8333
|
value: function buildProductFormatterContext(context) {
|
|
8330
|
-
var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$
|
|
8334
|
+
var _this$core$context5, _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context6;
|
|
8331
8335
|
var scheduleModule = this.getSchedule();
|
|
8332
8336
|
return {
|
|
8333
8337
|
scheduleModule: scheduleModule,
|
|
8334
8338
|
schedule_datetime: context.schedule_datetime,
|
|
8335
8339
|
customer_id: context.customer_id,
|
|
8336
8340
|
strategy_context: context.strategy_context,
|
|
8341
|
+
// 固定本次商品查询使用的语言,确保格式化与缓存使用同一份 locale 快照。
|
|
8342
|
+
locale: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.locale,
|
|
8337
8343
|
menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
|
|
8338
8344
|
scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
|
|
8339
|
-
dataVariantEvaluator: (_this$core$
|
|
8345
|
+
dataVariantEvaluator: (_this$core$context6 = this.core.context) === null || _this$core$context6 === void 0 ? void 0 : _this$core$context6.dataVariantEvaluator
|
|
8340
8346
|
};
|
|
8341
8347
|
}
|
|
8342
8348
|
|
|
@@ -89,8 +89,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
89
89
|
private buildBundleGroupPriceData;
|
|
90
90
|
/**
|
|
91
91
|
* 获取应用了价格的商品列表(带缓存)
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* 使用时间、客户、策略、商品范围和语言作为缓存 key
|
|
93
|
+
* 缓存的是已经应用了价格与多语言的完整商品列表,避免重复转换
|
|
94
94
|
* @param schedule_date 日期
|
|
95
95
|
* @param extraContext 额外的上下文数据(可选,由 Server 层传入)
|
|
96
96
|
* @param options 可选参数
|
|
@@ -61,7 +61,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
61
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
62
62
|
// LoggerManager 实例
|
|
63
63
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
64
|
-
//
|
|
64
|
+
// 商品格式化缓存:Map<查询上下文 key, 已应用价格与多语言的商品列表>
|
|
65
65
|
_defineProperty(_assertThisInitialized(_this), "productsPriceCache", new Map());
|
|
66
66
|
// 缓存配置
|
|
67
67
|
_defineProperty(_assertThisInitialized(_this), "CACHE_MAX_DAYS", 7);
|
|
@@ -585,8 +585,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
585
585
|
|
|
586
586
|
/**
|
|
587
587
|
* 获取应用了价格的商品列表(带缓存)
|
|
588
|
-
*
|
|
589
|
-
*
|
|
588
|
+
* 使用时间、客户、策略、商品范围和语言作为缓存 key
|
|
589
|
+
* 缓存的是已经应用了价格与多语言的完整商品列表,避免重复转换
|
|
590
590
|
* @param schedule_date 日期
|
|
591
591
|
* @param extraContext 额外的上下文数据(可选,由 Server 层传入)
|
|
592
592
|
* @param options 可选参数
|
|
@@ -877,11 +877,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
877
877
|
}, {
|
|
878
878
|
key: "getProductsPriceCacheKey",
|
|
879
879
|
value: function getProductsPriceCacheKey(schedule_date, extraContext, productIds) {
|
|
880
|
-
var _extraContext$custome;
|
|
880
|
+
var _ref13, _extraContext$locale, _this$core3, _extraContext$custome;
|
|
881
881
|
var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
|
|
882
|
+
var locale = (_ref13 = (_extraContext$locale = extraContext === null || extraContext === void 0 ? void 0 : extraContext.locale) !== null && _extraContext$locale !== void 0 ? _extraContext$locale : (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.locale) !== null && _ref13 !== void 0 ? _ref13 : '';
|
|
882
883
|
var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
|
|
883
884
|
var strategyScope = this.stringifyStable((extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context) || {});
|
|
884
|
-
return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : ''
|
|
885
|
+
return "".concat(datetime, ":locale:").concat(locale, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '') + ":strategy:".concat(strategyScope).concat(productScope);
|
|
885
886
|
}
|
|
886
887
|
|
|
887
888
|
/**
|
|
@@ -1119,8 +1120,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1119
1120
|
}, {
|
|
1120
1121
|
key: "shouldEnableLegacyPriceFormatter",
|
|
1121
1122
|
value: function shouldEnableLegacyPriceFormatter() {
|
|
1122
|
-
var _this$otherParams3, _this$
|
|
1123
|
-
return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$
|
|
1123
|
+
var _this$otherParams3, _this$core4;
|
|
1124
|
+
return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.enableLegacyPriceFormatter) === true;
|
|
1124
1125
|
}
|
|
1125
1126
|
|
|
1126
1127
|
/**
|
|
@@ -1300,11 +1301,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1300
1301
|
key: "fetchProductsByHttp",
|
|
1301
1302
|
value: (function () {
|
|
1302
1303
|
var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1303
|
-
var
|
|
1304
|
+
var _ref14, _ref14$category_ids, category_ids, _ref14$product_ids, product_ids, _ref14$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
|
|
1304
1305
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1305
1306
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1306
1307
|
case 0:
|
|
1307
|
-
|
|
1308
|
+
_ref14 = params || {}, _ref14$category_ids = _ref14.category_ids, category_ids = _ref14$category_ids === void 0 ? [] : _ref14$category_ids, _ref14$product_ids = _ref14.product_ids, product_ids = _ref14$product_ids === void 0 ? [] : _ref14$product_ids, _ref14$collection = _ref14.collection, collection = _ref14$collection === void 0 ? [] : _ref14$collection, customer_id = _ref14.customer_id, cacheId = _ref14.cacheId;
|
|
1308
1309
|
this.logInfo('fetchProductsByHttp: 开始请求', {
|
|
1309
1310
|
categoryIdsCount: category_ids.length,
|
|
1310
1311
|
productIdsCount: product_ids.length,
|
|
@@ -11,7 +11,7 @@ export declare function perfMark(label: string, durationMs: number, meta?: Recor
|
|
|
11
11
|
export declare function applyPriceDataToProducts(products: ProductData[], priceData: LoadProductsPriceData[]): ProductData[];
|
|
12
12
|
export declare const getIsSessionProduct: (product: ProductData) => boolean;
|
|
13
13
|
/**
|
|
14
|
-
* 根据 locale
|
|
14
|
+
* 根据 locale 格式化商品、分类、规格及套餐文案,缺少对应语言时回退 original。
|
|
15
15
|
*/
|
|
16
16
|
export declare function applyI18nToProducts(products: ProductData[], locale?: string): ProductData[];
|
|
17
17
|
/**
|