@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
@@ -0,0 +1,205 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ 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); }
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ import { cloneDeep } from 'lodash-es';
15
+ import Decimal from 'decimal.js';
16
+ import { getDiscountLifecycleReason } from "./availability";
17
+ import { isEntitlementPass, resolveEntitlementQuota } from "./entitlementPass";
18
+ function getEntitlementDiscountLines(product) {
19
+ var _product$_origin$prod, _product$_origin, _product$_originData, _ref, _product$discount_lis, _ref2, _ref3, _ref4, _product$product_bund, _product$_extend;
20
+ var nested = (_product$_origin$prod = product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.product) !== null && _product$_origin$prod !== void 0 ? _product$_origin$prod : product === null || product === void 0 || (_product$_originData = product._originData) === null || _product$_originData === void 0 ? void 0 : _product$_originData.product;
21
+ return [{
22
+ discount_list: (_ref = (_product$discount_lis = product === null || product === void 0 ? void 0 : product.discount_list) !== null && _product$discount_lis !== void 0 ? _product$discount_lis : nested === null || nested === void 0 ? void 0 : nested.discount_list) !== null && _ref !== void 0 ? _ref : []
23
+ }].concat(_toConsumableArray((_ref2 = (_ref3 = (_ref4 = (_product$product_bund = product === null || product === void 0 ? void 0 : product.product_bundle) !== null && _product$product_bund !== void 0 ? _product$product_bund : product === null || product === void 0 ? void 0 : product.bundle) !== null && _ref4 !== void 0 ? _ref4 : product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 || (_product$_extend = _product$_extend.other) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bundle) !== null && _ref3 !== void 0 ? _ref3 : nested === null || nested === void 0 ? void 0 : nested.product_bundle) !== null && _ref2 !== void 0 ? _ref2 : []));
24
+ }
25
+ export function hasEntitlementDiscount(product) {
26
+ return getEntitlementDiscountLines(product).some(function (line) {
27
+ return (line.discount_list || []).some(isEntitlementPass);
28
+ });
29
+ }
30
+ export function isPersistedEntitlementLine(product, mappedProduct) {
31
+ var _product$_origin$prod2, _product$_origin2, _product$_originData2, _product$_origin3, _product$_originData3, _product$_extend2, _product$metadata;
32
+ var nested = (_product$_origin$prod2 = product === null || product === void 0 || (_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.product) !== null && _product$_origin$prod2 !== void 0 ? _product$_origin$prod2 : product === null || product === void 0 || (_product$_originData2 = product._originData) === null || _product$_originData2 === void 0 ? void 0 : _product$_originData2.product;
33
+ var persisted = [product === null || product === void 0 ? void 0 : product.order_detail_id, product === null || product === void 0 ? void 0 : product.booking_id, product === null || product === void 0 || (_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.booking_id, product === null || product === void 0 || (_product$_originData3 = product._originData) === null || _product$_originData3 === void 0 ? void 0 : _product$_originData3.booking_id, product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.order_detail_id, nested === null || nested === void 0 ? void 0 : nested.order_detail_id, nested === null || nested === void 0 ? void 0 : nested.booking_id, mappedProduct === null || mappedProduct === void 0 ? void 0 : mappedProduct.order_detail_id, mappedProduct === null || mappedProduct === void 0 ? void 0 : mappedProduct.booking_id].some(function (value) {
34
+ return value !== undefined && value !== null && value !== '' && value !== 0 && value !== '0';
35
+ });
36
+ var lines = getEntitlementDiscountLines(mappedProduct !== null && mappedProduct !== void 0 ? mappedProduct : product);
37
+ // 已有预约上刚选的卡仍属本次使用,只有接口回传的明细才计入历史。
38
+ return lines.some(function (line) {
39
+ return (line.discount_list || []).some(isEntitlementPass);
40
+ }) && (persisted && (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.entitlement_source_identity) == null || lines.some(function (line) {
41
+ return (line.discount_list || []).some(function (item) {
42
+ return isEntitlementPass(item) && item.id;
43
+ });
44
+ }));
45
+ }
46
+
47
+ /** Refresh authoritative balances while retaining the user's scan/selection state. */
48
+ export function mergeEntitlementDiscountLists(current, incoming) {
49
+ var observed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : incoming;
50
+ var previous = new Map(current.map(function (item) {
51
+ return [String(item.id), item];
52
+ }));
53
+ var observedById = new Map(observed.map(function (item) {
54
+ return [String(item.id), item];
55
+ }));
56
+ var next = new Map();
57
+ current.filter(function (item) {
58
+ return item.isScan;
59
+ }).forEach(function (item) {
60
+ var fresh = observedById.get(String(item.id));
61
+ if (isEntitlementPass(item) && getDiscountLifecycleReason(fresh || item)) return;
62
+ next.set(String(item.id), item);
63
+ });
64
+ incoming.forEach(function (item) {
65
+ var old = previous.get(String(item.id));
66
+ if (old !== null && old !== void 0 && old.isScan && !isEntitlementPass(item)) return;
67
+ next.set(String(item.id), old && isEntitlementPass(item) ? _objectSpread(_objectSpread({}, item), {}, {
68
+ isScan: old.isScan,
69
+ isSelected: old.isSelected,
70
+ isManualSelect: old.isManualSelect
71
+ }) : item);
72
+ });
73
+ return _toConsumableArray(next.values());
74
+ }
75
+ export function retainScannedEntitlements(current, scanned) {
76
+ var result = new Map(current.map(function (item) {
77
+ return [String(item.id), item];
78
+ }));
79
+ scanned.filter(function (item) {
80
+ return isEntitlementPass(item) && !getDiscountLifecycleReason(item);
81
+ }).forEach(function (item) {
82
+ var previous = result.get(String(item.id));
83
+ var committed = item.committedAppliedProductDetails || (previous === null || previous === void 0 ? void 0 : previous.committedAppliedProductDetails) || [];
84
+ var isAvailable = !!item.isAvailable;
85
+ result.set(String(item.id), _objectSpread(_objectSpread({}, item), {}, {
86
+ isScan: true,
87
+ isAvailable: isAvailable,
88
+ isSelected: committed.length > 0,
89
+ reasonCode: isAvailable ? undefined : item.reasonCode || 'product_not_applicable',
90
+ committedAppliedProductDetails: committed,
91
+ appliedProductDetails: committed,
92
+ savedAmount: committed.length ? previous === null || previous === void 0 ? void 0 : previous.savedAmount : 0
93
+ }));
94
+ });
95
+ return _toConsumableArray(result.values());
96
+ }
97
+
98
+ /** Historical uses are display records; backend balance already excludes them. */
99
+ export function withCommittedEntitlementDetails(discounts, products, getProduct) {
100
+ var savedAmount = function savedAmount(details) {
101
+ return details.reduce(function (sum, detail) {
102
+ var _detail$discount;
103
+ return sum.plus(new Decimal(((_detail$discount = detail.discount) === null || _detail$discount === void 0 ? void 0 : _detail$discount.fixed_amount) || 0).times(detail._num));
104
+ }, new Decimal(0)).toNumber();
105
+ };
106
+ var committed = new Map();
107
+ var _iterator = _createForOfIteratorHelper(products),
108
+ _step;
109
+ try {
110
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
111
+ var origin = _step.value;
112
+ var product = getProduct(origin);
113
+ var persisted = isPersistedEntitlementLine(origin, product);
114
+ var lines = [product].concat(_toConsumableArray(product.bundle || []));
115
+ var bundleKeys = new Set((product.bundle || []).flatMap(function (line) {
116
+ return (line.discount_list || []).map(function (detail) {
117
+ var _detail$discount$reso, _detail$discount2, _detail$metadata;
118
+ return "".concat((_detail$discount$reso = (_detail$discount2 = detail.discount) === null || _detail$discount2 === void 0 ? void 0 : _detail$discount2.resource_id) !== null && _detail$discount$reso !== void 0 ? _detail$discount$reso : detail.id, ":").concat((_detail$metadata = detail.metadata) === null || _detail$metadata === void 0 ? void 0 : _detail$metadata.custom_product_bundle_map_id);
119
+ });
120
+ }));
121
+ var _iterator2 = _createForOfIteratorHelper(lines),
122
+ _step2;
123
+ try {
124
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
125
+ var line = _step2.value;
126
+ var _iterator3 = _createForOfIteratorHelper(line.discount_list || []),
127
+ _step3;
128
+ try {
129
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
130
+ var _detail$metadata2, _detail$discount$reso2, _detail$discount3, _ref5, _detail$discount$reso3, _detail$discount4, _ref6, _ref7, _detail$metadata$num, _detail$metadata3, _ref8, _product$quantity, _detail$discount$fixe, _detail$discount5;
131
+ var detail = _step3.value;
132
+ var bundleId = (_detail$metadata2 = detail.metadata) === null || _detail$metadata2 === void 0 ? void 0 : _detail$metadata2.custom_product_bundle_map_id;
133
+ if (!isEntitlementPass(detail) || !persisted && !detail.id || line === product && bundleId && bundleKeys.has("".concat((_detail$discount$reso2 = (_detail$discount3 = detail.discount) === null || _detail$discount3 === void 0 ? void 0 : _detail$discount3.resource_id) !== null && _detail$discount$reso2 !== void 0 ? _detail$discount$reso2 : detail.id, ":").concat(bundleId))) continue;
134
+ var id = (_ref5 = (_detail$discount$reso3 = (_detail$discount4 = detail.discount) === null || _detail$discount4 === void 0 ? void 0 : _detail$discount4.resource_id) !== null && _detail$discount$reso3 !== void 0 ? _detail$discount$reso3 : detail.resource_id) !== null && _ref5 !== void 0 ? _ref5 : detail.id;
135
+ if (id == null) continue;
136
+ var lineUses = Number((_ref6 = (_ref7 = (_detail$metadata$num = (_detail$metadata3 = detail.metadata) === null || _detail$metadata3 === void 0 ? void 0 : _detail$metadata3.num) !== null && _detail$metadata$num !== void 0 ? _detail$metadata$num : line.num) !== null && _ref7 !== void 0 ? _ref7 : line.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1);
137
+ if (!Number.isFinite(lineUses) || lineUses <= 0) continue;
138
+ var count = lineUses * (line === product && !bundleId ? 1 : Number((_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : 1));
139
+ var list = committed.get(String(id)) || [];
140
+ list.push(_objectSpread(_objectSpread({}, cloneDeep(detail)), {}, {
141
+ _num: count,
142
+ metadata: _objectSpread(_objectSpread({}, detail.metadata), {}, {
143
+ num: count
144
+ }),
145
+ discount: _objectSpread(_objectSpread({}, detail.discount), {}, {
146
+ fixed_amount: (_detail$discount$fixe = (_detail$discount5 = detail.discount) === null || _detail$discount5 === void 0 ? void 0 : _detail$discount5.fixed_amount) !== null && _detail$discount$fixe !== void 0 ? _detail$discount$fixe : new Decimal(detail.amount || 0).div(bundleId ? lineUses : 1).toNumber()
147
+ })
148
+ }));
149
+ committed.set(String(id), list);
150
+ }
151
+ } catch (err) {
152
+ _iterator3.e(err);
153
+ } finally {
154
+ _iterator3.f();
155
+ }
156
+ }
157
+ } catch (err) {
158
+ _iterator2.e(err);
159
+ } finally {
160
+ _iterator2.f();
161
+ }
162
+ }
163
+ } catch (err) {
164
+ _iterator.e(err);
165
+ } finally {
166
+ _iterator.f();
167
+ }
168
+ var next = discounts.map(function (item) {
169
+ if (!isEntitlementPass(item)) return item;
170
+ var details = committed.get(String(item.id)) || [];
171
+ committed.delete(String(item.id));
172
+ return _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
173
+ committedAppliedProductDetails: details,
174
+ isEditMode: details.length > 0 && !resolveEntitlementQuota(item)
175
+ }, item.isEditMode && resolveEntitlementQuota(item) ? {
176
+ isDisabled: false
177
+ } : {}), details.length && !resolveEntitlementQuota(item) ? {
178
+ isSelected: true,
179
+ isDisabled: true,
180
+ isUsed: true,
181
+ appliedProductDetails: details,
182
+ savedAmount: savedAmount(details)
183
+ } : {});
184
+ });
185
+ committed.forEach(function (details, id) {
186
+ var _first$discount;
187
+ var first = details[0];
188
+ next.push(_objectSpread(_objectSpread({}, first), {}, {
189
+ id: Number(id),
190
+ tag: 'entitlement_pass',
191
+ type: 'entitlement_pass',
192
+ format_title: (_first$discount = first.discount) === null || _first$discount === void 0 ? void 0 : _first$discount.title,
193
+ isEditMode: true,
194
+ isSelected: true,
195
+ isDisabled: true,
196
+ isUsed: true,
197
+ isAvailable: true,
198
+ committedAppliedProductDetails: details,
199
+ appliedProductDetails: details,
200
+ applicableProductDetails: [],
201
+ savedAmount: savedAmount(details)
202
+ }));
203
+ });
204
+ return next;
205
+ }
@@ -27,11 +27,14 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
27
27
  with_available_wallet_pass_flag?: 0 | 1;
28
28
  request_timezone: string;
29
29
  order_id?: number | string;
30
+ with_entitlement_pass?: 0 | 1;
31
+ filter_order_wallet_pass_usage?: 0 | 1;
30
32
  }): Promise<DiscountPrepareConfigResult>;
31
33
  private extractAvailableWalletIds;
32
- batchSearch(code: string, options?: {
34
+ batchSearch(code: string, customerIdOrOptions?: number | {
33
35
  customerId?: number;
34
- orderId?: number;
36
+ orderId?: number | string;
37
+ withEntitlementPass?: boolean;
35
38
  }): Promise<DiscountWithReason>;
36
39
  batchSearchByProductIds(productIds: number[]): Promise<any>;
37
40
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
@@ -1,4 +1,8 @@
1
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
7
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
8
  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); }
@@ -29,6 +33,8 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
29
33
  import { BaseModule } from "../BaseModule";
30
34
  import { DiscountHooks } from "./types";
31
35
  import Decimal from 'decimal.js';
36
+ import { isEntitlementPass } from "./entitlementPass";
37
+ import { getDiscountLifecycleReason, getDiscountUsageLimitFailKey } from "./availability";
32
38
  export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
33
39
  _inherits(DiscountModule, _BaseModule);
34
40
  var _super = _createSuper(DiscountModule);
@@ -165,8 +171,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
165
171
  key: "loadPrepareConfig",
166
172
  value: function () {
167
173
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
168
- var _params$with_availabl, _params$with_availabl2, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
169
- var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, goodPassList;
174
+ var _params$with_availabl, _params$with_availabl2, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6;
175
+ var prepareConfig, entitlementPassList, ids, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, goodPassList;
170
176
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
171
177
  while (1) switch (_context4.prev = _context4.next) {
172
178
  case 0:
@@ -180,20 +186,37 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
180
186
  }));
181
187
  case 3:
182
188
  prepareConfig = _context4.sent;
183
- 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) || []));
184
- 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) || []));
185
- availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_pass_list) || [];
189
+ entitlementPassList = params.with_entitlement_pass ? (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.entitlement_pass_list) || [] : [];
190
+ ids = new Set(entitlementPassList.map(function (item) {
191
+ return String(item.id);
192
+ }));
193
+ 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(function (item) {
194
+ return !ids.has(String(item.id));
195
+ })), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.discount_card_list) || []).filter(function (item) {
196
+ return !ids.has(String(item.id));
197
+ }))).filter(function (item) {
198
+ return params.with_entitlement_pass || !isEntitlementPass(item);
199
+ });
200
+ 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) || []));
201
+ availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.available_wallet_pass_list) || [];
186
202
  availableWalletIds = this.normalizePositiveNumberIds([].concat(_toConsumableArray(availableWalletList.map(function (item) {
187
203
  return item === null || item === void 0 ? void 0 : item.wallet_id;
188
204
  })), _toConsumableArray(availableWalletPassList.map(function (item) {
189
205
  return item === null || item === void 0 ? void 0 : item.product_id;
190
206
  }))));
207
+ if (!params.with_entitlement_pass) {
208
+ _context4.next = 13;
209
+ break;
210
+ }
211
+ _context4.next = 13;
212
+ return this.setOriginalDiscountList(rawDiscountList);
213
+ case 13:
191
214
  goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
192
215
  return _context4.abrupt("return", {
193
216
  discountList: goodPassList,
194
217
  availableWalletIds: this.extractAvailableWalletIds(prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.data)
195
218
  });
196
- case 10:
219
+ case 15:
197
220
  case "end":
198
221
  return _context4.stop();
199
222
  }
@@ -224,18 +247,22 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
224
247
  }, {
225
248
  key: "batchSearch",
226
249
  value: function () {
227
- var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
228
- var _ref, customerId, orderId, result, resultDiscountWithReason;
250
+ var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerIdOrOptions) {
251
+ var _this2 = this,
252
+ _entitlement$value,
253
+ _legacy$value;
254
+ var _ref, customerId, orderId, withEntitlementPass, params, _result, search, _yield$Promise$all, _yield$Promise$all2, legacy, entitlement, entitlementList, legacyList, ids, result;
229
255
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
230
256
  while (1) switch (_context5.prev = _context5.next) {
231
257
  case 0:
232
- _ref = options || {}, customerId = _ref.customerId, orderId = _ref.orderId;
233
- _context5.next = 3;
234
- return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
258
+ _ref = typeof customerIdOrOptions === 'number' ? {
259
+ customerId: customerIdOrOptions,
260
+ orderId: undefined,
261
+ withEntitlementPass: false
262
+ } : customerIdOrOptions || {}, customerId = _ref.customerId, orderId = _ref.orderId, withEntitlementPass = _ref.withEntitlementPass;
263
+ params = _objectSpread(_objectSpread({
235
264
  code: code,
236
265
  translate_flag: 1,
237
- tags: ['good_pass', 'product_discount_card'],
238
- // available: 1,
239
266
  relation_product: 1,
240
267
  with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
241
268
  order_behavior_count: 1,
@@ -245,12 +272,75 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
245
272
  order_behavior_count_order_id: orderId
246
273
  } : {}), {}, {
247
274
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
275
+ });
276
+ if (withEntitlementPass) {
277
+ _context5.next = 7;
278
+ break;
279
+ }
280
+ _context5.next = 5;
281
+ return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({}, params), {}, {
282
+ tags: ['good_pass', 'product_discount_card']
248
283
  }));
249
- case 3:
250
- result = _context5.sent;
251
- resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result === null || result === void 0 ? void 0 : result.data) || []) || [];
252
- return _context5.abrupt("return", resultDiscountWithReason);
253
- case 6:
284
+ case 5:
285
+ _result = _context5.sent;
286
+ return _context5.abrupt("return", this.filterEnabledDiscountListWithReason(((_result === null || _result === void 0 ? void 0 : _result.data) || []).filter(function (item) {
287
+ return !isEntitlementPass(item);
288
+ })));
289
+ case 7:
290
+ // 保留 develop 的旧券查询参数,多次卡单独查询并携带跨店状态。
291
+ search = function search(query) {
292
+ return _this2.request.get("/machinecode/batch-search", query).then(function (value) {
293
+ return {
294
+ status: 'fulfilled',
295
+ value: value
296
+ };
297
+ }, function (reason) {
298
+ return {
299
+ status: 'rejected',
300
+ reason: reason
301
+ };
302
+ });
303
+ };
304
+ _context5.next = 10;
305
+ return Promise.all([search(_objectSpread(_objectSpread({}, params), {}, {
306
+ tags: ['good_pass', 'product_discount_card']
307
+ })), search(_objectSpread(_objectSpread({}, params), {}, {
308
+ tags: ['entitlement_pass'],
309
+ with_franchisor_data: 1,
310
+ unified_status_info_flag: 1,
311
+ with: [].concat(_toConsumableArray(params.with), ['franchiseeWalletPass:shop_id,source_shop_id,product_id,use'])
312
+ }))]);
313
+ case 10:
314
+ _yield$Promise$all = _context5.sent;
315
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
316
+ legacy = _yield$Promise$all2[0];
317
+ entitlement = _yield$Promise$all2[1];
318
+ entitlementList = (entitlement.status === 'fulfilled' ? ((_entitlement$value = entitlement.value) === null || _entitlement$value === void 0 ? void 0 : _entitlement$value.data) || [] : []).filter(isEntitlementPass);
319
+ legacyList = legacy.status === 'fulfilled' ? ((_legacy$value = legacy.value) === null || _legacy$value === void 0 ? void 0 : _legacy$value.data) || [] : [];
320
+ ids = new Set(entitlementList.map(function (item) {
321
+ return String(item.id);
322
+ }));
323
+ result = this.filterEnabledDiscountListWithReason([].concat(_toConsumableArray(entitlementList), _toConsumableArray(legacyList.filter(function (item) {
324
+ return !isEntitlementPass(item) && !ids.has(String(item.id));
325
+ })))); // 任一类型查到可用卡即可继续,另一类型的查询失败不阻断该卡。
326
+ if (result.discountList.length) {
327
+ _context5.next = 23;
328
+ break;
329
+ }
330
+ if (!(legacy.status === 'rejected')) {
331
+ _context5.next = 21;
332
+ break;
333
+ }
334
+ throw legacy.reason;
335
+ case 21:
336
+ if (!(entitlement.status === 'rejected')) {
337
+ _context5.next = 23;
338
+ break;
339
+ }
340
+ throw entitlement.reason;
341
+ case 23:
342
+ return _context5.abrupt("return", result);
343
+ case 24:
254
344
  case "end":
255
345
  return _context5.stop();
256
346
  }
@@ -293,9 +383,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
293
383
  }, {
294
384
  key: "filterEnabledDiscountList",
295
385
  value: function filterEnabledDiscountList(discountList) {
296
- var _this2 = this;
386
+ var _this3 = this;
297
387
  return discountList.filter(function (discount) {
298
- 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);
388
+ return isEntitlementPass(discount) ? !getDiscountLifecycleReason(discount) : 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) && _this3.checkUsageCreditsLimit(discount);
299
389
  });
300
390
  }
301
391
 
@@ -362,14 +452,19 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
362
452
  }, {
363
453
  key: "filterEnabledDiscountListWithReason",
364
454
  value: function filterEnabledDiscountListWithReason(discountList) {
365
- var _this3 = this;
366
- var lists = discountList.filter(function (discount) {
455
+ var _this4 = this;
456
+ var entitlementPasses = discountList.filter(function (item) {
457
+ return isEntitlementPass(item) && !getDiscountLifecycleReason(item);
458
+ });
459
+ var lists = discountList.filter(function (item) {
460
+ return !isEntitlementPass(item);
461
+ }).filter(function (discount) {
367
462
  return discount.limit_status === 'enable';
368
463
  }).filter(function (discount) {
369
464
  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);
370
465
  return remaining;
371
466
  }).map(function (discount) {
372
- var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
467
+ var limitFailKey = _this4.checkUsageCreditsLimitWithFailKey(discount);
373
468
  return _objectSpread(_objectSpread({}, discount), {}, {
374
469
  usageLimitFailKey: limitFailKey
375
470
  });
@@ -384,8 +479,12 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
384
479
  return item.usageLimitFailKey;
385
480
  });
386
481
  return {
387
- discountList: availableLists,
388
- unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
482
+ discountList: [].concat(_toConsumableArray(entitlementPasses.map(function (item) {
483
+ return _objectSpread(_objectSpread({}, item), {}, {
484
+ usageLimitFailKey: getDiscountUsageLimitFailKey(item)
485
+ });
486
+ })), _toConsumableArray(availableLists)),
487
+ unavailableReasonKey: (currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey) || discountList.filter(isEntitlementPass).map(getDiscountLifecycleReason).find(Boolean) || null
389
488
  };
390
489
  }
391
490
 
@@ -45,6 +45,8 @@ interface ApplicableProductDetails {
45
45
  num: number;
46
46
  metadata?: {
47
47
  product_discount_difference?: number;
48
+ num?: number;
49
+ custom_product_bundle_map_id?: string;
48
50
  };
49
51
  discount?: {
50
52
  fixed_amount?: number;
@@ -63,10 +65,17 @@ interface UsageCreditsValue {
63
65
  max_per_week: number;
64
66
  max_per_month: number;
65
67
  }
66
- export declare type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
68
+ export type IncludedUses = {
69
+ type: 'limited';
70
+ value: number;
71
+ } | {
72
+ type: 'unlimited';
73
+ value: null;
74
+ };
75
+ export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
76
  export interface DiscountWithReason {
68
77
  discountList: Discount[];
69
- unavailableReasonKey: DiscountFilterRejectKey | null;
78
+ unavailableReasonKey: DiscountFilterRejectKey | string | null;
70
79
  }
71
80
  export interface DiscountPrepareConfigResult {
72
81
  discountList: Discount[];
@@ -97,20 +106,34 @@ export interface Discount {
97
106
  used_par_value: string;
98
107
  limit_status: string;
99
108
  limited_relation_product_data: Limitedrelationproductdata;
100
- balance: string;
109
+ balance?: string | number | null;
101
110
  format_title: Formattitle;
102
111
  metadata?: {
103
112
  num?: number;
104
113
  discount_card_type?: 'fixed_amount' | 'percent';
105
114
  custom_product_bundle_map_id?: string;
106
115
  validity_type?: "custom_schedule_validity" | "fixed_validity";
107
- discount_calculation_mode: 'item_level' | 'order_level';
108
- holder: {
116
+ included_uses?: IncludedUses;
117
+ discount_calculation_mode?: 'item_level' | 'order_level';
118
+ holder?: {
109
119
  type: "customer" | "custom";
110
120
  };
111
121
  };
112
122
  product: Product;
113
- type: "product" | 'good_pass';
123
+ type: 'product' | 'good_pass' | 'entitlement_pass' | 'discount_card' | 'product_discount_card';
124
+ shop_id?: number;
125
+ holder?: {
126
+ holder_type?: string;
127
+ holder_id?: number | string | Array<number | string>;
128
+ [key: string]: any;
129
+ };
130
+ reason?: string;
131
+ reasonCode?: string;
132
+ is_franchisor_pass?: number;
133
+ franchisee_wallet_pass?: {
134
+ use?: string;
135
+ };
136
+ committedAppliedProductDetails?: ApplicableProductDetails[];
114
137
  resource_id?: number;
115
138
  savedAmount?: number;
116
139
  isEditMode?: boolean;
@@ -39,7 +39,7 @@ export interface IFormItemData {
39
39
  /**
40
40
  * form_id 为 key 的 map 结构,如 948: { records: [], form: {} }
41
41
  */
42
- export declare type HolderFormMap = Record<string, IFormItemData>;
42
+ export type HolderFormMap = Record<string, IFormItemData>;
43
43
  /**
44
44
  * Holder 模块 reactive store,仅 holderMap 会触发 changed 事件
45
45
  */
@@ -61,7 +61,7 @@ export interface OpenDataApiResponse {
61
61
  message: string;
62
62
  data: OpenDataConfig;
63
63
  }
64
- export declare type OpenDataUnavailableReason = 'shop_disabled' | 'paused' | 'closed' | 'reservation_disabled';
64
+ export type OpenDataUnavailableReason = 'shop_disabled' | 'paused' | 'closed' | 'reservation_disabled';
65
65
  export interface OpenDataAvailabilityResult {
66
66
  available: boolean;
67
67
  reason: OpenDataUnavailableReason | null;
@@ -69,7 +69,7 @@ export interface OrderGiftSelectResult {
69
69
  *
70
70
  * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
71
71
  */
72
- export declare type OrderGiftSelectResolver = (ctx: OrderGiftSelectContext) => Promise<Partial<OrderProduct>[] | OrderGiftSelectResult | null>;
72
+ export type OrderGiftSelectResolver = (ctx: OrderGiftSelectContext) => Promise<Partial<OrderProduct>[] | OrderGiftSelectResult | null>;
73
73
  /** 未满足的促销策略(购物车底部 alert 渲染源) */
74
74
  export interface OrderUnfulfilledPromotion {
75
75
  strategyId: string;
@@ -318,7 +318,7 @@ export interface ReplaceTempOrderOptions {
318
318
  persist?: boolean;
319
319
  saveDraft?: boolean;
320
320
  }
321
- export declare type AddProductBookingInput = Record<string, any>;
321
+ export type AddProductBookingInput = Record<string, any>;
322
322
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
323
323
  export interface UpdateOrderProductParams {
324
324
  product_id: number | null;
@@ -376,7 +376,7 @@ export interface OrderProductMergeDecisionContext {
376
376
  booking?: AddProductBookingInput;
377
377
  defaultShouldMerge: boolean;
378
378
  }
379
- export declare type OrderProductMergeDecisionResult = boolean | {
379
+ export type OrderProductMergeDecisionResult = boolean | {
380
380
  shouldMerge: boolean;
381
381
  reason?: string;
382
382
  [key: string]: any;
@@ -524,11 +524,11 @@ export interface OrderPaymentData {
524
524
  created_at?: string;
525
525
  updated_at?: string;
526
526
  }
527
- export declare type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
527
+ export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
528
528
  export interface MapOrderPaymentsOptions {
529
529
  includeVoided?: boolean;
530
530
  }
531
- export declare type OrderSyncState = 'local' | 'submitting' | 'submitted' | 'failed' | 'remoteLoaded';
531
+ export type OrderSyncState = 'local' | 'submitting' | 'submitted' | 'failed' | 'remoteLoaded';
532
532
  export interface LoadSalesDetailParams {
533
533
  orderId?: number | string;
534
534
  orderNumber?: string;
@@ -1,5 +1,5 @@
1
1
  import type { OrderProductDiscountItem } from '../types';
2
- declare type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
2
+ type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
3
3
  export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
4
4
  export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
5
5
  export {};
@@ -1,4 +1,4 @@
1
- export declare type OrderCollectionKind = 'product' | 'booking' | 'payment';
1
+ export type OrderCollectionKind = 'product' | 'booking' | 'payment';
2
2
  export interface OrderCollectionIdentityStats {
3
3
  backfilledUidCount: number;
4
4
  collapsedDuplicateCount: number;
@@ -209,7 +209,7 @@ export interface SubmitPayloadEnhancerContext {
209
209
  bookingUuid: string;
210
210
  now: Date;
211
211
  }
212
- export declare type SubmitPayloadEnhancer = (payload: OrderSubmitPayload, ctx: SubmitPayloadEnhancerContext) => OrderSubmitPayload;
212
+ export type SubmitPayloadEnhancer = (payload: OrderSubmitPayload, ctx: SubmitPayloadEnhancerContext) => OrderSubmitPayload;
213
213
  export declare function buildSubmitPayload(params: {
214
214
  tempOrder: OrderTempOrder;
215
215
  cacheId?: string;