@pisell/pisellos 0.10.56 → 0.10.58

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 (118) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/OpenData/index.js +2 -1
  3. package/dist/modules/Order/index.d.ts +1 -0
  4. package/dist/modules/Order/index.js +118 -59
  5. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  6. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  7. package/dist/modules/Order/utils.d.ts +6 -4
  8. package/dist/modules/Order/utils.js +40 -16
  9. package/dist/modules/Payment/index.d.ts +0 -5
  10. package/dist/modules/Payment/index.js +35 -85
  11. package/dist/modules/ProductList/index.d.ts +3 -1
  12. package/dist/modules/ProductList/index.js +203 -95
  13. package/dist/modules/ProductList/types.d.ts +8 -0
  14. package/dist/modules/ProductList/types.js +2 -0
  15. package/dist/modules/ResourcePlanner/planner.js +10 -8
  16. package/dist/modules/Rules/index.js +16 -14
  17. package/dist/modules/Rules/types.d.ts +2 -0
  18. package/dist/server/index.js +122 -69
  19. package/dist/server/modules/floor-plan/index.js +34 -3
  20. package/dist/server/modules/payment/index.d.ts +25 -6
  21. package/dist/server/modules/payment/index.js +660 -133
  22. package/dist/server/test.json +1 -1
  23. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  24. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  25. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  26. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +46 -4
  27. package/dist/shared/receipt/small-ticket.d.ts +11 -0
  28. package/dist/shared/receipt/small-ticket.js +430 -255
  29. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  30. package/dist/shared/receipt/templateVisibility.js +64 -0
  31. package/dist/solution/BaseSales/index.d.ts +4 -2
  32. package/dist/solution/BaseSales/index.js +1328 -1214
  33. package/dist/solution/BaseSales/types.d.ts +5 -1
  34. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  35. package/dist/solution/BaseSales/utils.js +3 -2
  36. package/dist/solution/BookingTicket/index.d.ts +4 -1
  37. package/dist/solution/BookingTicket/index.js +120 -80
  38. package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
  39. package/dist/solution/OrderInvoicePreview/index.js +85 -14
  40. package/dist/solution/RegisterAndLogin/config.js +54 -11
  41. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  42. package/dist/solution/RegisterAndLogin/index.js +1 -1
  43. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  44. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  45. package/dist/solution/Sales/index.d.ts +2 -0
  46. package/dist/solution/Sales/index.js +15 -1
  47. package/dist/solution/ScanOrder/utils.js +3 -2
  48. package/dist/solution/UnifiedBookingSales/index.d.ts +7 -1
  49. package/dist/solution/UnifiedBookingSales/index.js +560 -401
  50. package/dist/solution/VenueBooking/index.d.ts +15 -2
  51. package/dist/solution/VenueBooking/index.js +1062 -785
  52. package/dist/solution/VenueBooking/types.d.ts +2 -1
  53. package/dist/solution/VenueBooking/types.js +1 -0
  54. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  55. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  56. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  57. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  58. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  59. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  60. package/lib/modules/OpenData/index.js +2 -1
  61. package/lib/modules/Order/index.d.ts +1 -0
  62. package/lib/modules/Order/index.js +71 -11
  63. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  64. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  65. package/lib/modules/Order/utils.d.ts +6 -4
  66. package/lib/modules/Order/utils.js +34 -13
  67. package/lib/modules/Payment/index.d.ts +0 -5
  68. package/lib/modules/Payment/index.js +3 -28
  69. package/lib/modules/ProductList/index.d.ts +3 -1
  70. package/lib/modules/ProductList/index.js +45 -6
  71. package/lib/modules/ProductList/types.d.ts +8 -0
  72. package/lib/modules/ProductList/types.js +1 -0
  73. package/lib/modules/ResourcePlanner/planner.js +10 -8
  74. package/lib/modules/Rules/index.js +16 -14
  75. package/lib/modules/Rules/types.d.ts +2 -0
  76. package/lib/server/index.js +72 -28
  77. package/lib/server/modules/floor-plan/index.js +29 -1
  78. package/lib/server/modules/payment/index.d.ts +25 -6
  79. package/lib/server/modules/payment/index.js +350 -78
  80. package/lib/server/test.json +1 -1
  81. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  82. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  83. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  84. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +42 -4
  85. package/lib/shared/receipt/small-ticket.d.ts +11 -0
  86. package/lib/shared/receipt/small-ticket.js +234 -30
  87. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  88. package/lib/shared/receipt/templateVisibility.js +63 -0
  89. package/lib/solution/BaseSales/index.d.ts +4 -2
  90. package/lib/solution/BaseSales/index.js +79 -18
  91. package/lib/solution/BaseSales/types.d.ts +5 -1
  92. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  93. package/lib/solution/BaseSales/utils.js +2 -1
  94. package/lib/solution/BookingTicket/index.d.ts +4 -1
  95. package/lib/solution/BookingTicket/index.js +14 -2
  96. package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
  97. package/lib/solution/OrderInvoicePreview/index.js +61 -7
  98. package/lib/solution/RegisterAndLogin/config.js +57 -11
  99. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  100. package/lib/solution/RegisterAndLogin/index.js +9 -1
  101. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  102. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  103. package/lib/solution/Sales/index.d.ts +2 -0
  104. package/lib/solution/Sales/index.js +10 -1
  105. package/lib/solution/ScanOrder/utils.js +2 -1
  106. package/lib/solution/UnifiedBookingSales/index.d.ts +7 -1
  107. package/lib/solution/UnifiedBookingSales/index.js +85 -7
  108. package/lib/solution/VenueBooking/index.d.ts +15 -2
  109. package/lib/solution/VenueBooking/index.js +243 -96
  110. package/lib/solution/VenueBooking/types.d.ts +2 -1
  111. package/lib/solution/VenueBooking/types.js +1 -0
  112. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  113. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  114. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  115. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  116. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  117. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  118. package/package.json +1 -1
@@ -22,9 +22,11 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
22
22
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
23
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
24
24
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
25
- import dayjs from 'dayjs';
25
+ import dayjs from "dayjs";
26
26
  import customParseFormat from 'dayjs/plugin/customParseFormat';
27
27
  import Decimal from 'decimal.js';
28
+ import { withOriginalBundleOptionPrices } from "./utils/weighedProduct";
29
+ import { hasManualProductDiscountFlag } from "./utils/manualProductDiscount";
28
30
  import { getProductHolderConfig } from "../Holder/utils";
29
31
  import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
30
32
  import { createUuidV4 } from "./utils/orderCollectionIdentity";
@@ -578,8 +580,9 @@ export function getBundleSellingMagnitude(bundle) {
578
580
  * = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
579
581
  * - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),不含 option、
580
582
  * 不含折扣。**权威源**。
581
- * - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
582
- * - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
583
+ * - `product_sku.option[].add_price` 保留单规格折前单价;Rules 的 option.price 只用于本次计算。
584
+ * - `metadata.main_product_original_price` = source + Σ(option.add_price × option.num)(含 option、不含折扣)。
585
+ * - `metadata.main_product_selling_price` = main_original − 行内 per-unit amount(含主商品及 option 优惠)。
583
586
  * - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
584
587
  *
585
588
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
@@ -588,8 +591,9 @@ export function getBundleSellingMagnitude(bundle) {
588
591
  * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
589
592
  * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
590
593
  * total(source + option + bundle)对齐。
594
+ * - `getProduct.options` 用单规格原价参与重算;主商品折后价从 main_selling 减去 option 折后合计反推。
591
595
  * - `setProduct` 反向流程:把 Rules 返回的 source-level `main_product_selling_price` / `price`
592
- * 加回 Σoptions,重新合成含 option 的 main_product_* 并派生 composite。
596
+ * 加回单规格原价合计,再减去 optionDiscountAmount;保留订单单规格原价供取消折扣及后续重算。
593
597
  * 优先级:
594
598
  * 1. `values.main_product_selling_price`(券应用分支,per-unit 券后 source-level 主价)
595
599
  * 2. `values.price`(还原分支 `restoredPrice`、good_pass 归零)
@@ -812,6 +816,15 @@ export function createDefaultOrderRulesHooks(getBookings) {
812
816
  var effectiveNum = Number(num) > 0 ? Number(num) : 1;
813
817
  return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
814
818
  };
819
+
820
+ // optionDiscountAmount 已是每件主商品内的单规格优惠合计,不再乘商品数量。
821
+ var getOptionDiscountAmount = function getOptionDiscountAmount(discountList) {
822
+ return (discountList || []).reduce(function (total, discount) {
823
+ var _discount$metadata, _discount$metadata2;
824
+ if (discount !== null && discount !== void 0 && (_discount$metadata = discount.metadata) !== null && _discount$metadata !== void 0 && _discount$metadata.custom_product_bundle_map_id) return total;
825
+ return total.plus(Number(discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.optionDiscountAmount) || 0);
826
+ }, new Decimal(0));
827
+ };
815
828
  var getBundleIdentity = function getBundleIdentity(bundle) {
816
829
  var _ref21, _bundle$bundle_id, _ref22, _ref23, _bundle$bundle_produc, _ref24, _ref25, _bundle$bundle_varian, _ref26, _bundle$bundle_group_;
817
830
  return [(_ref21 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref21 !== void 0 ? _ref21 : '', (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : '', (_ref24 = (_ref25 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref25 !== void 0 ? _ref25 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0, (_ref26 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref26 !== void 0 ? _ref26 : ''].join('|');
@@ -849,12 +862,14 @@ export function createDefaultOrderRulesHooks(getBookings) {
849
862
  var _product$metadata7, _product$metadata8, _product$metadata9, _metadataAny$_promoti;
850
863
  // source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
851
864
  var metadataAny = product.metadata || {};
852
- var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
865
+ var productOptions = getProductSkuOptions(product);
866
+ var optionSum = sumOptionUnitPrice(productOptions);
867
+ var optionSellingSum = optionSum.minus(getOptionDiscountAmount(product.discount_list));
853
868
  var sourcePrice;
854
869
  if (metadataAny.source_product_price !== undefined) {
855
870
  sourcePrice = String(metadataAny.source_product_price);
856
871
  } else if (metadataAny.main_product_selling_price !== undefined) {
857
- sourcePrice = new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString();
872
+ sourcePrice = new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSellingSum).toDecimalPlaces(2).toString();
858
873
  } else {
859
874
  var _product$selling_pric;
860
875
  sourcePrice = String((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
@@ -885,6 +900,12 @@ export function createDefaultOrderRulesHooks(getBookings) {
885
900
  num: product.num || 1,
886
901
  discount_list: product.discount_list || [],
887
902
  bundle: product.product_bundle || [],
903
+ // 仅在 Rules 入参中映射 price,避免折后价污染订单的 add_price。
904
+ options: productOptions.map(function (option) {
905
+ return _objectSpread(_objectSpread({}, option), {}, {
906
+ price: option.add_price
907
+ });
908
+ }),
888
909
  booking_id: ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_id) || null,
889
910
  isClient: false,
890
911
  // 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
@@ -892,20 +913,22 @@ export function createDefaultOrderRulesHooks(getBookings) {
892
913
  isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
893
914
  holder_id: (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.holder_id,
894
915
  startDate: getProductStartDate(product),
895
- main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
916
+ main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSellingSum).toDecimalPlaces(2).toString() : undefined,
896
917
  inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
897
918
  _promotion: metadataAny._promotion
898
919
  };
899
920
  },
900
921
  setProduct: function setProduct(product, values) {
901
- var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _values$discount_list, _values$quantity2;
922
+ var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _values$discount_list, _product$product_sku, _values$quantity2;
902
923
  var nextNum = Number((_ref32 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref32 !== void 0 ? _ref32 : 1) || 1;
903
924
  var metadataAny = product.metadata || {};
904
925
  var existedSource = (_ref33 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref33 !== void 0 ? _ref33 : '0';
905
926
  var nextOptions = getProductSkuOptions(product);
906
927
  var optionSum = sumOptionUnitPrice(nextOptions);
928
+ var nextDiscountList = (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list;
929
+ var optionSellingSum = optionSum.minus(getOptionDiscountAmount(nextDiscountList));
907
930
 
908
- // Rules 返回的 main_product_selling_price / price / total 均为 source-level。
931
+ // Rules 返回的 main_product_selling_price / price 为不含 option 的主商品价。
909
932
  // 优先级:main_product_selling_price(per-unit 券后 source)> price(还原/good_pass 分支)>
910
933
  // total/num(仅当 Rules 只给 total 时的兜底)> 保留当前 source。
911
934
  var nextSourceSellingPrice = values.main_product_selling_price !== undefined ? String(values.main_product_selling_price) : values.price !== undefined ? String(values.price) : values.total !== undefined ? toUnitPriceString(values.total, nextNum) : String(existedSource);
@@ -914,8 +937,8 @@ export function createDefaultOrderRulesHooks(getBookings) {
914
937
  // 缺省时保留现有 source(券前 = 当前 source)。
915
938
  var nextSourceOriginalPrice = values.original_price !== undefined ? String(values.original_price) : String(existedSource);
916
939
 
917
- // 含 option 的 main_product_*
918
- var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
940
+ // 成交价只加回 option 折后合计;原价仍使用订单中保存的 option 原价。
941
+ var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSellingSum).toDecimalPlaces(2).toFixed(2);
919
942
  var nextMainOriginalPrice = new Decimal(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
920
943
  var nextBundle = values.bundle !== undefined ? mergeRulesBundlePrices(product.product_bundle, values.bundle) : product.product_bundle;
921
944
  var composedSellingPrice = composeLinePrice({
@@ -924,7 +947,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
924
947
  });
925
948
  var composedOriginalPrice = composeLinePrice({
926
949
  mainPrice: nextMainOriginalPrice,
927
- bundle: nextBundle,
950
+ bundle: Number((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadataAny) ? withOriginalBundleOptionPrices(nextBundle) : nextBundle,
928
951
  useOriginalBundle: true
929
952
  });
930
953
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
@@ -935,7 +958,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
935
958
  return _objectSpread(_objectSpread({}, product), {}, {
936
959
  selling_price: composedSellingPrice,
937
960
  original_price: finalOriginalPrice,
938
- discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
961
+ discount_list: nextDiscountList,
939
962
  num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
940
963
  product_bundle: nextBundle,
941
964
  metadata: _objectSpread(_objectSpread({}, metadataAny), {}, {
@@ -1026,6 +1049,7 @@ export function ensureCartItemOriginHolder(cartItem, window) {
1026
1049
  form_record: [formRecordId]
1027
1050
  };
1028
1051
  }
1052
+ ;
1029
1053
  export var getAllDiscountList = function getAllDiscountList(cartItem) {
1030
1054
  var _cartItem$_origin2, _cartItem$_origin3;
1031
1055
  var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$_origin2 = cartItem._origin) === null || _cartItem$_origin2 === void 0 || (_cartItem$_origin2 = _cartItem$_origin2.product) === null || _cartItem$_origin2 === void 0 ? void 0 : _cartItem$_origin2.discount_list) || [];
@@ -1513,7 +1537,7 @@ export function buildSubmitPayload(params) {
1513
1537
  shop_discount: tempOrder.shop_discount || '0.00',
1514
1538
  surcharge_fee: tempOrder.surcharge_fee || '0.00',
1515
1539
  note: tempOrder.note || '',
1516
- delivery_type: tempOrder.delivery_type || 'nil',
1540
+ delivery_type: tempOrder.delivery_type || 'shop_service',
1517
1541
  schedule_date: scheduleDate,
1518
1542
  // created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
1519
1543
  bookings: (tempOrder.bookings || []).filter(function (booking) {
@@ -1636,11 +1660,11 @@ export function mapPaymentItemsToOrderPayments(paymentItems) {
1636
1660
  */
1637
1661
  export function formatV1Product(products) {
1638
1662
  return products.map(function (product) {
1639
- var _product$product_sku, _product$note;
1663
+ var _product$product_sku2, _product$note;
1640
1664
  return {
1641
1665
  bundle: product.product_bundle,
1642
1666
  key: product.product_id,
1643
- option: ((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) || [],
1667
+ option: ((_product$product_sku2 = product.product_sku) === null || _product$product_sku2 === void 0 ? void 0 : _product$product_sku2.option) || [],
1644
1668
  product_id: product.product_id,
1645
1669
  product_variant_id: product.product_variant_id,
1646
1670
  num: product.product_quantity,
@@ -171,11 +171,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
171
171
  * 获取钱包支付方式
172
172
  */
173
173
  getWalletPaymentMethod(): Promise<PaymentMethod | null>;
174
- /**
175
- * 确保支付模块所需的数据库表已创建
176
- */
177
- /** @deprecated */
178
- private ensurePaymentTables;
179
174
  /**
180
175
  * 获取部分支付的订单
181
176
  */
@@ -199,10 +199,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
199
199
  this.app = this.appPlugin.getApp();
200
200
  this.dbManager = this.app.dbManager;
201
201
  this.logger = this.app.logger;
202
-
203
- // 确保支付模块所需的对象存储已创建
204
- // await this.ensurePaymentTables();
205
-
206
202
  this.registerNetworkHandlers();
207
203
 
208
204
  // // 预连接数据库
@@ -1739,7 +1735,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1739
1735
  case 0:
1740
1736
  _context21.prev = 0;
1741
1737
  _context21.next = 3;
1742
- return this.dbManager.getAll('pay_method');
1738
+ return this.getPayMethodListAsync();
1743
1739
  case 3:
1744
1740
  payMethods = _context21.sent;
1745
1741
  return _context21.abrupt("return", payMethods.find(function (method) {
@@ -1775,7 +1771,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1775
1771
  case 0:
1776
1772
  _context22.prev = 0;
1777
1773
  _context22.next = 3;
1778
- return this.dbManager.getAll('pay_method');
1774
+ return this.getPayMethodListAsync();
1779
1775
  case 3:
1780
1776
  payMethods = _context22.sent;
1781
1777
  return _context22.abrupt("return", payMethods.find(function (method) {
@@ -1811,7 +1807,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1811
1807
  case 0:
1812
1808
  _context23.prev = 0;
1813
1809
  _context23.next = 3;
1814
- return this.dbManager.getAll('pay_method');
1810
+ return this.getPayMethodListAsync();
1815
1811
  case 3:
1816
1812
  payMethods = _context23.sent;
1817
1813
  return _context23.abrupt("return", payMethods.find(function (method) {
@@ -1834,82 +1830,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1834
1830
  return getWalletPaymentMethod;
1835
1831
  }()
1836
1832
  /**
1837
- * 确保支付模块所需的数据库表已创建
1833
+ * 获取部分支付的订单
1838
1834
  */
1839
1835
  /** @deprecated */
1840
1836
  )
1841
1837
  }, {
1842
- key: "ensurePaymentTables",
1838
+ key: "getPartiallyPaidOrdersAsync",
1843
1839
  value: (function () {
1844
- var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1840
+ var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1841
+ var allOrders;
1845
1842
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1846
1843
  while (1) switch (_context24.prev = _context24.next) {
1847
1844
  case 0:
1848
1845
  _context24.prev = 0;
1849
1846
  _context24.next = 3;
1850
- return this.dbManager.getAll('pay_method');
1851
- case 3:
1852
- _context24.next = 9;
1853
- break;
1854
- case 5:
1855
- _context24.prev = 5;
1856
- _context24.t0 = _context24["catch"](0);
1857
- console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
1858
- console.warn('{ name: "pay_method", keyPath: "id" }');
1859
- case 9:
1860
- _context24.prev = 9;
1861
- _context24.next = 12;
1862
- return this.dbManager.getAll('order');
1863
- case 12:
1864
- _context24.next = 18;
1865
- break;
1866
- case 14:
1867
- _context24.prev = 14;
1868
- _context24.t1 = _context24["catch"](9);
1869
- console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
1870
- console.warn('{ name: "order", keyPath: "uuid" }');
1871
- case 18:
1872
- case "end":
1873
- return _context24.stop();
1874
- }
1875
- }, _callee24, this, [[0, 5], [9, 14]]);
1876
- }));
1877
- function ensurePaymentTables() {
1878
- return _ensurePaymentTables.apply(this, arguments);
1879
- }
1880
- return ensurePaymentTables;
1881
- }()
1882
- /**
1883
- * 获取部分支付的订单
1884
- */
1885
- /** @deprecated */
1886
- )
1887
- }, {
1888
- key: "getPartiallyPaidOrdersAsync",
1889
- value: (function () {
1890
- var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1891
- var allOrders;
1892
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1893
- while (1) switch (_context25.prev = _context25.next) {
1894
- case 0:
1895
- _context25.prev = 0;
1896
- _context25.next = 3;
1897
1847
  return this.dbManager.getAll('order');
1898
1848
  case 3:
1899
- allOrders = _context25.sent;
1900
- return _context25.abrupt("return", allOrders.filter(function (order) {
1849
+ allOrders = _context24.sent;
1850
+ return _context24.abrupt("return", allOrders.filter(function (order) {
1901
1851
  return order.payment_status === PaymentStatus.PartiallyPaid;
1902
1852
  }));
1903
1853
  case 7:
1904
- _context25.prev = 7;
1905
- _context25.t0 = _context25["catch"](0);
1906
- console.error('[PaymentModule] 获取部分支付订单失败', _context25.t0);
1907
- return _context25.abrupt("return", []);
1854
+ _context24.prev = 7;
1855
+ _context24.t0 = _context24["catch"](0);
1856
+ console.error('[PaymentModule] 获取部分支付订单失败', _context24.t0);
1857
+ return _context24.abrupt("return", []);
1908
1858
  case 11:
1909
1859
  case "end":
1910
- return _context25.stop();
1860
+ return _context24.stop();
1911
1861
  }
1912
- }, _callee25, this, [[0, 7]]);
1862
+ }, _callee24, this, [[0, 7]]);
1913
1863
  }));
1914
1864
  function getPartiallyPaidOrdersAsync() {
1915
1865
  return _getPartiallyPaidOrdersAsync.apply(this, arguments);
@@ -1930,17 +1880,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1930
1880
  }, {
1931
1881
  key: "roundAmountAsync",
1932
1882
  value: function () {
1933
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
1883
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(originalAmount, interval, rule) {
1934
1884
  var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
1935
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1936
- while (1) switch (_context26.prev = _context26.next) {
1885
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1886
+ while (1) switch (_context25.prev = _context25.next) {
1937
1887
  case 0:
1938
- _context26.prev = 0;
1888
+ _context25.prev = 0;
1939
1889
  // 参数验证
1940
1890
  amount = new Decimal(originalAmount);
1941
1891
  roundingInterval = new Decimal(interval);
1942
1892
  if (!roundingInterval.lte(0)) {
1943
- _context26.next = 5;
1893
+ _context25.next = 5;
1944
1894
  break;
1945
1895
  }
1946
1896
  throw new Error('舍入间隔必须大于 0');
@@ -1954,25 +1904,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1954
1904
 
1955
1905
  // 计算基础值:x / interval
1956
1906
  baseValue = amount.div(roundingInterval);
1957
- _context26.t0 = rule;
1958
- _context26.next = _context26.t0 === RoundingRule.Standard ? 12 : _context26.t0 === 'standard' ? 12 : _context26.t0 === RoundingRule.StandardDown ? 14 : _context26.t0 === 'standard_rounding_midpoint_down' ? 14 : _context26.t0 === RoundingRule.AlwaysUp ? 16 : _context26.t0 === 'always_up' ? 16 : _context26.t0 === RoundingRule.AlwaysDown ? 18 : _context26.t0 === 'always_down' ? 18 : 20;
1907
+ _context25.t0 = rule;
1908
+ _context25.next = _context25.t0 === RoundingRule.Standard ? 12 : _context25.t0 === 'standard' ? 12 : _context25.t0 === RoundingRule.StandardDown ? 14 : _context25.t0 === 'standard_rounding_midpoint_down' ? 14 : _context25.t0 === RoundingRule.AlwaysUp ? 16 : _context25.t0 === 'always_up' ? 16 : _context25.t0 === RoundingRule.AlwaysDown ? 18 : _context25.t0 === 'always_down' ? 18 : 20;
1959
1909
  break;
1960
1910
  case 12:
1961
1911
  // 标准舍入(中点向上)
1962
1912
  roundedValue = this.standardRound(baseValue, true);
1963
- return _context26.abrupt("break", 21);
1913
+ return _context25.abrupt("break", 21);
1964
1914
  case 14:
1965
1915
  // 标准舍入(中点向下)
1966
1916
  roundedValue = this.standardRound(baseValue, false);
1967
- return _context26.abrupt("break", 21);
1917
+ return _context25.abrupt("break", 21);
1968
1918
  case 16:
1969
1919
  // 总是向上舍入
1970
1920
  roundedValue = baseValue.ceil();
1971
- return _context26.abrupt("break", 21);
1921
+ return _context25.abrupt("break", 21);
1972
1922
  case 18:
1973
1923
  // 总是向下舍入
1974
1924
  roundedValue = baseValue.floor();
1975
- return _context26.abrupt("break", 21);
1925
+ return _context25.abrupt("break", 21);
1976
1926
  case 20:
1977
1927
  throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
1978
1928
  case 21:
@@ -1980,10 +1930,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1980
1930
  finalAmount = roundedValue.mul(roundingInterval);
1981
1931
  originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
1982
1932
  if (!finalAmount.eq(0)) {
1983
- _context26.next = 25;
1933
+ _context25.next = 25;
1984
1934
  break;
1985
1935
  }
1986
- return _context26.abrupt("return", {
1936
+ return _context25.abrupt("return", {
1987
1937
  originalAmount: originalAmountStr,
1988
1938
  roundedAmount: originalAmountStr,
1989
1939
  roundingDifference: '0.00'
@@ -1992,21 +1942,21 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1992
1942
  roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
1993
1943
  roundingDifference = finalAmount.sub(amount);
1994
1944
  roundingDifferenceStr = roundingDifference.toFixed(2);
1995
- return _context26.abrupt("return", {
1945
+ return _context25.abrupt("return", {
1996
1946
  originalAmount: originalAmountStr,
1997
1947
  roundedAmount: roundedAmountStr,
1998
1948
  roundingDifference: roundingDifferenceStr
1999
1949
  });
2000
1950
  case 31:
2001
- _context26.prev = 31;
2002
- _context26.t1 = _context26["catch"](0);
2003
- console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
2004
- throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
1951
+ _context25.prev = 31;
1952
+ _context25.t1 = _context25["catch"](0);
1953
+ console.error('[PaymentModule] 金额舍入失败:', _context25.t1);
1954
+ throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context25.t1 instanceof Error ? _context25.t1.message : String(_context25.t1)));
2005
1955
  case 35:
2006
1956
  case "end":
2007
- return _context26.stop();
1957
+ return _context25.stop();
2008
1958
  }
2009
- }, _callee26, this, [[0, 31]]);
1959
+ }, _callee25, this, [[0, 31]]);
2010
1960
  }));
2011
1961
  function roundAmountAsync(_x27, _x28, _x29) {
2012
1962
  return _roundAmountAsync.apply(this, arguments);
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { ProductListLoadProductsParams, ProductListStoreQueryParams } from './types';
3
+ import { ProductListLoadProductsParams, ProductListStoreQueryParams, ProductEnrichmentContext } from './types';
4
4
  import { ProductData } from '../Product/types';
5
5
  export * from './types';
6
6
  export declare class ProductList extends BaseModule implements Module {
@@ -19,6 +19,8 @@ export declare class ProductList extends BaseModule implements Module {
19
19
  * productList.updateOtherParams({ channel: 'pos' });
20
20
  */
21
21
  updateOtherParams(params: Record<string, any>): void;
22
+ enrichProducts(products: ProductData[], context: ProductEnrichmentContext): Promise<ProductData[]>;
23
+ private enrichCatalog;
22
24
  storeChange(path?: string, value?: any): Promise<void>;
23
25
  /**
24
26
  * 获取加时商品列表。