@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
@@ -491,7 +491,7 @@ export interface OrderPaymentData {
491
491
  voucher_id?: string | number;
492
492
  origin_amount?: string;
493
493
  service_fee?: string;
494
- status?: 'active' | 'paid' | 'voided' | 'payment_pending' | string;
494
+ status?: 'active' | 'voided' | string;
495
495
  /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
496
496
  payment_time?: string;
497
497
  wallet_pass_usage_unit?: unknown;
@@ -537,15 +537,9 @@ export interface SyncPaymentsToOrderParams {
537
537
  smallTicketDataFlag?: number;
538
538
  businessCode?: string;
539
539
  channel?: string;
540
- confirmPendingVoucherPayments?: boolean;
541
540
  }
542
541
  export interface SyncPaymentsToOrderResult<T = any> {
543
542
  isFullyPaid: boolean;
544
- isOrderFullyPaid: boolean;
545
- isDepositFullyPaid: boolean;
546
- paymentStage: 'deposit' | 'normal';
547
- depositAmount: string;
548
- orderExpectedAmount: string;
549
543
  submitResult?: T;
550
544
  }
551
545
  export interface OrderIdentitySnapshot {
@@ -697,7 +691,6 @@ export interface OrderModuleAPI {
697
691
  payments?: OrderPaymentSource[];
698
692
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
699
693
  smallTicketDataFlag?: number;
700
- confirmPendingVoucherPayments?: boolean;
701
694
  enhancePayload?: SubmitPayloadEnhancer;
702
695
  }) => Promise<T>;
703
696
  submitTempOrderAsync: <T = any>(params?: {
@@ -709,7 +702,6 @@ export interface OrderModuleAPI {
709
702
  payments?: OrderPaymentSource[];
710
703
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
711
704
  smallTicketDataFlag?: number;
712
- confirmPendingVoucherPayments?: boolean;
713
705
  enhancePayload?: SubmitPayloadEnhancer;
714
706
  }) => Promise<T>;
715
707
  getOrderPayments: () => OrderPaymentData[];
@@ -717,17 +709,7 @@ export interface OrderModuleAPI {
717
709
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
718
710
  updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
719
711
  deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
720
- updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
721
- status?: 'paid' | 'payment_pending';
722
- }) => OrderPaymentData[];
723
- confirmPendingVoucherPayments: (options?: {
724
- persist?: boolean;
725
- recalculateSummary?: boolean;
726
- }) => OrderPaymentData[];
727
- discardPendingVoucherPayments: (options?: {
728
- persist?: boolean;
729
- recalculateSummary?: boolean;
730
- }) => OrderPaymentData[];
712
+ updateVoucherOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
731
713
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
732
714
  saveDraft: () => Promise<void>;
733
715
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
@@ -254,10 +254,6 @@ export declare function clearTempOrderHolderAssignments(tempOrder: OrderTempOrde
254
254
  * getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
255
255
  */
256
256
  export declare function getOrderProductLineUid(product: Record<string, any> | null | undefined): string | null;
257
- export declare function getRuntimeProductOrigin(tempOrder: OrderTempOrder | null | undefined, product: any): Record<string, any> | null;
258
- export declare function isHolderConfigRequired(holderConfig: any): boolean;
259
- export declare function productRequiresFormSubject(tempOrder: OrderTempOrder | null | undefined, product: any): boolean;
260
- export declare function resolveIsFormSubject(tempOrder: OrderTempOrder | null | undefined, product?: any): boolean;
261
257
  /**
262
258
  * 判断展示字段是否为空(含 i18n 对象全空)。
263
259
  *
@@ -1,8 +1,7 @@
1
- var _excluded = ["custom_product_bundle_map_id"],
2
- _excluded2 = ["unique_identification_number"],
3
- _excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
4
- _excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
5
- _excluded5 = ["collect_pax", "table_occupancy_duration"];
1
+ var _excluded = ["unique_identification_number"],
2
+ _excluded2 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
3
+ _excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
4
+ _excluded4 = ["collect_pax", "table_occupancy_duration"];
6
5
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
6
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -447,54 +446,6 @@ export function normalizeOrderProductDiscountList(discountList) {
447
446
  return normalized;
448
447
  });
449
448
  }
450
- function resolveSubmitBundleMapId(bundle) {
451
- var _bundle$metadata;
452
- var metadataMapId = (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata.custom_product_bundle_map_id;
453
- if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
454
- return metadataMapId;
455
- }
456
- if (bundle._id !== undefined && bundle._id !== null && bundle._id !== '') {
457
- return bundle._id;
458
- }
459
- return undefined;
460
- }
461
- function collectSubmitProductDiscountList(product) {
462
- var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
463
- var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
464
- _step6;
465
- try {
466
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
467
- var bundle = _step6.value;
468
- if (!bundle || _typeof(bundle) !== 'object') continue;
469
- var bundleMapId = resolveSubmitBundleMapId(bundle);
470
- var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
471
- var _iterator7 = _createForOfIteratorHelper(bundleDiscountList),
472
- _step7;
473
- try {
474
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
475
- var discount = _step7.value;
476
- if (!discount || _typeof(discount) !== 'object') continue;
477
- var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
478
- 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;
479
- submitDiscountList.push(_objectSpread(_objectSpread({}, discount), discountMapId !== undefined ? {
480
- metadata: _objectSpread(_objectSpread({}, discountMetadata), {}, {
481
- custom_product_bundle_map_id: discountMapId
482
- })
483
- } : {}));
484
- }
485
- } catch (err) {
486
- _iterator7.e(err);
487
- } finally {
488
- _iterator7.f();
489
- }
490
- }
491
- } catch (err) {
492
- _iterator6.e(err);
493
- } finally {
494
- _iterator6.f();
495
- }
496
- return normalizeOrderProductDiscountList(submitDiscountList);
497
- }
498
449
 
499
450
  /**
500
451
  * 手动改价(price_override)时行级 original_price(composite 单价):
@@ -832,8 +783,6 @@ function formatSubmitBundleItems(bundle) {
832
783
  var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
833
784
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
834
785
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
835
- var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
836
- submitMetadata = _objectWithoutProperties(existedMetadata, _excluded);
837
786
 
838
787
  // bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
839
788
  // markup/原价维持原值;与后端口径一致(price 仍为毛价)。
@@ -845,8 +794,6 @@ function formatSubmitBundleItems(bundle) {
845
794
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
846
795
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
847
796
  var num = toBundleNumber((_rawBundle$num = rawBundle.num) !== null && _rawBundle$num !== void 0 ? _rawBundle$num : rawBundle.quantity, 1);
848
- var bundleMapId = resolveSubmitBundleMapId(rawBundle);
849
- var hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
850
797
  return {
851
798
  is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
852
799
  bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
@@ -863,9 +810,7 @@ function formatSubmitBundleItems(bundle) {
863
810
  bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
864
811
  bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
865
812
  bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
866
- metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
867
- custom_product_bundle_map_id: bundleMapId
868
- } : {}), {}, {
813
+ metadata: _objectSpread(_objectSpread({}, existedMetadata), {}, {
869
814
  surcharge_fee: surchargeFee,
870
815
  relation_surcharge_ids: relationSurchargeIds,
871
816
  product_discount_difference: productDiscountDifference
@@ -894,7 +839,7 @@ function normalizeSubmitProduct(product) {
894
839
  var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
895
840
  var _ref28 = product,
896
841
  _runtimeUid = _ref28.unique_identification_number,
897
- submitProduct = _objectWithoutProperties(_ref28, _excluded2);
842
+ submitProduct = _objectWithoutProperties(_ref28, _excluded);
898
843
  var num = submitProduct.num,
899
844
  _productSurchargeFee = submitProduct.surcharge_fee,
900
845
  _deprecatedDiscountAmount = submitProduct.discount_amount,
@@ -902,7 +847,7 @@ function normalizeSubmitProduct(product) {
902
847
  _deprecatedDiscountway = submitProduct.discountway,
903
848
  _deprecatedProductDiscountReason = submitProduct.product_discount_reason,
904
849
  _deprecatedDiscountPer = submitProduct.discount_per,
905
- productRest = _objectWithoutProperties(submitProduct, _excluded3);
850
+ productRest = _objectWithoutProperties(submitProduct, _excluded2);
906
851
  delete productRest["product_".concat('option', "_item")];
907
852
  var rawMetadata = submitProduct.metadata || {};
908
853
  var bookingUid = rawMetadata.booking_uid;
@@ -932,7 +877,7 @@ function normalizeSubmitProduct(product) {
932
877
  } : {}), {}, {
933
878
  product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
934
879
  product_sku: productSku,
935
- discount_list: collectSubmitProductDiscountList(submitProduct),
880
+ discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
936
881
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
937
882
  metadata: cleanMetadata,
938
883
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
@@ -954,19 +899,19 @@ export function normalizeBookingSubType(booking) {
954
899
  export function normalizeSubmitBooking(booking) {
955
900
  var rawMetadata = booking.metadata || {};
956
901
  var cleanMetadata = {};
957
- var _iterator8 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
958
- _step8;
902
+ var _iterator6 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
903
+ _step6;
959
904
  try {
960
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
961
- var key = _step8.value;
905
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
906
+ var key = _step6.value;
962
907
  if (rawMetadata[key] !== undefined) {
963
908
  cleanMetadata[key] = rawMetadata[key];
964
909
  }
965
910
  }
966
911
  } catch (err) {
967
- _iterator8.e(err);
912
+ _iterator6.e(err);
968
913
  } finally {
969
- _iterator8.f();
914
+ _iterator6.f();
970
915
  }
971
916
  if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
972
917
  var bookingRecord = booking;
@@ -1090,7 +1035,7 @@ export function buildSubmitPayload(params) {
1090
1035
  _totalRefundAmount = _ref29.total_refund_amount,
1091
1036
  _createDate = _ref29.create_date,
1092
1037
  _holderId = _ref29.holder_id,
1093
- tempOrderRest = _objectWithoutProperties(_ref29, _excluded4);
1038
+ tempOrderRest = _objectWithoutProperties(_ref29, _excluded3);
1094
1039
  var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
1095
1040
  if (!submitType) {
1096
1041
  var _tempOrder$bookings;
@@ -1141,7 +1086,7 @@ export function buildSubmitPayload(params) {
1141
1086
  var _ref31 = tempOrder.metadata || {},
1142
1087
  _collectPax = _ref31.collect_pax,
1143
1088
  _tableOccupancyDuration = _ref31.table_occupancy_duration,
1144
- rest = _objectWithoutProperties(_ref31, _excluded5);
1089
+ rest = _objectWithoutProperties(_ref31, _excluded4);
1145
1090
  return _objectSpread({}, rest);
1146
1091
  }(),
1147
1092
  products: (tempOrder.products || []).map(function (product) {
@@ -1279,25 +1224,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1279
1224
  target[key] = null;
1280
1225
  changed = true;
1281
1226
  };
1282
- var _iterator9 = _createForOfIteratorHelper(tempOrder.products || []),
1283
- _step9;
1227
+ var _iterator7 = _createForOfIteratorHelper(tempOrder.products || []),
1228
+ _step7;
1284
1229
  try {
1285
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1286
- var product = _step9.value;
1230
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1231
+ var product = _step7.value;
1287
1232
  if (product.metadata && _typeof(product.metadata) === 'object') {
1288
1233
  resetHolderField(product.metadata);
1289
1234
  }
1290
1235
  }
1291
1236
  } catch (err) {
1292
- _iterator9.e(err);
1237
+ _iterator7.e(err);
1293
1238
  } finally {
1294
- _iterator9.f();
1239
+ _iterator7.f();
1295
1240
  }
1296
- var _iterator10 = _createForOfIteratorHelper(tempOrder.bookings || []),
1297
- _step10;
1241
+ var _iterator8 = _createForOfIteratorHelper(tempOrder.bookings || []),
1242
+ _step8;
1298
1243
  try {
1299
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1300
- var booking = _step10.value;
1244
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1245
+ var booking = _step8.value;
1301
1246
  var bookingRecord = booking;
1302
1247
  if (booking.metadata && _typeof(booking.metadata) === 'object') {
1303
1248
  resetHolderField(booking.metadata);
@@ -1308,9 +1253,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1308
1253
  }
1309
1254
  }
1310
1255
  } catch (err) {
1311
- _iterator10.e(err);
1256
+ _iterator8.e(err);
1312
1257
  } finally {
1313
- _iterator10.f();
1258
+ _iterator8.f();
1314
1259
  }
1315
1260
  var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
1316
1261
  if (productsByUid && _typeof(productsByUid) === 'object') {
@@ -1342,37 +1287,6 @@ export function getOrderProductLineUid(product) {
1342
1287
  if (uid === undefined || uid === null || uid === '') return null;
1343
1288
  return String(uid);
1344
1289
  }
1345
- export function getRuntimeProductOrigin(tempOrder, product) {
1346
- var _tempOrder$_extend2, _tempOrder$_extend3;
1347
- var uid = getOrderProductLineUid(product);
1348
- if (uid && tempOrder !== null && tempOrder !== void 0 && (_tempOrder$_extend2 = tempOrder._extend) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2.productsByUid) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2[uid]) !== null && _tempOrder$_extend2 !== void 0 && _tempOrder$_extend2.origin) {
1349
- return tempOrder._extend.productsByUid[uid].origin;
1350
- }
1351
- var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
1352
- var _ref32, _item$product_id, _ref33, _product$product_id;
1353
- return item === product || getOrderProductLineUid(item) === uid || String((_ref32 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref32 !== void 0 ? _ref32 : '') === String((_ref33 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref33 !== void 0 ? _ref33 : '');
1354
- });
1355
- var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
1356
- return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[matchedUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin) || null : null;
1357
- }
1358
- export function isHolderConfigRequired(holderConfig) {
1359
- if (!holderConfig || _typeof(holderConfig) !== 'object') return false;
1360
- if (holderConfig.status === 'disable') return false;
1361
- return Number(holderConfig.required) === 1;
1362
- }
1363
- export function productRequiresFormSubject(tempOrder, product) {
1364
- var runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
1365
- return isHolderConfigRequired(product === null || product === void 0 ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin === null || runtimeOrigin === void 0 ? void 0 : runtimeOrigin.holder_config);
1366
- }
1367
- export function resolveIsFormSubject(tempOrder, product) {
1368
- var _tempOrder$holder;
1369
- // 旧版预约维度的 holder 类型仍然生效;新版则从当前商品 holder_config 判断。
1370
- if ((tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.type) === 'form') return true;
1371
- if (product) return productRequiresFormSubject(tempOrder, product);
1372
- return ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).some(function (item) {
1373
- return productRequiresFormSubject(tempOrder, item);
1374
- });
1375
- }
1376
1290
 
1377
1291
  /**
1378
1292
  * 判断展示字段是否为空(含 i18n 对象全空)。
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -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[];
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
3
+ import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
5
  import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
6
6
  import { WindowPlugin } from '../../plugins';
@@ -24,7 +24,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
24
24
  holders: {
25
25
  form_record_id: number;
26
26
  }[];
27
- isFormSubject: RulesFormSubject;
27
+ isFormSubject: boolean;
28
28
  }): {
29
29
  isAvailable: boolean;
30
30
  discountList: Discount[];
@@ -43,7 +43,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
43
43
  holders: {
44
44
  form_record_id: number;
45
45
  }[];
46
- isFormSubject: RulesFormSubject;
46
+ isFormSubject: boolean;
47
47
  orderTotalAmount: number;
48
48
  }, options?: {
49
49
  isSelected?: boolean;
@@ -118,8 +118,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
118
118
  // 非表单类型 holder 视为匹配
119
119
  if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
120
120
  // 主预约holder, 目前(20251124)默认只考虑单个holder的情况
121
- // 旧版 holders[0].form_record_id 新版 holders[0]
122
- var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : undefined;
121
+ var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
123
122
  var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
124
123
  // 商品不需要选holder,则不对比holder,直接返回true,
125
124
  if (!product.isNeedHolder) return true;
@@ -324,10 +323,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
324
323
  holders = _ref2.holders,
325
324
  isFormSubject = _ref2.isFormSubject,
326
325
  orderTotalAmount = _ref2.orderTotalAmount;
327
- var resolveIsFormSubject = function resolveIsFormSubject(product) {
328
- return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
329
- };
330
-
331
326
  // 识别出来是不是在编辑的界面里又新增了商品
332
327
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
333
328
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -890,7 +885,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
890
885
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
891
886
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
892
887
  var isHolderMatch = _this3.checkHolderMatch(discount, {
893
- isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
888
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
894
889
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
895
890
  }, holders);
896
891
  var timeLimit = true;
@@ -1093,7 +1088,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1093
1088
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
1094
1089
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
1095
1090
  var isHolderMatch = _this3.checkHolderMatch(discount, {
1096
- isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1091
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1097
1092
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
1098
1093
  }, holders);
1099
1094
  // 如果 holder 不匹配,则不适用
@@ -22,7 +22,6 @@ export interface DiscountResult {
22
22
  productList: any[];
23
23
  discountList: any[];
24
24
  }
25
- export type RulesFormSubject = boolean | ((product: any) => boolean);
26
25
  export interface RulesModuleAPI {
27
26
  setRulesList: (rulesList: Rules[]) => Promise<void>;
28
27
  clear: () => Promise<void>;
@@ -32,7 +31,7 @@ export interface RulesModuleAPI {
32
31
  holders: {
33
32
  form_record_id: number;
34
33
  }[];
35
- isFormSubject: RulesFormSubject;
34
+ isFormSubject: boolean;
36
35
  orderTotalAmount: number;
37
36
  }) => DiscountResult;
38
37
  }
@@ -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
  * 存储订阅者信息,便于数据变更时推送最新结果
@@ -431,9 +475,6 @@ declare class Server {
431
475
  private shouldLookupLocalPrintOrder;
432
476
  private getLocalPrintOrderLookup;
433
477
  private handleLocalPrintOrder;
434
- private handleMachinecodeBatchMetadata;
435
- private resolveMachinecodeBatchMetadataLookup;
436
- private syncMachinecodeBatchMetadataToLocalOrder;
437
478
  private handleOrderCheckoutSubmit;
438
479
  private handleSyncCheckoutSubmit;
439
480
  private handlePendingSyncCheckoutOrder;
@@ -565,6 +606,12 @@ declare class Server {
565
606
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
566
607
  */
567
608
  private computeProductQueryResult;
609
+ /**
610
+ * 构建商品格式化上下文。
611
+ *
612
+ * 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
613
+ */
614
+ private buildProductFormatterContext;
568
615
  /**
569
616
  * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
570
617
  * 由 ProductsModule 的 onProductsSyncCompleted 事件触发