@pisell/pisellos 2.2.259 → 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 (103) 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 +1 -32
  15. package/dist/modules/Order/index.js +288 -615
  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/modules/SalesSummary/index.d.ts +3 -7
  28. package/dist/modules/SalesSummary/index.js +39 -67
  29. package/dist/modules/SalesSummary/types.d.ts +0 -1
  30. package/dist/modules/SalesSummary/utils.js +1 -2
  31. package/dist/modules/SurchargeList/index.d.ts +4 -6
  32. package/dist/modules/SurchargeList/index.js +39 -62
  33. package/dist/modules/SurchargeList/types.d.ts +2 -6
  34. package/dist/server/index.d.ts +50 -3
  35. package/dist/server/index.js +1040 -1075
  36. package/dist/server/modules/order/index.d.ts +3 -22
  37. package/dist/server/modules/order/index.js +316 -398
  38. package/dist/server/modules/products/index.d.ts +26 -7
  39. package/dist/server/modules/products/index.js +166 -76
  40. package/dist/server/modules/products/types.d.ts +14 -0
  41. package/dist/solution/BaseSales/index.d.ts +2 -22
  42. package/dist/solution/BaseSales/index.js +701 -995
  43. package/dist/solution/BaseSales/types.d.ts +0 -1
  44. package/dist/solution/BaseSales/types.js +1 -2
  45. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
  46. package/dist/solution/BookingByStep/index.d.ts +1 -1
  47. package/dist/solution/BookingTicket/index.d.ts +0 -8
  48. package/dist/solution/BookingTicket/index.js +6 -153
  49. package/dist/solution/BookingTicket/types.d.ts +2 -0
  50. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  51. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  53. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  54. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  55. package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
  56. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  57. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  58. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  59. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  60. package/lib/model/strategy/adapter/index.d.ts +4 -0
  61. package/lib/model/strategy/adapter/index.js +13 -2
  62. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
  63. package/lib/modules/Order/index.d.ts +1 -32
  64. package/lib/modules/Order/index.js +64 -402
  65. package/lib/modules/Order/types.d.ts +2 -20
  66. package/lib/modules/Order/utils.d.ts +0 -4
  67. package/lib/modules/Order/utils.js +2 -84
  68. package/lib/modules/Product/index.d.ts +1 -1
  69. package/lib/modules/Product/types.d.ts +22 -0
  70. package/lib/modules/ProductList/index.d.ts +1 -1
  71. package/lib/modules/ProductList/index.js +4 -2
  72. package/lib/modules/ProductList/types.d.ts +2 -0
  73. package/lib/modules/Rules/index.d.ts +3 -3
  74. package/lib/modules/Rules/index.js +3 -4
  75. package/lib/modules/Rules/types.d.ts +1 -2
  76. package/lib/modules/SalesSummary/index.d.ts +3 -7
  77. package/lib/modules/SalesSummary/index.js +11 -28
  78. package/lib/modules/SalesSummary/types.d.ts +0 -1
  79. package/lib/modules/SalesSummary/utils.js +0 -2
  80. package/lib/modules/SurchargeList/index.d.ts +4 -6
  81. package/lib/modules/SurchargeList/index.js +21 -41
  82. package/lib/modules/SurchargeList/types.d.ts +2 -6
  83. package/lib/server/index.d.ts +50 -3
  84. package/lib/server/index.js +215 -244
  85. package/lib/server/modules/order/index.d.ts +3 -22
  86. package/lib/server/modules/order/index.js +53 -103
  87. package/lib/server/modules/products/index.d.ts +26 -7
  88. package/lib/server/modules/products/index.js +113 -35
  89. package/lib/server/modules/products/types.d.ts +14 -0
  90. package/lib/solution/BaseSales/index.d.ts +2 -22
  91. package/lib/solution/BaseSales/index.js +60 -246
  92. package/lib/solution/BaseSales/types.d.ts +0 -1
  93. package/lib/solution/BaseSales/types.js +1 -2
  94. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
  95. package/lib/solution/BookingByStep/index.d.ts +1 -1
  96. package/lib/solution/BookingTicket/index.d.ts +0 -8
  97. package/lib/solution/BookingTicket/index.js +0 -101
  98. package/lib/solution/BookingTicket/types.d.ts +2 -0
  99. package/package.json +1 -1
  100. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  101. package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
  102. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
  103. 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);
@@ -66,8 +66,7 @@ function normalizeBundleItems(bundleItems) {
66
66
  price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
67
67
  bundle_selling_price: unitStr,
68
68
  original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
69
- option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
70
- discount_list: preferPriceField ? [] : bundleItem.discount_list
69
+ option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
71
70
  });
72
71
  // bundle_selling_price 落「正净额」:markdown = |price| − Σoptions;markup/原价维持原值。
73
72
  normalizedItem.bundle_selling_price = getBundleSellingMagnitude(magnitudeSource).toFixed(2);
@@ -106,9 +105,7 @@ export function transformBaseProductToOrderProduct(params) {
106
105
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
107
106
  var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
108
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');
109
- 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;
110
- var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
111
- 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);
112
109
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
113
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));
114
111
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
@@ -151,7 +148,7 @@ export function transformBaseProductToOrderProduct(params) {
151
148
  mainPrice: 0,
152
149
  bundle: productBundle
153
150
  });
154
- var derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
151
+ var derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
155
152
  var mainProductSellingPrice = toPriceString(Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice));
156
153
  var metadata = _objectSpread(_objectSpread({
157
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 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -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
- handleRedeem(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,152 +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
- }() // 触发核销
2661
- }, {
2662
- key: "handleRedeem",
2663
- value: function () {
2664
- var _handleRedeem = _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, status, voucherIdSet, tempOrder, vouchers, 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
- voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
2671
- status = params.is_checkin ? 'used' : 'unused';
2672
- this.logger.addLog({
2673
- type: 'info',
2674
- title: '[BookingTicket] handleRedeem',
2675
- metadata: {
2676
- voucher_ids: voucherIds,
2677
- status: status
2678
- }
2679
- });
2680
- voucherIdSet = new Set(voucherIds);
2681
- 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);
2682
- 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()) || [];
2683
- hasUpdatedVoucher = false;
2684
- nextVouchers = vouchers.map(function (voucher) {
2685
- if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
2686
- hasUpdatedVoucher = true;
2687
- return _objectSpread(_objectSpread({}, voucher), {}, {
2688
- status: status
2689
- });
2690
- });
2691
- if (!(tempOrder && hasUpdatedVoucher)) {
2692
- _context33.next = 11;
2693
- break;
2694
- }
2695
- _context33.next = 11;
2696
- return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
2697
- vouchers: nextVouchers
2698
- }));
2699
- case 11:
2700
- this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
2701
- if (!(voucherIds.length === 0)) {
2702
- _context33.next = 14;
2703
- break;
2704
- }
2705
- return _context33.abrupt("return", {
2706
- code: 200,
2707
- status: true,
2708
- message: '',
2709
- data: []
2710
- });
2711
- case 14:
2712
- identity = this.getOrderIdentity();
2713
- externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
2714
- 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;
2715
- 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;
2716
- return _context33.abrupt("return", this.request.post('/machinecode/batch', {
2717
- ids: voucherIds,
2718
- status: status,
2719
- order_lookup: orderLookup,
2720
- order_id: orderId,
2721
- external_sale_number: externalSaleNumber
2722
- }, {
2723
- osServer: true
2724
- }));
2725
- case 19:
2726
- case "end":
2727
- return _context33.stop();
2728
- }
2729
- }, _callee33, this);
2730
- }));
2731
- function handleRedeem(_x24) {
2732
- return _handleRedeem.apply(this, arguments);
2733
- }
2734
- return handleRedeem;
2735
- }()
2736
2589
  /**
2737
2590
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
2738
2591
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -2740,12 +2593,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2740
2593
  }, {
2741
2594
  key: "destroy",
2742
2595
  value: (function () {
2743
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2596
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2744
2597
  var _this$scan;
2745
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2746
- while (1) switch (_context34.prev = _context34.next) {
2598
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2599
+ while (1) switch (_context32.prev = _context32.next) {
2747
2600
  case 0:
2748
- _context34.next = 2;
2601
+ _context32.next = 2;
2749
2602
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
2750
2603
  case 2:
2751
2604
  try {
@@ -2756,9 +2609,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2756
2609
  scanCache.clear();
2757
2610
  case 4:
2758
2611
  case "end":
2759
- return _context34.stop();
2612
+ return _context32.stop();
2760
2613
  }
2761
- }, _callee34, this);
2614
+ }, _callee32, this);
2762
2615
  }));
2763
2616
  function destroy() {
2764
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;