@pisell/pisellos 2.3.22 → 2.3.24
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/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +42 -15
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils.d.ts +2 -2
- package/dist/modules/Order/utils.js +35 -47
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/server/index.d.ts +50 -0
- package/dist/server/index.js +995 -749
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +167 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +30 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +27 -4
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils.d.ts +2 -2
- package/lib/modules/Order/utils.js +0 -3
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/server/index.d.ts +50 -0
- package/lib/server/index.js +206 -29
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +114 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +17 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -68,6 +68,10 @@ export interface DiscountWithReason {
|
|
|
68
68
|
discountList: Discount[];
|
|
69
69
|
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
70
70
|
}
|
|
71
|
+
export interface DiscountPrepareConfigResult {
|
|
72
|
+
discountList: Discount[];
|
|
73
|
+
availableWalletIds: number[];
|
|
74
|
+
}
|
|
71
75
|
interface ExtensionData {
|
|
72
76
|
id: number;
|
|
73
77
|
shop_id: number;
|
|
@@ -75,6 +75,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
75
75
|
apply?: boolean;
|
|
76
76
|
}): Promise<Discount[]>;
|
|
77
77
|
getDiscountList(): Discount[];
|
|
78
|
+
getAvailableWalletIds(): number[];
|
|
78
79
|
private ensureEditDiscountConfigForProductChange;
|
|
79
80
|
scanCode(code: string, customerId?: number): Promise<{
|
|
80
81
|
isAvailable: boolean;
|
|
@@ -276,6 +277,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
276
277
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
277
278
|
private buildTempOrderCustomer;
|
|
278
279
|
private isCustomerBoundDiscount;
|
|
280
|
+
private shouldKeepCustomerBoundDiscountAfterCustomerChange;
|
|
279
281
|
private productHasCustomerBoundDiscount;
|
|
280
282
|
private shouldSkipDiscountCalculation;
|
|
281
283
|
private clearCustomerBoundDiscounts;
|
|
@@ -295,14 +295,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
295
295
|
if (!this.store.summary) {
|
|
296
296
|
this.store.summary = createEmptySummary();
|
|
297
297
|
}
|
|
298
|
+
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
299
|
+
this.store.availableWalletIds = [];
|
|
300
|
+
}
|
|
298
301
|
this.request = this.core.getPlugin('request');
|
|
299
302
|
appPlugin = this.core.getPlugin('app');
|
|
300
303
|
if (appPlugin) {
|
|
301
|
-
_context.next =
|
|
304
|
+
_context.next = 9;
|
|
302
305
|
break;
|
|
303
306
|
}
|
|
304
307
|
throw new Error('Order 模块需要 app 插件支持');
|
|
305
|
-
case
|
|
308
|
+
case 9:
|
|
306
309
|
app = appPlugin.getApp();
|
|
307
310
|
this.logger = app.logger;
|
|
308
311
|
this.window = this.core.getPlugin('window');
|
|
@@ -315,7 +318,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
315
318
|
this.otherParams = otherParams;
|
|
316
319
|
this.registerDiscountModules(options);
|
|
317
320
|
this.logInfo('OrderModule initialized successfully');
|
|
318
|
-
case
|
|
321
|
+
case 21:
|
|
319
322
|
case "end":
|
|
320
323
|
return _context.stop();
|
|
321
324
|
}
|
|
@@ -492,7 +495,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
492
495
|
value: function () {
|
|
493
496
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
494
497
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
495
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
498
|
+
var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
496
499
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
497
500
|
while (1) switch (_context3.prev = _context3.next) {
|
|
498
501
|
case 0:
|
|
@@ -504,37 +507,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
504
507
|
with_good_pass: 1,
|
|
505
508
|
with_discount_card: 1,
|
|
506
509
|
with_wallet_pass_holder: 1,
|
|
510
|
+
with_available_wallet_flag: 1,
|
|
511
|
+
with_available_wallet_pass_flag: 1,
|
|
507
512
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
508
513
|
}, orderId ? {
|
|
509
514
|
order_id: orderId
|
|
510
515
|
} : {}));
|
|
511
516
|
case 3:
|
|
512
|
-
|
|
517
|
+
prepareConfigResult = _context3.sent;
|
|
518
|
+
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
519
|
+
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
513
520
|
if (!discountList) {
|
|
514
|
-
_context3.next =
|
|
521
|
+
_context3.next = 18;
|
|
515
522
|
break;
|
|
516
523
|
}
|
|
517
|
-
|
|
524
|
+
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
525
|
+
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
518
526
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
519
527
|
});
|
|
528
|
+
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
529
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
530
|
+
});
|
|
531
|
+
currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
|
|
532
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
533
|
+
}));
|
|
520
534
|
runtimeDiscountIds = new Set();
|
|
521
535
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
536
|
+
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
522
537
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
523
538
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
524
539
|
return true;
|
|
525
540
|
});
|
|
526
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
527
|
-
_context3.next =
|
|
541
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
542
|
+
_context3.next = 16;
|
|
528
543
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
529
|
-
case
|
|
530
|
-
_context3.next =
|
|
544
|
+
case 16:
|
|
545
|
+
_context3.next = 18;
|
|
531
546
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
532
|
-
case
|
|
547
|
+
case 18:
|
|
533
548
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
534
549
|
this.applyDiscount();
|
|
535
550
|
}
|
|
536
551
|
return _context3.abrupt("return", this.getDiscountList());
|
|
537
|
-
case
|
|
552
|
+
case 20:
|
|
538
553
|
case "end":
|
|
539
554
|
return _context3.stop();
|
|
540
555
|
}
|
|
@@ -551,6 +566,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
551
566
|
var _this$store$discount5;
|
|
552
567
|
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
553
568
|
}
|
|
569
|
+
}, {
|
|
570
|
+
key: "getAvailableWalletIds",
|
|
571
|
+
value: function getAvailableWalletIds() {
|
|
572
|
+
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
573
|
+
}
|
|
554
574
|
}, {
|
|
555
575
|
key: "ensureEditDiscountConfigForProductChange",
|
|
556
576
|
value: function () {
|
|
@@ -2962,6 +2982,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2962
2982
|
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2963
2983
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2964
2984
|
}
|
|
2985
|
+
}, {
|
|
2986
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
2987
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2988
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
2989
|
+
}
|
|
2965
2990
|
}, {
|
|
2966
2991
|
key: "productHasCustomerBoundDiscount",
|
|
2967
2992
|
value: function productHasCustomerBoundDiscount(product) {
|
|
@@ -3029,11 +3054,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
3054
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3030
3055
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3031
3056
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3032
|
-
if (discount
|
|
3057
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3033
3058
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3034
3059
|
});
|
|
3035
3060
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3036
|
-
if (discount
|
|
3061
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3037
3062
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3038
3063
|
});
|
|
3039
3064
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
@@ -3105,6 +3130,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3105
3130
|
}
|
|
3106
3131
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3107
3132
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3133
|
+
this.store.availableWalletIds = [];
|
|
3108
3134
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3109
3135
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3110
3136
|
this.applyDiscount();
|
|
@@ -3149,6 +3175,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3149
3175
|
tempOrder.email = '';
|
|
3150
3176
|
tempOrder.customer = null;
|
|
3151
3177
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3178
|
+
this.store.availableWalletIds = [];
|
|
3152
3179
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3153
3180
|
this.persistTempOrder();
|
|
3154
3181
|
this.saveDraftInBackground();
|
|
@@ -309,6 +309,7 @@ export interface OrderState {
|
|
|
309
309
|
lastOrderInfo?: Record<string, any>;
|
|
310
310
|
syncState?: OrderSyncState;
|
|
311
311
|
discountList: any[];
|
|
312
|
+
availableWalletIds?: number[];
|
|
312
313
|
discount: DiscountModule | null;
|
|
313
314
|
rules: RulesModule | null;
|
|
314
315
|
}
|
|
@@ -775,6 +776,7 @@ export interface OrderModuleAPI {
|
|
|
775
776
|
apply?: boolean;
|
|
776
777
|
}) => Promise<Discount[]>;
|
|
777
778
|
getDiscountList: () => Discount[];
|
|
779
|
+
getAvailableWalletIds: () => number[];
|
|
778
780
|
applyDiscount: () => void;
|
|
779
781
|
/**
|
|
780
782
|
* 注入促销评估器。
|
|
@@ -67,8 +67,8 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
67
67
|
/**
|
|
68
68
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
71
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
72
72
|
*/
|
|
73
73
|
export declare function calculateOrderProductsDeposit(products?: OrderProduct[], options?: {
|
|
74
74
|
productsByUid?: Record<string, Record<string, any>>;
|
|
@@ -252,8 +252,8 @@ function getOrderProductDeposit(product, runtimeOrigin) {
|
|
|
252
252
|
/**
|
|
253
253
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
254
254
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
255
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
256
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
257
257
|
*/
|
|
258
258
|
export function calculateOrderProductsDeposit() {
|
|
259
259
|
var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -273,30 +273,18 @@ export function calculateOrderProductsDeposit() {
|
|
|
273
273
|
product.deposit = deposit;
|
|
274
274
|
if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
|
|
275
275
|
total = total.plus(deposit.total);
|
|
276
|
-
var _iterator4 = _createForOfIteratorHelper(
|
|
276
|
+
var _iterator4 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
277
277
|
_step4;
|
|
278
278
|
try {
|
|
279
279
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
280
|
-
var
|
|
281
|
-
|
|
280
|
+
var protocol = _step4.value;
|
|
281
|
+
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
282
282
|
}
|
|
283
283
|
} catch (err) {
|
|
284
284
|
_iterator4.e(err);
|
|
285
285
|
} finally {
|
|
286
286
|
_iterator4.f();
|
|
287
287
|
}
|
|
288
|
-
var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
289
|
-
_step5;
|
|
290
|
-
try {
|
|
291
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
292
|
-
var protocol = _step5.value;
|
|
293
|
-
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
294
|
-
}
|
|
295
|
-
} catch (err) {
|
|
296
|
-
_iterator5.e(err);
|
|
297
|
-
} finally {
|
|
298
|
-
_iterator5.f();
|
|
299
|
-
}
|
|
300
288
|
hasDeposit = true;
|
|
301
289
|
}
|
|
302
290
|
} catch (err) {
|
|
@@ -460,19 +448,19 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
460
448
|
}
|
|
461
449
|
function collectSubmitProductDiscountList(product) {
|
|
462
450
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
463
|
-
var
|
|
464
|
-
|
|
451
|
+
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
452
|
+
_step5;
|
|
465
453
|
try {
|
|
466
|
-
for (
|
|
467
|
-
var bundle =
|
|
454
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
455
|
+
var bundle = _step5.value;
|
|
468
456
|
if (!bundle || _typeof(bundle) !== 'object') continue;
|
|
469
457
|
var bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
470
458
|
var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
471
|
-
var
|
|
472
|
-
|
|
459
|
+
var _iterator6 = _createForOfIteratorHelper(bundleDiscountList),
|
|
460
|
+
_step6;
|
|
473
461
|
try {
|
|
474
|
-
for (
|
|
475
|
-
var discount =
|
|
462
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
463
|
+
var discount = _step6.value;
|
|
476
464
|
if (!discount || _typeof(discount) !== 'object') continue;
|
|
477
465
|
var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
|
|
478
466
|
var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
@@ -483,15 +471,15 @@ function collectSubmitProductDiscountList(product) {
|
|
|
483
471
|
} : {}));
|
|
484
472
|
}
|
|
485
473
|
} catch (err) {
|
|
486
|
-
|
|
474
|
+
_iterator6.e(err);
|
|
487
475
|
} finally {
|
|
488
|
-
|
|
476
|
+
_iterator6.f();
|
|
489
477
|
}
|
|
490
478
|
}
|
|
491
479
|
} catch (err) {
|
|
492
|
-
|
|
480
|
+
_iterator5.e(err);
|
|
493
481
|
} finally {
|
|
494
|
-
|
|
482
|
+
_iterator5.f();
|
|
495
483
|
}
|
|
496
484
|
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
497
485
|
}
|
|
@@ -961,19 +949,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
961
949
|
export function normalizeSubmitBooking(booking) {
|
|
962
950
|
var rawMetadata = booking.metadata || {};
|
|
963
951
|
var cleanMetadata = {};
|
|
964
|
-
var
|
|
965
|
-
|
|
952
|
+
var _iterator7 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
953
|
+
_step7;
|
|
966
954
|
try {
|
|
967
|
-
for (
|
|
968
|
-
var key =
|
|
955
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
956
|
+
var key = _step7.value;
|
|
969
957
|
if (rawMetadata[key] !== undefined) {
|
|
970
958
|
cleanMetadata[key] = rawMetadata[key];
|
|
971
959
|
}
|
|
972
960
|
}
|
|
973
961
|
} catch (err) {
|
|
974
|
-
|
|
962
|
+
_iterator7.e(err);
|
|
975
963
|
} finally {
|
|
976
|
-
|
|
964
|
+
_iterator7.f();
|
|
977
965
|
}
|
|
978
966
|
if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
|
|
979
967
|
var bookingRecord = booking;
|
|
@@ -1286,25 +1274,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1286
1274
|
target[key] = null;
|
|
1287
1275
|
changed = true;
|
|
1288
1276
|
};
|
|
1289
|
-
var
|
|
1290
|
-
|
|
1277
|
+
var _iterator8 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1278
|
+
_step8;
|
|
1291
1279
|
try {
|
|
1292
|
-
for (
|
|
1293
|
-
var product =
|
|
1280
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1281
|
+
var product = _step8.value;
|
|
1294
1282
|
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1295
1283
|
resetHolderField(product.metadata);
|
|
1296
1284
|
}
|
|
1297
1285
|
}
|
|
1298
1286
|
} catch (err) {
|
|
1299
|
-
|
|
1287
|
+
_iterator8.e(err);
|
|
1300
1288
|
} finally {
|
|
1301
|
-
|
|
1289
|
+
_iterator8.f();
|
|
1302
1290
|
}
|
|
1303
|
-
var
|
|
1304
|
-
|
|
1291
|
+
var _iterator9 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1292
|
+
_step9;
|
|
1305
1293
|
try {
|
|
1306
|
-
for (
|
|
1307
|
-
var booking =
|
|
1294
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1295
|
+
var booking = _step9.value;
|
|
1308
1296
|
var bookingRecord = booking;
|
|
1309
1297
|
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1310
1298
|
resetHolderField(booking.metadata);
|
|
@@ -1315,9 +1303,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1315
1303
|
}
|
|
1316
1304
|
}
|
|
1317
1305
|
} catch (err) {
|
|
1318
|
-
|
|
1306
|
+
_iterator9.e(err);
|
|
1319
1307
|
} finally {
|
|
1320
|
-
|
|
1308
|
+
_iterator9.f();
|
|
1321
1309
|
}
|
|
1322
1310
|
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
1323
1311
|
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
@@ -9,6 +9,26 @@ export interface ProductCollection {
|
|
|
9
9
|
/** 商品集合封面 */
|
|
10
10
|
cover: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 商品 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
14
|
+
*/
|
|
15
|
+
export interface ProductDataVariant {
|
|
16
|
+
/** 变体记录 id */
|
|
17
|
+
id: number;
|
|
18
|
+
/** 店铺 id */
|
|
19
|
+
shop_id: number;
|
|
20
|
+
/** 所属模块,商品场景固定为 product */
|
|
21
|
+
module: string;
|
|
22
|
+
/** 模块数据 id,商品场景对应 product.id */
|
|
23
|
+
module_data_id: number;
|
|
24
|
+
/** 关联 data_variant_rule.id */
|
|
25
|
+
data_variant_rule_id: number;
|
|
26
|
+
/** 命中策略后覆盖到商品上的字段 */
|
|
27
|
+
data: Record<string, any>;
|
|
28
|
+
created_at: string | null;
|
|
29
|
+
updated_at: string | null;
|
|
30
|
+
deleted_at: string | null;
|
|
31
|
+
}
|
|
12
32
|
/**
|
|
13
33
|
* 商品基本信息接口
|
|
14
34
|
*/
|
|
@@ -214,6 +234,8 @@ export interface ProductData {
|
|
|
214
234
|
bundle_group_count: number;
|
|
215
235
|
/** 选项组数量 */
|
|
216
236
|
option_group_count: number;
|
|
237
|
+
/** 智能定价变体列表,/product/query with dataVariants 返回 */
|
|
238
|
+
data_variants?: ProductDataVariant[];
|
|
217
239
|
/** 服务时长 */
|
|
218
240
|
service_times?: any;
|
|
219
241
|
}
|
|
@@ -26,7 +26,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
26
26
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
27
|
*/
|
|
28
28
|
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
|
|
29
|
-
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
|
|
29
|
+
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
|
|
30
30
|
callback?: (result: any) => void;
|
|
31
31
|
subscriberId?: string;
|
|
32
32
|
}): Promise<any>;
|
|
@@ -152,6 +152,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
152
152
|
extension_type,
|
|
153
153
|
_ref$status,
|
|
154
154
|
status,
|
|
155
|
+
strategy_context,
|
|
155
156
|
options,
|
|
156
157
|
userPlugin,
|
|
157
158
|
customer_id,
|
|
@@ -162,7 +163,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
163
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
163
164
|
while (1) switch (_context4.prev = _context4.next) {
|
|
164
165
|
case 0:
|
|
165
|
-
_ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status;
|
|
166
|
+
_ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
|
|
166
167
|
options = _args4.length > 1 ? _args4[1] : undefined;
|
|
167
168
|
// // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
168
169
|
// if (!schedule_ids?.length) {
|
|
@@ -206,7 +207,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
207
|
is_eject: 1,
|
|
207
208
|
with_schedule: with_schedule,
|
|
208
209
|
schedule_datetime: schedule_datetime,
|
|
209
|
-
extension_type: extension_type
|
|
210
|
+
extension_type: extension_type,
|
|
211
|
+
strategy_context: strategy_context
|
|
210
212
|
}, {
|
|
211
213
|
osServer: true,
|
|
212
214
|
callback: options === null || options === void 0 ? void 0 : options.callback,
|
|
@@ -12,6 +12,8 @@ export interface ProductListLoadProductsParams {
|
|
|
12
12
|
with_schedule?: number;
|
|
13
13
|
extension_type?: string[];
|
|
14
14
|
status?: string;
|
|
15
|
+
/** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
|
|
16
|
+
strategy_context?: Record<string, any>;
|
|
15
17
|
}
|
|
16
18
|
export interface ProductListData {
|
|
17
19
|
list: ProductData[];
|
package/dist/server/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ declare class Server {
|
|
|
47
47
|
private prefixRouterGet;
|
|
48
48
|
router: Router;
|
|
49
49
|
private productQuerySubscribers;
|
|
50
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
|
+
private productQueryScheduleTimers;
|
|
50
52
|
private orderQuerySubscribers;
|
|
51
53
|
private bookingQuerySubscribers;
|
|
52
54
|
private bookingRemoteQuerySubscribers;
|
|
@@ -210,6 +212,48 @@ declare class Server {
|
|
|
210
212
|
* 根据 subscriberId 移除商品查询订阅者
|
|
211
213
|
*/
|
|
212
214
|
removeProductQuerySubscriber(subscriberId?: string): void;
|
|
215
|
+
/**
|
|
216
|
+
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
217
|
+
*/
|
|
218
|
+
private buildProductQueryResultPayload;
|
|
219
|
+
/**
|
|
220
|
+
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
221
|
+
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
222
|
+
*/
|
|
223
|
+
private shouldScheduleProductQueryReload;
|
|
224
|
+
/**
|
|
225
|
+
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
226
|
+
*/
|
|
227
|
+
private clearSubscriberScheduleTimers;
|
|
228
|
+
/**
|
|
229
|
+
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
230
|
+
*/
|
|
231
|
+
private removeScheduleTimerRef;
|
|
232
|
+
/**
|
|
233
|
+
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
234
|
+
*/
|
|
235
|
+
private computeScheduleTimePointDelayMs;
|
|
236
|
+
/**
|
|
237
|
+
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
238
|
+
*/
|
|
239
|
+
private refreshSubscriberScheduleAtExecution;
|
|
240
|
+
/**
|
|
241
|
+
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
242
|
+
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
243
|
+
*/
|
|
244
|
+
private scheduleSubscriberTimePointReloads;
|
|
245
|
+
/**
|
|
246
|
+
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
247
|
+
*/
|
|
248
|
+
private onScheduleTimePointTimerFire;
|
|
249
|
+
/**
|
|
250
|
+
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
251
|
+
*/
|
|
252
|
+
private recomputeAndNotifySubscriber;
|
|
253
|
+
/**
|
|
254
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
255
|
+
*/
|
|
256
|
+
private syncProductQueryScheduleTimers;
|
|
213
257
|
/**
|
|
214
258
|
* 处理商品查询请求
|
|
215
259
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -570,6 +614,12 @@ declare class Server {
|
|
|
570
614
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
571
615
|
*/
|
|
572
616
|
private computeProductQueryResult;
|
|
617
|
+
/**
|
|
618
|
+
* 构建商品格式化上下文。
|
|
619
|
+
*
|
|
620
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
621
|
+
*/
|
|
622
|
+
private buildProductFormatterContext;
|
|
573
623
|
/**
|
|
574
624
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
575
625
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|