@pisell/pisellos 2.2.302 → 2.2.304

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 (157) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  3. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  4. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  5. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  6. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  7. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  8. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  9. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
  12. package/dist/modules/Discount/index.d.ts +2 -0
  13. package/dist/modules/Discount/index.js +41 -5
  14. package/dist/modules/Discount/types.d.ts +21 -0
  15. package/dist/modules/OpenData/index.d.ts +15 -2
  16. package/dist/modules/OpenData/index.js +307 -19
  17. package/dist/modules/OpenData/types.d.ts +55 -0
  18. package/dist/modules/OpenData/types.js +7 -1
  19. package/dist/modules/OpenData/utils.d.ts +21 -1
  20. package/dist/modules/OpenData/utils.js +138 -0
  21. package/dist/modules/Order/index.d.ts +50 -7
  22. package/dist/modules/Order/index.js +1690 -815
  23. package/dist/modules/Order/salesNotes.d.ts +31 -0
  24. package/dist/modules/Order/salesNotes.js +492 -0
  25. package/dist/modules/Order/types.d.ts +117 -10
  26. package/dist/modules/Order/types.js +6 -1
  27. package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
  28. package/dist/modules/Order/utils/virtualSettlement.js +284 -0
  29. package/dist/modules/Order/utils.d.ts +5 -1
  30. package/dist/modules/Order/utils.js +138 -33
  31. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  32. package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
  33. package/dist/modules/Payment/walletpass.js +20 -21
  34. package/dist/modules/Product/types.d.ts +23 -0
  35. package/dist/modules/ProductList/index.d.ts +2 -1
  36. package/dist/modules/ProductList/index.js +100 -20
  37. package/dist/modules/ProductList/types.d.ts +10 -0
  38. package/dist/modules/Rules/index.d.ts +5 -0
  39. package/dist/modules/Rules/index.js +30 -14
  40. package/dist/modules/SalesSummary/index.d.ts +1 -0
  41. package/dist/modules/SalesSummary/index.js +4 -3
  42. package/dist/modules/SalesSummary/types.d.ts +1 -0
  43. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  44. package/dist/modules/SalesSummary/utils.js +21 -1
  45. package/dist/plugins/request.d.ts +2 -1
  46. package/dist/plugins/request.js +4 -2
  47. package/dist/server/index.d.ts +21 -0
  48. package/dist/server/index.js +1774 -1285
  49. package/dist/server/modules/order/types.d.ts +50 -0
  50. package/dist/server/modules/order/types.js +2 -0
  51. package/dist/server/utils/small-ticket.d.ts +4 -1
  52. package/dist/server/utils/small-ticket.js +461 -96
  53. package/dist/solution/BaseSales/index.d.ts +24 -3
  54. package/dist/solution/BaseSales/index.js +1484 -873
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  56. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  58. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
  59. package/dist/solution/BookingByStep/index.d.ts +1 -1
  60. package/dist/solution/BookingTicket/index.d.ts +22 -5
  61. package/dist/solution/BookingTicket/index.js +558 -443
  62. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  63. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  64. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  65. package/dist/solution/RegisterAndLogin/config.js +95 -40
  66. package/dist/solution/RegisterAndLogin/index.js +4 -1
  67. package/dist/solution/Sales/index.d.ts +16 -1
  68. package/dist/solution/Sales/index.js +338 -63
  69. package/dist/solution/Sales/types.d.ts +10 -0
  70. package/dist/solution/ScanOrder/index.d.ts +1 -0
  71. package/dist/solution/ScanOrder/index.js +31 -27
  72. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  73. package/dist/solution/ScanOrder/utils.js +2 -0
  74. package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
  75. package/dist/solution/UnifiedBookingSales/index.js +874 -527
  76. package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
  77. package/dist/solution/VenueBooking/index.d.ts +1 -0
  78. package/dist/solution/VenueBooking/index.js +8 -4
  79. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  80. package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
  81. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  82. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  83. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  84. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  85. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  86. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  87. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  88. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  89. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
  90. package/lib/modules/Discount/index.d.ts +2 -0
  91. package/lib/modules/Discount/index.js +34 -2
  92. package/lib/modules/Discount/types.d.ts +21 -0
  93. package/lib/modules/OpenData/index.d.ts +15 -2
  94. package/lib/modules/OpenData/index.js +230 -3
  95. package/lib/modules/OpenData/types.d.ts +55 -0
  96. package/lib/modules/OpenData/types.js +9 -1
  97. package/lib/modules/OpenData/utils.d.ts +21 -1
  98. package/lib/modules/OpenData/utils.js +126 -0
  99. package/lib/modules/Order/index.d.ts +50 -7
  100. package/lib/modules/Order/index.js +704 -64
  101. package/lib/modules/Order/salesNotes.d.ts +31 -0
  102. package/lib/modules/Order/salesNotes.js +382 -0
  103. package/lib/modules/Order/types.d.ts +117 -10
  104. package/lib/modules/Order/types.js +5 -1
  105. package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
  106. package/lib/modules/Order/utils/virtualSettlement.js +262 -0
  107. package/lib/modules/Order/utils.d.ts +5 -1
  108. package/lib/modules/Order/utils.js +127 -21
  109. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  110. package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
  111. package/lib/modules/Payment/walletpass.js +14 -11
  112. package/lib/modules/Product/types.d.ts +23 -0
  113. package/lib/modules/ProductList/index.d.ts +2 -1
  114. package/lib/modules/ProductList/index.js +47 -2
  115. package/lib/modules/ProductList/types.d.ts +10 -0
  116. package/lib/modules/Rules/index.d.ts +5 -0
  117. package/lib/modules/Rules/index.js +22 -12
  118. package/lib/modules/SalesSummary/index.d.ts +1 -0
  119. package/lib/modules/SalesSummary/index.js +4 -2
  120. package/lib/modules/SalesSummary/types.d.ts +1 -0
  121. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  122. package/lib/modules/SalesSummary/utils.js +17 -1
  123. package/lib/plugins/request.d.ts +2 -1
  124. package/lib/plugins/request.js +3 -2
  125. package/lib/server/index.d.ts +21 -0
  126. package/lib/server/index.js +492 -108
  127. package/lib/server/modules/order/types.d.ts +50 -0
  128. package/lib/server/modules/order/types.js +1 -0
  129. package/lib/server/utils/small-ticket.d.ts +4 -1
  130. package/lib/server/utils/small-ticket.js +427 -72
  131. package/lib/solution/BaseSales/index.d.ts +24 -3
  132. package/lib/solution/BaseSales/index.js +433 -30
  133. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  134. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  135. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  136. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
  137. package/lib/solution/BookingByStep/index.d.ts +1 -1
  138. package/lib/solution/BookingTicket/index.d.ts +22 -5
  139. package/lib/solution/BookingTicket/index.js +60 -15
  140. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
  141. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  142. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  143. package/lib/solution/RegisterAndLogin/config.js +49 -8
  144. package/lib/solution/RegisterAndLogin/index.js +4 -1
  145. package/lib/solution/Sales/index.d.ts +16 -1
  146. package/lib/solution/Sales/index.js +168 -1
  147. package/lib/solution/Sales/types.d.ts +10 -0
  148. package/lib/solution/ScanOrder/index.d.ts +1 -0
  149. package/lib/solution/ScanOrder/index.js +5 -1
  150. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  151. package/lib/solution/ScanOrder/utils.js +1 -0
  152. package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
  153. package/lib/solution/UnifiedBookingSales/index.js +169 -16
  154. package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
  155. package/lib/solution/VenueBooking/index.d.ts +1 -0
  156. package/lib/solution/VenueBooking/index.js +5 -1
  157. package/package.json +1 -1
@@ -8,10 +8,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
8
8
  * 现金支付推荐算法
9
9
  *
10
10
  * 核心原理:
11
- * 1. 每个推荐金额都应该是独立的最优组合
12
- * 2. 不推荐在已有最优解基础上添加额外面额的组合
13
- * 3. 优先推荐使用不同数量币种的组合
14
- * 4. 根据组合判断去重,避免扩展组合
11
+ * 1. 第一项始终是精确应付金额
12
+ * 2. 其余推荐只能是严格大于应付金额的真实币种面额
13
+ * 3. 最多推荐三个更高面额
15
14
  */
16
15
 
17
16
  /**
@@ -47,377 +46,28 @@ export var CURRENCY_DENOMINATIONS = {
47
46
  'DEFAULT': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01]
48
47
  };
49
48
 
50
- /**
51
- * 支付组合类型定义
52
- */
53
-
54
49
  /**
55
50
  * 最优支付金额推荐算法
56
- * 推荐通过不同数量面额组合刚好足够支付的最小金额
51
+ * 返回精确应付金额,以及最多三个更高的真实币种面额
57
52
  *
58
53
  * @param targetAmount 目标金额
59
54
  * @param denominations 币种面值数组
60
55
  * @returns 推荐支付金额数组
61
56
  */
62
57
  export function recommendOptimalPayments(targetAmount, denominations) {
63
- // 参数验证
64
- if (targetAmount <= 0 || !isFinite(targetAmount) || isNaN(targetAmount)) {
58
+ if (targetAmount <= 0 || !Number.isFinite(targetAmount)) {
65
59
  return [];
66
60
  }
67
- if (!denominations || !Array.isArray(denominations) || denominations.length === 0) {
68
- return [Math.ceil(targetAmount)];
69
- }
70
-
71
- // 过滤有效面额并限制搜索空间以提高性能
72
- var maxReasonableDenom = targetAmount * 5; // 适度限制搜索空间
73
- var validDenoms = denominations.filter(function (denom) {
74
- return denom > 0 && isFinite(denom) && !isNaN(denom) && denom <= maxReasonableDenom;
75
- }).slice(0, 8); // 限制面额数量以提高性能
76
-
77
- if (validDenoms.length === 0) {
78
- // 如果没有合适的面额,返回最接近的整数金额
79
- return [Math.ceil(targetAmount)];
80
- }
81
- try {
82
- // 处理精度问题,将金额转换为整数计算
83
- var precision = 100; // 假设最小单位是0.01
84
- var target = Math.round(targetAmount * precision);
85
- var denoms = validDenoms.map(function (d) {
86
- return Math.round(d * precision);
87
- }).sort(function (a, b) {
88
- return b - a;
89
- });
90
-
91
- // 存储不同的支付组合方案
92
- var paymentOptions = [];
93
-
94
- // 首先尝试找到精确匹配的组合
95
- var exactCombination = findExactCombination(target, denoms, precision);
96
- if (exactCombination) {
97
- paymentOptions.push(exactCombination);
98
- }
99
-
100
- // 为了提高效率,我们将按币种数量来生成组合
101
- // 1币种组合:只用一种面额
102
- for (var i = 0; i < Math.min(denoms.length, 6); i++) {
103
- var denom = denoms[i];
104
- var count = Math.ceil(target / denom);
105
- var sum = count * denom;
106
- if (sum >= target && count <= 12) {
107
- // 限制硬币数量以提高性能
108
- paymentOptions.push({
109
- combination: Array(count).fill(denom / precision),
110
- sum: sum / precision,
111
- coinCount: count,
112
- denomTypes: 1
113
- });
114
- }
115
- }
116
-
117
- // 2币种组合:使用两种面额(大幅限制搜索范围以提高性能)
118
- for (var _i = 0; _i < Math.min(denoms.length - 1, 5); _i++) {
119
- for (var j = _i + 1; j < Math.min(denoms.length, 6); j++) {
120
- var denom1 = denoms[_i];
121
- var denom2 = denoms[j];
122
-
123
- // 大幅限制搜索范围,基于目标金额动态调整
124
- var maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 8);
125
- var maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 10);
126
- for (var count1 = 1; count1 <= maxCount1; count1++) {
127
- for (var count2 = 1; count2 <= maxCount2; count2++) {
128
- var _sum = count1 * denom1 + count2 * denom2;
129
- if (_sum >= target) {
130
- var combination = [].concat(_toConsumableArray(Array(count1).fill(denom1 / precision)), _toConsumableArray(Array(count2).fill(denom2 / precision)));
131
- paymentOptions.push({
132
- combination: combination,
133
- sum: _sum / precision,
134
- coinCount: count1 + count2,
135
- denomTypes: 2
136
- });
137
- }
138
- }
139
- }
140
- }
141
- }
142
-
143
- // 3币种组合:使用三种面额(大幅限制搜索以提高效率)
144
- for (var _i2 = 0; _i2 < Math.min(denoms.length - 2, 3); _i2++) {
145
- for (var _j = _i2 + 1; _j < Math.min(denoms.length - 1, 4); _j++) {
146
- for (var k = _j + 1; k < Math.min(denoms.length, 5); k++) {
147
- var _denom = denoms[_i2];
148
- var _denom2 = denoms[_j];
149
- var denom3 = denoms[k];
150
-
151
- // 大幅限制搜索范围
152
- var _maxCount = Math.min(Math.ceil(target / _denom) + 1, 5);
153
- var _maxCount2 = Math.min(Math.ceil(target / _denom2) + 1, 6);
154
- var maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 8);
155
- for (var _count = 1; _count <= _maxCount; _count++) {
156
- for (var _count2 = 1; _count2 <= _maxCount2; _count2++) {
157
- for (var count3 = 1; count3 <= maxCount3; count3++) {
158
- var _sum2 = _count * _denom + _count2 * _denom2 + count3 * denom3;
159
- if (_sum2 >= target) {
160
- var _combination = [].concat(_toConsumableArray(Array(_count).fill(_denom / precision)), _toConsumableArray(Array(_count2).fill(_denom2 / precision)), _toConsumableArray(Array(count3).fill(denom3 / precision)));
161
- paymentOptions.push({
162
- combination: _combination,
163
- sum: _sum2 / precision,
164
- coinCount: _count + _count2 + count3,
165
- denomTypes: 3
166
- });
167
- }
168
- }
169
- }
170
- }
171
- }
172
- }
173
- }
174
-
175
- // 4币种组合:使用四种面额(极度限制搜索以提高性能)
176
- for (var _i3 = 0; _i3 < Math.min(denoms.length - 3, 2); _i3++) {
177
- for (var _j2 = _i3 + 1; _j2 < Math.min(denoms.length - 2, 3); _j2++) {
178
- for (var _k = _j2 + 1; _k < Math.min(denoms.length - 1, 4); _k++) {
179
- for (var l = _k + 1; l < Math.min(denoms.length, 5); l++) {
180
- var _denom3 = denoms[_i3];
181
- var _denom4 = denoms[_j2];
182
- var _denom5 = denoms[_k];
183
- var denom4 = denoms[l];
184
-
185
- // 极度限制搜索范围
186
- var _maxCount3 = Math.min(Math.ceil(target / _denom3) + 1, 3);
187
- var _maxCount4 = Math.min(Math.ceil(target / _denom4) + 1, 4);
188
- var _maxCount5 = Math.min(Math.ceil(target / _denom5) + 1, 5);
189
- var maxCount4 = Math.min(Math.ceil(target / denom4) + 1, 6);
190
- for (var _count3 = 1; _count3 <= _maxCount3; _count3++) {
191
- for (var _count4 = 1; _count4 <= _maxCount4; _count4++) {
192
- for (var _count5 = 1; _count5 <= _maxCount5; _count5++) {
193
- for (var count4 = 1; count4 <= maxCount4; count4++) {
194
- var _sum3 = _count3 * _denom3 + _count4 * _denom4 + _count5 * _denom5 + count4 * denom4;
195
- if (_sum3 >= target) {
196
- var _combination2 = [].concat(_toConsumableArray(Array(_count3).fill(_denom3 / precision)), _toConsumableArray(Array(_count4).fill(_denom4 / precision)), _toConsumableArray(Array(_count5).fill(_denom5 / precision)), _toConsumableArray(Array(count4).fill(denom4 / precision)));
197
- paymentOptions.push({
198
- combination: _combination2,
199
- sum: _sum3 / precision,
200
- coinCount: _count3 + _count4 + _count5 + count4,
201
- denomTypes: 4
202
- });
203
- }
204
- }
205
- }
206
- }
207
- }
208
- }
209
- }
210
- }
211
- }
212
-
213
- // 如果没有找到任何组合,提供默认建议
214
- if (paymentOptions.length === 0) {
215
- // 找到大于等于目标金额的最小面额
216
- var minValidDenom = validDenoms.find(function (denom) {
217
- return denom >= targetAmount;
218
- });
219
- if (minValidDenom) {
220
- return [minValidDenom];
221
- } else {
222
- // 使用最大面额的组合
223
- var maxDenom = Math.max.apply(Math, _toConsumableArray(validDenoms));
224
- var _count6 = Math.ceil(targetAmount / maxDenom);
225
- return [_count6 * maxDenom];
226
- }
227
- }
228
-
229
- // 移除重复和扩展组合
230
- var uniqueCombinations = removeDuplicateAndExtendedCombinations(paymentOptions, targetAmount);
231
-
232
- // 按币种类型数量排序,然后按总硬币数量排序,最后按金额排序
233
- uniqueCombinations.sort(function (a, b) {
234
- if (a.denomTypes !== b.denomTypes) {
235
- return a.denomTypes - b.denomTypes;
236
- }
237
- if (a.coinCount !== b.coinCount) {
238
- return a.coinCount - b.coinCount;
239
- }
240
- return a.sum - b.sum;
241
- });
242
-
243
- // 按金额去重并返回推荐的支付金额
244
- var uniqueAmounts = new Set();
245
- var finalResults = [];
246
- for (var _i4 = 0, _uniqueCombinations = uniqueCombinations; _i4 < _uniqueCombinations.length; _i4++) {
247
- var item = _uniqueCombinations[_i4];
248
- var roundedAmount = Math.round(item.sum * 100) / 100; // 处理浮点数精度
249
- if (!uniqueAmounts.has(roundedAmount) && finalResults.length < 10) {
250
- uniqueAmounts.add(roundedAmount);
251
- finalResults.push(roundedAmount);
252
- }
253
- }
254
- return finalResults.sort(function (a, b) {
255
- return a - b;
256
- });
257
- } catch (error) {
258
- // 发生错误时返回安全的默认值
259
- console.warn('推荐支付金额计算出错:', error);
260
- // 返回最接近的整数金额作为兜底
261
- var safeAmount = Math.ceil(targetAmount);
262
- return [targetAmount, safeAmount];
263
- }
264
- }
265
-
266
- /**
267
- * 尝试找到精确匹配目标金额的组合
268
- */
269
- function findExactCombination(target, denoms, precision) {
270
- // 简单的深度优先搜索,限制搜索深度
271
- function dfs(remaining, denomIndex, currentCombination) {
272
- if (remaining === 0) {
273
- return currentCombination;
274
- }
275
- if (remaining < 0 || denomIndex >= denoms.length || currentCombination.length > 10) {
276
- return null;
277
- }
278
- var denom = denoms[denomIndex];
279
-
280
- // 尝试使用当前面额 0 到 maxCount 次
281
- var maxCount = Math.min(Math.floor(remaining / denom), 8);
282
- for (var count = maxCount; count >= 0; count--) {
283
- var newCombination = [].concat(_toConsumableArray(currentCombination), _toConsumableArray(Array(count).fill(denom)));
284
- var result = dfs(remaining - count * denom, denomIndex + 1, newCombination);
285
- if (result) {
286
- return result;
287
- }
288
- }
289
- return null;
290
- }
291
- var exactMatch = dfs(target, 0, []);
292
- if (exactMatch && exactMatch.length > 0) {
293
- var denomTypes = new Set(exactMatch).size;
294
- return {
295
- combination: exactMatch.map(function (d) {
296
- return d / precision;
297
- }),
298
- sum: target / precision,
299
- coinCount: exactMatch.length,
300
- denomTypes: denomTypes
301
- };
302
- }
303
- return null;
304
- }
305
-
306
- /**
307
- * 移除重复和扩展组合
308
- * 核心原理:如果组合A包含组合B的所有硬币,并且还有额外硬币,则A是B的扩展,应该被移除
309
- */
310
- function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
311
- var result = [];
312
-
313
- // 按币种类型数量、硬币数量、金额排序,确保较简单的组合在前面
314
- combinations.sort(function (a, b) {
315
- if (a.denomTypes !== b.denomTypes) {
316
- return a.denomTypes - b.denomTypes;
317
- }
318
- if (a.coinCount !== b.coinCount) {
319
- return a.coinCount - b.coinCount;
320
- }
321
- return a.sum - b.sum;
322
- });
323
- for (var i = 0; i < combinations.length; i++) {
324
- var current = combinations[i];
325
- var shouldSkip = false;
326
-
327
- // 检查当前组合是否与已添加的组合重复或者是扩展
328
- for (var j = 0; j < result.length; j++) {
329
- var existing = result[j];
330
-
331
- // 如果完全相同,跳过
332
- if (isSameCombination(current.combination, existing.combination)) {
333
- shouldSkip = true;
334
- break;
335
- }
336
-
337
- // 如果当前组合是已存在组合的扩展,跳过
338
- if (isExtensionOf(current.combination, existing.combination)) {
339
- shouldSkip = true;
340
- break;
341
- }
342
- }
343
-
344
- // 检查是否有其他组合是当前组合的扩展,如果有,移除那些扩展
345
- if (!shouldSkip) {
346
- // 移除所有当前组合的扩展
347
- for (var _j3 = result.length - 1; _j3 >= 0; _j3--) {
348
- if (isExtensionOf(result[_j3].combination, current.combination)) {
349
- result.splice(_j3, 1);
350
- }
351
- }
352
- result.push(current);
353
- }
354
- }
355
- return result;
356
- }
357
-
358
- /**
359
- * 检查组合A是否是组合B的扩展(即A包含B的所有硬币,并且还有额外的硬币)
360
- */
361
- function isExtensionOf(combinationA, combinationB) {
362
- // 如果A的硬币数量少于等于B,A不可能是B的扩展
363
- if (combinationA.length <= combinationB.length) {
364
- return false;
365
- }
366
-
367
- // 统计每个面额的数量
368
- var countA = {};
369
- var countB = {};
370
- combinationA.forEach(function (coin) {
371
- countA[coin] = (countA[coin] || 0) + 1;
372
- });
373
- combinationB.forEach(function (coin) {
374
- countB[coin] = (countB[coin] || 0) + 1;
375
- });
376
-
377
- // 检查B的所有面额在A中是否都有足够的数量
378
- for (var coin in countB) {
379
- if (!countA[coin] || countA[coin] < countB[coin]) {
380
- return false;
381
- }
382
- }
383
-
384
- // 检查A是否有B没有的额外硬币
385
- var hasExtra = false;
386
- for (var _coin in countA) {
387
- if (countA[_coin] > (countB[_coin] || 0)) {
388
- hasExtra = true;
389
- break;
390
- }
391
- }
392
- return hasExtra;
393
- }
394
-
395
- /**
396
- * 检查两个组合是否本质相同(相同的面额组合)
397
- */
398
- function isSameCombination(combinationA, combinationB) {
399
- if (combinationA.length !== combinationB.length) {
400
- return false;
401
- }
402
- var countA = {};
403
- var countB = {};
404
- combinationA.forEach(function (coin) {
405
- countA[coin] = (countA[coin] || 0) + 1;
406
- });
407
- combinationB.forEach(function (coin) {
408
- countB[coin] = (countB[coin] || 0) + 1;
409
- });
410
-
411
- // 检查两个组合是否有相同的面额和数量
412
- for (var coin in countA) {
413
- if (countA[coin] !== (countB[coin] || 0)) {
414
- return false;
415
- }
416
- }
417
- for (var _coin2 in countB) {
418
- if (countB[_coin2] !== (countA[_coin2] || 0)) {
419
- return false;
420
- }
421
- }
422
- return true;
61
+ var precision = 100;
62
+ var normalizedTarget = Math.round(targetAmount * precision) / precision;
63
+ var higherDenominations = _toConsumableArray(new Set((Array.isArray(denominations) ? denominations : []).filter(function (denomination) {
64
+ return denomination > 0 && Number.isFinite(denomination);
65
+ }).map(function (denomination) {
66
+ return Math.round(denomination * precision) / precision;
67
+ }))).filter(function (denomination) {
68
+ return denomination > normalizedTarget;
69
+ }).sort(function (a, b) {
70
+ return a - b;
71
+ }).slice(0, 3);
72
+ return [normalizedTarget].concat(_toConsumableArray(higherDenominations));
423
73
  }
@@ -851,7 +851,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
851
851
  key: "getUserIdentificationCodeListAsync",
852
852
  value: function () {
853
853
  var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
854
- var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams, platform, response, sortedData;
854
+ var _newParams$products, _newParams$prepare_pa, _this$walletParams4, newParams, response, sortedData;
855
855
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
856
856
  while (1) switch (_context6.prev = _context6.next) {
857
857
  case 0:
@@ -864,20 +864,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
864
864
  this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
865
865
  return _context6.abrupt("return", []);
866
866
  case 5:
867
- platform = this.paymentModule.getPlatform();
868
- if (!(platform === 'pc' || platform === 'h5')) {
869
- _context6.next = 11;
870
- break;
871
- }
872
- this.userIdentificationCodes = [];
873
- this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
874
- userIdentificationCodes: []
875
- });
876
- this.paymentModule.logInfo('[WalletPass] 用户端平台跳过获取用户识别码列表', {
877
- platform: platform
878
- });
879
- return _context6.abrupt("return", []);
880
- case 11:
867
+ // const platform = this.paymentModule.getPlatform();
868
+ // if (platform === 'pc' || platform === 'h5') {
869
+ // this.userIdentificationCodes = [];
870
+ // this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
871
+ // userIdentificationCodes: [],
872
+ // } as OnUserIdentificationCodesUpdatedEventData);
873
+ // this.paymentModule.logInfo(
874
+ // '[WalletPass] 用户端平台跳过获取用户识别码列表',
875
+ // { platform },
876
+ // );
877
+ // return [];
878
+ // }
879
+
881
880
  if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
882
881
  newParams.payment_order_id = undefined;
883
882
  }
@@ -888,9 +887,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
888
887
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
889
888
  payment_order_id: (_this$walletParams4 = this.walletParams) === null || _this$walletParams4 === void 0 ? void 0 : _this$walletParams4.payment_order_id
890
889
  });
891
- _context6.next = 15;
890
+ _context6.next = 9;
892
891
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
893
- case 15:
892
+ case 9:
894
893
  response = _context6.sent;
895
894
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
896
895
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
@@ -911,19 +910,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
911
910
  })
912
911
  });
913
912
  return _context6.abrupt("return", this.userIdentificationCodes);
914
- case 23:
915
- _context6.prev = 23;
913
+ case 17:
914
+ _context6.prev = 17;
916
915
  _context6.t0 = _context6["catch"](0);
917
916
  this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context6.t0, {
918
917
  customer_id: params.customer_id,
919
918
  available: params.available
920
919
  });
921
920
  return _context6.abrupt("return", []);
922
- case 27:
921
+ case 21:
923
922
  case "end":
924
923
  return _context6.stop();
925
924
  }
926
- }, _callee6, this, [[0, 23]]);
925
+ }, _callee6, this, [[0, 17]]);
927
926
  }));
928
927
  function getUserIdentificationCodeListAsync(_x7) {
929
928
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
@@ -23,12 +23,25 @@ export interface ProductDataVariant {
23
23
  module_data_id: number;
24
24
  /** 关联 data_variant_rule.id */
25
25
  data_variant_rule_id: number;
26
+ /** 多货币结算等业务类型 */
27
+ business_type?: 'multi_currency_settlement' | string;
28
+ /** 数据状态;多货币结算仅处理 enable 记录 */
29
+ status?: 'enable' | 'disable' | string;
26
30
  /** 命中策略后覆盖到商品上的字段 */
27
31
  data: Record<string, any>;
28
32
  created_at: string | null;
29
33
  updated_at: string | null;
30
34
  deleted_at: string | null;
31
35
  }
36
+ export interface ProductSettlementOption extends Record<string, any> {
37
+ settlement_type: 'legal_currency' | 'virtual_currency' | string;
38
+ currency_product_id?: number;
39
+ price: string;
40
+ data_variant_id?: number;
41
+ data_variant_rule_id: number | string;
42
+ available: boolean;
43
+ disabled_reason?: string;
44
+ }
32
45
  /**
33
46
  * 商品基本信息接口
34
47
  */
@@ -61,6 +74,8 @@ export interface ProductData {
61
74
  sum_stock: number;
62
75
  /** 商品价格 */
63
76
  price: string;
77
+ /** 当前上下文解析出的可选结算货币 */
78
+ available_settlement_options?: ProductSettlementOption[];
64
79
  /** 商品原价 */
65
80
  original_price: string;
66
81
  /** 商品成本价 */
@@ -239,6 +254,14 @@ export interface ProductData {
239
254
  option_group_count: number;
240
255
  /** 智能定价变体列表,/product/query with dataVariants 返回 */
241
256
  data_variants?: ProductDataVariant[];
257
+ /**
258
+ * 商品接口规则计算结果;data_variant_ids 按优先级从高到低排列。
259
+ * 空数组表示规则已经计算完成但没有命中 Data Variant。
260
+ */
261
+ metadata?: {
262
+ data_variant_ids?: Array<number | string>;
263
+ [key: string]: any;
264
+ };
242
265
  /** 服务时长 */
243
266
  service_times?: any;
244
267
  }
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { ProductListLoadProductsParams } from './types';
3
+ import { ProductListLoadProductsParams, ProductListStoreQueryParams } from './types';
4
4
  import { ProductData } from '../Product/types';
5
5
  export * from './types';
6
6
  export declare class ProductList extends BaseModule implements Module {
@@ -52,6 +52,7 @@ export declare class ProductList extends BaseModule implements Module {
52
52
  getRawProductPriceSources(ids: number[]): Map<number, ProductData>;
53
53
  getProducts(): Promise<ProductData[]>;
54
54
  getProduct(id: number): Promise<ProductData | undefined>;
55
+ queryProducts(params?: ProductListStoreQueryParams): Promise<ProductData[]>;
55
56
  getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
56
57
  addProduct(products: ProductData[]): Promise<void>;
57
58
  selectProducts(products: ProductData[]): Promise<void>;