@pisell/pisellos 2.2.258 → 2.2.260

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.
Files changed (90) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
  14. package/dist/modules/Order/index.d.ts +2 -30
  15. package/dist/modules/Order/index.js +241 -508
  16. package/dist/modules/Order/types.d.ts +2 -20
  17. package/dist/modules/Order/utils.d.ts +0 -4
  18. package/dist/modules/Order/utils.js +28 -114
  19. package/dist/modules/Product/index.d.ts +1 -1
  20. package/dist/modules/Product/types.d.ts +22 -0
  21. package/dist/modules/ProductList/index.d.ts +1 -1
  22. package/dist/modules/ProductList/index.js +4 -2
  23. package/dist/modules/ProductList/types.d.ts +2 -0
  24. package/dist/modules/Rules/index.d.ts +3 -3
  25. package/dist/modules/Rules/index.js +3 -8
  26. package/dist/modules/Rules/types.d.ts +1 -2
  27. package/dist/server/index.d.ts +50 -3
  28. package/dist/server/index.js +958 -1000
  29. package/dist/server/modules/order/index.d.ts +3 -22
  30. package/dist/server/modules/order/index.js +314 -397
  31. package/dist/server/modules/products/index.d.ts +26 -7
  32. package/dist/server/modules/products/index.js +166 -76
  33. package/dist/server/modules/products/types.d.ts +14 -0
  34. package/dist/solution/BaseSales/index.d.ts +2 -16
  35. package/dist/solution/BaseSales/index.js +314 -484
  36. package/dist/solution/BaseSales/types.d.ts +0 -1
  37. package/dist/solution/BaseSales/types.js +1 -2
  38. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
  39. package/dist/solution/BookingByStep/index.d.ts +1 -1
  40. package/dist/solution/BookingTicket/index.d.ts +1 -9
  41. package/dist/solution/BookingTicket/index.js +6 -162
  42. package/dist/solution/BookingTicket/types.d.ts +2 -0
  43. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  44. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  46. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  48. package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  50. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  52. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  53. package/lib/model/strategy/adapter/index.d.ts +4 -0
  54. package/lib/model/strategy/adapter/index.js +13 -2
  55. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  56. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
  57. package/lib/modules/Order/index.d.ts +2 -30
  58. package/lib/modules/Order/index.js +57 -340
  59. package/lib/modules/Order/types.d.ts +2 -20
  60. package/lib/modules/Order/utils.d.ts +0 -4
  61. package/lib/modules/Order/utils.js +2 -84
  62. package/lib/modules/Product/index.d.ts +1 -1
  63. package/lib/modules/Product/types.d.ts +22 -0
  64. package/lib/modules/ProductList/index.d.ts +1 -1
  65. package/lib/modules/ProductList/index.js +4 -2
  66. package/lib/modules/ProductList/types.d.ts +2 -0
  67. package/lib/modules/Rules/index.d.ts +3 -3
  68. package/lib/modules/Rules/index.js +3 -4
  69. package/lib/modules/Rules/types.d.ts +1 -2
  70. package/lib/server/index.d.ts +50 -3
  71. package/lib/server/index.js +215 -230
  72. package/lib/server/modules/order/index.d.ts +3 -22
  73. package/lib/server/modules/order/index.js +51 -102
  74. package/lib/server/modules/products/index.d.ts +26 -7
  75. package/lib/server/modules/products/index.js +113 -35
  76. package/lib/server/modules/products/types.d.ts +14 -0
  77. package/lib/solution/BaseSales/index.d.ts +2 -16
  78. package/lib/solution/BaseSales/index.js +31 -143
  79. package/lib/solution/BaseSales/types.d.ts +0 -1
  80. package/lib/solution/BaseSales/types.js +1 -2
  81. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
  82. package/lib/solution/BookingByStep/index.d.ts +1 -1
  83. package/lib/solution/BookingTicket/index.d.ts +1 -9
  84. package/lib/solution/BookingTicket/index.js +0 -112
  85. package/lib/solution/BookingTicket/types.d.ts +2 -0
  86. package/package.json +1 -1
  87. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  88. package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
  89. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  90. package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
@@ -14,7 +14,6 @@ export declare const BaseSalesHookNames: {
14
14
  readonly onCartValidationChanged: "onCartValidationChanged";
15
15
  readonly onPaymentSyncStart: "onPaymentSyncStart";
16
16
  readonly onPaymentSyncEnd: "onPaymentSyncEnd";
17
- readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
18
17
  };
19
18
  export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
20
19
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
@@ -9,8 +9,7 @@ export var BaseSalesHookNames = {
9
9
  onRefresh: 'onRefresh',
10
10
  onCartValidationChanged: 'onCartValidationChanged',
11
11
  onPaymentSyncStart: 'onPaymentSyncStart',
12
- onPaymentSyncEnd: 'onPaymentSyncEnd',
13
- onDepositPaymentSyncEnd: 'onDepositPaymentSyncEnd'
12
+ onPaymentSyncEnd: 'onPaymentSyncEnd'
14
13
  };
15
14
  export function createBaseSalesHook(moduleName, hookName) {
16
15
  return "".concat(moduleName, ":").concat(hookName);
@@ -105,9 +105,7 @@ export function transformBaseProductToOrderProduct(params) {
105
105
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
106
106
  var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
107
107
  var sourceProductPrice = toPriceString((_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref21 !== void 0 ? _ref21 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
108
- var explicitLineTotal = (_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total;
109
- var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
110
- var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
108
+ var lineCompositeTotal = toPriceString((_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total, sourceProductPrice);
111
109
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
112
110
  var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
113
111
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
@@ -150,7 +148,7 @@ export function transformBaseProductToOrderProduct(params) {
150
148
  mainPrice: 0,
151
149
  bundle: productBundle
152
150
  });
153
- var derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
151
+ var derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
154
152
  var mainProductSellingPrice = toPriceString(Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice));
155
153
  var metadata = _objectSpread(_objectSpread({
156
154
  unique: payload.unique,
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 2 | 3 | 6 | 4;
314
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -551,14 +551,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
551
551
  setOtherParams(params: Record<string, any>, { cover }?: {
552
552
  cover?: boolean;
553
553
  }): Promise<void>;
554
- private getDeviceTaskPlugin;
555
- handlePrintWristband(params: {
556
- voucher_ids: number[];
557
- }): Promise<void>;
558
- handleCheckIn(params: {
559
- voucher_ids: number[];
560
- is_checkin: boolean;
561
- }): Promise<any>;
562
554
  /**
563
555
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
564
556
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -49,7 +49,6 @@ import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItem
49
49
  import { buildProductOptionStringFromOrderLine } from "../../modules/BookingContext/utils/orderLineDisplay";
50
50
  import { applyBookingsStatus, applyChildBookingStatus, resolveScheduleId, resolveStatusAfterTransition, restoreBookingsStatus, restoreChildBookingStatus } from "./utils/bookingStatus";
51
51
  import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resolveBestAddTimePlan";
52
- import { createUuidV4 } from "../../modules/Order/utils";
53
52
  var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
54
53
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
55
54
 
@@ -2587,161 +2586,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2587
2586
  }
2588
2587
  return setOtherParams;
2589
2588
  }()
2590
- }, {
2591
- key: "getDeviceTaskPlugin",
2592
- value: function getDeviceTaskPlugin() {
2593
- var _app$getApp;
2594
- var app = this.core.getPlugin('app');
2595
- return (app === null || app === void 0 || (_app$getApp = app.getApp()) === null || _app$getApp === void 0 ? void 0 : _app$getApp.getPlugin('deviceTask')) || null;
2596
- }
2597
-
2598
- // 打印手环,单个或批量都可以
2599
- }, {
2600
- key: "handlePrintWristband",
2601
- value: function () {
2602
- var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2603
- var _this$getOrderIdentit;
2604
- var deviceTask, deviceId, idempotencyKey;
2605
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2606
- while (1) switch (_context32.prev = _context32.next) {
2607
- case 0:
2608
- deviceTask = this.getDeviceTaskPlugin();
2609
- if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
2610
- _context32.next = 4;
2611
- break;
2612
- }
2613
- this.logger.addLog({
2614
- type: 'info',
2615
- title: '[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用',
2616
- metadata: {
2617
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2618
- }
2619
- });
2620
- return _context32.abrupt("return");
2621
- case 4:
2622
- this.logger.addLog({
2623
- type: 'info',
2624
- title: '[BookingTicket] handlePrintWristband',
2625
- metadata: {
2626
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2627
- }
2628
- });
2629
- _context32.next = 7;
2630
- return this.getShortNumberOrDeviceId();
2631
- case 7:
2632
- deviceId = _context32.sent;
2633
- idempotencyKey = createUuidV4();
2634
- deviceTask.dispatch({
2635
- action: 'print_all',
2636
- device_id: deviceId,
2637
- payload: {
2638
- type: 'WRISTBAND',
2639
- data: {
2640
- order_id: (_this$getOrderIdentit = this.getOrderIdentity()) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId,
2641
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2642
- }
2643
- },
2644
- idempotency_key: idempotencyKey,
2645
- name: 'PRINT_WRISTBAND',
2646
- source: 'bookingTicket',
2647
- source_type: 'handlePrintWristband',
2648
- source_id: idempotencyKey
2649
- });
2650
- case 10:
2651
- case "end":
2652
- return _context32.stop();
2653
- }
2654
- }, _callee32, this);
2655
- }));
2656
- function handlePrintWristband(_x23) {
2657
- return _handlePrintWristband.apply(this, arguments);
2658
- }
2659
- return handlePrintWristband;
2660
- }() // 触发 checkIn
2661
- }, {
2662
- key: "handleCheckIn",
2663
- value: function () {
2664
- var _handleCheckIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2665
- var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
2666
- var voucherIds, voucherIdSet, tempOrder, vouchers, batchMetadata, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
2667
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2668
- while (1) switch (_context33.prev = _context33.next) {
2669
- case 0:
2670
- this.logger.addLog({
2671
- type: 'info',
2672
- title: '[BookingTicket] handleCheckIn',
2673
- metadata: {
2674
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids],
2675
- is_checkin: params.is_checkin
2676
- }
2677
- });
2678
- voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
2679
- voucherIdSet = new Set(voucherIds);
2680
- tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2681
- vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
2682
- batchMetadata = [];
2683
- hasUpdatedVoucher = false;
2684
- nextVouchers = vouchers.map(function (voucher) {
2685
- var _voucher$metadata;
2686
- if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
2687
- hasUpdatedVoucher = true;
2688
- var metadata = _objectSpread(_objectSpread({}, voucher.metadata || {}), {}, {
2689
- ticket: _objectSpread(_objectSpread({}, ((_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.ticket) || {}), {}, {
2690
- is_checkin: params.is_checkin
2691
- })
2692
- });
2693
- batchMetadata.push({
2694
- voucher_id: voucher.voucher_id,
2695
- metadata: metadata
2696
- });
2697
- return _objectSpread(_objectSpread({}, voucher), {}, {
2698
- metadata: metadata
2699
- });
2700
- });
2701
- if (!(tempOrder && hasUpdatedVoucher)) {
2702
- _context33.next = 11;
2703
- break;
2704
- }
2705
- _context33.next = 11;
2706
- return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
2707
- vouchers: nextVouchers
2708
- }));
2709
- case 11:
2710
- this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
2711
- if (!(batchMetadata.length === 0)) {
2712
- _context33.next = 14;
2713
- break;
2714
- }
2715
- return _context33.abrupt("return", {
2716
- code: 200,
2717
- status: true,
2718
- message: '',
2719
- data: []
2720
- });
2721
- case 14:
2722
- identity = this.getOrderIdentity();
2723
- externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
2724
- orderId = (_ref20 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref20 !== void 0 ? _ref20 : undefined;
2725
- orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
2726
- return _context33.abrupt("return", this.request.post('/machinecode/batch-metadata', {
2727
- data: batchMetadata,
2728
- order_lookup: orderLookup,
2729
- order_id: orderId,
2730
- external_sale_number: externalSaleNumber
2731
- }, {
2732
- osServer: true
2733
- }));
2734
- case 19:
2735
- case "end":
2736
- return _context33.stop();
2737
- }
2738
- }, _callee33, this);
2739
- }));
2740
- function handleCheckIn(_x24) {
2741
- return _handleCheckIn.apply(this, arguments);
2742
- }
2743
- return handleCheckIn;
2744
- }()
2745
2589
  /**
2746
2590
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
2747
2591
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -2749,12 +2593,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2749
2593
  }, {
2750
2594
  key: "destroy",
2751
2595
  value: (function () {
2752
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2596
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2753
2597
  var _this$scan;
2754
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2755
- while (1) switch (_context34.prev = _context34.next) {
2598
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2599
+ while (1) switch (_context32.prev = _context32.next) {
2756
2600
  case 0:
2757
- _context34.next = 2;
2601
+ _context32.next = 2;
2758
2602
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
2759
2603
  case 2:
2760
2604
  try {
@@ -2765,9 +2609,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2765
2609
  scanCache.clear();
2766
2610
  case 4:
2767
2611
  case "end":
2768
- return _context34.stop();
2612
+ return _context32.stop();
2769
2613
  }
2770
- }, _callee34, this);
2614
+ }, _callee32, this);
2771
2615
  }));
2772
2616
  function destroy() {
2773
2617
  return _destroy.apply(this, arguments);
@@ -83,6 +83,8 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
+ strategy_context?: Record<string, any>;
86
88
  }
87
89
  /**
88
90
  * 加载商品详情的参数
@@ -0,0 +1,49 @@
1
+ import type { EvaluationResult, RuntimeContext } from '../../type';
2
+ import type { BusinessAdapter } from '../type';
3
+ import type { DataVariantBusinessData, DataVariantProduct } from './type';
4
+ /**
5
+ * Data Variant 适配器。
6
+ *
7
+ * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
8
+ */
9
+ export declare class DataVariantAdapter implements BusinessAdapter {
10
+ name: string;
11
+ version: string;
12
+ /**
13
+ * 准备批量全局上下文。
14
+ *
15
+ * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
16
+ */
17
+ prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
18
+ /**
19
+ * 准备全局预计算上下文。
20
+ */
21
+ prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
22
+ /**
23
+ * 准备单商品上下文。
24
+ *
25
+ * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
26
+ */
27
+ prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
28
+ transformResult(result: EvaluationResult): EvaluationResult;
29
+ formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
30
+ result: EvaluationResult;
31
+ businessData?: DataVariantBusinessData;
32
+ };
33
+ /**
34
+ * 构建 menu_match 使用的轻量商品对象。
35
+ *
36
+ * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
37
+ */
38
+ buildProductValue(product: DataVariantProduct): {
39
+ id: number;
40
+ product_variant_id: number;
41
+ collection_ids: number[];
42
+ };
43
+ private toNumber;
44
+ /**
45
+ * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
+ */
47
+ private normalizeCustomerId;
48
+ }
49
+ export default DataVariantAdapter;
@@ -0,0 +1,139 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/dataVariant/adapter.ts
20
+ var adapter_exports = {};
21
+ __export(adapter_exports, {
22
+ DataVariantAdapter: () => DataVariantAdapter,
23
+ default: () => adapter_default
24
+ });
25
+ module.exports = __toCommonJS(adapter_exports);
26
+ var DataVariantAdapter = class {
27
+ constructor() {
28
+ this.name = "DataVariantAdapter";
29
+ this.version = "1.0.0";
30
+ }
31
+ /**
32
+ * 准备批量全局上下文。
33
+ *
34
+ * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
35
+ */
36
+ prepareContext(businessData) {
37
+ return this.prepareGlobalContext(businessData);
38
+ }
39
+ /**
40
+ * 准备全局预计算上下文。
41
+ */
42
+ prepareGlobalContext(businessData) {
43
+ const {
44
+ products,
45
+ scheduleDateTime,
46
+ channel,
47
+ orderType,
48
+ businessCode,
49
+ customerId,
50
+ custom
51
+ } = businessData;
52
+ const normalizedCustomerId = this.normalizeCustomerId(customerId);
53
+ const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
54
+ return {
55
+ entities: {
56
+ products
57
+ },
58
+ attributes: {
59
+ ...custom,
60
+ schedule: scheduleDateTime || "",
61
+ channel: channel || (custom == null ? void 0 : custom.channel) || "",
62
+ orderType: orderType || (custom == null ? void 0 : custom.orderType) || (custom == null ? void 0 : custom.order_type) || "",
63
+ // snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
64
+ customer_id: normalizedCustomerId,
65
+ customerId: normalizedCustomerId,
66
+ business_code: resolvedBusinessCode
67
+ },
68
+ metadata: {
69
+ timestamp: Date.now()
70
+ }
71
+ };
72
+ }
73
+ /**
74
+ * 准备单商品上下文。
75
+ *
76
+ * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
77
+ */
78
+ prepareProductContext(businessData, product) {
79
+ const base = this.prepareGlobalContext(businessData);
80
+ const productValue = this.buildProductValue(product);
81
+ return {
82
+ ...base,
83
+ entities: {
84
+ ...base.entities,
85
+ currentProduct: product
86
+ },
87
+ attributes: {
88
+ ...base.attributes,
89
+ product: productValue,
90
+ productIdAndVariantId: {
91
+ product_id: productValue.id,
92
+ product_variant_id: productValue.product_variant_id
93
+ }
94
+ }
95
+ };
96
+ }
97
+ transformResult(result) {
98
+ return result;
99
+ }
100
+ formatConfig(result, businessData) {
101
+ return { result, businessData };
102
+ }
103
+ /**
104
+ * 构建 menu_match 使用的轻量商品对象。
105
+ *
106
+ * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
107
+ */
108
+ buildProductValue(product) {
109
+ const productId = this.toNumber(product.id ?? product.product_id);
110
+ const variantId = this.toNumber(
111
+ product.product_variant_id ?? product.variant_id
112
+ );
113
+ const collectionIds = Array.isArray(product.collection) ? product.collection.map((item) => this.toNumber(item == null ? void 0 : item.id)).filter((id) => id > 0) : [];
114
+ return {
115
+ id: productId,
116
+ product_variant_id: variantId,
117
+ collection_ids: collectionIds
118
+ };
119
+ }
120
+ toNumber(value) {
121
+ const parsed = Number(value);
122
+ return Number.isFinite(parsed) ? parsed : 0;
123
+ }
124
+ /**
125
+ * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
126
+ */
127
+ normalizeCustomerId(value) {
128
+ if (value === void 0 || value === null || value === "") {
129
+ return void 0;
130
+ }
131
+ const parsed = Number(value);
132
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
133
+ }
134
+ };
135
+ var adapter_default = DataVariantAdapter;
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ DataVariantAdapter
139
+ });
@@ -0,0 +1,87 @@
1
+ import type { ConditionRule, StrategyConfig } from '../../type';
2
+ import type { ConditionScope, DataVariantBusinessData, DataVariantMenu, DataVariantRuleMetadata, MenuScope, ResolvedDataVariantResult } from './type';
3
+ /**
4
+ * Data Variant 评估器。
5
+ *
6
+ * 当前阶段只提供策略模型能力和示例验证,不接入 ProductList 业务链路。
7
+ */
8
+ export declare class DataVariantEvaluator {
9
+ private adapter;
10
+ private strategyConfigs;
11
+ constructor();
12
+ /**
13
+ * 设置策略配置列表,仅保留 metadata.type === 'data_variant' 的策略。
14
+ */
15
+ setStrategyConfigs(configs: StrategyConfig[]): void;
16
+ getStrategyConfigs(): StrategyConfig<DataVariantRuleMetadata>[];
17
+ /**
18
+ * 批量解析商品 Data Variant。
19
+ *
20
+ * 先执行全局预计算,再只针对商品自身 data_variants 引用到的规则做商品级判断。
21
+ */
22
+ resolveProducts(businessData: DataVariantBusinessData): ResolvedDataVariantResult;
23
+ /**
24
+ * 根据 operator/field 判断条件是否依赖当前商品。
25
+ */
26
+ getConditionScope(rule: ConditionRule): ConditionScope;
27
+ /**
28
+ * 将餐牌 partyroom_package 预构建为 Map/Set 索引。
29
+ */
30
+ buildMenuScopeMap(menuList: DataVariantMenu[]): Map<number, MenuScope>;
31
+ /**
32
+ * 从当前策略中所有 schedule_match.value 绑定的 schedule_id 提取时间点。
33
+ *
34
+ * 这里不依赖餐牌,只读取策略配置和调用方传入的 scheduleList。
35
+ */
36
+ buildScheduleTimePoints(strategyConfigs: StrategyConfig<DataVariantRuleMetadata>[], scheduleList: NonNullable<DataVariantBusinessData['scheduleList']>): string[];
37
+ private buildGlobalEffectiveRuleMap;
38
+ private resolveProduct;
39
+ /**
40
+ * 解析套餐子商品上的 Data Variant 覆盖。
41
+ *
42
+ * bundle_item 以 bundle_product_id / bundle_variant_id 作为商品身份参与 product_match 等条件判断。
43
+ */
44
+ private resolveProductBundleItems;
45
+ /**
46
+ * 将 bundle_item 转为 DataVariantProduct 并评估 data_variants。
47
+ */
48
+ private resolveBundleItem;
49
+ /**
50
+ * bundle_item 的商品身份映射:bundle_product_id + bundle_variant_id。
51
+ */
52
+ private toBundleItemDataVariantProduct;
53
+ /**
54
+ * 仅回写命中的字段,避免污染 bundle_item 的结构字段。
55
+ */
56
+ private mergeBundleItemResolvedData;
57
+ private evaluateProductRules;
58
+ /**
59
+ * 拆分策略条件。
60
+ *
61
+ * 当前 MVP 支持顶层 and 原子条件拆分;复杂条件保守地放到商品级完整判断。
62
+ */
63
+ private splitStrategyConfig;
64
+ private createEngine;
65
+ private evaluateScheduleMatch;
66
+ private evaluateMenuMatch;
67
+ private collectScheduleIdsFromStrategies;
68
+ private extractTimePointsFromSchedules;
69
+ private addDateTimePoint;
70
+ private addRawTimePoint;
71
+ private extractTimeFromDateTime;
72
+ private normalizeTime;
73
+ private timeToMinutes;
74
+ private isProductInMenuScope;
75
+ private mergeMatchedVariants;
76
+ private getProductDataVariants;
77
+ private normalizeStrategyConfigs;
78
+ private isStrategyActive;
79
+ private getStrategyPriority;
80
+ private createAlwaysTrueConditions;
81
+ private flattenConditionRules;
82
+ private isConditionGroup;
83
+ private normalizeNumberArray;
84
+ private buildProductKey;
85
+ private toNumber;
86
+ }
87
+ export default DataVariantEvaluator;