@pisell/pisellos 0.10.40 → 0.10.42

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 (73) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  2. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  3. package/dist/modules/Customer/index.js +4 -2
  4. package/dist/modules/Customer/types.d.ts +2 -0
  5. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  6. package/dist/modules/Discount/entitlementPass.js +147 -0
  7. package/dist/modules/Discount/index.d.ts +2 -0
  8. package/dist/modules/Discount/index.js +39 -13
  9. package/dist/modules/Discount/types.d.ts +26 -5
  10. package/dist/modules/Order/index.d.ts +6 -1
  11. package/dist/modules/Order/index.js +283 -118
  12. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  13. package/dist/modules/Order/utils.js +17 -1
  14. package/dist/modules/Payment/types.d.ts +21 -1
  15. package/dist/modules/Payment/types.js +2 -0
  16. package/dist/modules/Payment/walletpass.d.ts +1 -1
  17. package/dist/modules/Payment/walletpass.js +80 -47
  18. package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
  19. package/dist/modules/ResourcePlanner/planner.js +163 -46
  20. package/dist/modules/ResourcePlanner/types.d.ts +17 -0
  21. package/dist/modules/Rules/index.js +310 -134
  22. package/dist/solution/BaseSales/index.d.ts +3 -0
  23. package/dist/solution/BaseSales/index.js +11 -2
  24. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  25. package/dist/solution/BookingByStep/index.d.ts +2 -2
  26. package/dist/solution/BookingTicket/index.d.ts +1 -2
  27. package/dist/solution/BookingTicket/index.js +60 -63
  28. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  29. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +266 -150
  30. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -3
  31. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
  32. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +8 -4
  33. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  34. package/dist/solution/ShopDiscount/index.js +41 -21
  35. package/dist/solution/ShopDiscount/utils.js +3 -2
  36. package/dist/solution/UnifiedBookingSales/index.js +94 -21
  37. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  38. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  39. package/lib/modules/Customer/index.js +4 -1
  40. package/lib/modules/Customer/types.d.ts +2 -0
  41. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  42. package/lib/modules/Discount/entitlementPass.js +141 -0
  43. package/lib/modules/Discount/index.d.ts +2 -0
  44. package/lib/modules/Discount/index.js +25 -9
  45. package/lib/modules/Discount/types.d.ts +26 -5
  46. package/lib/modules/Order/index.d.ts +6 -1
  47. package/lib/modules/Order/index.js +172 -28
  48. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  49. package/lib/modules/Order/utils.js +19 -1
  50. package/lib/modules/Payment/types.d.ts +21 -1
  51. package/lib/modules/Payment/types.js +1 -0
  52. package/lib/modules/Payment/walletpass.d.ts +1 -1
  53. package/lib/modules/Payment/walletpass.js +29 -9
  54. package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
  55. package/lib/modules/ResourcePlanner/planner.js +137 -35
  56. package/lib/modules/ResourcePlanner/types.d.ts +17 -0
  57. package/lib/modules/Rules/index.js +230 -96
  58. package/lib/solution/BaseSales/index.d.ts +3 -0
  59. package/lib/solution/BaseSales/index.js +9 -2
  60. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  61. package/lib/solution/BookingByStep/index.d.ts +2 -2
  62. package/lib/solution/BookingTicket/index.d.ts +1 -2
  63. package/lib/solution/BookingTicket/index.js +36 -33
  64. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  65. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +127 -42
  66. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +7 -3
  67. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
  68. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +7 -3
  69. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  70. package/lib/solution/ShopDiscount/index.js +26 -6
  71. package/lib/solution/ShopDiscount/utils.js +3 -2
  72. package/lib/solution/UnifiedBookingSales/index.js +86 -22
  73. package/package.json +1 -1
@@ -13,6 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
13
13
  import dayjs from 'dayjs';
14
14
  import { getProductSkuOptions } from "../../Order/utils";
15
15
  import { resolveManualDiscountMessage } from "../../Order/utils/manualProductDiscount";
16
+ import { isEntitlementPass } from "../../Discount/entitlementPass";
16
17
  import { buildProductOptionStringFromOrderLine } from "./orderLineDisplay";
17
18
  function safeFormat(value, fmt) {
18
19
  if (value === undefined || value === null) return undefined;
@@ -125,20 +126,56 @@ function resolveProductCover(product, booking, sourceProduct) {
125
126
  var _ref6, _cover;
126
127
  return (_ref6 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref6 !== void 0 ? _ref6 : '';
127
128
  }
128
- function resolveMainProductPrice(product, fallback) {
129
- var _metadata$main_produc;
130
- var metadata = product.metadata || {};
131
- var value = (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : metadata.source_product_price;
129
+ function toFinitePrice(value) {
130
+ if (value === undefined || value === null || value === '') return null;
132
131
  var parsed = Number(value);
133
- return Number.isFinite(parsed) ? parsed : fallback;
132
+ return Number.isFinite(parsed) ? parsed : null;
133
+ }
134
+ function hasEntitlementPassDiscount(product) {
135
+ var hasEntitlementDiscount = function hasEntitlementDiscount(discountList) {
136
+ return Array.isArray(discountList) && discountList.some(isEntitlementPass);
137
+ };
138
+ return hasEntitlementDiscount(product.discount_list) || Array.isArray(product.product_bundle) && product.product_bundle.some(function (bundle) {
139
+ return hasEntitlementDiscount(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
140
+ });
141
+ }
142
+ function resolveMainProductPrice(product, fallback, sourceProduct) {
143
+ var _variant, _metadata$origin, _ref7, _ref8, _price, _metadata$origin2, _metadata$origin3;
144
+ var restoreEntitlementPrice = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
145
+ var metadata = product.metadata || {};
146
+ if (!restoreEntitlementPrice) {
147
+ var _metadata$main_produc;
148
+ var value = (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : metadata.source_product_price;
149
+ var parsed = Number(value);
150
+ return Number.isFinite(parsed) ? parsed : fallback;
151
+ }
152
+ var sourcePrice = toFinitePrice(metadata.source_product_price);
153
+ if (sourcePrice !== null) return sourcePrice;
154
+ var variantId = Number(product.product_variant_id || 0);
155
+ var variantList = (_variant = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant) !== null && _variant !== void 0 ? _variant : (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.variant;
156
+ if (variantId > 0 && Array.isArray(variantList)) {
157
+ var _matched$price;
158
+ var matched = variantList.find(function (variant) {
159
+ return Number(variant === null || variant === void 0 ? void 0 : variant.id) === variantId;
160
+ });
161
+ var variantPrice = toFinitePrice((_matched$price = matched === null || matched === void 0 ? void 0 : matched.price) !== null && _matched$price !== void 0 ? _matched$price : matched === null || matched === void 0 ? void 0 : matched.base_price);
162
+ if (variantPrice !== null) return variantPrice;
163
+ }
164
+ var catalogPrice = toFinitePrice((_ref7 = (_ref8 = (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref8 !== void 0 ? _ref8 : (_metadata$origin2 = metadata.origin) === null || _metadata$origin2 === void 0 ? void 0 : _metadata$origin2.price) !== null && _ref7 !== void 0 ? _ref7 : (_metadata$origin3 = metadata.origin) === null || _metadata$origin3 === void 0 ? void 0 : _metadata$origin3.base_price);
165
+ if (catalogPrice !== null) return catalogPrice;
166
+
167
+ // legacy 数据没有 source_product_price 时,main_product_original_price
168
+ // 仍比已被月卡改写为 0 的 selling_price 更可靠。
169
+ var legacyMainPrice = toFinitePrice(metadata.main_product_original_price);
170
+ return legacyMainPrice !== null && legacyMainPrice !== void 0 ? legacyMainPrice : fallback;
134
171
  }
135
172
  function mapOrderBundleToOtherBundle(bundle) {
136
173
  return bundle.map(function (item) {
137
- var _ref7, _ref8, _item$original_price;
174
+ var _ref9, _ref10, _item$original_price;
138
175
  return _objectSpread(_objectSpread({}, item), {}, {
139
176
  // 后端历史订单可能没有 original_price;此时 price 是折前毛价,
140
177
  // bundle_selling_price 已包含折扣,不能把它当成编辑时的新原价。
141
- original_price: (_ref7 = (_ref8 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : item.bundle_selling_price
178
+ original_price: (_ref9 = (_ref10 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref10 !== void 0 ? _ref10 : item.price) !== null && _ref9 !== void 0 ? _ref9 : item.bundle_selling_price
142
179
  });
143
180
  });
144
181
  }
@@ -169,10 +206,10 @@ function synthesizeProductResourceFromBooking(booking) {
169
206
  });
170
207
  if (relationIdsByForm.size === 0) return undefined;
171
208
  return {
172
- resources: Array.from(relationIdsByForm.entries()).map(function (_ref9) {
173
- var _ref10 = _slicedToArray(_ref9, 2),
174
- formId = _ref10[0],
175
- relationIds = _ref10[1];
209
+ resources: Array.from(relationIdsByForm.entries()).map(function (_ref11) {
210
+ var _ref12 = _slicedToArray(_ref11, 2),
211
+ formId = _ref12[0],
212
+ relationIds = _ref12[1];
176
213
  return {
177
214
  id: formId,
178
215
  status: 1,
@@ -192,15 +229,16 @@ function synthesizeProductResourceFromBooking(booking) {
192
229
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
193
230
  */
194
231
  export function buildCacheItemFromOrderLine(input) {
195
- var _ref11, _sourceProduct$holder, _sourceProduct$origin, _product$metadata, _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$bundle_edit, _product$product_vari, _product$num, _ref12, _product$note, _booking$detail2, _product$metadata2, _product$metadata3, _ref13, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref14, _booking$id;
232
+ var _ref13, _sourceProduct$holder, _sourceProduct$origin, _product$metadata, _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$bundle_edit, _product$product_vari, _product$num, _ref14, _product$note, _booking$detail2, _product$metadata2, _product$metadata3, _ref15, _extension_type, _booking$product2, _booking$product3, _price2, _product$product_sku, _product$order_detail, _ref16, _booking$id;
196
233
  var product = input.product,
197
234
  booking = input.booking,
198
235
  sourceProduct = input.sourceProduct;
199
- var holderConfig = (_ref11 = (_sourceProduct$holder = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config) !== null && _sourceProduct$holder !== void 0 ? _sourceProduct$holder : sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$origin = sourceProduct.origin) === null || _sourceProduct$origin === void 0 ? void 0 : _sourceProduct$origin.holder_config) !== null && _ref11 !== void 0 ? _ref11 : (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.holder_config;
236
+ var holderConfig = (_ref13 = (_sourceProduct$holder = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config) !== null && _sourceProduct$holder !== void 0 ? _sourceProduct$holder : sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$origin = sourceProduct.origin) === null || _sourceProduct$origin === void 0 ? void 0 : _sourceProduct$origin.holder_config) !== null && _ref13 !== void 0 ? _ref13 : (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.holder_config;
200
237
  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;
201
238
  var selling = Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
202
239
  var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
203
- var mainProductPrice = resolveMainProductPrice(product, selling);
240
+ var shouldRestoreEntitlementPrice = hasEntitlementPassDiscount(product);
241
+ var mainProductPrice = resolveMainProductPrice(product, selling, sourceProduct, shouldRestoreEntitlementPrice);
204
242
  var startDate = safeFormat(booking.start_date, 'YYYY-MM-DD');
205
243
  var endDate = safeFormat(booking.end_date, 'YYYY-MM-DD');
206
244
  var startTime = normalizeTimeString(booking.start_time);
@@ -230,7 +268,7 @@ export function buildCacheItemFromOrderLine(input) {
230
268
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
231
269
  product_name: productTitle,
232
270
  product_cover: productCover,
233
- note: (_ref12 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref12 !== void 0 ? _ref12 : '',
271
+ note: (_ref14 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref14 !== void 0 ? _ref14 : '',
234
272
  price: mainProductPrice,
235
273
  total: selling,
236
274
  origin_total: original,
@@ -256,7 +294,8 @@ export function buildCacheItemFromOrderLine(input) {
256
294
  }
257
295
  }
258
296
  if (((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.price_override) != null || manualDiscount) {
259
- extend.priceOverride = selling;
297
+ var _product$metadata$pri, _product$metadata4;
298
+ extend.priceOverride = shouldRestoreEntitlementPrice ? (_product$metadata$pri = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.price_override) !== null && _product$metadata$pri !== void 0 ? _product$metadata$pri : selling : selling;
260
299
  }
261
300
  if (booking.holder !== undefined) {
262
301
  extend.holder = booking.holder;
@@ -269,9 +308,9 @@ export function buildCacheItemFromOrderLine(input) {
269
308
  } : {}), {}, {
270
309
  id: resolvedId,
271
310
  product_id: resolvedId,
272
- extension_type: (_ref13 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
311
+ extension_type: (_ref15 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref15 !== void 0 ? _ref15 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
273
312
  title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
274
- price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
313
+ price: (_price2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price2 !== void 0 ? _price2 : selling,
275
314
  selling_price: product.selling_price,
276
315
  original_price: product.original_price
277
316
  }, Number(((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1 ? {
@@ -283,7 +322,7 @@ export function buildCacheItemFromOrderLine(input) {
283
322
  new: 0,
284
323
  autoClose: false,
285
324
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
286
- booking_id: (_ref14 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref14 !== void 0 ? _ref14 : 0
325
+ booking_id: (_ref16 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref16 !== void 0 ? _ref16 : 0
287
326
  });
288
327
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
289
328
  base.capacity = sourceProduct.capacity;
@@ -8,6 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
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
10
  import { getProductSkuOptions } from "../../Order/utils";
11
+ import { isEntitlementPass } from "../../Discount/entitlementPass";
11
12
  import { buildProductOptionStringFromOrderLine } from "./orderLineDisplay";
12
13
  /**
13
14
  * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
@@ -52,13 +53,22 @@ function resolveSourceProductPrice(product, sourceProduct) {
52
53
  }
53
54
  return Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
54
55
  }
56
+ function hasEntitlementPassDiscount(product) {
57
+ var hasEntitlementDiscount = function hasEntitlementDiscount(discountList) {
58
+ return Array.isArray(discountList) && discountList.some(isEntitlementPass);
59
+ };
60
+ return hasEntitlementDiscount(product.discount_list) || Array.isArray(product.product_bundle) && product.product_bundle.some(function (bundle) {
61
+ return hasEntitlementDiscount(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
62
+ });
63
+ }
55
64
 
56
65
  /** 订单行 bundle → booking other.bundle(保留 original_price 供 setProductPrice 按比例分摊) */
57
66
  function mapOrderBundleToOtherBundle(bundle) {
67
+ var preferManualPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
58
68
  return bundle.map(function (item) {
59
- var _ref, _ref2, _item$original_price, _ref3, _item$bundle_selling_, _item$original_total, _ref4, _item$num, _ref5, _item$quantity;
69
+ var _ref, _ref2, _item$original_price, _ref3, _item$price, _ref4, _item$bundle_selling_, _item$original_total, _ref5, _item$num, _ref6, _item$quantity;
60
70
  var catalogOriginal = (_ref = (_ref2 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref2 !== void 0 ? _ref2 : item.price) !== null && _ref !== void 0 ? _ref : item.bundle_selling_price;
61
- var selling = (_ref3 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref3 !== void 0 ? _ref3 : catalogOriginal;
71
+ var selling = preferManualPrice ? (_ref3 = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.bundle_selling_price) !== null && _ref3 !== void 0 ? _ref3 : catalogOriginal : (_ref4 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref4 !== void 0 ? _ref4 : catalogOriginal;
62
72
  var _omitBundleSelling = item.bundle_selling_price,
63
73
  rest = _objectWithoutProperties(item, _excluded);
64
74
  var isMarkupOrMarkdown = (item.price_type === 'markdown' || item.price_type === 'markup') && (item.price_type_ext === '' || item.price_type_ext === undefined || item.price_type_ext === null);
@@ -69,13 +79,13 @@ function mapOrderBundleToOtherBundle(bundle) {
69
79
  }, isMarkupOrMarkdown ? {} : {
70
80
  original_total: (_item$original_total = item.original_total) !== null && _item$original_total !== void 0 ? _item$original_total : catalogOriginal
71
81
  }), {}, {
72
- num: (_ref4 = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.quantity) !== null && _ref4 !== void 0 ? _ref4 : 1,
73
- quantity: (_ref5 = (_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : item.num) !== null && _ref5 !== void 0 ? _ref5 : 1
82
+ num: (_ref5 = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.quantity) !== null && _ref5 !== void 0 ? _ref5 : 1,
83
+ quantity: (_ref6 = (_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : item.num) !== null && _ref6 !== void 0 ? _ref6 : 1
74
84
  });
75
85
  });
76
86
  }
77
87
  export function buildNormalProductCacheItemFromOrderLine(input) {
78
- var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _ref7, _cover, _price3, _product$order_detail, _product$product_sku;
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;
79
89
  var product = input.product,
80
90
  sourceProduct = input.sourceProduct;
81
91
  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;
@@ -83,9 +93,11 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
83
93
  var selling = Number((_product$selling_pric2 = product.selling_price) !== null && _product$selling_pric2 !== void 0 ? _product$selling_pric2 : 0);
84
94
  var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
85
95
  var uid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
86
- var option = getProductSkuOptions(product);
87
- var bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : []);
88
96
  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;
97
+ 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
+ var hasPriceOverride = (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined || shouldPreserveEntitlementPriceOverride;
99
+ var option = getProductSkuOptions(product);
100
+ var bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [], shouldPreserveEntitlementPriceOverride);
89
101
  var productOptionString = buildProductOptionStringFromOrderLine(product);
90
102
  var discountList = product.discount_list || [];
91
103
  var other = {
@@ -114,12 +126,12 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
114
126
  _skuValue: JSON.parse(JSON.stringify(skuValue)),
115
127
  isNormalProduct: true,
116
128
  metadata: {
117
- product_add_schedule_time: (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.product_add_schedule_time
129
+ product_add_schedule_time: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.product_add_schedule_time
118
130
  }
119
131
  }, productOptionString ? {
120
132
  product_option_string: productOptionString
121
- } : {}), (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined ? {
122
- priceOverride: originExtend.priceOverride
133
+ } : {}), hasPriceOverride ? {
134
+ priceOverride: shouldPreserveEntitlementPriceOverride ? (_originExtend$priceOv = originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== null && _originExtend$priceOv !== void 0 ? _originExtend$priceOv : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.price_override : originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride
123
135
  } : {}), (originExtend === null || originExtend === void 0 ? void 0 : originExtend.bundle_edit) !== undefined ? {
124
136
  bundle_edit: originExtend.bundle_edit
125
137
  } : {});
@@ -131,8 +143,8 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
131
143
  id: resolvedId,
132
144
  product_id: resolvedId,
133
145
  _id: uid,
134
- title: (_ref6 = (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : product.product_title) !== null && _ref6 !== void 0 ? _ref6 : '',
135
- cover: (_ref7 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref7 !== void 0 ? _ref7 : '',
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 : '',
136
148
  price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
137
149
  selling_price: product.selling_price,
138
150
  original_price: product.original_price
@@ -197,7 +197,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
197
197
  url = '/franchisee/customer/select-list';
198
198
  }
199
199
  _params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, _otherParams = _objectWithoutProperties(params, _excluded);
200
- queryParams = _objectSpread(_objectSpread({
200
+ queryParams = _objectSpread(_objectSpread(_objectSpread({
201
201
  skip: skip,
202
202
  num: num,
203
203
  sort_by: SORT_BY,
@@ -206,7 +206,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
206
206
  search_wallet_pass_flag: 1
207
207
  }, search && {
208
208
  search: search
209
- }), _otherParams);
209
+ }), _otherParams), url === '/customer/select-list' ? {
210
+ with_franchisor_data: 1
211
+ } : {});
210
212
  _context2.next = 7;
211
213
  return this.request.get(url, queryParams, {
212
214
  cache: {
@@ -50,6 +50,8 @@ export interface ShopGetCustomerListParams {
50
50
  search_wallet_flag?: 0 | 1;
51
51
  /** wallet pass搜索标识 */
52
52
  search_wallet_pass_flag?: 0 | 1;
53
+ /** 是否查询连锁加盟组合店铺数据 */
54
+ with_franchisor_data?: boolean | 0 | 1;
53
55
  /** 其他筛选参数 */
54
56
  [key: string]: any;
55
57
  }
@@ -0,0 +1,34 @@
1
+ export declare const ENTITLEMENT_PASS_TYPE = "entitlement_pass";
2
+ export declare const GOOD_PASS_TYPE = "good_pass";
3
+ type DiscountLike = {
4
+ id?: number | string | null;
5
+ tag?: unknown;
6
+ type?: unknown;
7
+ discount?: object | null;
8
+ metadata?: object | null;
9
+ extension_data?: unknown;
10
+ balance?: unknown;
11
+ expire_time?: unknown;
12
+ };
13
+ export type EntitlementQuota = {
14
+ type: 'limited';
15
+ value: number;
16
+ balance: number;
17
+ } | {
18
+ type: 'unlimited';
19
+ value: null;
20
+ balance: null;
21
+ };
22
+ export declare function isEntitlementPass(discount: DiscountLike | null | undefined): boolean;
23
+ export declare function isFullCoveragePass(discount: DiscountLike | null | undefined): boolean;
24
+ /**
25
+ * Resolve the authoritative total-use contract for an Entitlement Pass.
26
+ * Invalid or missing configuration fails closed. Legacy mode/total_uses fields
27
+ * are intentionally unsupported.
28
+ */
29
+ export declare function resolveEntitlementQuota(discount: DiscountLike | null | undefined): EntitlementQuota | null;
30
+ export declare function getRemainingEntitlementUses(discount: DiscountLike | null | undefined, usedCount: number, requestedCount: number): number;
31
+ export declare function hasAvailableEntitlementUses(discount: DiscountLike | null | undefined): boolean;
32
+ /** Sort Entitlement Passes by expiry, finite balance, then card instance id. */
33
+ export declare function compareEntitlementPassPriority(left: DiscountLike, right: DiscountLike): number;
34
+ export {};
@@ -0,0 +1,147 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ 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); }
8
+ import dayjs from 'dayjs';
9
+ export var ENTITLEMENT_PASS_TYPE = 'entitlement_pass';
10
+ export var GOOD_PASS_TYPE = 'good_pass';
11
+ function getDiscountType(discount) {
12
+ var nestedDiscount = discount === null || discount === void 0 ? void 0 : discount.discount;
13
+ return String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || (nestedDiscount === null || nestedDiscount === void 0 ? void 0 : nestedDiscount.tag) || (nestedDiscount === null || nestedDiscount === void 0 ? void 0 : nestedDiscount.type) || '');
14
+ }
15
+ export function isEntitlementPass(discount) {
16
+ return getDiscountType(discount) === ENTITLEMENT_PASS_TYPE;
17
+ }
18
+ export function isFullCoveragePass(discount) {
19
+ var type = getDiscountType(discount);
20
+ return type === GOOD_PASS_TYPE || type === ENTITLEMENT_PASS_TYPE;
21
+ }
22
+ function resolveIncludedUses(discount) {
23
+ var _discount$extension_d;
24
+ var metadata = discount.metadata;
25
+ var hasMetadataIncludedUses = !!metadata && _typeof(metadata) === 'object' && Object.prototype.hasOwnProperty.call(metadata, 'included_uses');
26
+ var rawValue = hasMetadataIncludedUses ? metadata === null || metadata === void 0 ? void 0 : metadata.included_uses : Array.isArray(discount.extension_data) ? (_discount$extension_d = discount.extension_data.find(function (item) {
27
+ return (item === null || item === void 0 ? void 0 : item.field_key) === 'included_uses';
28
+ })) === null || _discount$extension_d === void 0 ? void 0 : _discount$extension_d.value : undefined;
29
+ if (!rawValue || _typeof(rawValue) !== 'object' || Array.isArray(rawValue)) {
30
+ return null;
31
+ }
32
+ var includedUses = rawValue;
33
+ if (includedUses.type === 'unlimited' && includedUses.value === null) {
34
+ return {
35
+ type: 'unlimited',
36
+ value: null
37
+ };
38
+ }
39
+ if (includedUses.type === 'limited' && typeof includedUses.value === 'number' && Number.isInteger(includedUses.value) && includedUses.value >= 1 && includedUses.value <= 9999) {
40
+ return {
41
+ type: 'limited',
42
+ value: includedUses.value
43
+ };
44
+ }
45
+ return null;
46
+ }
47
+ function resolveNonNegativeInteger(value) {
48
+ if (typeof value !== 'number' && typeof value !== 'string' || typeof value === 'string' && value.trim() === '') {
49
+ return null;
50
+ }
51
+ var normalizedValue = Number(value);
52
+ if (!Number.isInteger(normalizedValue) || normalizedValue < 0) return null;
53
+ return normalizedValue;
54
+ }
55
+
56
+ /**
57
+ * Resolve the authoritative total-use contract for an Entitlement Pass.
58
+ * Invalid or missing configuration fails closed. Legacy mode/total_uses fields
59
+ * are intentionally unsupported.
60
+ */
61
+ export function resolveEntitlementQuota(discount) {
62
+ if (!isEntitlementPass(discount)) return null;
63
+ var includedUses = resolveIncludedUses(discount);
64
+ if (!includedUses) return null;
65
+ if (includedUses.type === 'unlimited') {
66
+ return {
67
+ type: 'unlimited',
68
+ value: null,
69
+ balance: null
70
+ };
71
+ }
72
+ var balance = resolveNonNegativeInteger(discount === null || discount === void 0 ? void 0 : discount.balance);
73
+ if (balance === null) return null;
74
+ return {
75
+ type: 'limited',
76
+ value: includedUses.value,
77
+ balance: balance
78
+ };
79
+ }
80
+ export function getRemainingEntitlementUses(discount, usedCount, requestedCount) {
81
+ var quota = resolveEntitlementQuota(discount);
82
+ var normalizedRequestedCount = Math.max(Math.floor(Number(requestedCount) || 0), 0);
83
+ if (!quota || normalizedRequestedCount <= 0) return 0;
84
+ if (quota.type === 'unlimited') return normalizedRequestedCount;
85
+ var normalizedUsedCount = Math.max(Math.floor(Number(usedCount) || 0), 0);
86
+ return Math.min(Math.max(quota.balance - normalizedUsedCount, 0), normalizedRequestedCount);
87
+ }
88
+ export function hasAvailableEntitlementUses(discount) {
89
+ var quota = resolveEntitlementQuota(discount);
90
+ return !!quota && (quota.type === 'unlimited' || quota.balance > 0);
91
+ }
92
+ function resolveExpireTimestamp(value) {
93
+ if (typeof value !== 'string' || !value.trim()) return Number.POSITIVE_INFINITY;
94
+ var normalizedValue = value.trim();
95
+ var calendarParts = normalizedValue.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/);
96
+ if (calendarParts) {
97
+ var _calendarParts = _slicedToArray(calendarParts, 7),
98
+ year = _calendarParts[1],
99
+ month = _calendarParts[2],
100
+ day = _calendarParts[3],
101
+ _calendarParts$ = _calendarParts[4],
102
+ hour = _calendarParts$ === void 0 ? '0' : _calendarParts$,
103
+ _calendarParts$2 = _calendarParts[5],
104
+ minute = _calendarParts$2 === void 0 ? '0' : _calendarParts$2,
105
+ _calendarParts$3 = _calendarParts[6],
106
+ second = _calendarParts$3 === void 0 ? '0' : _calendarParts$3;
107
+ var yearNumber = Number(year);
108
+ var monthNumber = Number(month);
109
+ var dayNumber = Number(day);
110
+ var hourNumber = Number(hour);
111
+ var minuteNumber = Number(minute);
112
+ var secondNumber = Number(second);
113
+ var daysInMonth = new Date(Date.UTC(yearNumber, monthNumber, 0)).getUTCDate();
114
+ if (yearNumber <= 0 || monthNumber < 1 || monthNumber > 12 || dayNumber < 1 || dayNumber > daysInMonth || hourNumber < 0 || hourNumber > 23 || minuteNumber < 0 || minuteNumber > 59 || secondNumber < 0 || secondNumber > 59) {
115
+ return Number.POSITIVE_INFINITY;
116
+ }
117
+ }
118
+ var date = dayjs(normalizedValue);
119
+ return date.isValid() ? date.valueOf() : Number.POSITIVE_INFINITY;
120
+ }
121
+ function compareIds(left, right) {
122
+ var leftNumber = Number(left);
123
+ var rightNumber = Number(right);
124
+ if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {
125
+ return leftNumber - rightNumber;
126
+ }
127
+ return String(left !== null && left !== void 0 ? left : '').localeCompare(String(right !== null && right !== void 0 ? right : ''), undefined, {
128
+ numeric: true
129
+ });
130
+ }
131
+
132
+ /** Sort Entitlement Passes by expiry, finite balance, then card instance id. */
133
+ export function compareEntitlementPassPriority(left, right) {
134
+ var expireDifference = resolveExpireTimestamp(left.expire_time) - resolveExpireTimestamp(right.expire_time);
135
+ if (!Number.isNaN(expireDifference) && expireDifference !== 0) {
136
+ return expireDifference;
137
+ }
138
+ var leftQuota = resolveEntitlementQuota(left);
139
+ var rightQuota = resolveEntitlementQuota(right);
140
+ var leftBalance = (leftQuota === null || leftQuota === void 0 ? void 0 : leftQuota.type) === 'limited' ? leftQuota.balance : Number.POSITIVE_INFINITY;
141
+ var rightBalance = (rightQuota === null || rightQuota === void 0 ? void 0 : rightQuota.type) === 'limited' ? rightQuota.balance : Number.POSITIVE_INFINITY;
142
+ var balanceDifference = leftBalance - rightBalance;
143
+ if (!Number.isNaN(balanceDifference) && balanceDifference !== 0) {
144
+ return balanceDifference;
145
+ }
146
+ return compareIds(left.id, right.id);
147
+ }
@@ -26,6 +26,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
26
26
  with_available_wallet_flag?: 0 | 1;
27
27
  with_available_wallet_pass_flag?: 0 | 1;
28
28
  with_virtual_currency?: 0 | 1;
29
+ with_entitlement_pass?: 0 | 1;
29
30
  request_timezone: string;
30
31
  order_id?: number | string;
31
32
  }): Promise<DiscountPrepareConfigResult>;
@@ -36,6 +37,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
36
37
  }): Promise<DiscountWithReason>;
37
38
  batchSearchByProductIds(productIds: number[]): Promise<any>;
38
39
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
40
+ private hasAvailableBalance;
39
41
  private checkUsageCreditsLimit;
40
42
  filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
41
43
  private checkUsageCreditsLimitWithFailKey;
@@ -29,6 +29,7 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
29
29
  import { BaseModule } from "../BaseModule";
30
30
  import { DiscountHooks } from "./types";
31
31
  import Decimal from 'decimal.js';
32
+ import { hasAvailableEntitlementUses, isEntitlementPass } from "./entitlementPass";
32
33
  export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
33
34
  _inherits(DiscountModule, _BaseModule);
34
35
  var _super = _createSuper(DiscountModule);
@@ -165,8 +166,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
165
166
  key: "loadPrepareConfig",
166
167
  value: function () {
167
168
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
168
- var _params$with_availabl, _params$with_availabl2, _params$with_virtual_, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6;
169
- var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, virtualCurrencyList, goodPassList;
169
+ var _params$with_availabl, _params$with_availabl2, _params$with_virtual_, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6, _prepareConfig$data7;
170
+ var prepareConfig, rawEntitlementPassList, entitlementPassList, entitlementPassIds, excludeEntitlementDuplicates, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, virtualCurrencyList, goodPassList;
170
171
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
171
172
  while (1) switch (_context4.prev = _context4.next) {
172
173
  case 0:
@@ -181,15 +182,28 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
181
182
  }));
182
183
  case 3:
183
184
  prepareConfig = _context4.sent;
184
- rawDiscountList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []));
185
- availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.available_wallet_list) || []));
186
- availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_pass_list) || [];
185
+ rawEntitlementPassList = prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.entitlement_pass_list;
186
+ entitlementPassList = Array.isArray(rawEntitlementPassList) ? rawEntitlementPassList : [];
187
+ entitlementPassIds = new Set(entitlementPassList.map(function (discount) {
188
+ return discount === null || discount === void 0 ? void 0 : discount.id;
189
+ }).filter(function (id) {
190
+ return id !== undefined && id !== null;
191
+ }).map(function (id) {
192
+ return String(id);
193
+ }));
194
+ excludeEntitlementDuplicates = function excludeEntitlementDuplicates(discount) {
195
+ var id = discount === null || discount === void 0 ? void 0 : discount.id;
196
+ return id === undefined || id === null || !entitlementPassIds.has(String(id));
197
+ };
198
+ rawDiscountList = [].concat(_toConsumableArray(entitlementPassList), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.good_pass_list) || []).filter(excludeEntitlementDuplicates)), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.discount_card_list) || []).filter(excludeEntitlementDuplicates)));
199
+ availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_list) || []));
200
+ availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.available_wallet_pass_list) || [];
187
201
  availableWalletIds = this.normalizePositiveNumberIds([].concat(_toConsumableArray(availableWalletList.map(function (item) {
188
202
  return item === null || item === void 0 ? void 0 : item.wallet_id;
189
203
  })), _toConsumableArray(availableWalletPassList.map(function (item) {
190
204
  return item === null || item === void 0 ? void 0 : item.product_id;
191
205
  }))));
192
- virtualCurrencyList = this.normalizeVirtualCurrencyList(prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.virtual_currency_list);
206
+ virtualCurrencyList = this.normalizeVirtualCurrencyList(prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data7 = prepareConfig.data) === null || _prepareConfig$data7 === void 0 ? void 0 : _prepareConfig$data7.virtual_currency_list);
193
207
  goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
194
208
  return _context4.abrupt("return", {
195
209
  discountList: goodPassList,
@@ -199,7 +213,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
199
213
  return _objectSpread({}, item || {});
200
214
  })
201
215
  });
202
- case 11:
216
+ case 15:
203
217
  case "end":
204
218
  return _context4.stop();
205
219
  }
@@ -253,7 +267,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
253
267
  return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
254
268
  code: code,
255
269
  translate_flag: 1,
256
- tags: ['good_pass', 'product_discount_card'],
270
+ tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
257
271
  // available: 1,
258
272
  relation_product: 1,
259
273
  with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
@@ -292,8 +306,11 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
292
306
  return this.request.get("/machinecode/batch-search", {
293
307
  ids: productIds,
294
308
  translate_flag: 1,
295
- tags: ['good_pass', 'product_discount_card'],
296
- relation_product: 1
309
+ tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
310
+ relation_product: 1,
311
+ with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
312
+ unified_status_info_flag: 1,
313
+ request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
297
314
  });
298
315
  case 2:
299
316
  result = _context6.sent;
@@ -314,9 +331,19 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
314
331
  value: function filterEnabledDiscountList(discountList) {
315
332
  var _this2 = this;
316
333
  return discountList.filter(function (discount) {
317
- return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
334
+ return discount.limit_status === 'enable' && _this2.hasAvailableBalance(discount) && _this2.checkUsageCreditsLimit(discount);
318
335
  });
319
336
  }
337
+ }, {
338
+ key: "hasAvailableBalance",
339
+ value: function hasAvailableBalance(discount) {
340
+ if (isEntitlementPass(discount)) {
341
+ return hasAvailableEntitlementUses(discount);
342
+ }
343
+
344
+ // good_pass 与折扣卡继续沿用原有金额余额判断。
345
+ return new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
346
+ }
320
347
 
321
348
  // 检查使用次数限制
322
349
  }, {
@@ -385,8 +412,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
385
412
  var lists = discountList.filter(function (discount) {
386
413
  return discount.limit_status === 'enable';
387
414
  }).filter(function (discount) {
388
- var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
389
- return remaining;
415
+ return _this3.hasAvailableBalance(discount);
390
416
  }).map(function (discount) {
391
417
  var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
392
418
  return _objectSpread(_objectSpread({}, discount), {}, {