@pisell/pisellos 2.2.260 → 2.2.262

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 (107) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.js +1 -6
  6. package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  7. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +23 -13
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  12. package/dist/modules/Discount/index.d.ts +5 -2
  13. package/dist/modules/Discount/index.js +30 -7
  14. package/dist/modules/Discount/types.d.ts +4 -0
  15. package/dist/modules/Order/index.d.ts +45 -2
  16. package/dist/modules/Order/index.js +1552 -926
  17. package/dist/modules/Order/types.d.ts +36 -2
  18. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  19. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  22. package/dist/modules/Order/utils.d.ts +8 -3
  23. package/dist/modules/Order/utils.js +136 -56
  24. package/dist/modules/Rules/index.d.ts +4 -10
  25. package/dist/modules/Rules/index.js +63 -12
  26. package/dist/modules/Rules/types.d.ts +12 -2
  27. package/dist/modules/SalesSummary/index.d.ts +7 -3
  28. package/dist/modules/SalesSummary/index.js +67 -39
  29. package/dist/modules/SalesSummary/types.d.ts +1 -0
  30. package/dist/modules/SalesSummary/utils.js +2 -1
  31. package/dist/modules/SurchargeList/index.d.ts +6 -4
  32. package/dist/modules/SurchargeList/index.js +62 -39
  33. package/dist/modules/SurchargeList/types.d.ts +6 -2
  34. package/dist/server/index.d.ts +8 -0
  35. package/dist/server/index.js +1365 -911
  36. package/dist/server/modules/order/index.d.ts +32 -7
  37. package/dist/server/modules/order/index.js +551 -464
  38. package/dist/server/modules/order/types.d.ts +4 -0
  39. package/dist/server/modules/products/index.d.ts +5 -1
  40. package/dist/server/modules/products/index.js +384 -315
  41. package/dist/server/modules/products/types.d.ts +4 -0
  42. package/dist/solution/BaseSales/index.d.ts +42 -2
  43. package/dist/solution/BaseSales/index.js +1416 -775
  44. package/dist/solution/BaseSales/types.d.ts +7 -1
  45. package/dist/solution/BaseSales/types.js +3 -2
  46. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  47. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  48. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +20 -4
  50. package/dist/solution/BookingByStep/index.d.ts +1 -1
  51. package/dist/solution/BookingTicket/index.d.ts +8 -0
  52. package/dist/solution/BookingTicket/index.js +212 -31
  53. package/dist/solution/ShopDiscount/index.js +15 -14
  54. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  55. package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
  56. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  57. package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
  58. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -2
  59. package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  60. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  61. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -1
  62. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  63. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  64. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  65. package/lib/modules/Discount/index.d.ts +5 -2
  66. package/lib/modules/Discount/index.js +23 -3
  67. package/lib/modules/Discount/types.d.ts +4 -0
  68. package/lib/modules/Order/index.d.ts +45 -2
  69. package/lib/modules/Order/index.js +720 -116
  70. package/lib/modules/Order/types.d.ts +36 -2
  71. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  72. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  73. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  74. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  75. package/lib/modules/Order/utils.d.ts +8 -3
  76. package/lib/modules/Order/utils.js +104 -18
  77. package/lib/modules/Rules/index.d.ts +4 -10
  78. package/lib/modules/Rules/index.js +61 -9
  79. package/lib/modules/Rules/types.d.ts +12 -2
  80. package/lib/modules/SalesSummary/index.d.ts +7 -3
  81. package/lib/modules/SalesSummary/index.js +28 -11
  82. package/lib/modules/SalesSummary/types.d.ts +1 -0
  83. package/lib/modules/SalesSummary/utils.js +2 -0
  84. package/lib/modules/SurchargeList/index.d.ts +6 -4
  85. package/lib/modules/SurchargeList/index.js +41 -21
  86. package/lib/modules/SurchargeList/types.d.ts +6 -2
  87. package/lib/server/index.d.ts +8 -0
  88. package/lib/server/index.js +336 -11
  89. package/lib/server/modules/order/index.d.ts +32 -7
  90. package/lib/server/modules/order/index.js +298 -189
  91. package/lib/server/modules/order/types.d.ts +4 -0
  92. package/lib/server/modules/products/index.d.ts +5 -1
  93. package/lib/server/modules/products/index.js +21 -0
  94. package/lib/server/modules/products/types.d.ts +4 -0
  95. package/lib/solution/BaseSales/index.d.ts +42 -2
  96. package/lib/solution/BaseSales/index.js +535 -108
  97. package/lib/solution/BaseSales/types.d.ts +7 -1
  98. package/lib/solution/BaseSales/types.js +2 -1
  99. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  100. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  101. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  102. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -6
  103. package/lib/solution/BookingByStep/index.d.ts +1 -1
  104. package/lib/solution/BookingTicket/index.d.ts +8 -0
  105. package/lib/solution/BookingTicket/index.js +134 -8
  106. package/lib/solution/ShopDiscount/index.js +2 -1
  107. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
- var _excluded = ["unique_identification_number"],
2
- _excluded2 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
3
- _excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
4
- _excluded4 = ["collect_pax", "table_occupancy_duration"];
1
+ var _excluded = ["custom_product_bundle_map_id"],
2
+ _excluded2 = ["unique_identification_number"],
3
+ _excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
4
+ _excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
5
+ _excluded5 = ["collect_pax", "table_occupancy_duration"];
5
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -20,6 +21,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
20
21
  import dayjs from "dayjs";
21
22
  import Decimal from 'decimal.js';
22
23
  import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
24
+ import { createUuidV4 } from "./utils/orderCollectionIdentity";
23
25
  /**
24
26
  * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
25
27
  *
@@ -251,8 +253,8 @@ function getOrderProductDeposit(product, runtimeOrigin) {
251
253
  /**
252
254
  * 仅基于 tempOrder.products 重算整单定金。
253
255
  *
254
- * 对齐 Checkout relation_products 分支:商品定金先按商品规则计算,
255
- * 再扣减商品券/折扣卡抵扣金额;tempOrder.bookings 不参与这里的计算。
256
+ * 商品折扣在进入定金计算前已体现在商品行价格字段中,
257
+ * 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
256
258
  */
257
259
  export function calculateOrderProductsDeposit() {
258
260
  var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -272,30 +274,18 @@ export function calculateOrderProductsDeposit() {
272
274
  product.deposit = deposit;
273
275
  if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
274
276
  total = total.plus(deposit.total);
275
- var _iterator4 = _createForOfIteratorHelper(product.discount_list || []),
277
+ var _iterator4 = _createForOfIteratorHelper(deposit.protocols || []),
276
278
  _step4;
277
279
  try {
278
280
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
279
- var discount = _step4.value;
280
- total = total.minus((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
281
+ var protocol = _step4.value;
282
+ if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
281
283
  }
282
284
  } catch (err) {
283
285
  _iterator4.e(err);
284
286
  } finally {
285
287
  _iterator4.f();
286
288
  }
287
- var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
288
- _step5;
289
- try {
290
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
291
- var protocol = _step5.value;
292
- if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
293
- }
294
- } catch (err) {
295
- _iterator5.e(err);
296
- } finally {
297
- _iterator5.f();
298
- }
299
289
  hasDeposit = true;
300
290
  }
301
291
  } catch (err) {
@@ -446,6 +436,54 @@ export function normalizeOrderProductDiscountList(discountList) {
446
436
  return normalized;
447
437
  });
448
438
  }
439
+ function resolveSubmitBundleMapId(bundle) {
440
+ var _bundle$metadata;
441
+ var metadataMapId = (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata.custom_product_bundle_map_id;
442
+ if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
443
+ return metadataMapId;
444
+ }
445
+ if (bundle._id !== undefined && bundle._id !== null && bundle._id !== '') {
446
+ return bundle._id;
447
+ }
448
+ return undefined;
449
+ }
450
+ function collectSubmitProductDiscountList(product) {
451
+ var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
452
+ var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
453
+ _step5;
454
+ try {
455
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
456
+ var bundle = _step5.value;
457
+ if (!bundle || _typeof(bundle) !== 'object') continue;
458
+ var bundleMapId = resolveSubmitBundleMapId(bundle);
459
+ var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
460
+ var _iterator6 = _createForOfIteratorHelper(bundleDiscountList),
461
+ _step6;
462
+ try {
463
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
464
+ var discount = _step6.value;
465
+ if (!discount || _typeof(discount) !== 'object') continue;
466
+ var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
467
+ var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
468
+ submitDiscountList.push(_objectSpread(_objectSpread({}, discount), discountMapId !== undefined ? {
469
+ metadata: _objectSpread(_objectSpread({}, discountMetadata), {}, {
470
+ custom_product_bundle_map_id: discountMapId
471
+ })
472
+ } : {}));
473
+ }
474
+ } catch (err) {
475
+ _iterator6.e(err);
476
+ } finally {
477
+ _iterator6.f();
478
+ }
479
+ }
480
+ } catch (err) {
481
+ _iterator5.e(err);
482
+ } finally {
483
+ _iterator5.f();
484
+ }
485
+ return normalizeOrderProductDiscountList(submitDiscountList);
486
+ }
449
487
 
450
488
  /**
451
489
  * 手动改价(price_override)时行级 original_price(composite 单价):
@@ -537,11 +575,14 @@ export function createDefaultOrderRulesHooks() {
537
575
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
538
576
  var current = currentByIdentity.get(getBundleIdentity(bundle));
539
577
  if (!current) return bundle;
578
+ var bundleWithDisplayFields = _objectSpread(_objectSpread({}, bundle), isEmptyOrderProductDisplayValue(bundle.cover) && !isEmptyOrderProductDisplayValue(current.cover) ? {
579
+ cover: current.cover
580
+ } : {});
540
581
  var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
541
- if (!isProductPriceBundle) return bundle;
582
+ if (!isProductPriceBundle) return bundleWithDisplayFields;
542
583
  var sourcePrice = (_ref18 = (_ref19 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref19 !== void 0 ? _ref19 : current.original_price) !== null && _ref18 !== void 0 ? _ref18 : current.bundle_selling_price;
543
584
  var originalPrice = (_ref20 = (_ref21 = (_ref22 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref22 !== void 0 ? _ref22 : current.price) !== null && _ref21 !== void 0 ? _ref21 : current.custom_price) !== null && _ref20 !== void 0 ? _ref20 : sourcePrice;
544
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundle), sourcePrice !== undefined ? {
585
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
545
586
  price: sourcePrice
546
587
  } : {}), originalPrice !== undefined ? {
547
588
  original_price: originalPrice
@@ -714,14 +755,7 @@ export var getAllDiscountList = function getAllDiscountList(cartItem) {
714
755
 
715
756
  // ─── 以下为从 ScanOrder/utils.ts 迁入的 Order 专属工具函数 ───
716
757
 
717
- export function createUuidV4() {
718
- var template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
719
- return template.replace(/[xy]/g, function (char) {
720
- var randomValue = Math.floor(Math.random() * 16);
721
- var value = char === 'x' ? randomValue : randomValue & 0x3 | 0x8;
722
- return value.toString(16);
723
- });
724
- }
758
+ export { createUuidV4 };
725
759
  export function isTempOrder(data) {
726
760
  if (!data || _typeof(data) !== 'object') return false;
727
761
  if (!Array.isArray(data.products)) return false;
@@ -783,6 +817,8 @@ function formatSubmitBundleItems(bundle) {
783
817
  var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
784
818
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
785
819
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
820
+ var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
821
+ submitMetadata = _objectWithoutProperties(existedMetadata, _excluded);
786
822
 
787
823
  // bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
788
824
  // markup/原价维持原值;与后端口径一致(price 仍为毛价)。
@@ -794,6 +830,8 @@ function formatSubmitBundleItems(bundle) {
794
830
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
795
831
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
796
832
  var num = toBundleNumber((_rawBundle$num = rawBundle.num) !== null && _rawBundle$num !== void 0 ? _rawBundle$num : rawBundle.quantity, 1);
833
+ var bundleMapId = resolveSubmitBundleMapId(rawBundle);
834
+ var hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
797
835
  return {
798
836
  is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
799
837
  bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
@@ -810,7 +848,10 @@ function formatSubmitBundleItems(bundle) {
810
848
  bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
811
849
  bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
812
850
  bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
813
- metadata: _objectSpread(_objectSpread({}, existedMetadata), {}, {
851
+ cover: rawBundle.cover,
852
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
853
+ custom_product_bundle_map_id: bundleMapId
854
+ } : {}), {}, {
814
855
  surcharge_fee: surchargeFee,
815
856
  relation_surcharge_ids: relationSurchargeIds,
816
857
  product_discount_difference: productDiscountDifference
@@ -839,7 +880,7 @@ function normalizeSubmitProduct(product) {
839
880
  var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
840
881
  var _ref28 = product,
841
882
  _runtimeUid = _ref28.unique_identification_number,
842
- submitProduct = _objectWithoutProperties(_ref28, _excluded);
883
+ submitProduct = _objectWithoutProperties(_ref28, _excluded2);
843
884
  var num = submitProduct.num,
844
885
  _productSurchargeFee = submitProduct.surcharge_fee,
845
886
  _deprecatedDiscountAmount = submitProduct.discount_amount,
@@ -847,7 +888,7 @@ function normalizeSubmitProduct(product) {
847
888
  _deprecatedDiscountway = submitProduct.discountway,
848
889
  _deprecatedProductDiscountReason = submitProduct.product_discount_reason,
849
890
  _deprecatedDiscountPer = submitProduct.discount_per,
850
- productRest = _objectWithoutProperties(submitProduct, _excluded2);
891
+ productRest = _objectWithoutProperties(submitProduct, _excluded3);
851
892
  delete productRest["product_".concat('option', "_item")];
852
893
  var rawMetadata = submitProduct.metadata || {};
853
894
  var bookingUid = rawMetadata.booking_uid;
@@ -869,6 +910,9 @@ function normalizeSubmitProduct(product) {
869
910
  if (rawMetadata.is_rule !== undefined) {
870
911
  cleanMetadata.is_rule = rawMetadata.is_rule;
871
912
  }
913
+ if (rawMetadata.holder_config !== undefined) {
914
+ cleanMetadata.holder_config = rawMetadata.holder_config;
915
+ }
872
916
  var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
873
917
  option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
874
918
  });
@@ -877,7 +921,7 @@ function normalizeSubmitProduct(product) {
877
921
  } : {}), {}, {
878
922
  product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
879
923
  product_sku: productSku,
880
- discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
924
+ discount_list: collectSubmitProductDiscountList(submitProduct),
881
925
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
882
926
  metadata: cleanMetadata,
883
927
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
@@ -899,19 +943,19 @@ export function normalizeBookingSubType(booking) {
899
943
  export function normalizeSubmitBooking(booking) {
900
944
  var rawMetadata = booking.metadata || {};
901
945
  var cleanMetadata = {};
902
- var _iterator6 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
903
- _step6;
946
+ var _iterator7 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
947
+ _step7;
904
948
  try {
905
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
906
- var key = _step6.value;
949
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
950
+ var key = _step7.value;
907
951
  if (rawMetadata[key] !== undefined) {
908
952
  cleanMetadata[key] = rawMetadata[key];
909
953
  }
910
954
  }
911
955
  } catch (err) {
912
- _iterator6.e(err);
956
+ _iterator7.e(err);
913
957
  } finally {
914
- _iterator6.f();
958
+ _iterator7.f();
915
959
  }
916
960
  if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
917
961
  var bookingRecord = booking;
@@ -1035,7 +1079,7 @@ export function buildSubmitPayload(params) {
1035
1079
  _totalRefundAmount = _ref29.total_refund_amount,
1036
1080
  _createDate = _ref29.create_date,
1037
1081
  _holderId = _ref29.holder_id,
1038
- tempOrderRest = _objectWithoutProperties(_ref29, _excluded3);
1082
+ tempOrderRest = _objectWithoutProperties(_ref29, _excluded4);
1039
1083
  var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
1040
1084
  if (!submitType) {
1041
1085
  var _tempOrder$bookings;
@@ -1086,7 +1130,7 @@ export function buildSubmitPayload(params) {
1086
1130
  var _ref31 = tempOrder.metadata || {},
1087
1131
  _collectPax = _ref31.collect_pax,
1088
1132
  _tableOccupancyDuration = _ref31.table_occupancy_duration,
1089
- rest = _objectWithoutProperties(_ref31, _excluded4);
1133
+ rest = _objectWithoutProperties(_ref31, _excluded5);
1090
1134
  return _objectSpread({}, rest);
1091
1135
  }(),
1092
1136
  products: (tempOrder.products || []).map(function (product) {
@@ -1224,25 +1268,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1224
1268
  target[key] = null;
1225
1269
  changed = true;
1226
1270
  };
1227
- var _iterator7 = _createForOfIteratorHelper(tempOrder.products || []),
1228
- _step7;
1271
+ var _iterator8 = _createForOfIteratorHelper(tempOrder.products || []),
1272
+ _step8;
1229
1273
  try {
1230
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1231
- var product = _step7.value;
1274
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1275
+ var product = _step8.value;
1232
1276
  if (product.metadata && _typeof(product.metadata) === 'object') {
1233
1277
  resetHolderField(product.metadata);
1234
1278
  }
1235
1279
  }
1236
1280
  } catch (err) {
1237
- _iterator7.e(err);
1281
+ _iterator8.e(err);
1238
1282
  } finally {
1239
- _iterator7.f();
1283
+ _iterator8.f();
1240
1284
  }
1241
- var _iterator8 = _createForOfIteratorHelper(tempOrder.bookings || []),
1242
- _step8;
1285
+ var _iterator9 = _createForOfIteratorHelper(tempOrder.bookings || []),
1286
+ _step9;
1243
1287
  try {
1244
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1245
- var booking = _step8.value;
1288
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1289
+ var booking = _step9.value;
1246
1290
  var bookingRecord = booking;
1247
1291
  if (booking.metadata && _typeof(booking.metadata) === 'object') {
1248
1292
  resetHolderField(booking.metadata);
@@ -1253,9 +1297,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1253
1297
  }
1254
1298
  }
1255
1299
  } catch (err) {
1256
- _iterator8.e(err);
1300
+ _iterator9.e(err);
1257
1301
  } finally {
1258
- _iterator8.f();
1302
+ _iterator9.f();
1259
1303
  }
1260
1304
  var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
1261
1305
  if (productsByUid && _typeof(productsByUid) === 'object') {
@@ -1287,6 +1331,42 @@ export function getOrderProductLineUid(product) {
1287
1331
  if (uid === undefined || uid === null || uid === '') return null;
1288
1332
  return String(uid);
1289
1333
  }
1334
+ export function getRuntimeProductOrigin(tempOrder, product) {
1335
+ var _tempOrder$_extend2, _tempOrder$_extend3;
1336
+ var uid = getOrderProductLineUid(product);
1337
+ if (uid && tempOrder !== null && tempOrder !== void 0 && (_tempOrder$_extend2 = tempOrder._extend) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2.productsByUid) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2[uid]) !== null && _tempOrder$_extend2 !== void 0 && _tempOrder$_extend2.origin) {
1338
+ return tempOrder._extend.productsByUid[uid].origin;
1339
+ }
1340
+ var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
1341
+ var _ref32, _item$product_id, _ref33, _product$product_id;
1342
+ return item === product || getOrderProductLineUid(item) === uid || String((_ref32 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref32 !== void 0 ? _ref32 : '') === String((_ref33 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref33 !== void 0 ? _ref33 : '');
1343
+ });
1344
+ var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
1345
+ return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[matchedUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin) || null : null;
1346
+ }
1347
+ export function isHolderConfigRequired(holderConfig) {
1348
+ if (!holderConfig || _typeof(holderConfig) !== 'object') return false;
1349
+ if (holderConfig.status === 'disable') return false;
1350
+ return Number(holderConfig.required) === 1;
1351
+ }
1352
+ export function productRequiresFormSubject(tempOrder, product) {
1353
+ var _tempOrder$products, _orderProduct$metadat;
1354
+ var _orderProduct = tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.find(function (item) {
1355
+ return item.metadata.unique_identification_number === product._id || item.product_id === product.id;
1356
+ });
1357
+ var runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
1358
+ return isHolderConfigRequired(_orderProduct === null || _orderProduct === void 0 || (_orderProduct$metadat = _orderProduct.metadata) === null || _orderProduct$metadat === void 0 ? void 0 : _orderProduct$metadat.holder_config) || isHolderConfigRequired(runtimeOrigin === null || runtimeOrigin === void 0 ? void 0 : runtimeOrigin.holder_config) || isHolderConfigRequired(product === null || product === void 0 ? void 0 : product.holder_config);
1359
+ }
1360
+ export function resolveIsFormSubject(tempOrder, product) {
1361
+ var _tempOrder$holder;
1362
+ debugger;
1363
+ // 旧版预约维度的 holder 类型仍然生效;新版则从当前商品 holder_config 判断。
1364
+ if ((tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.type) === 'form') return true;
1365
+ if (product) return productRequiresFormSubject(tempOrder, product);
1366
+ return ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).some(function (item) {
1367
+ return productRequiresFormSubject(tempOrder, item);
1368
+ });
1369
+ }
1290
1370
 
1291
1371
  /**
1292
1372
  * 判断展示字段是否为空(含 i18n 对象全空)。
@@ -1319,7 +1399,7 @@ export function isEmptyOrderProductDisplayValue(value) {
1319
1399
  */
1320
1400
  export function mergeOrderProductDisplayFields(previous, next) {
1321
1401
  var merged = _objectSpread({}, next);
1322
- var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'variant_title', 'product_sku', 'payment_price'];
1402
+ var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'product_cover', 'variant_title', 'product_sku', 'payment_price'];
1323
1403
  displayFields.forEach(function (field) {
1324
1404
  if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
1325
1405
  merged[field] = previous[field];
@@ -1,8 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
3
+ import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
- import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
6
5
  import { WindowPlugin } from '../../plugins';
7
6
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
8
7
  protected defaultName: string;
@@ -24,7 +23,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
24
23
  holders: {
25
24
  form_record_id: number;
26
25
  }[];
27
- isFormSubject: boolean;
26
+ isFormSubject: RulesFormSubject;
28
27
  }): {
29
28
  isAvailable: boolean;
30
29
  discountList: Discount[];
@@ -43,14 +42,9 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
43
42
  holders: {
44
43
  form_record_id: number;
45
44
  }[];
46
- isFormSubject: boolean;
45
+ isFormSubject: RulesFormSubject;
47
46
  orderTotalAmount: number;
48
- }, options?: {
49
- isSelected?: boolean;
50
- discountId?: number;
51
- selectedList?: SetDiscountSelectedParams[];
52
- scan?: boolean;
53
- }): DiscountResult;
47
+ }, options?: RulesCalcDiscountOptions): DiscountResult;
54
48
  /**
55
49
  * 检查优惠是否符合 PackageSubItemUsageRules 配置
56
50
  * @param discount 优惠券
@@ -118,7 +118,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
118
118
  // 非表单类型 holder 视为匹配
119
119
  if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
120
120
  // 主预约holder, 目前(20251124)默认只考虑单个holder的情况
121
- var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
121
+ // 旧版 holders[0].form_record_id 新版 holders[0]
122
+ var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : undefined;
122
123
  var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
123
124
  // 商品不需要选holder,则不对比holder,直接返回true,
124
125
  if (!product.isNeedHolder) return true;
@@ -323,6 +324,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
323
324
  holders = _ref2.holders,
324
325
  isFormSubject = _ref2.isFormSubject,
325
326
  orderTotalAmount = _ref2.orderTotalAmount;
327
+ var resolveIsFormSubject = function resolveIsFormSubject(product) {
328
+ return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
329
+ };
330
+
326
331
  // 识别出来是不是在编辑的界面里又新增了商品
327
332
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
328
333
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -330,6 +335,32 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
330
335
  }) && productList.find(function (n) {
331
336
  return !n.booking_id;
332
337
  });
338
+ var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
339
+ return uid !== undefined && uid !== null && uid !== '';
340
+ }).map(String));
341
+ var getOriginProductUid = function getOriginProductUid(originProduct) {
342
+ var _originProduct$metada, _originProduct$metada2;
343
+ var uid = (_originProduct$metada = originProduct === null || originProduct === void 0 || (_originProduct$metada2 = originProduct.metadata) === null || _originProduct$metada2 === void 0 ? void 0 : _originProduct$metada2.unique_identification_number) !== null && _originProduct$metada !== void 0 ? _originProduct$metada : originProduct === null || originProduct === void 0 ? void 0 : originProduct.unique_identification_number;
344
+ if (uid === undefined || uid === null || uid === '') return undefined;
345
+ return String(uid);
346
+ };
347
+ var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
348
+ if (!selectedDiscount) return false;
349
+ var uid = getOriginProductUid(originProduct);
350
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
351
+ var discountType = selectedDiscount.tag || selectedDiscount.type;
352
+ return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
353
+ };
354
+ var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
355
+ var _discount2;
356
+ if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
357
+ var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
358
+ if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
359
+ return undefined;
360
+ }
361
+ var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
362
+ return Number.isFinite(percent) ? percent : undefined;
363
+ };
333
364
  var editModeDiscount = [];
334
365
  var addModeDiscount = [];
335
366
  discountList.forEach(function (discount) {
@@ -358,11 +389,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
358
389
  }
359
390
  });
360
391
  }
361
-
362
- // 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
363
- var filteredDiscountList = addModeDiscount.filter(function (discount) {
364
- return !discount.isManualSelect;
365
- });
366
392
  var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
367
393
  if (!hasDiscountInput) {
368
394
  return {
@@ -370,6 +396,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
370
396
  productList: productList
371
397
  };
372
398
  }
399
+ var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
400
+ var discountType = discount.tag || discount.type;
401
+ return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
402
+ };
403
+
404
+ // 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
405
+ // Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
406
+ var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
407
+ return !discount.isManualSelect;
408
+ })), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
373
409
 
374
410
  // 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
375
411
  var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
@@ -885,7 +921,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
885
921
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
886
922
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
887
923
  var isHolderMatch = _this3.checkHolderMatch(discount, {
888
- isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
924
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
889
925
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
890
926
  }, holders);
891
927
  var timeLimit = true;
@@ -1051,7 +1087,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1051
1087
  var _product$discount_lis3, _product$discount_lis4;
1052
1088
  // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
1053
1089
  var discountType = discount.tag || discount.type;
1054
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
1090
+ var currentOriginUid = getOriginProductUid(originProduct);
1091
+ var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
1092
+ if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
1093
+ var uid = currentOriginUid;
1094
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
1095
+ if (!discount.isSelected) return false;
1096
+ }
1097
+ if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
1055
1098
  var _discount$config2;
1056
1099
  // 如果策略检查后没有config,说明不可用
1057
1100
  if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
@@ -1088,7 +1131,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1088
1131
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
1089
1132
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
1090
1133
  var isHolderMatch = _this3.checkHolderMatch(discount, {
1091
- isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1134
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1092
1135
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
1093
1136
  }, holders);
1094
1137
  // 如果 holder 不匹配,则不适用
@@ -1279,7 +1322,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1279
1322
  }
1280
1323
  return;
1281
1324
  }
1282
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct) {
1325
+ var shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
1326
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
1283
1327
  return;
1284
1328
  }
1285
1329
 
@@ -1320,7 +1364,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1320
1364
  }));
1321
1365
  }
1322
1366
  for (var i = 0; i < splitCount; i++) {
1323
- var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1367
+ var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
1324
1368
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1325
1369
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1326
1370
  // 标记优惠券为已使用
@@ -1358,11 +1402,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1358
1402
  var productDiscountDifference = void 0;
1359
1403
  var discountedOptions = product.options;
1360
1404
  var optionDiscountAmount = 0;
1405
+ var reapplyDiscountPercent = void 0;
1361
1406
  if (isOrderLevel && productAllocation) {
1362
1407
  // order_level:使用预计算的分摊金额
1363
1408
  amount = productAllocation.discountAmount;
1364
1409
  productDiscountDifference = productAllocation.difference;
1365
1410
  mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1411
+ } else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
1412
+ // Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
1413
+ var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
1414
+ reapplyDiscountPercent = new Decimal(percent).toFixed(2);
1415
+ mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
1416
+ amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
1366
1417
  } else {
1367
1418
  // item_level 或其他类型:使用原有逻辑
1368
1419
  mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
@@ -1395,7 +1446,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1395
1446
  title: _selectedDiscount.format_title,
1396
1447
  original_amount: product.price,
1397
1448
  product_id: originProduct.id || originProduct.product_id,
1398
- percent: _selectedDiscount.par_value,
1449
+ percent: (_reapplyDiscountPerce = reapplyDiscountPercent) !== null && _reapplyDiscountPerce !== void 0 ? _reapplyDiscountPerce : _selectedDiscount.par_value,
1399
1450
  discount_product_id: _selectedDiscount.product_id
1400
1451
  },
1401
1452
  // 前端使用的num数量,为了计算优惠金额
@@ -1,4 +1,5 @@
1
1
  import { Discount } from '../Discount/types';
2
+ import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
2
3
  export declare enum UnavailableReason {
3
4
  TimeLimit = "time_limit",
4
5
  ProductNotApplicable = "product_not_applicable",
@@ -22,6 +23,15 @@ export interface DiscountResult {
22
23
  productList: any[];
23
24
  discountList: any[];
24
25
  }
26
+ export type RulesFormSubject = boolean | ((product: any) => boolean);
27
+ export interface RulesCalcDiscountOptions {
28
+ isSelected?: boolean;
29
+ discountId?: number;
30
+ selectedList?: SetDiscountSelectedParams[];
31
+ scan?: boolean;
32
+ /** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
33
+ reapplyBookingDiscountProductUids?: string[];
34
+ }
25
35
  export interface RulesModuleAPI {
26
36
  setRulesList: (rulesList: Rules[]) => Promise<void>;
27
37
  clear: () => Promise<void>;
@@ -31,9 +41,9 @@ export interface RulesModuleAPI {
31
41
  holders: {
32
42
  form_record_id: number;
33
43
  }[];
34
- isFormSubject: boolean;
44
+ isFormSubject: RulesFormSubject;
35
45
  orderTotalAmount: number;
36
- }) => DiscountResult;
46
+ }, options?: RulesCalcDiscountOptions) => DiscountResult;
37
47
  }
38
48
  type ProductDetail = {
39
49
  isClient?: boolean;
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
9
9
  private store;
10
10
  private request;
11
11
  private surchargeListModuleName;
12
+ private otherParams;
13
+ private surchargeListChannel;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  /**
15
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
17
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
16
18
  *
17
19
  * @example
18
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
20
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
19
21
  */
20
22
  updateOtherParams(params: Record<string, any>): Promise<void>;
21
- getSurchargeList(): Promise<void>;
23
+ private resolveChannel;
24
+ getSurchargeList(channel?: string): Promise<void>;
22
25
  private getAppData;
23
26
  private getTaxConfig;
24
27
  getSummary(params: {
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
26
29
  isPriceIncludeTax?: number;
27
30
  taxRate?: number;
28
31
  shopDiscount?: string | number;
32
+ channel?: string;
29
33
  }): Promise<{
30
34
  tax_title: string;
31
35
  tax_rate: number | undefined;