@pisell/pisellos 0.10.55 → 0.10.57

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 (114) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  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 +1 -1
  8. package/dist/modules/Order/utils.js +9 -6
  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.js +18 -5
  12. package/dist/modules/ResourcePlanner/planner.js +10 -8
  13. package/dist/modules/Rules/index.js +16 -14
  14. package/dist/modules/Rules/types.d.ts +2 -0
  15. package/dist/plugins/request.d.ts +4 -0
  16. package/dist/server/index.js +122 -69
  17. package/dist/server/modules/floor-plan/index.js +34 -3
  18. package/dist/server/modules/payment/index.d.ts +25 -6
  19. package/dist/server/modules/payment/index.js +660 -133
  20. package/dist/server/test.json +1 -1
  21. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  22. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  23. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  24. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  25. package/dist/shared/receipt/small-ticket.d.ts +11 -0
  26. package/dist/shared/receipt/small-ticket.js +430 -255
  27. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  28. package/dist/shared/receipt/templateVisibility.js +64 -0
  29. package/dist/solution/BaseSales/index.d.ts +4 -2
  30. package/dist/solution/BaseSales/index.js +1328 -1214
  31. package/dist/solution/BaseSales/types.d.ts +5 -1
  32. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  33. package/dist/solution/BaseSales/utils.js +3 -2
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +4 -1
  36. package/dist/solution/BookingTicket/index.js +120 -80
  37. package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
  38. package/dist/solution/OrderInvoicePreview/index.js +87 -16
  39. package/dist/solution/RegisterAndLogin/config.js +54 -11
  40. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  41. package/dist/solution/RegisterAndLogin/index.js +1 -1
  42. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  43. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  44. package/dist/solution/Sales/index.d.ts +2 -0
  45. package/dist/solution/Sales/index.js +15 -1
  46. package/dist/solution/ScanOrder/utils.js +3 -2
  47. package/dist/solution/UnifiedBookingSales/index.js +12 -13
  48. package/dist/solution/VenueBooking/index.d.ts +15 -2
  49. package/dist/solution/VenueBooking/index.js +1062 -785
  50. package/dist/solution/VenueBooking/types.d.ts +2 -1
  51. package/dist/solution/VenueBooking/types.js +1 -0
  52. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  53. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  54. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  55. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  56. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  57. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  58. package/lib/modules/OpenData/index.js +2 -1
  59. package/lib/modules/Order/index.d.ts +1 -0
  60. package/lib/modules/Order/index.js +71 -11
  61. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  62. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  63. package/lib/modules/Order/utils.d.ts +1 -1
  64. package/lib/modules/Order/utils.js +5 -3
  65. package/lib/modules/Payment/index.d.ts +0 -5
  66. package/lib/modules/Payment/index.js +3 -28
  67. package/lib/modules/ProductList/index.js +14 -1
  68. package/lib/modules/ResourcePlanner/planner.js +10 -8
  69. package/lib/modules/Rules/index.js +16 -14
  70. package/lib/modules/Rules/types.d.ts +2 -0
  71. package/lib/plugins/request.d.ts +4 -0
  72. package/lib/server/index.js +72 -28
  73. package/lib/server/modules/floor-plan/index.js +29 -1
  74. package/lib/server/modules/payment/index.d.ts +25 -6
  75. package/lib/server/modules/payment/index.js +350 -78
  76. package/lib/server/test.json +1 -1
  77. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  78. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  79. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  80. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  81. package/lib/shared/receipt/small-ticket.d.ts +11 -0
  82. package/lib/shared/receipt/small-ticket.js +234 -30
  83. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  84. package/lib/shared/receipt/templateVisibility.js +63 -0
  85. package/lib/solution/BaseSales/index.d.ts +4 -2
  86. package/lib/solution/BaseSales/index.js +79 -18
  87. package/lib/solution/BaseSales/types.d.ts +5 -1
  88. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  89. package/lib/solution/BaseSales/utils.js +2 -1
  90. package/lib/solution/BookingByStep/index.d.ts +1 -1
  91. package/lib/solution/BookingTicket/index.d.ts +4 -1
  92. package/lib/solution/BookingTicket/index.js +14 -2
  93. package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
  94. package/lib/solution/OrderInvoicePreview/index.js +62 -10
  95. package/lib/solution/RegisterAndLogin/config.js +57 -11
  96. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  97. package/lib/solution/RegisterAndLogin/index.js +9 -1
  98. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  99. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  100. package/lib/solution/Sales/index.d.ts +2 -0
  101. package/lib/solution/Sales/index.js +10 -1
  102. package/lib/solution/ScanOrder/utils.js +2 -1
  103. package/lib/solution/UnifiedBookingSales/index.js +5 -6
  104. package/lib/solution/VenueBooking/index.d.ts +15 -2
  105. package/lib/solution/VenueBooking/index.js +243 -96
  106. package/lib/solution/VenueBooking/types.d.ts +2 -1
  107. package/lib/solution/VenueBooking/types.js +1 -0
  108. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  109. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  110. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  111. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  112. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  113. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  114. 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";
@@ -898,7 +900,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
898
900
  };
899
901
  },
900
902
  setProduct: function setProduct(product, values) {
901
- var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _values$discount_list, _values$quantity2;
903
+ var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _product$product_sku, _values$discount_list, _values$quantity2;
902
904
  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
905
  var metadataAny = product.metadata || {};
904
906
  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';
@@ -924,7 +926,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
924
926
  });
925
927
  var composedOriginalPrice = composeLinePrice({
926
928
  mainPrice: nextMainOriginalPrice,
927
- bundle: nextBundle,
929
+ 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
930
  useOriginalBundle: true
929
931
  });
930
932
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
@@ -1026,6 +1028,7 @@ export function ensureCartItemOriginHolder(cartItem, window) {
1026
1028
  form_record: [formRecordId]
1027
1029
  };
1028
1030
  }
1031
+ ;
1029
1032
  export var getAllDiscountList = function getAllDiscountList(cartItem) {
1030
1033
  var _cartItem$_origin2, _cartItem$_origin3;
1031
1034
  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 +1516,7 @@ export function buildSubmitPayload(params) {
1513
1516
  shop_discount: tempOrder.shop_discount || '0.00',
1514
1517
  surcharge_fee: tempOrder.surcharge_fee || '0.00',
1515
1518
  note: tempOrder.note || '',
1516
- delivery_type: tempOrder.delivery_type || 'nil',
1519
+ delivery_type: tempOrder.delivery_type || 'shop_service',
1517
1520
  schedule_date: scheduleDate,
1518
1521
  // created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
1519
1522
  bookings: (tempOrder.bookings || []).filter(function (booking) {
@@ -1636,11 +1639,11 @@ export function mapPaymentItemsToOrderPayments(paymentItems) {
1636
1639
  */
1637
1640
  export function formatV1Product(products) {
1638
1641
  return products.map(function (product) {
1639
- var _product$product_sku, _product$note;
1642
+ var _product$product_sku2, _product$note;
1640
1643
  return {
1641
1644
  bundle: product.product_bundle,
1642
1645
  key: product.product_id,
1643
- option: ((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) || [],
1646
+ option: ((_product$product_sku2 = product.product_sku) === null || _product$product_sku2 === void 0 ? void 0 : _product$product_sku2.option) || [],
1644
1647
  product_id: product.product_id,
1645
1648
  product_variant_id: product.product_variant_id,
1646
1649
  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);
@@ -156,7 +156,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
156
156
  value: function () {
157
157
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
158
158
  var _this$otherParams,
159
+ _this$otherParams$bus,
159
160
  _this$otherParams2,
161
+ _this$otherParams3,
162
+ _this$otherParams4,
160
163
  _this2 = this;
161
164
  var _ref,
162
165
  _ref$category_ids,
@@ -185,6 +188,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
185
188
  channelMap,
186
189
  rawApplicationCode,
187
190
  mappedApplicationCode,
191
+ configuredBusinessCode,
192
+ resolvedStrategyContext,
188
193
  queryPayload,
189
194
  handledByOsServer,
190
195
  originalCallback,
@@ -227,7 +232,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
227
232
  };
228
233
  rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
229
234
  mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
230
- queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform) ? {} : {
235
+ configuredBusinessCode = (_this$otherParams$bus = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code; // application_code 是后端商品筛选字段;智能定价评估器则只读取
236
+ // strategy_context 中的 channel / business_code。默认补齐两者,
237
+ // 但允许调用方显式传入的上下文覆盖默认值。
238
+ resolvedStrategyContext = _objectSpread(_objectSpread(_objectSpread({}, mappedApplicationCode ? {
239
+ channel: mappedApplicationCode
240
+ } : {}), configuredBusinessCode ? {
241
+ business_code: configuredBusinessCode
242
+ } : {}), strategy_context || {});
243
+ queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform) ? {} : {
231
244
  open_quotation: 1
232
245
  }), {}, {
233
246
  open_bundle: 0,
@@ -256,7 +269,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
256
269
  with_schedule: with_schedule,
257
270
  schedule_datetime: schedule_datetime,
258
271
  extension_type: extension_type,
259
- strategy_context: strategy_context
272
+ strategy_context: Object.keys(resolvedStrategyContext).length ? resolvedStrategyContext : undefined
260
273
  });
261
274
  handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
262
275
  originalCallback = typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? options.callback : undefined;
@@ -305,14 +318,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
305
318
  return _ref2.apply(this, arguments);
306
319
  };
307
320
  }()) : undefined;
308
- _context5.next = 14;
321
+ _context5.next = 16;
309
322
  return this.request.post("/product/query", queryPayload, {
310
323
  osServer: true,
311
324
  callback: subscriptionCallback,
312
325
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
313
326
  customToast: function customToast() {}
314
327
  });
315
- case 14:
328
+ case 16:
316
329
  productsData = _context5.sent;
317
330
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
318
331
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
@@ -335,7 +348,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
335
348
  // }
336
349
  this.addProduct(sortedList);
337
350
  return _context5.abrupt("return", sortedList);
338
- case 20:
351
+ case 22:
339
352
  case "end":
340
353
  return _context5.stop();
341
354
  }
@@ -436,7 +436,7 @@ function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinute
436
436
  }
437
437
  function normalizeRequirementGroup(product, requirementGroup) {
438
438
  var _requirementGroup$for;
439
- var resourceType = 'single';
439
+ var resourceType = requirementGroup.resourceType === 'multiple' || requirementGroup.resourceType === 'capacity' ? requirementGroup.resourceType : 'single';
440
440
  var required = requirementGroup.required !== false;
441
441
  var min = required ? 1 : 0;
442
442
  return _objectSpread(_objectSpread({}, requirementGroup), {}, {
@@ -482,7 +482,7 @@ function normalizeProducts(products) {
482
482
  function normalizeResources(resources) {
483
483
  return resources.map(function (resource) {
484
484
  return _objectSpread(_objectSpread({}, resource), {}, {
485
- resourceType: 'single',
485
+ resourceType: resource.resourceType === 'multiple' || resource.resourceType === 'capacity' ? resource.resourceType : 'single',
486
486
  capacity: Math.max(1, Number(resource.capacity || 1) || 1),
487
487
  windows: (resource.windows || []).map(function (window) {
488
488
  return _objectSpread({}, window);
@@ -637,7 +637,8 @@ function buildCells(projection) {
637
637
  var usedCapacity = segmentOccupancies.reduce(function (sum, occupancy) {
638
638
  return sum + Math.max(1, Number(occupancy.pax || 1) || 1);
639
639
  }, 0);
640
- var remainingCapacity = Math.max(0, resource.capacity - usedCapacity);
640
+ // 预约模式来自商品资源组;v2 资源记录可能不包含 type。
641
+ var remainingCapacity = requirementGroup.resourceType === 'single' && segmentOccupancies.length > 0 ? 0 : Math.max(0, resource.capacity - usedCapacity);
641
642
  var requiredCapacity = resolveRequiredCapacity(requirementGroup, product);
642
643
  var reasonCodes = Array.from(new Set(segmentOccupancies.flatMap(function (occupancy) {
643
644
  var source = occupancy.source || 'remote';
@@ -671,7 +672,7 @@ function buildCells(projection) {
671
672
  requirementFormId: requirementGroup.formId,
672
673
  resourceId: resource.id,
673
674
  resourceName: resource.name,
674
- resourceType: resource.resourceType,
675
+ resourceType: requirementGroup.resourceType,
675
676
  startAt: formatDateTime(start, timezoneName, fixedOffsetMinutes),
676
677
  endAt: formatDateTime(end, timezoneName, fixedOffsetMinutes),
677
678
  date: formatDate(start, timezoneName),
@@ -679,7 +680,7 @@ function buildCells(projection) {
679
680
  endTime: formatTime(end, timezoneName),
680
681
  timezone: projection.meta.timezone,
681
682
  status: status,
682
- // 资源组当前统一单选;具体资源仍用 capacity 表达可承载的预约数量。
683
+ // capacity 表示人数;single 被占用时不再贡献可用容量。
683
684
  remainingCapacity: remainingCapacity,
684
685
  maxCapacity: resource.capacity,
685
686
  reasonCodes: Array.from(new Set(reasonCodes)),
@@ -1739,7 +1740,7 @@ function evaluateCandidate(projection, candidate, request) {
1739
1740
  resourceName: resource.name,
1740
1741
  resourceFormId: resource.formId,
1741
1742
  policyId: (_resource$raw = resource.raw) === null || _resource$raw === void 0 ? void 0 : _resource$raw.policy_id,
1742
- resourceType: resource.resourceType,
1743
+ resourceType: requirementGroup.resourceType,
1743
1744
  status: _isPast ? 'past' : 'unavailable',
1744
1745
  maxPartySize: 0,
1745
1746
  reasonCodes: _isPast ? ['past'] : [].concat(_toConsumableArray(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), ['outside_resource_window'])
@@ -1763,7 +1764,7 @@ function evaluateCandidate(projection, candidate, request) {
1763
1764
  resourceName: resource.name,
1764
1765
  resourceFormId: resource.formId,
1765
1766
  policyId: (_resource$raw2 = resource.raw) === null || _resource$raw2 === void 0 ? void 0 : _resource$raw2.policy_id,
1766
- resourceType: resource.resourceType,
1767
+ resourceType: requirementGroup.resourceType,
1767
1768
  status: status,
1768
1769
  remainingCapacity: remainingCapacity,
1769
1770
  maxCapacity: maxCapacity,
@@ -2330,7 +2331,8 @@ export function validateAvailabilitySelection(projection, params) {
2330
2331
  var remainingCapacity = matchedCell === null || matchedCell === void 0 ? void 0 : matchedCell.remainingCapacity;
2331
2332
  if (option && (option.status === 'available' || option.status === 'limited') && remainingCapacity !== undefined) {
2332
2333
  var capacityPerBooking = normalizedPartySize !== null && normalizedPartySize !== void 0 ? normalizedPartySize : 1;
2333
- var availableQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
2334
+ var capacityQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
2335
+ var availableQuantity = matchedGroup.resourceType === 'single' ? Math.min(1, capacityQuantity) : capacityQuantity;
2334
2336
  if (normalizedBookingCount > availableQuantity) {
2335
2337
  conflicts.push({
2336
2338
  code: 'resource_capacity_exceeded',
@@ -387,7 +387,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
387
387
  }) && productList.find(function (n) {
388
388
  return !n.booking_id;
389
389
  });
390
- var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
390
+ var reapplyWeighedDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids) || []).map(String));
391
+ var reapplyBookingDiscountProductUids = new Set([].concat(_toConsumableArray((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []), _toConsumableArray(reapplyWeighedDiscountProductUids)).filter(function (uid) {
391
392
  return uid !== undefined && uid !== null && uid !== '';
392
393
  }).map(String));
393
394
  var getOriginProductUid = function getOriginProductUid(originProduct) {
@@ -400,8 +401,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
400
401
  if (!selectedDiscount) return false;
401
402
  var uid = getOriginProductUid(originProduct);
402
403
  if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
403
- var discountType = selectedDiscount.tag || selectedDiscount.type || '';
404
- return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
404
+ var discountType = selectedDiscount.tag || selectedDiscount.type;
405
+ return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '');
405
406
  };
406
407
  var resolveReapplyBookingDiscountPercent = function resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount) {
407
408
  var _discount2;
@@ -454,8 +455,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
454
455
  };
455
456
  }
456
457
  var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
457
- var discountType = discount.tag || discount.type || '';
458
- return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
458
+ var discountType = discount.tag || discount.type;
459
+ return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '');
459
460
  };
460
461
 
461
462
  // 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
@@ -695,9 +696,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
695
696
  addModeDiscount.forEach(function (discount) {
696
697
  // 即使没有匹配的动态策略,服务端状态和次数限制也不能被覆盖为可用。
697
698
  if (discount.reasonCode) return;
698
- var discountType = discount.tag || discount.type || '';
699
+ var discountType = discount.tag || discount.type;
699
700
  // 对两类全额抵扣卡和折扣卡执行附加策略检查。
700
- if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
701
+ if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '')) {
701
702
  var _discount$unified_ava, _discount$limited_rel, _discount$limited_rel2;
702
703
  var entitlementQuota = isEntitlementPass(discount) ? resolveEntitlementQuota(discount) : null;
703
704
  if (isEntitlementPass(discount) && !entitlementQuota) {
@@ -1319,7 +1320,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1319
1320
  }));
1320
1321
 
1321
1322
  // 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
1322
- if (isPersistedProduct && hasExistingWalletDiscount) {
1323
+ var isReweighedProduct = reapplyWeighedDiscountProductUids.has(getOriginProductUid(originProduct) || '');
1324
+ if (isPersistedProduct && hasExistingWalletDiscount && !isReweighedProduct) {
1323
1325
  if (flatItem.type === 'main') {
1324
1326
  processedProductsMap.set(product._id, [originProduct]);
1325
1327
  }
@@ -1334,7 +1336,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1334
1336
  var _product$discount_lis3, _product$discount_lis4;
1335
1337
  if (_this4.isItemRewardProductDiscount(product)) return false;
1336
1338
  // 🔥 检查策略可用性(针对全额抵扣卡和折扣卡)
1337
- var discountType = discount.tag || discount.type || '';
1339
+ var discountType = discount.tag || discount.type;
1338
1340
  var currentOriginUid = getOriginProductUid(originProduct);
1339
1341
  var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
1340
1342
  if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
@@ -1342,7 +1344,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1342
1344
  if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
1343
1345
  if (!discount.isSelected) return false;
1344
1346
  }
1345
- if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
1347
+ if (['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '') && !isReapplyEditModeDiscountForProduct) {
1346
1348
  var _discount$config4;
1347
1349
  // 如果策略检查后没有config,说明不可用
1348
1350
  if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config4 = discount.config) !== null && _discount$config4 !== void 0 && _discount$config4.isAvailable)) {
@@ -1418,8 +1420,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1418
1420
  // 识别用户本次显式选择的卡券,供次卡和折扣卡各自的优先级使用。
1419
1421
  // 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
1420
1422
  var explicitlySelectedDiscount = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
1421
- var discountType = discount.tag || discount.type || '';
1422
- return String(discount.id) === String(options.discountId) && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
1423
+ var discountType = discount.tag || discount.type;
1424
+ return String(discount.id) === String(options.discountId) && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '');
1423
1425
  }) : undefined;
1424
1426
  // 折扣卡会复用于整条商品行;商品券必须继续按单张拆分,不能复用该分支。
1425
1427
  var explicitlySelectedDiscountCard = explicitlySelectedDiscount && !isFullCoveragePass(explicitlySelectedDiscount) ? explicitlySelectedDiscount : undefined;
@@ -1435,8 +1437,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1435
1437
  return id !== undefined && id !== null;
1436
1438
  }).map(String));
1437
1439
  var appliedDiscountCard = options !== null && options !== void 0 && options.scan ? undefined : applicableDiscounts.find(function (discount) {
1438
- var discountType = discount.tag || discount.type || '';
1439
- return discount.isSelected === true && ['discount_card', 'product_discount_card'].includes(discountType) && appliedWalletDiscountIds.has(String(discount.id));
1440
+ var discountType = discount.tag || discount.type;
1441
+ return discount.isSelected === true && ['discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '') && appliedWalletDiscountIds.has(String(discount.id));
1440
1442
  });
1441
1443
  var appliedEntitlementPass = options !== null && options !== void 0 && options.scan || (options === null || options === void 0 ? void 0 : options.preserveEntitlementSelection) === false ? undefined : applicableDiscounts.find(function (discount) {
1442
1444
  return isEntitlementPass(discount) && discount.isSelected === true && appliedWalletDiscountIds.has(String(discount.id));
@@ -35,6 +35,8 @@ export interface RulesCalcDiscountOptions {
35
35
  preserveEntitlementSelection?: boolean;
36
36
  /** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
37
37
  reapplyBookingDiscountProductUids?: string[];
38
+ /** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
39
+ reapplyWeighedDiscountProductUids?: string[];
38
40
  }
39
41
  export interface RulesModuleAPI {
40
42
  setRulesList: (rulesList: Rules[]) => Promise<void>;
@@ -56,6 +56,10 @@ export interface CacheProps {
56
56
  * 请求配置
57
57
  */
58
58
  export interface RequestOptions {
59
+ /** Customer-only, credential-free GET /open/document/{id} on picoding. */
60
+ publicInvoiceDocument?: boolean;
61
+ /** Route through the host's configured picoding environment. */
62
+ pisell2?: boolean;
59
63
  /** Let the caller handle read-only preview failures without host navigation/toasts. */
60
64
  manualErrorHandling?: boolean;
61
65
  skipErrorHandler?: boolean;