@pisell/pisellos 2.3.164 → 2.3.166

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 (77) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +89 -104
  2. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  3. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
  4. package/dist/modules/Holder/utils.d.ts +2 -0
  5. package/dist/modules/Holder/utils.js +32 -2
  6. package/dist/modules/OpenData/contactInfo.d.ts +20 -0
  7. package/dist/modules/OpenData/contactInfo.js +70 -0
  8. package/dist/modules/OpenData/index.d.ts +1 -0
  9. package/dist/modules/OpenData/index.js +1 -0
  10. package/dist/modules/OpenData/types.d.ts +9 -0
  11. package/dist/modules/Order/holderRelations.d.ts +14 -0
  12. package/dist/modules/Order/holderRelations.js +154 -0
  13. package/dist/modules/Order/index.d.ts +1 -1
  14. package/dist/modules/Order/index.js +89 -44
  15. package/dist/modules/Order/types.d.ts +19 -1
  16. package/dist/modules/Order/types.js +2 -0
  17. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  18. package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
  19. package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
  20. package/dist/modules/Order/utils.d.ts +1 -1
  21. package/dist/modules/Order/utils.js +35 -9
  22. package/dist/modules/Rules/index.js +62 -61
  23. package/dist/server/index.js +18 -12
  24. package/dist/server/modules/order/index.d.ts +4 -0
  25. package/dist/server/modules/order/index.js +255 -190
  26. package/dist/server/modules/order/types.d.ts +3 -0
  27. package/dist/server/modules/products/index.js +3 -2
  28. package/dist/shared/receipt/small-ticket.js +17 -6
  29. package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
  30. package/dist/solution/BaseSales/index.d.ts +4 -0
  31. package/dist/solution/BaseSales/index.js +1116 -935
  32. package/dist/solution/BaseSales/types.d.ts +2 -1
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  34. package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
  35. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
  36. package/dist/solution/BookingTicket/index.d.ts +15 -1
  37. package/dist/solution/BookingTicket/index.js +784 -501
  38. package/dist/solution/UnifiedBookingSales/index.js +1 -1
  39. package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
  40. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  41. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
  42. package/lib/modules/Holder/utils.d.ts +2 -0
  43. package/lib/modules/Holder/utils.js +27 -1
  44. package/lib/modules/OpenData/contactInfo.d.ts +20 -0
  45. package/lib/modules/OpenData/contactInfo.js +56 -0
  46. package/lib/modules/OpenData/index.d.ts +1 -0
  47. package/lib/modules/OpenData/index.js +12 -0
  48. package/lib/modules/OpenData/types.d.ts +9 -0
  49. package/lib/modules/Order/holderRelations.d.ts +14 -0
  50. package/lib/modules/Order/holderRelations.js +98 -0
  51. package/lib/modules/Order/index.d.ts +1 -1
  52. package/lib/modules/Order/index.js +44 -12
  53. package/lib/modules/Order/types.d.ts +19 -1
  54. package/lib/modules/Order/types.js +1 -0
  55. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  56. package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
  57. package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
  58. package/lib/modules/Order/utils.d.ts +1 -1
  59. package/lib/modules/Order/utils.js +27 -6
  60. package/lib/modules/Rules/index.js +2 -1
  61. package/lib/server/index.js +6 -0
  62. package/lib/server/modules/order/index.d.ts +4 -0
  63. package/lib/server/modules/order/index.js +46 -4
  64. package/lib/server/modules/order/types.d.ts +3 -0
  65. package/lib/server/modules/products/index.js +2 -1
  66. package/lib/shared/receipt/small-ticket.js +15 -7
  67. package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
  68. package/lib/solution/BaseSales/index.d.ts +4 -0
  69. package/lib/solution/BaseSales/index.js +68 -2
  70. package/lib/solution/BaseSales/types.d.ts +2 -1
  71. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  72. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
  74. package/lib/solution/BookingTicket/index.d.ts +15 -1
  75. package/lib/solution/BookingTicket/index.js +132 -3
  76. package/lib/solution/UnifiedBookingSales/index.js +1 -1
  77. package/package.json +1 -1
@@ -269,6 +269,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
269
269
  var productResults = this.evaluateProducts(input);
270
270
 
271
271
  // 2. 收集所有适用的促销(去重)
272
+ // strategyId is metadata and is not guaranteed to be unique. Use the actual
273
+ // configuration as the key so one strategy cannot overwrite another strategy's
274
+ // label/action when their IDs happen to be the same.
272
275
  var promotionMap = new Map();
273
276
  var _iterator3 = _createForOfIteratorHelper(productResults),
274
277
  _step3;
@@ -280,7 +283,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
280
283
  try {
281
284
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
282
285
  var promo = _step4.value;
283
- var existing = promotionMap.get(promo.strategyId);
286
+ var existing = promotionMap.get(promo.strategyConfig);
284
287
  var product = productResult.product;
285
288
 
286
289
  // 计算促销数量:如果是 bundle 子商品匹配,数量 = 主商品数量 × 子商品数量
@@ -303,7 +306,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
303
306
  // 新促销
304
307
  var productMatchedBundleIndexMap = new Map();
305
308
  productMatchedBundleIndexMap.set(product.id, promo.matchedBundleIndex);
306
- promotionMap.set(promo.strategyId, _objectSpread(_objectSpread({}, promo), {}, {
309
+ promotionMap.set(promo.strategyConfig, _objectSpread(_objectSpread({}, promo), {}, {
307
310
  applicableProducts: [product],
308
311
  totalQuantity: promoQuantity,
309
312
  totalAmount: product.price * product.quantity,
@@ -367,7 +370,7 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
367
370
  var cartResult = this.evaluateCart(input);
368
371
 
369
372
  // 2. 按 action priority 排序促销组(从 strategyConfig 获取 priority)
370
- var sortedGroups = this.sortPromotionGroupsByPriority(cartResult.promotionGroups, cartResult.applicablePromotions);
373
+ var sortedGroups = this.sortPromotionGroupsByPriority(cartResult.promotionGroups);
371
374
 
372
375
  // 3. 追踪已处理的商品(避免重复处理)
373
376
  // key: `${product_id}_${product_variant_id}`
@@ -664,30 +667,12 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
664
667
  */
665
668
  }, {
666
669
  key: "sortPromotionGroupsByPriority",
667
- value: function sortPromotionGroupsByPriority(groups, promotions) {
668
- // 创建策略ID到优先级的映射
669
- var priorityMap = new Map();
670
- var _iterator9 = _createForOfIteratorHelper(promotions),
671
- _step9;
672
- try {
673
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
674
- var _promo$strategyConfig2, _actions$0$priority, _actions$;
675
- var promo = _step9.value;
676
- var actions = ((_promo$strategyConfig2 = promo.strategyConfig) === null || _promo$strategyConfig2 === void 0 ? void 0 : _promo$strategyConfig2.actions) || [];
677
- var priority = (_actions$0$priority = (_actions$ = actions[0]) === null || _actions$ === void 0 ? void 0 : _actions$.priority) !== null && _actions$0$priority !== void 0 ? _actions$0$priority : 999;
678
- priorityMap.set(promo.strategyId, priority);
679
- }
680
-
681
- // 按优先级排序(数值越小优先级越高)
682
- } catch (err) {
683
- _iterator9.e(err);
684
- } finally {
685
- _iterator9.f();
686
- }
670
+ value: function sortPromotionGroupsByPriority(groups) {
671
+ // 按优先级排序(数值越小优先级越高)
687
672
  return _toConsumableArray(groups).sort(function (a, b) {
688
- var _priorityMap$get, _priorityMap$get2;
689
- var priorityA = (_priorityMap$get = priorityMap.get(a.strategyId)) !== null && _priorityMap$get !== void 0 ? _priorityMap$get : 999;
690
- var priorityB = (_priorityMap$get2 = priorityMap.get(b.strategyId)) !== null && _priorityMap$get2 !== void 0 ? _priorityMap$get2 : 999;
673
+ var _a$strategyConfig$act, _a$strategyConfig, _b$strategyConfig$act, _b$strategyConfig;
674
+ var priorityA = (_a$strategyConfig$act = (_a$strategyConfig = a.strategyConfig) === null || _a$strategyConfig === void 0 || (_a$strategyConfig = _a$strategyConfig.actions) === null || _a$strategyConfig === void 0 || (_a$strategyConfig = _a$strategyConfig[0]) === null || _a$strategyConfig === void 0 ? void 0 : _a$strategyConfig.priority) !== null && _a$strategyConfig$act !== void 0 ? _a$strategyConfig$act : 999;
675
+ var priorityB = (_b$strategyConfig$act = (_b$strategyConfig = b.strategyConfig) === null || _b$strategyConfig === void 0 || (_b$strategyConfig = _b$strategyConfig.actions) === null || _b$strategyConfig === void 0 || (_b$strategyConfig = _b$strategyConfig[0]) === null || _b$strategyConfig === void 0 ? void 0 : _b$strategyConfig.priority) !== null && _b$strategyConfig$act !== void 0 ? _b$strategyConfig$act : 999;
691
676
  return priorityA - priorityB;
692
677
  });
693
678
  }
@@ -720,11 +705,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
720
705
  // 1. 展开所有商品为单件列表(排除已处理的数量)
721
706
  // 每个单件记录来自哪个原商品(通过 product.id)
722
707
  var unitProducts = [];
723
- var _iterator10 = _createForOfIteratorHelper(groupProducts),
724
- _step10;
708
+ var _iterator9 = _createForOfIteratorHelper(groupProducts),
709
+ _step9;
725
710
  try {
726
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
727
- var product = _step10.value;
711
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
712
+ var product = _step9.value;
728
713
  var key = this.getProductKey(product);
729
714
  var processedQty = processedQuantityMap.get(key) || 0;
730
715
  var availableQty = product.quantity - processedQty;
@@ -741,9 +726,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
741
726
  }
742
727
  }
743
728
  } catch (err) {
744
- _iterator10.e(err);
729
+ _iterator9.e(err);
745
730
  } finally {
746
- _iterator10.f();
731
+ _iterator9.f();
747
732
  }
748
733
  if (unitProducts.length === 0) {
749
734
  return {
@@ -775,25 +760,25 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
775
760
 
776
761
  // 5. 按原商品 id 统计参与促销和不参与的数量
777
762
  var promotionQtyByProductId = new Map();
778
- var _iterator11 = _createForOfIteratorHelper(inPromotionUnits),
779
- _step11;
763
+ var _iterator10 = _createForOfIteratorHelper(inPromotionUnits),
764
+ _step10;
780
765
  try {
781
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
782
- var _unit = _step11.value;
766
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
767
+ var _unit = _step10.value;
783
768
  var id = _unit.productId;
784
769
  promotionQtyByProductId.set(id, (promotionQtyByProductId.get(id) || 0) + 1);
785
770
  }
786
771
  } catch (err) {
787
- _iterator11.e(err);
772
+ _iterator10.e(err);
788
773
  } finally {
789
- _iterator11.f();
774
+ _iterator10.f();
790
775
  }
791
776
  var remainingQtyByProductId = new Map();
792
- var _iterator12 = _createForOfIteratorHelper(notInPromotionUnits),
793
- _step12;
777
+ var _iterator11 = _createForOfIteratorHelper(notInPromotionUnits),
778
+ _step11;
794
779
  try {
795
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
796
- var _unit2 = _step12.value;
780
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
781
+ var _unit2 = _step11.value;
797
782
  var _id = _unit2.productId;
798
783
  remainingQtyByProductId.set(_id, (remainingQtyByProductId.get(_id) || 0) + 1);
799
784
  }
@@ -802,9 +787,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
802
787
  // 按组内原价比例均摊
803
788
  // 记录每个原商品的均摊价格累加(用于后续聚合)
804
789
  } catch (err) {
805
- _iterator12.e(err);
790
+ _iterator11.e(err);
806
791
  } finally {
807
- _iterator12.f();
792
+ _iterator11.f();
808
793
  }
809
794
  var allocatedPricesByProductId = new Map();
810
795
  for (var g = 0; g < groupCount; g++) {
@@ -836,11 +821,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
836
821
  }
837
822
 
838
823
  // 7. 为每个原商品生成结果
839
- var _iterator13 = _createForOfIteratorHelper(groupProducts),
840
- _step13;
824
+ var _iterator12 = _createForOfIteratorHelper(groupProducts),
825
+ _step12;
841
826
  try {
842
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
843
- var _product = _step13.value;
827
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
828
+ var _product = _step12.value;
844
829
  var _key = this.getProductKey(_product);
845
830
  var _processedQty = processedQuantityMap.get(_key) || 0;
846
831
  var _availableQty = _product.quantity - _processedQty;
@@ -928,9 +913,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
928
913
 
929
914
  // 8. 尾差调整:确保促销商品的 finalPrice × quantity 之和精确等于 groupPrice × groupCount
930
915
  } catch (err) {
931
- _iterator13.e(err);
916
+ _iterator12.e(err);
932
917
  } finally {
933
- _iterator13.f();
918
+ _iterator12.f();
934
919
  }
935
920
  if (groupCount > 0) {
936
921
  var expectedPromoTotal = new Decimal(groupPrice).mul(groupCount);
@@ -938,17 +923,17 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
938
923
  return p.inPromotion;
939
924
  });
940
925
  var actualPromoTotal = new Decimal(0);
941
- var _iterator14 = _createForOfIteratorHelper(promoItems),
942
- _step14;
926
+ var _iterator13 = _createForOfIteratorHelper(promoItems),
927
+ _step13;
943
928
  try {
944
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
945
- var _p = _step14.value;
929
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
930
+ var _p = _step13.value;
946
931
  actualPromoTotal = actualPromoTotal.plus(new Decimal(_p.finalPrice).mul(_p.quantity));
947
932
  }
948
933
  } catch (err) {
949
- _iterator14.e(err);
934
+ _iterator13.e(err);
950
935
  } finally {
951
- _iterator14.f();
936
+ _iterator13.f();
952
937
  }
953
938
  var roundingDiff = actualPromoTotal.minus(expectedPromoTotal);
954
939
  if (!roundingDiff.eq(0)) {
@@ -979,17 +964,17 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
979
964
 
980
965
  // 重新计算 finalAmount
981
966
  finalAmount = new Decimal(0);
982
- var _iterator15 = _createForOfIteratorHelper(result),
983
- _step15;
967
+ var _iterator14 = _createForOfIteratorHelper(result),
968
+ _step14;
984
969
  try {
985
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
986
- var p = _step15.value;
970
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
971
+ var p = _step14.value;
987
972
  finalAmount = finalAmount.plus(new Decimal(p.finalPrice).mul(p.quantity));
988
973
  }
989
974
  } catch (err) {
990
- _iterator15.e(err);
975
+ _iterator14.e(err);
991
976
  } finally {
992
- _iterator15.f();
977
+ _iterator14.f();
993
978
  }
994
979
  }
995
980
  }
@@ -1027,11 +1012,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1027
1012
  // 对于 bundle 子商品匹配,促销数量 = 主商品数量 × bundle子商品数量
1028
1013
  var totalPromoQty = 0;
1029
1014
  var productInfoMap = new Map();
1030
- var _iterator16 = _createForOfIteratorHelper(groupProducts),
1031
- _step16;
1015
+ var _iterator15 = _createForOfIteratorHelper(groupProducts),
1016
+ _step15;
1032
1017
  try {
1033
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1034
- var product = _step16.value;
1018
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1019
+ var product = _step15.value;
1035
1020
  var key = this.getProductKey(product);
1036
1021
  var processedQty = processedQuantityMap.get(key) || 0;
1037
1022
  var availableQty = product.quantity - processedQty;
@@ -1057,18 +1042,18 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1057
1042
 
1058
1043
  // 2. 判断是否满足促销条件
1059
1044
  } catch (err) {
1060
- _iterator16.e(err);
1045
+ _iterator15.e(err);
1061
1046
  } finally {
1062
- _iterator16.f();
1047
+ _iterator15.f();
1063
1048
  }
1064
1049
  var isFulfilled = totalPromoQty >= buyQuantity;
1065
1050
 
1066
1051
  // 3. 生成商品结果(第二次遍历)
1067
- var _iterator17 = _createForOfIteratorHelper(groupProducts),
1068
- _step17;
1052
+ var _iterator16 = _createForOfIteratorHelper(groupProducts),
1053
+ _step16;
1069
1054
  try {
1070
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
1071
- var _product2 = _step17.value;
1055
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1056
+ var _product2 = _step16.value;
1072
1057
  var _key2 = this.getProductKey(_product2);
1073
1058
  var info = productInfoMap.get(_key2);
1074
1059
  if (!info || info.availableQty <= 0) continue;
@@ -1096,9 +1081,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1096
1081
 
1097
1082
  // 4. 计算赠品数量(使用促销数量)
1098
1083
  } catch (err) {
1099
- _iterator17.e(err);
1084
+ _iterator16.e(err);
1100
1085
  } finally {
1101
- _iterator17.f();
1086
+ _iterator16.f();
1102
1087
  }
1103
1088
  var giftCount = 0;
1104
1089
  if (isFulfilled) {
@@ -1173,11 +1158,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1173
1158
  return b.originalPrice.minus(a.originalPrice).toNumber();
1174
1159
  }).slice(0, rewardLimit);
1175
1160
  var selectedByProductId = new Map();
1176
- var _iterator18 = _createForOfIteratorHelper(selectedUnits),
1177
- _step18;
1161
+ var _iterator17 = _createForOfIteratorHelper(selectedUnits),
1162
+ _step17;
1178
1163
  try {
1179
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1180
- var unit = _step18.value;
1164
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
1165
+ var unit = _step17.value;
1181
1166
  var existing = selectedByProductId.get(unit.product.id);
1182
1167
  if (existing) {
1183
1168
  existing.quantity += 1;
@@ -1190,18 +1175,18 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1190
1175
  }
1191
1176
  }
1192
1177
  } catch (err) {
1193
- _iterator18.e(err);
1178
+ _iterator17.e(err);
1194
1179
  } finally {
1195
- _iterator18.f();
1180
+ _iterator17.f();
1196
1181
  }
1197
1182
  var result = [];
1198
1183
  var originalAmount = new Decimal(0);
1199
1184
  var finalAmount = new Decimal(0);
1200
- var _iterator19 = _createForOfIteratorHelper(targetProducts),
1201
- _step19;
1185
+ var _iterator18 = _createForOfIteratorHelper(targetProducts),
1186
+ _step18;
1202
1187
  try {
1203
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
1204
- var product = _step19.value;
1188
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1189
+ var product = _step18.value;
1205
1190
  var key = this.getProductKey(product);
1206
1191
  var processedQty = processedQuantityMap.get(key) || 0;
1207
1192
  var availableQty = product.quantity - processedQty;
@@ -1240,9 +1225,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1240
1225
  processedQuantityMap.set(key, processedQty + availableQty);
1241
1226
  }
1242
1227
  } catch (err) {
1243
- _iterator19.e(err);
1228
+ _iterator18.e(err);
1244
1229
  } finally {
1245
- _iterator19.f();
1230
+ _iterator18.f();
1246
1231
  }
1247
1232
  return {
1248
1233
  products: result,
@@ -1260,11 +1245,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1260
1245
  key: "getAvailablePromotionQuantity",
1261
1246
  value: function getAvailablePromotionQuantity(products, processedQuantityMap, matchedBundleIndexMap) {
1262
1247
  var total = 0;
1263
- var _iterator20 = _createForOfIteratorHelper(products),
1264
- _step20;
1248
+ var _iterator19 = _createForOfIteratorHelper(products),
1249
+ _step19;
1265
1250
  try {
1266
- for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
1267
- var product = _step20.value;
1251
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
1252
+ var product = _step19.value;
1268
1253
  var key = this.getProductKey(product);
1269
1254
  var processedQty = processedQuantityMap.get(key) || 0;
1270
1255
  var availableQty = product.quantity - processedQty;
@@ -1278,9 +1263,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1278
1263
  }
1279
1264
  }
1280
1265
  } catch (err) {
1281
- _iterator20.e(err);
1266
+ _iterator19.e(err);
1282
1267
  } finally {
1283
- _iterator20.f();
1268
+ _iterator19.f();
1284
1269
  }
1285
1270
  return total;
1286
1271
  }
@@ -1288,11 +1273,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1288
1273
  key: "buildItemRewardTargetUnits",
1289
1274
  value: function buildItemRewardTargetUnits(products, processedQuantityMap, detail) {
1290
1275
  var units = [];
1291
- var _iterator21 = _createForOfIteratorHelper(products),
1292
- _step21;
1276
+ var _iterator20 = _createForOfIteratorHelper(products),
1277
+ _step20;
1293
1278
  try {
1294
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
1295
- var product = _step21.value;
1279
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
1280
+ var product = _step20.value;
1296
1281
  var key = this.getProductKey(product);
1297
1282
  var processedQty = processedQuantityMap.get(key) || 0;
1298
1283
  var availableQty = product.quantity - processedQty;
@@ -1311,9 +1296,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1311
1296
  }
1312
1297
  }
1313
1298
  } catch (err) {
1314
- _iterator21.e(err);
1299
+ _iterator20.e(err);
1315
1300
  } finally {
1316
- _iterator21.f();
1301
+ _iterator20.f();
1317
1302
  }
1318
1303
  return units;
1319
1304
  }
@@ -1369,11 +1354,11 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1369
1354
  key: "getRemainingProducts",
1370
1355
  value: function getRemainingProducts(allProducts, processedQuantityMap) {
1371
1356
  var result = [];
1372
- var _iterator22 = _createForOfIteratorHelper(allProducts),
1373
- _step22;
1357
+ var _iterator21 = _createForOfIteratorHelper(allProducts),
1358
+ _step21;
1374
1359
  try {
1375
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
1376
- var product = _step22.value;
1360
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
1361
+ var product = _step21.value;
1377
1362
  var key = this.getProductKey(product);
1378
1363
  var processedQty = processedQuantityMap.get(key) || 0;
1379
1364
  var remainingQty = product.quantity - processedQty;
@@ -1388,9 +1373,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1388
1373
  }
1389
1374
  }
1390
1375
  } catch (err) {
1391
- _iterator22.e(err);
1376
+ _iterator21.e(err);
1392
1377
  } finally {
1393
- _iterator22.f();
1378
+ _iterator21.f();
1394
1379
  }
1395
1380
  return result;
1396
1381
  }
@@ -1,8 +1,10 @@
1
- import type { OrderProduct } from '../../Order/types';
1
+ import type { OrderHolderRelation, OrderProduct } from '../../Order/types';
2
2
  export interface BuildNormalProductCacheItemFromOrderLineInput {
3
3
  /** tempOrder.products 中的一行(普通商品,无关联 booking) */
4
4
  product: OrderProduct;
5
5
  /** 商品 catalog / 详情,用于 variant / option / bundle 模板字段 */
6
6
  sourceProduct?: Record<string, any> | null;
7
+ /** 整单关系集合,按商品行 UID 回填。 */
8
+ holder_relations?: OrderHolderRelation[];
7
9
  }
8
10
  export declare function buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
@@ -7,13 +7,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  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); }
8
8
  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; }
9
9
  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; }
10
+ import { cloneDeep } from 'lodash-es';
11
+ import { getProductHolderRelations } from "../../Order/holderRelations";
10
12
  import { getProductSkuOptions } from "../../Order/utils";
11
13
  import { isEntitlementPass } from "../../Discount/entitlementPass";
14
+ import { resolveProductHolderConfig } from "../../Holder/utils";
12
15
  import { buildProductOptionStringFromOrderLine } from "./orderLineDisplay";
13
16
  /**
14
17
  * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
15
18
  *
16
- * 与 `buildCacheItemFromOrderLine`(预约行 + booking)并列;不含 resource / duration / holder 等预约字段。
19
+ * 与 `buildCacheItemFromOrderLine`(预约行 + booking)并列;Holder 从订单关系回填,不生成预约字段。
17
20
  */
18
21
  /**
19
22
  * 解析 v2 主商品 source 价(不含 option、不含 bundle),供 SkuDetailModal / transform 使用。
@@ -85,7 +88,7 @@ function mapOrderBundleToOtherBundle(bundle) {
85
88
  });
86
89
  }
87
90
  export function buildNormalProductCacheItemFromOrderLine(input) {
88
- var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$metadata3, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata4, _originExtend$priceOv, _product$metadata5, _ref7, _title2, _ref8, _cover, _price3, _product$order_detail, _product$product_sku;
91
+ var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$metadata3, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata4, _originExtend$priceOv, _product$metadata5, _ref7, _resolveProductHolder, _ref8, _title2, _ref9, _cover, _price3, _product$order_detail, _product$product_sku;
89
92
  var product = input.product,
90
93
  sourceProduct = input.sourceProduct;
91
94
  var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
@@ -94,6 +97,23 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
94
97
  var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
95
98
  var uid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
96
99
  var originExtend = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 || (_product$metadata2 = _product$metadata2.origin) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._extend;
100
+ var holderRelations = cloneDeep(getProductHolderRelations(input, product));
101
+ var formRelations = holderRelations.filter(function (relation) {
102
+ return relation.holder_type === 'form';
103
+ });
104
+ var holderIds = formRelations.map(function (relation) {
105
+ return relation.holder_id;
106
+ });
107
+ var holderNames = formRelations.map(function (relation) {
108
+ var _relation$metadata;
109
+ return (_relation$metadata = relation.metadata) === null || _relation$metadata === void 0 ? void 0 : _relation$metadata.name;
110
+ }).filter(function (name) {
111
+ return typeof name === 'string' && name.length > 0;
112
+ });
113
+ var holder = formRelations.length > 0 ? _objectSpread(_objectSpread({}, formRelations[0].metadata || {}), {}, {
114
+ form_record: holderIds,
115
+ name: holderNames.join(',')
116
+ }) : null;
97
117
  var shouldPreserveEntitlementPriceOverride = hasEntitlementPassDiscount(product) && ((originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined || ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.price_override) != null);
98
118
  var hasPriceOverride = (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined || shouldPreserveEntitlementPriceOverride;
99
119
  var option = getProductSkuOptions(product);
@@ -125,6 +145,9 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
125
145
  skuValue: JSON.parse(JSON.stringify(skuValue)),
126
146
  _skuValue: JSON.parse(JSON.stringify(skuValue)),
127
147
  isNormalProduct: true,
148
+ holder_relations: holderRelations,
149
+ holder: holder,
150
+ holder_id: holderIds,
128
151
  metadata: {
129
152
  product_add_schedule_time: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.product_add_schedule_time
130
153
  }
@@ -140,11 +163,12 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
140
163
  extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
141
164
  }
142
165
  return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
166
+ holder_config: (_ref7 = (_resolveProductHolder = resolveProductHolderConfig(sourceProduct)) !== null && _resolveProductHolder !== void 0 ? _resolveProductHolder : resolveProductHolderConfig(product)) !== null && _ref7 !== void 0 ? _ref7 : undefined,
143
167
  id: resolvedId,
144
168
  product_id: resolvedId,
145
169
  _id: uid,
146
- title: (_ref7 = (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : product.product_title) !== null && _ref7 !== void 0 ? _ref7 : '',
147
- cover: (_ref8 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref8 !== void 0 ? _ref8 : '',
170
+ title: (_ref8 = (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : product.product_title) !== null && _ref8 !== void 0 ? _ref8 : '',
171
+ cover: (_ref9 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref9 !== void 0 ? _ref9 : '',
148
172
  price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
149
173
  selling_price: product.selling_price,
150
174
  original_price: product.original_price
@@ -1,5 +1,7 @@
1
1
  import { ProductData } from '../Product/types';
2
2
  import { IFormItemData, IHolderConfig } from './types';
3
+ /** 保留显式禁用配置;仅在新配置缺失时兼容商品旧 holder 定义。 */
4
+ export declare function resolveProductHolderConfig(product?: ProductData | Record<string, any> | null): Record<string, any> | null;
3
5
  export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
4
6
  export declare function getFormIdFromHolderConfig(config: IHolderConfig): number;
5
7
  export declare function normalizeFormId(formId: number | string): number;
@@ -1,7 +1,37 @@
1
+ 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); }
2
+ /** 保留显式禁用配置;仅在新配置缺失时兼容商品旧 holder 定义。 */
3
+ export function resolveProductHolderConfig(product) {
4
+ var _source$metadata, _source$origin, _source$metadata2, _source$_origin, _source$_extend, _source$_extend2, _source$_extend3, _source$_extend4, _source$_extend5, _source$_extend6, _source$_extend7, _source$origin2, _source$metadata3, _source$_origin2, _source$_extend8, _source$_extend9, _source$_extend10, _source$_extend11, _legacy$custom, _legacy$custom2;
5
+ if (!product || _typeof(product) !== 'object') return null;
6
+ var source = product;
7
+ var configSources = [source.holder_config, (_source$metadata = source.metadata) === null || _source$metadata === void 0 ? void 0 : _source$metadata.holder_config, (_source$origin = source.origin) === null || _source$origin === void 0 ? void 0 : _source$origin.holder_config, (_source$metadata2 = source.metadata) === null || _source$metadata2 === void 0 || (_source$metadata2 = _source$metadata2.origin) === null || _source$metadata2 === void 0 ? void 0 : _source$metadata2.holder_config, (_source$_origin = source._origin) === null || _source$_origin === void 0 ? void 0 : _source$_origin.holder_config, (_source$_extend = source._extend) === null || _source$_extend === void 0 ? void 0 : _source$_extend.holder_config, (_source$_extend2 = source._extend) === null || _source$_extend2 === void 0 || (_source$_extend2 = _source$_extend2.product) === null || _source$_extend2 === void 0 ? void 0 : _source$_extend2.holder_config, (_source$_extend3 = source._extend) === null || _source$_extend3 === void 0 || (_source$_extend3 = _source$_extend3.product) === null || _source$_extend3 === void 0 || (_source$_extend3 = _source$_extend3.origin) === null || _source$_extend3 === void 0 ? void 0 : _source$_extend3.holder_config, (_source$_extend4 = source._extend) === null || _source$_extend4 === void 0 || (_source$_extend4 = _source$_extend4.product) === null || _source$_extend4 === void 0 || (_source$_extend4 = _source$_extend4.metadata) === null || _source$_extend4 === void 0 ? void 0 : _source$_extend4.holder_config, (_source$_extend5 = source._extend) === null || _source$_extend5 === void 0 || (_source$_extend5 = _source$_extend5.product) === null || _source$_extend5 === void 0 || (_source$_extend5 = _source$_extend5.metadata) === null || _source$_extend5 === void 0 || (_source$_extend5 = _source$_extend5.origin) === null || _source$_extend5 === void 0 ? void 0 : _source$_extend5.holder_config, (_source$_extend6 = source._extend) === null || _source$_extend6 === void 0 || (_source$_extend6 = _source$_extend6.product) === null || _source$_extend6 === void 0 || (_source$_extend6 = _source$_extend6._origin) === null || _source$_extend6 === void 0 ? void 0 : _source$_extend6.holder_config, (_source$_extend7 = source._extend) === null || _source$_extend7 === void 0 || (_source$_extend7 = _source$_extend7.product) === null || _source$_extend7 === void 0 || (_source$_extend7 = _source$_extend7._extend) === null || _source$_extend7 === void 0 ? void 0 : _source$_extend7.holder_config];
8
+ var config = configSources.find(function (value) {
9
+ return value !== null && _typeof(value) === 'object';
10
+ });
11
+ if (config) return config;
12
+
13
+ // metadata.holder / _extend.holder 是选择结果,不能作为商品配置读取。
14
+ var legacySources = [source.holder, (_source$origin2 = source.origin) === null || _source$origin2 === void 0 ? void 0 : _source$origin2.holder, (_source$metadata3 = source.metadata) === null || _source$metadata3 === void 0 || (_source$metadata3 = _source$metadata3.origin) === null || _source$metadata3 === void 0 ? void 0 : _source$metadata3.holder, (_source$_origin2 = source._origin) === null || _source$_origin2 === void 0 ? void 0 : _source$_origin2.holder, (_source$_extend8 = source._extend) === null || _source$_extend8 === void 0 || (_source$_extend8 = _source$_extend8.product) === null || _source$_extend8 === void 0 ? void 0 : _source$_extend8.holder, (_source$_extend9 = source._extend) === null || _source$_extend9 === void 0 || (_source$_extend9 = _source$_extend9.product) === null || _source$_extend9 === void 0 || (_source$_extend9 = _source$_extend9.origin) === null || _source$_extend9 === void 0 ? void 0 : _source$_extend9.holder, (_source$_extend10 = source._extend) === null || _source$_extend10 === void 0 || (_source$_extend10 = _source$_extend10.product) === null || _source$_extend10 === void 0 || (_source$_extend10 = _source$_extend10.metadata) === null || _source$_extend10 === void 0 || (_source$_extend10 = _source$_extend10.origin) === null || _source$_extend10 === void 0 ? void 0 : _source$_extend10.holder, (_source$_extend11 = source._extend) === null || _source$_extend11 === void 0 || (_source$_extend11 = _source$_extend11.product) === null || _source$_extend11 === void 0 || (_source$_extend11 = _source$_extend11._origin) === null || _source$_extend11 === void 0 ? void 0 : _source$_extend11.holder];
15
+ var legacy = legacySources.find(function (value) {
16
+ return value && _typeof(value) === 'object' && !Array.isArray(value) && typeof value.type === 'string';
17
+ });
18
+ if (!legacy) return null;
19
+ var formId = (_legacy$custom = legacy.custom) === null || _legacy$custom === void 0 ? void 0 : _legacy$custom.custom_id;
20
+ if (legacy.type === 'custom' && ((_legacy$custom2 = legacy.custom) === null || _legacy$custom2 === void 0 ? void 0 : _legacy$custom2.type) === 'form' && (typeof formId === 'number' || typeof formId === 'string') && Number.isInteger(Number(formId)) && Number(formId) > 0) {
21
+ return {
22
+ status: 'enable',
23
+ required: 0,
24
+ resource_id: formId
25
+ };
26
+ }
27
+ return {
28
+ status: 'disable',
29
+ required: 0
30
+ };
31
+ }
1
32
  export function getProductHolderConfig(product) {
2
- var _product$holder_confi, _product$origin;
3
33
  if (!product) return null;
4
- var config = (_product$holder_confi = product === null || product === void 0 ? void 0 : product.holder_config) !== null && _product$holder_confi !== void 0 ? _product$holder_confi : product === null || product === void 0 || (_product$origin = product.origin) === null || _product$origin === void 0 ? void 0 : _product$origin.holder_config;
34
+ var config = resolveProductHolderConfig(product);
5
35
  if (config !== null && config !== void 0 && config.status && (config === null || config === void 0 ? void 0 : config.status) !== 'enable') return null;
6
36
  if (!(config !== null && config !== void 0 && config.resource_id)) return null;
7
37
  return config;
@@ -0,0 +1,20 @@
1
+ import type { OpenDataConfig } from './types';
2
+ export declare const CONTACT_INFO_FIELDS: readonly ["first_name", "last_name", "phone", "email"];
3
+ export type ContactInfoField = typeof CONTACT_INFO_FIELDS[number];
4
+ export interface ContactInfoConfig {
5
+ enabled: boolean;
6
+ fields: Record<ContactInfoField, {
7
+ visible: boolean;
8
+ required: boolean;
9
+ }>;
10
+ }
11
+ export declare function resolveContactInfoConfig(data?: OpenDataConfig | null): ContactInfoConfig;
12
+ export declare function getMissingContactInfoFields(config: ContactInfoConfig, value: unknown): ContactInfoField[];
13
+ export declare function isContactRecord(value: unknown): value is Record<string, any>;
14
+ /** Customer relations wrap the contact in value; sales orders store the object itself. */
15
+ export declare function extractCustomerContactInfo(customer: unknown): Record<string, any> | null;
16
+ export declare class ContactInfoRequiredError extends Error {
17
+ readonly fields: ContactInfoField[];
18
+ readonly code = "CONTACT_INFO_REQUIRED";
19
+ constructor(fields: ContactInfoField[]);
20
+ }