@pisell/pisellos 0.0.571 → 0.0.572

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 (143) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/dataVariant/type.d.ts +3 -3
  3. package/dist/model/strategy/adapter/itemRule/type.d.ts +6 -6
  4. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  5. package/dist/model/strategy/adapter/promotion/type.d.ts +5 -5
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  8. package/dist/model/strategy/type.d.ts +1 -1
  9. package/dist/modules/BookingContext/types.d.ts +4 -4
  10. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +1 -1
  11. package/dist/modules/Customer/types.d.ts +1 -1
  12. package/dist/modules/Discount/availability.d.ts +7 -0
  13. package/dist/modules/Discount/availability.js +52 -0
  14. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  15. package/dist/modules/Discount/entitlementPass.js +147 -0
  16. package/dist/modules/Discount/entitlementState.d.ts +8 -0
  17. package/dist/modules/Discount/entitlementState.js +205 -0
  18. package/dist/modules/Discount/index.d.ts +5 -2
  19. package/dist/modules/Discount/index.js +124 -25
  20. package/dist/modules/Discount/types.d.ts +29 -6
  21. package/dist/modules/Holder/types.d.ts +1 -1
  22. package/dist/modules/OpenData/types.d.ts +1 -1
  23. package/dist/modules/Order/types.d.ts +5 -5
  24. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +1 -1
  25. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +1 -1
  26. package/dist/modules/Order/utils.d.ts +1 -1
  27. package/dist/modules/Payment/types.d.ts +7 -7
  28. package/dist/modules/Product/index.d.ts +1 -1
  29. package/dist/modules/ResourcePlanner/types.d.ts +4 -4
  30. package/dist/modules/Rules/entitlementLines.d.ts +8 -0
  31. package/dist/modules/Rules/entitlementLines.js +159 -0
  32. package/dist/modules/Rules/index.d.ts +13 -3
  33. package/dist/modules/Rules/index.js +617 -342
  34. package/dist/modules/Rules/types.d.ts +4 -4
  35. package/dist/modules/ScanOrderLogger/types.d.ts +2 -2
  36. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +9 -9
  39. package/dist/plugins/app.d.ts +1 -1
  40. package/dist/plugins/request.d.ts +2 -2
  41. package/dist/plugins/window.d.ts +2 -2
  42. package/dist/server/modules/floor-plan/types.d.ts +1 -1
  43. package/dist/server/modules/menu/types.d.ts +1 -1
  44. package/dist/server/modules/order/types.d.ts +16 -16
  45. package/dist/server/modules/products/types.d.ts +1 -1
  46. package/dist/server/modules/resource/types.d.ts +1 -1
  47. package/dist/server/modules/schedule/utils.d.ts +1 -1
  48. package/dist/server/types.d.ts +4 -4
  49. package/dist/server/utils/small-ticket.d.ts +1 -1
  50. package/dist/solution/BaseSales/index.d.ts +1 -1
  51. package/dist/solution/BaseSales/types.d.ts +7 -7
  52. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -1
  53. package/dist/solution/BookingByStep/index.d.ts +1 -1
  54. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.d.ts +13 -1
  56. package/dist/solution/BookingTicket/types.d.ts +3 -3
  57. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  58. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +1 -1
  59. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +1 -1
  60. package/dist/solution/Sales/types.d.ts +4 -4
  61. package/dist/solution/ScanOrder/types.d.ts +5 -5
  62. package/dist/solution/ShopDiscount/index.d.ts +3 -0
  63. package/dist/solution/ShopDiscount/index.js +161 -78
  64. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  65. package/dist/solution/ShopDiscount/utils.d.ts +3 -2
  66. package/dist/solution/ShopDiscount/utils.js +40 -1
  67. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -1
  68. package/dist/solution/VenueBooking/types.d.ts +1 -1
  69. package/dist/types/index.d.ts +1 -1
  70. package/dist/utils/task.d.ts +2 -2
  71. package/dist/utils/watch.d.ts +2 -2
  72. package/lib/effects/index.d.ts +2 -2
  73. package/lib/model/strategy/adapter/dataVariant/type.d.ts +3 -3
  74. package/lib/model/strategy/adapter/itemRule/type.d.ts +6 -6
  75. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  76. package/lib/model/strategy/adapter/promotion/type.d.ts +5 -5
  77. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  78. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  79. package/lib/model/strategy/type.d.ts +1 -1
  80. package/lib/modules/BookingContext/types.d.ts +4 -4
  81. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +1 -1
  82. package/lib/modules/Customer/types.d.ts +1 -1
  83. package/lib/modules/Discount/availability.d.ts +7 -0
  84. package/lib/modules/Discount/availability.js +46 -0
  85. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  86. package/lib/modules/Discount/entitlementPass.js +141 -0
  87. package/lib/modules/Discount/entitlementState.d.ts +8 -0
  88. package/lib/modules/Discount/entitlementState.js +150 -0
  89. package/lib/modules/Discount/index.d.ts +5 -2
  90. package/lib/modules/Discount/index.js +59 -14
  91. package/lib/modules/Discount/types.d.ts +29 -6
  92. package/lib/modules/Holder/types.d.ts +1 -1
  93. package/lib/modules/OpenData/types.d.ts +1 -1
  94. package/lib/modules/Order/types.d.ts +5 -5
  95. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +1 -1
  96. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +1 -1
  97. package/lib/modules/Order/utils.d.ts +1 -1
  98. package/lib/modules/Payment/types.d.ts +7 -7
  99. package/lib/modules/Product/index.d.ts +1 -1
  100. package/lib/modules/ResourcePlanner/types.d.ts +4 -4
  101. package/lib/modules/Rules/entitlementLines.d.ts +8 -0
  102. package/lib/modules/Rules/entitlementLines.js +128 -0
  103. package/lib/modules/Rules/index.d.ts +13 -3
  104. package/lib/modules/Rules/index.js +284 -61
  105. package/lib/modules/Rules/types.d.ts +4 -4
  106. package/lib/modules/ScanOrderLogger/types.d.ts +2 -2
  107. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  108. package/lib/modules/Schedule/type.d.ts +7 -7
  109. package/lib/modules/Schedule/types.d.ts +9 -9
  110. package/lib/plugins/app.d.ts +1 -1
  111. package/lib/plugins/request.d.ts +2 -2
  112. package/lib/plugins/window.d.ts +2 -2
  113. package/lib/server/modules/floor-plan/types.d.ts +1 -1
  114. package/lib/server/modules/menu/types.d.ts +1 -1
  115. package/lib/server/modules/order/types.d.ts +16 -16
  116. package/lib/server/modules/products/types.d.ts +1 -1
  117. package/lib/server/modules/resource/types.d.ts +1 -1
  118. package/lib/server/modules/schedule/utils.d.ts +1 -1
  119. package/lib/server/types.d.ts +4 -4
  120. package/lib/server/utils/small-ticket.d.ts +1 -1
  121. package/lib/solution/BaseSales/index.d.ts +1 -1
  122. package/lib/solution/BaseSales/types.d.ts +7 -7
  123. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -1
  124. package/lib/solution/BookingByStep/index.d.ts +1 -1
  125. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  126. package/lib/solution/BookingTicket/index.d.ts +13 -1
  127. package/lib/solution/BookingTicket/types.d.ts +3 -3
  128. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  129. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +1 -1
  130. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +1 -1
  131. package/lib/solution/Sales/types.d.ts +4 -4
  132. package/lib/solution/ScanOrder/types.d.ts +5 -5
  133. package/lib/solution/ShopDiscount/index.d.ts +3 -0
  134. package/lib/solution/ShopDiscount/index.js +55 -18
  135. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  136. package/lib/solution/ShopDiscount/utils.d.ts +3 -2
  137. package/lib/solution/ShopDiscount/utils.js +39 -3
  138. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -1
  139. package/lib/solution/VenueBooking/types.d.ts +1 -1
  140. package/lib/types/index.d.ts +1 -1
  141. package/lib/utils/task.d.ts +2 -2
  142. package/lib/utils/watch.d.ts +2 -2
  143. package/package.json +19 -18
@@ -629,12 +629,12 @@ export declare enum PaymentHooks {
629
629
  OnOrderAmountChanged = "payment:onOrderAmountChanged",
630
630
  OnPaymentSyncError = "payment:onPaymentSyncError",
631
631
  OnPaymentSyncSuccess = "payment:onPaymentSyncSuccess",
632
- OnWalletRecommendListUpdated = 0,
633
- OnWalletRecommendListCleared = 0,
634
- OnUserIdentificationCodesUpdated = 0,
635
- OnUserIdentificationCodesCleared = 0,
636
- OnWalletCacheCleared = 0,
637
- OnSearchIdentificationCodeCompleted = 0
632
+ OnWalletRecommendListUpdated = "wallet:onWalletRecommendListUpdated",
633
+ OnWalletRecommendListCleared = "wallet:onWalletRecommendListCleared",
634
+ OnUserIdentificationCodesUpdated = "wallet:onUserIdentificationCodesUpdated",
635
+ OnUserIdentificationCodesCleared = "wallet:onUserIdentificationCodesCleared",
636
+ OnWalletCacheCleared = "wallet:onWalletCacheCleared",
637
+ OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted"
638
638
  }
639
639
  /**
640
640
  * 钱包推荐扣款请求参数
@@ -797,7 +797,7 @@ export interface SearchIdentificationCodeResponse {
797
797
  /**
798
798
  * 搜索识别码结果类型
799
799
  */
800
- export declare type SearchIdentificationCodeResult = {
800
+ export type SearchIdentificationCodeResult = {
801
801
  type: 'walletCode';
802
802
  data: SearchIdentificationCodeItem[];
803
803
  } | {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -1,7 +1,7 @@
1
- export declare type ResourcePlannerMode = 'appointment' | 'scan_order' | 'venue_grid';
2
- export declare type ResourcePlannerProductKind = 'normal' | 'duration' | 'session' | 'venue_slot';
3
- export declare type ResourcePlannerResourceType = 'single' | 'multiple' | 'capacity';
4
- export declare type ResourcePlannerStatus = 'available' | 'limited' | 'full' | 'conflict' | 'unavailable' | 'past';
1
+ export type ResourcePlannerMode = 'appointment' | 'scan_order' | 'venue_grid';
2
+ export type ResourcePlannerProductKind = 'normal' | 'duration' | 'session' | 'venue_slot';
3
+ export type ResourcePlannerResourceType = 'single' | 'multiple' | 'capacity';
4
+ export type ResourcePlannerStatus = 'available' | 'limited' | 'full' | 'conflict' | 'unavailable' | 'past';
5
5
  export interface ResourcePlannerTimeRange {
6
6
  start_at: string;
7
7
  end_at: string;
@@ -0,0 +1,8 @@
1
+ import type { RulesParamsHooks } from './types';
2
+ export declare function isEntitlementRuntimeLine(product: any, mappedProduct?: any): boolean;
3
+ /** 仅同步本次多次卡行的数量与价格,沿用 Rules 的主商品、套餐计算结果。 */
4
+ export declare function rebuildEntitlementLine(origin: any, bundle: any[], hooks: RulesParamsHooks, count?: number): any;
5
+ /** 重算只还原本次多次卡;套餐和多 Holder 按父商品份数计算,不再合并商品行。 */
6
+ export declare function prepareEntitlementLines(products: any[], hooks: RulesParamsHooks, canUseEntitlement: (product: any) => boolean): any[];
7
+ /** 客户端钩子可能保留原 _id,只给新增的重复行补标识,保留拆分结果。 */
8
+ export declare function finalizeEntitlementLines(products: any[], hooks: RulesParamsHooks): any[];
@@ -0,0 +1,159 @@
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
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 { cloneDeep } from 'lodash-es';
8
+ import Decimal from 'decimal.js';
9
+ import { isEntitlementPass } from "../Discount/entitlementPass";
10
+ import { hasEntitlementDiscount, isPersistedEntitlementLine } from "../Discount/entitlementState";
11
+ var SOURCE = 'entitlement_source_identity';
12
+ function isManualDiscount(data) {
13
+ var _data$isManualDiscoun, _data$discount_list;
14
+ return (_data$isManualDiscoun = data.isManualDiscount) !== null && _data$isManualDiscoun !== void 0 ? _data$isManualDiscoun : data.total != data.origin_total && (data.bundle || []).every(function (item) {
15
+ var _item$discount_list;
16
+ return !((_item$discount_list = item.discount_list) !== null && _item$discount_list !== void 0 && _item$discount_list.length);
17
+ }) && (!((_data$discount_list = data.discount_list) !== null && _data$discount_list !== void 0 && _data$discount_list.length) || data.discount_list.every(function (item) {
18
+ return item.type === 'product';
19
+ }));
20
+ }
21
+ export function isEntitlementRuntimeLine(product, mappedProduct) {
22
+ var _product$metadata;
23
+ return ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata[SOURCE]) != null && !isPersistedEntitlementLine(product, mappedProduct) && !isManualDiscount(mappedProduct !== null && mappedProduct !== void 0 ? mappedProduct : product);
24
+ }
25
+
26
+ /** 仅同步本次多次卡行的数量与价格,沿用 Rules 的主商品、套餐计算结果。 */
27
+ export function rebuildEntitlementLine(origin, bundle, hooks, count) {
28
+ var _ref, _ref2, _ref4, _data$original_price;
29
+ var data = hooks.getProduct(origin);
30
+ var quantity = (_ref = (_ref2 = count !== null && count !== void 0 ? count : data.quantity) !== null && _ref2 !== void 0 ? _ref2 : data.num) !== null && _ref !== void 0 ? _ref : 1;
31
+ var discounts = (data.discount_list || []).map(function (item) {
32
+ var _item$metadata;
33
+ return isEntitlementPass(item) && !((_item$metadata = item.metadata) !== null && _item$metadata !== void 0 && _item$metadata.custom_product_bundle_map_id) ? _objectSpread(_objectSpread({}, item), {}, {
34
+ _num: quantity,
35
+ metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
36
+ num: quantity
37
+ })
38
+ }) : item;
39
+ });
40
+ var mainDiscount = discounts.filter(function (item) {
41
+ var _item$metadata2;
42
+ return !((_item$metadata2 = item.metadata) !== null && _item$metadata2 !== void 0 && _item$metadata2.custom_product_bundle_map_id);
43
+ }).reduce(function (sum, item) {
44
+ var _ref3, _item$metadata$mainPr, _item$metadata3;
45
+ return sum.plus((_ref3 = (_item$metadata$mainPr = (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.mainProductDiscountAmount) !== null && _item$metadata$mainPr !== void 0 ? _item$metadata$mainPr : item.amount) !== null && _ref3 !== void 0 ? _ref3 : 0);
46
+ }, new Decimal(0));
47
+ var originalPrice = new Decimal((_ref4 = (_data$original_price = data.original_price) !== null && _data$original_price !== void 0 ? _data$original_price : data.price) !== null && _ref4 !== void 0 ? _ref4 : 0);
48
+ var sourceSellingPrice = originalPrice.minus(mainDiscount).toNumber();
49
+ var optionPrice = (data.options || []).reduce(function (sum, item) {
50
+ var _ref5, _item$price, _ref6, _item$num;
51
+ return sum.plus(new Decimal((_ref5 = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.add_price) !== null && _ref5 !== void 0 ? _ref5 : 0).times((_ref6 = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1));
52
+ }, new Decimal(0));
53
+ var bundleTotal = bundle.reduce(function (sum, item) {
54
+ return sum.plus(new Decimal(item.price || 0).times(item.num || 1));
55
+ }, new Decimal(0));
56
+ var bundleOriginalTotal = bundle.reduce(function (sum, item) {
57
+ var _ref7, _item$original_price;
58
+ return sum.plus(new Decimal((_ref7 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.price) !== null && _ref7 !== void 0 ? _ref7 : 0).times(item.num || 1));
59
+ }, new Decimal(0));
60
+ return hooks.setProduct(origin, {
61
+ quantity: quantity,
62
+ discount_list: discounts,
63
+ bundle: bundle,
64
+ price: sourceSellingPrice,
65
+ main_product_selling_price: sourceSellingPrice,
66
+ total: new Decimal(sourceSellingPrice).plus(optionPrice).plus(bundleTotal).toNumber(),
67
+ origin_total: originalPrice.plus(optionPrice).plus(bundleOriginalTotal).toNumber()
68
+ });
69
+ }
70
+ function setLineIdentity(row, id) {
71
+ row._id = id;
72
+ row.metadata = _objectSpread(_objectSpread({}, row.metadata), {}, {
73
+ unique_identification_number: id
74
+ });
75
+ if (row._extend) row._extend.unique_identification_number = id;
76
+ return row;
77
+ }
78
+
79
+ /** 重算只还原本次多次卡;套餐和多 Holder 按父商品份数计算,不再合并商品行。 */
80
+ export function prepareEntitlementLines(products, hooks, canUseEntitlement) {
81
+ return products.flatMap(function (original) {
82
+ var _original$metadata, _origin$metadata$SOUR, _origin$metadata, _data$discount_list2, _ref11, _data$original_price2, _mainEntitlement$disc;
83
+ var data = hooks.getProduct(original);
84
+ if (isPersistedEntitlementLine(original, data) || isManualDiscount(data)) return [original];
85
+ var applicable = canUseEntitlement(original);
86
+ if (!((_original$metadata = original.metadata) !== null && _original$metadata !== void 0 && _original$metadata[SOURCE]) && !hasEntitlementDiscount(data) && !applicable) return [original];
87
+ var origin = cloneDeep(original);
88
+ origin.metadata = _objectSpread(_objectSpread({}, origin.metadata), {}, _defineProperty({}, SOURCE, (_origin$metadata$SOUR = (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata[SOURCE]) !== null && _origin$metadata$SOUR !== void 0 ? _origin$metadata$SOUR : data._id));
89
+ var bundle = (data.bundle || []).map(function (item) {
90
+ var _ref8, _ref9, _ref10, _item$original_price2, _entitlement$discount;
91
+ var entitlement = (item.discount_list || []).find(isEntitlementPass);
92
+ if (!entitlement) return item;
93
+ var discounts = (item.discount_list || []).filter(function (discount) {
94
+ return !isEntitlementPass(discount);
95
+ });
96
+ var originalPrice = (_ref8 = (_ref9 = (_ref10 = (_item$original_price2 = item.original_price) !== null && _item$original_price2 !== void 0 ? _item$original_price2 : (_entitlement$discount = entitlement.discount) === null || _entitlement$discount === void 0 ? void 0 : _entitlement$discount.original_amount) !== null && _ref10 !== void 0 ? _ref10 : item.product_price) !== null && _ref9 !== void 0 ? _ref9 : item.price) !== null && _ref8 !== void 0 ? _ref8 : 0;
97
+ var amount = discounts.reduce(function (sum, discount) {
98
+ return sum.plus(discount.amount || 0);
99
+ }, new Decimal(0));
100
+ var price = new Decimal(originalPrice).minus(amount.div(item.num || 1)).toNumber();
101
+ return _objectSpread(_objectSpread({}, item), {}, {
102
+ original_price: originalPrice,
103
+ price: price,
104
+ bundle_selling_price: price,
105
+ discount_list: discounts
106
+ });
107
+ });
108
+ var mainEntitlement = (_data$discount_list2 = data.discount_list) === null || _data$discount_list2 === void 0 ? void 0 : _data$discount_list2.find(isEntitlementPass);
109
+ var restored = hooks.setProduct(origin, {
110
+ original_price: (_ref11 = (_data$original_price2 = data.original_price) !== null && _data$original_price2 !== void 0 ? _data$original_price2 : mainEntitlement === null || mainEntitlement === void 0 || (_mainEntitlement$disc = mainEntitlement.discount) === null || _mainEntitlement$disc === void 0 ? void 0 : _mainEntitlement$disc.original_amount) !== null && _ref11 !== void 0 ? _ref11 : data.price,
111
+ discount_list: (data.discount_list || []).filter(function (item) {
112
+ return !isEntitlementPass(item);
113
+ }),
114
+ bundle: bundle
115
+ });
116
+ var row = rebuildEntitlementLine(restored, bundle, hooks);
117
+ var count = Math.max(1, Math.floor(Number(data.quantity || data.num || 1)));
118
+ if (!applicable || count <= 1 || !bundle.length && !Array.isArray(data.holder_id)) return [row];
119
+ return Array.from({
120
+ length: count
121
+ }, function (_, index) {
122
+ var _unit$_origin;
123
+ var unit = cloneDeep(row);
124
+ // booking 使用 _extend.holder_id,appointmentBooking 使用购物车 Holder。
125
+ for (var _i = 0, _arr = [unit, unit._extend]; _i < _arr.length; _i++) {
126
+ var source = _arr[_i];
127
+ if (Array.isArray(source === null || source === void 0 ? void 0 : source.holder_id)) source.holder_id = source.holder_id.slice(index, index + 1);
128
+ }
129
+ if (Array.isArray((_unit$_origin = unit._origin) === null || _unit$_origin === void 0 || (_unit$_origin = _unit$_origin.holder) === null || _unit$_origin === void 0 ? void 0 : _unit$_origin.form_record)) {
130
+ var records = unit._origin.holder.form_record;
131
+ // 单 Holder 的多份商品仍归属同一人;多个 Holder 才按份对应。
132
+ if (records.length > 1) unit._origin.holder.form_record = records.slice(index, index + 1);
133
+ }
134
+ return setLineIdentity(rebuildEntitlementLine(unit, hooks.getProduct(unit).bundle || [], hooks, 1), "".concat(data._id, ":entitlement-unit:").concat(index));
135
+ });
136
+ });
137
+ }
138
+
139
+ /** 客户端钩子可能保留原 _id,只给新增的重复行补标识,保留拆分结果。 */
140
+ export function finalizeEntitlementLines(products, hooks) {
141
+ var runtime = function runtime(item) {
142
+ return isEntitlementRuntimeLine(item, hooks.getProduct(item));
143
+ };
144
+ var seen = new Set(products.filter(function (item) {
145
+ return !runtime(item);
146
+ }).map(function (item) {
147
+ return String(item._id);
148
+ }));
149
+ return products.map(function (origin, index) {
150
+ var _origin$_id;
151
+ if (!runtime(origin)) return origin;
152
+ var base = String((_origin$_id = origin._id) !== null && _origin$_id !== void 0 ? _origin$_id : hooks.getProduct(origin)._id);
153
+ var id = base;
154
+ var ordinal = index;
155
+ while (seen.has(id)) id = "".concat(base, ":entitlement-split:").concat(ordinal++);
156
+ seen.add(id);
157
+ return id === String(origin._id) ? origin : setLineIdentity(cloneDeep(origin), id);
158
+ });
159
+ }
@@ -2,6 +2,7 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
3
  import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
+ import { WalletPassEvaluator } from '../../model/strategy/adapter/walletPass/evaluator';
5
6
  import { WindowPlugin } from '../../plugins';
6
7
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
7
8
  protected defaultName: string;
@@ -9,11 +10,19 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
9
10
  private store;
10
11
  window: WindowPlugin;
11
12
  private hooks;
13
+ private entitlementPassEnabled;
14
+ private defaultWalletPassEvaluator?;
15
+ setEntitlementPassEnabled(enabled: boolean): void;
12
16
  constructor(name?: string, version?: string);
13
17
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
18
  setRulesList(rulesList: Rules[]): Promise<void>;
15
19
  getRulesList(): Rules[];
16
- getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
20
+ getWalletPassEvaluator(): WalletPassEvaluator | undefined;
21
+ private normalizeHolderRecordIds;
22
+ /**
23
+ * 商品未开启 Holder 选择时跳过匹配;已开启时,特定 form Holder 卡
24
+ * 只适用于同一 Holder Record,是否必填不影响匹配规则。
25
+ */
17
26
  private checkHolderMatch;
18
27
  isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
19
28
  oldDiscountList: Discount[];
@@ -21,7 +30,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
21
30
  productList: any[];
22
31
  orderTotalAmount: number;
23
32
  holders: {
24
- form_record_id: number;
33
+ form_record_id: number | string;
25
34
  }[];
26
35
  isFormSubject: RulesFormSubject;
27
36
  }): {
@@ -29,6 +38,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
29
38
  discountList: Discount[];
30
39
  productList: any[];
31
40
  unavailableReason?: UnavailableReason;
41
+ evaluatedDiscountList?: Discount[];
32
42
  };
33
43
  filterDiscountListByType(discountList: Discount[], type: string): Discount[];
34
44
  /** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
@@ -40,7 +50,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
40
50
  discountList: Discount[];
41
51
  productList: any[];
42
52
  holders: {
43
- form_record_id: number;
53
+ form_record_id: number | string;
44
54
  }[];
45
55
  isFormSubject: RulesFormSubject;
46
56
  orderTotalAmount: number;