@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
@@ -25,6 +25,10 @@ export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSales
25
25
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
26
26
  export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
27
27
  export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
28
+ export interface BaseSalesCashPaymentOptions {
29
+ /** 指定现金支付方式;省略时使用默认 CASHMANUAL。 */
30
+ paymentMethodId?: number | string;
31
+ }
28
32
  export interface BaseSalesSubmitSalesOrderParams {
29
33
  payments?: OrderPaymentSource[];
30
34
  paymentStatus?: BaseSalesPaymentStatus;
@@ -40,7 +44,7 @@ export interface BaseSalesCashPaymentConfig {
40
44
  amountDue: number;
41
45
  recommendedAmounts: number[];
42
46
  }
43
- export interface BaseSalesPayCashParams {
47
+ export interface BaseSalesPayCashParams extends BaseSalesCashPaymentOptions {
44
48
  /** 实际计入订单的现金支付金额(部分支付时小于待付金额)。 */
45
49
  amount: number;
46
50
  /** 顾客实际交付现金;可大于 amount。 */
@@ -11,6 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
11
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
13
  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; }
14
+ import { resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "../../../modules/Order/utils/weighedProduct";
14
15
  import { composeLinePrice, getBundleSellingMagnitude, normalizeProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
15
16
  import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
16
17
  function toNumber(value) {
@@ -101,11 +102,12 @@ function appendDataVariantIds(base) {
101
102
  return Array.isArray(base) || result.length ? result : undefined;
102
103
  }
103
104
  function normalizeOptionItems(optionItems) {
105
+ var useOriginalPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
104
106
  if (!Array.isArray(optionItems)) return [];
105
107
  return optionItems.map(function (optionItem) {
106
- var _optionItem$option_gr, _ref, _optionItem$price, _optionItem$num;
108
+ var _optionItem$option_gr, _ref, _ref2, _ref3, _optionItem$num;
107
109
  var optionGroupItemId = toNumber((_optionItem$option_gr = optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id) !== null && _optionItem$option_gr !== void 0 ? _optionItem$option_gr : optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
108
- var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
110
+ var price = (_ref = (_ref2 = (_ref3 = useOriginalPrice ? optionItem === null || optionItem === void 0 ? void 0 : optionItem.original_price : undefined) !== null && _ref3 !== void 0 ? _ref3 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref2 !== void 0 ? _ref2 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
109
111
  return _objectSpread(_objectSpread({}, optionItem), {}, {
110
112
  option_group_item_id: optionGroupItemId,
111
113
  option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
@@ -117,10 +119,13 @@ function normalizeOptionItems(optionItems) {
117
119
  }
118
120
  function normalizeBundleItems(bundleItems) {
119
121
  var preferPriceField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
122
+ var preferBundleSellingPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
120
123
  if (!Array.isArray(bundleItems)) return [];
121
124
  return bundleItems.map(function (bundleItem) {
122
- var _ref2, _ref3, _ref4, _bundleItem$price, _ref5, _ref6, _ref7, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref8, _ref9, _bundleItem$original_, _normalizedItem$price;
123
- var unitSelling = preferPriceField ? (_ref2 = (_ref3 = (_ref4 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundleItem.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_price) !== null && _ref2 !== void 0 ? _ref2 : '0' : (_ref5 = (_ref6 = (_ref7 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref7 !== void 0 ? _ref7 : bundleItem.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.product_price) !== null && _ref5 !== void 0 ? _ref5 : '0';
125
+ var _ref4, _ref5, _ref6, _bundleItem$price, _ref7, _ref8, _ref9, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref10, _ref11, _bundleItem$original_, _normalizedItem$price;
126
+ // Weighed manual prices distribute the bundle base and nested options separately.
127
+ // Its explicit selling amount already includes those options.
128
+ var unitSelling = preferPriceField && !preferBundleSellingPrice ? (_ref4 = (_ref5 = (_ref6 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.custom_price) !== null && _ref5 !== void 0 ? _ref5 : bundleItem.product_price) !== null && _ref4 !== void 0 ? _ref4 : '0' : (_ref7 = (_ref8 = (_ref9 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.custom_price) !== null && _ref8 !== void 0 ? _ref8 : bundleItem.product_price) !== null && _ref7 !== void 0 ? _ref7 : '0';
124
129
  var unitStr = toPriceString(unitSelling, '0.00');
125
130
  var num = toSafePositiveInt((_bundleItem$num = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.quantity, 1);
126
131
  var magnitudeSource = _objectSpread(_objectSpread({}, bundleItem), {}, {
@@ -135,7 +140,7 @@ function normalizeBundleItems(bundleItems) {
135
140
  // price 保留毛价(markdown 仍为正),由 price_type 决定符号。
136
141
  price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
137
142
  bundle_selling_price: unitStr,
138
- original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
143
+ original_price: (_ref10 = (_ref11 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : unitStr,
139
144
  option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
140
145
  discount_list: preferPriceField ? [] : bundleItem.discount_list
141
146
  });
@@ -163,49 +168,55 @@ function findVariantById(origin, variantId) {
163
168
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
164
169
  */
165
170
  export function transformBaseProductToOrderProduct(params) {
166
- var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref15, _findVariantById, _origin$production_co, _ref16, _ref17, _ref18, _ref19, _ref20, _matchedVariant$price, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend2, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend3, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend4, _payload$_extend5, _extend3, _payload$_extend6, _payload$_extend7, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
171
+ var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price, _ref25, _payload$line_total, _payload$_extend3, _ref26, _ref27, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref28, _ref29, _origin$base_price, _ref30, _ref31, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _ref32, _ref33, _payload$tax_fee, _ref34, _ref35, _payload$is_charge_ta;
167
172
  var payload = params.payload,
168
173
  _params$fallbackProdu = params.fallbackProductId,
169
174
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
170
175
  if (!payload || _typeof(payload) !== 'object') return null;
171
176
  var sourceProduct = params.sourceProduct || params.sourceItem || {};
172
- var productId = toProductId((_ref10 = (_ref11 = (_ref12 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref10 !== void 0 ? _ref10 : fallbackProductId);
177
+ var productId = toProductId((_ref12 = (_ref13 = (_ref14 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref12 !== void 0 ? _ref12 : fallbackProductId);
173
178
  if (productId === null) return null;
174
- var productVariantId = toNumber((_ref13 = (_ref14 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
179
+ var productVariantId = toNumber((_ref15 = (_ref16 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref15 !== void 0 ? _ref15 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
175
180
  var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
176
181
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
177
182
  var authoritativeDataVariantIds = cloneFirstDataVariantIds((_payload$metadata = payload.metadata) === null || _payload$metadata === void 0 ? void 0 : _payload$metadata.data_variant_ids, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.data_variant_ids, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad = callbackOrigin.metadata) === null || _callbackOrigin$metad === void 0 ? void 0 : _callbackOrigin$metad.data_variant_ids, origin === null || origin === void 0 || (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata.data_variant_ids);
178
183
  var selectedSettlementSnapshot = firstNonBlank(payload.selected_settlement_snapshot, (_payload$metadata2 = payload.metadata) === null || _payload$metadata2 === void 0 ? void 0 : _payload$metadata2.selected_settlement_snapshot, (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 || (_payload$_extend = _payload$_extend.metadata) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 || (_sourceProduct$_exten = _sourceProduct$_exten.metadata) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad2 = callbackOrigin.metadata) === null || _callbackOrigin$metad2 === void 0 ? void 0 : _callbackOrigin$metad2.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_exte = callbackOrigin._extend) === null || _callbackOrigin$_exte === void 0 || (_callbackOrigin$_exte = _callbackOrigin$_exte.metadata) === null || _callbackOrigin$_exte === void 0 ? void 0 : _callbackOrigin$_exte.selected_settlement_snapshot);
179
184
  var locallyAppliedVariantIds = authoritativeDataVariantIds === undefined ? cloneFirstDataVariantIds((_payload$_dataVariant = payload._dataVariant) === null || _payload$_dataVariant === void 0 ? void 0 : _payload$_dataVariant.appliedVariantIds, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_dataV = sourceProduct._dataVariant) === null || _sourceProduct$_dataV === void 0 ? void 0 : _sourceProduct$_dataV.appliedVariantIds, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_data = callbackOrigin._dataVariant) === null || _callbackOrigin$_data === void 0 ? void 0 : _callbackOrigin$_data.appliedVariantIds, origin === null || origin === void 0 || (_origin$_dataVariant = origin._dataVariant) === null || _origin$_dataVariant === void 0 ? void 0 : _origin$_dataVariant.appliedVariantIds) : undefined;
180
185
  var dataVariantIds = appendDataVariantIds(authoritativeDataVariantIds, locallyAppliedVariantIds, selectedSettlementSnapshot === null || selectedSettlementSnapshot === void 0 ? void 0 : selectedSettlementSnapshot.data_variant_id);
181
- var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
186
+ var matchedVariant = (_ref17 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref17 !== void 0 ? _ref17 : findVariantById(origin, productVariantId);
182
187
  var productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.production_code : (_origin$production_co = origin === null || origin === void 0 ? void 0 : origin.production_code) !== null && _origin$production_co !== void 0 ? _origin$production_co : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.production_code);
183
188
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
184
189
  // 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
185
- // 此时优先从商品/variant 快照读取目录价;售价仍由 line_total - bundle 推导。
186
- var catalogSourcePrice = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
187
- var sourceProductPrice = toPriceString(hasPriceOverride ? (_ref21 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref21 !== void 0 ? _ref21 : payload.selling_price : (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : catalogSourcePrice, '0.00');
188
- var explicitLineTotal = (_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.total;
190
+ // 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
191
+ // 售价仍由 line_total - bundle 推导。
192
+ var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
193
+ var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
194
+ var sourceProductPrice = toPriceString(weighedSourcePrice !== null && weighedSourcePrice !== void 0 ? weighedSourcePrice : hasPriceOverride ? (_ref23 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref23 !== void 0 ? _ref23 : payload.selling_price : (_ref24 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref24 !== void 0 ? _ref24 : catalogSourcePrice, '0.00');
195
+ var explicitLineTotal = (_ref25 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref25 !== void 0 ? _ref25 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
189
196
  var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
190
197
  var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
191
- var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
192
- var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
198
+ var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref26 = (_ref27 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref27 !== void 0 ? _ref27 : payload.options) !== null && _ref26 !== void 0 ? _ref26 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
199
+ var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
193
200
  // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
194
201
  // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
195
202
  var uniqueIdentificationNumber = payload.unique_identification_number;
196
203
  var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
197
- var originTotal = resolveManualDiscountOriginTotal({
204
+ var originTotal = weighedSourcePrice !== undefined ? Number(composeLinePrice({
205
+ mainPrice: Number(weighedSourcePrice) + sumOptionUnitPrice(productOptionItem).toNumber(),
206
+ bundle: hasPriceOverride ? withOriginalBundleOptionPrices(productBundle) : productBundle,
207
+ useOriginalBundle: true
208
+ })) : resolveManualDiscountOriginTotal({
198
209
  originTotal: payload.origin_total,
199
- extendOriginTotal: (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.origin_total,
210
+ extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
200
211
  originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
201
212
  sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
202
- catalogUnitPrice: (_ref26 = (_ref27 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref27 !== void 0 ? _ref27 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref26 !== void 0 ? _ref26 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
213
+ catalogUnitPrice: (_ref28 = (_ref29 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref28 !== void 0 ? _ref28 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
203
214
  quantity: resolvedQuantity
204
215
  });
205
- var sellingTotal = Number((_ref28 = (_ref29 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref29 !== void 0 ? _ref29 : (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.total) !== null && _ref28 !== void 0 ? _ref28 : lineCompositeTotal);
216
+ var sellingTotal = Number((_ref30 = (_ref31 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref31 !== void 0 ? _ref31 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref30 !== void 0 ? _ref30 : lineCompositeTotal);
206
217
  var discountReason = resolveManualDiscountReasonFromSources({
207
218
  discountReason: payload.discount_reason,
208
- extendDiscountReason: (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.discount_reason,
219
+ extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
209
220
  originExtendDiscountReason: origin === null || origin === void 0 || (_extend3 = origin._extend) === null || _extend3 === void 0 ? void 0 : _extend3.discount_reason
210
221
  });
211
222
  var lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
@@ -218,8 +229,8 @@ export function transformBaseProductToOrderProduct(params) {
218
229
  sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
219
230
  quantity: resolvedQuantity,
220
231
  message: discountReason,
221
- discountway: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discountway,
222
- discount_per: (_payload$_extend7 = payload._extend) === null || _payload$_extend7 === void 0 ? void 0 : _payload$_extend7.discount_per
232
+ discountway: (_payload$_extend7 = payload._extend) === null || _payload$_extend7 === void 0 ? void 0 : _payload$_extend7.discountway,
233
+ discount_per: (_payload$_extend8 = payload._extend) === null || _payload$_extend8 === void 0 ? void 0 : _payload$_extend8.discount_per
223
234
  })) : payload.discount_list || [];
224
235
 
225
236
  // v2:source 不含 option;main_product_* 含 option(与 normalizeOrderProduct 一致)
@@ -281,13 +292,17 @@ export function transformBaseProductToOrderProduct(params) {
281
292
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
282
293
  selling_price: lineCompositeTotal,
283
294
  original_price: lineOriginalPrice,
284
- tax_fee: toPriceString((_ref30 = (_ref31 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref31 !== void 0 ? _ref31 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
285
- is_charge_tax: toNumber((_ref32 = (_ref33 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
295
+ tax_fee: toPriceString((_ref32 = (_ref33 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
296
+ is_charge_tax: toNumber((_ref34 = (_ref35 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref34 !== void 0 ? _ref34 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
286
297
  metadata: metadata,
287
298
  note: payload.note != null ? String(payload.note) : '',
288
299
  product_title: productTitle,
289
300
  product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
290
- _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
301
+ _origin: _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), weighedSourcePrice !== undefined && hasPriceOverride ? {
302
+ _extend: _objectSpread(_objectSpread({}, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct._extend), {}, {
303
+ origin_total: originTotal
304
+ })
305
+ } : {}), {}, {
291
306
  callbackData: payload
292
307
  })
293
308
  });
@@ -4,9 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { withOriginalBundleOptionPrices } from "../../modules/Order/utils/weighedProduct";
7
8
  import Decimal from 'decimal.js';
8
9
  import { composeLinePrice, createUuidV4, ensureProductSku, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
9
- import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
10
+ import { ensureManualProductDiscountList, hasManualProductDiscountFlag } from "../../modules/Order/utils/manualProductDiscount";
10
11
 
11
12
  /**
12
13
  * 构建金额全为 0 的空 summary。
@@ -241,7 +242,7 @@ export function normalizeOrderProduct(product) {
241
242
  });
242
243
  var composedOriginalPrice = composeLinePrice({
243
244
  mainPrice: mainOriginalStr,
244
- bundle: normalizedBundle,
245
+ bundle: Number(productSku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadata) ? withOriginalBundleOptionPrices(normalizedBundle) : normalizedBundle,
245
246
  useOriginalBundle: true
246
247
  });
247
248
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
329
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -8,6 +8,7 @@ import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
10
10
  import type { LoadSalesDetailParams } from '../../modules/Order/types';
11
+ import type { GlobalScanSearchType } from './utils/scan/formatGlobalScan';
11
12
  import type { AddAddTimeProductToBookingInput, AddAddTimeProductsToBookingInput, GlobalScanHandleResult, GlobalScanHostBridge } from './types';
12
13
  import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
13
14
  import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
@@ -31,10 +32,10 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
31
32
  private orderCustomerDiscountRefreshCustomerId;
32
33
  private orderCustomerDiscountRefreshTarget;
33
34
  private orderCustomerPromotionRefreshInFlight;
35
+ private readonly customerResolveRequests;
34
36
  protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
35
37
  protected loadOpenDataInFlightTarget: string | null;
36
38
  protected openDataTarget: string | null;
37
- private readonly customerResolveRequests;
38
39
  /**
39
40
  * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
40
41
  * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
@@ -537,6 +538,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
537
538
  * ```
538
539
  */
539
540
  handleGlobalScanCode(code: string, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
541
+ /** 查询码类型;复用原有识别和缓存,不写订单、不打开选择 UI。 */
542
+ getGlobalScanCodeType(code: string): Promise<GlobalScanSearchType | null>;
540
543
  resolveBestAddTimePlan(addTimeProducts: any[], targetMinutes: number): any;
541
544
  /**
542
545
  * 构造一条绑定到已有 booking 的加时商品行。