@pisell/pisellos 2.3.37 → 2.3.38

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 (90) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  11. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  14. package/dist/modules/OpenData/index.d.ts +2 -0
  15. package/dist/modules/OpenData/index.js +8 -0
  16. package/dist/modules/Order/index.js +21 -14
  17. package/dist/modules/Order/utils.js +2 -1
  18. package/dist/modules/Payment/index.js +1 -1
  19. package/dist/modules/Payment/types.d.ts +73 -4
  20. package/dist/modules/Payment/types.js +18 -3
  21. package/dist/modules/Payment/walletpass.d.ts +25 -1
  22. package/dist/modules/Payment/walletpass.js +707 -157
  23. package/dist/modules/Rules/index.d.ts +1 -0
  24. package/dist/modules/Rules/index.js +75 -49
  25. package/dist/server/index.js +19 -18
  26. package/dist/server/modules/order/index.d.ts +5 -0
  27. package/dist/server/modules/order/index.js +52 -31
  28. package/dist/solution/BaseSales/index.d.ts +77 -11
  29. package/dist/solution/BaseSales/index.js +1322 -297
  30. package/dist/solution/BaseSales/types.d.ts +52 -0
  31. package/dist/solution/BaseSales/types.js +2 -1
  32. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  33. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +7 -3
  36. package/dist/solution/BookingTicket/index.js +130 -48
  37. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  38. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  39. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  40. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  41. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  42. package/dist/solution/ScanOrder/index.js +31 -20
  43. package/dist/solution/VenueBooking/index.js +30 -19
  44. package/dist/types/index.d.ts +1 -0
  45. package/lib/core/index.d.ts +2 -0
  46. package/lib/core/index.js +4 -0
  47. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  48. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  49. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  50. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  51. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  52. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  53. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  54. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  55. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  56. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  57. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  58. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  59. package/lib/modules/OpenData/index.d.ts +2 -0
  60. package/lib/modules/OpenData/index.js +5 -0
  61. package/lib/modules/Order/index.js +10 -4
  62. package/lib/modules/Order/utils.js +6 -1
  63. package/lib/modules/Payment/index.js +1 -1
  64. package/lib/modules/Payment/types.d.ts +73 -4
  65. package/lib/modules/Payment/types.js +4 -3
  66. package/lib/modules/Payment/walletpass.d.ts +25 -1
  67. package/lib/modules/Payment/walletpass.js +470 -21
  68. package/lib/modules/Rules/index.d.ts +1 -0
  69. package/lib/modules/Rules/index.js +30 -7
  70. package/lib/server/index.js +5 -3
  71. package/lib/server/modules/order/index.d.ts +5 -0
  72. package/lib/server/modules/order/index.js +24 -2
  73. package/lib/solution/BaseSales/index.d.ts +77 -11
  74. package/lib/solution/BaseSales/index.js +682 -39
  75. package/lib/solution/BaseSales/types.d.ts +52 -0
  76. package/lib/solution/BaseSales/types.js +2 -1
  77. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  78. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingTicket/index.d.ts +7 -3
  81. package/lib/solution/BookingTicket/index.js +60 -8
  82. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  83. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  84. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  85. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  86. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  87. package/lib/solution/ScanOrder/index.js +8 -0
  88. package/lib/solution/VenueBooking/index.js +8 -0
  89. package/lib/types/index.d.ts +1 -0
  90. package/package.json +2 -2
@@ -12,6 +12,8 @@ export declare const PROMOTION_ACTION_TYPES: {
12
12
  readonly X_ITEMS_FOR_Y_PRICE: "X_ITEMS_FOR_Y_PRICE";
13
13
  /** 买X送Y(买X件送Y件,可累计) */
14
14
  readonly BUY_X_GET_Y_FREE: "BUY_X_GET_Y_FREE";
15
+ /** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
16
+ readonly ITEM_REWARD: "ITEM_REWARD";
15
17
  /** 固定折扣 */
16
18
  readonly DISCOUNT_RATE: "DISCOUNT_RATE";
17
19
  /** 固定减价 */
@@ -66,6 +68,59 @@ export interface BuyXGetYFreeConfig {
66
68
  /** 可选的赠品列表 */
67
69
  giftProducts?: ProductIdentifier[];
68
70
  }
71
+ /**
72
+ * 商品奖励优惠方式
73
+ *
74
+ * - free: 目标商品最终价为 0
75
+ * - percent_off: 目标商品按百分比折扣,rewardValue 为 0-100
76
+ * - amount_off: 每个目标商品固定减免 rewardValue
77
+ * - fixed_price: 目标商品改为固定价 rewardValue
78
+ */
79
+ export type ItemRewardMethod = 'free' | 'percent_off' | 'amount_off' | 'fixed_price';
80
+ /**
81
+ * 商品奖励数量规则
82
+ *
83
+ * - per_condition_quantity: 每满足 N 个条件商品,奖励 Y 个目标商品
84
+ * - all_targets: 满足条件后奖励全部目标商品
85
+ * - max_per_order: 满足条件后每单最多奖励固定数量目标商品
86
+ */
87
+ export type ItemRewardQuantityRule = 'per_condition_quantity' | 'all_targets' | 'max_per_order';
88
+ /** 商品奖励目标选择规则 */
89
+ export type ItemRewardTargetSelection = 'consumer_best';
90
+ /**
91
+ * 商品奖励 - Action Value
92
+ *
93
+ * @example
94
+ * value: {
95
+ * rewardMethod: 'free',
96
+ * quantityRule: 'per_condition_quantity',
97
+ * triggerQuantity: 1,
98
+ * rewardQuantity: 1,
99
+ * }
100
+ */
101
+ export interface ItemRewardValue {
102
+ /** 奖励方式 */
103
+ rewardMethod: ItemRewardMethod;
104
+ /** 奖励值:percent_off/amount_off/fixed_price 使用,free 可省略 */
105
+ rewardValue?: number;
106
+ /** 奖励数量规则 */
107
+ quantityRule: ItemRewardQuantityRule;
108
+ /** 每满足 N 个条件商品;默认 1 */
109
+ triggerQuantity?: number;
110
+ /** 奖励 Y 个目标商品;默认 1 */
111
+ rewardQuantity?: number;
112
+ /** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
113
+ maxRewardQuantity?: number;
114
+ }
115
+ /**
116
+ * 商品奖励 - Action Config
117
+ */
118
+ export interface ItemRewardConfig {
119
+ /** 奖励对象,本期支持指定商品/变体;product_variant_id=0 表示任意变体 */
120
+ rewardTargets?: ProductIdentifier[];
121
+ /** 目标商品超额时的选择规则;本期支持 consumer_best */
122
+ targetSelection?: ItemRewardTargetSelection;
123
+ }
69
124
  /**
70
125
  * 商品标识
71
126
  *
@@ -102,10 +157,19 @@ export interface BuyXGetYFreeAction extends Omit<ActionEffect, 'type' | 'value'
102
157
  valueType: 'object';
103
158
  config?: BuyXGetYFreeConfig;
104
159
  }
160
+ /**
161
+ * 商品奖励 Action
162
+ */
163
+ export interface ItemRewardAction extends Omit<ActionEffect, 'type' | 'value' | 'config'> {
164
+ type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
165
+ value: ItemRewardValue;
166
+ valueType: 'object';
167
+ config?: ItemRewardConfig;
168
+ }
105
169
  /**
106
170
  * 促销活动 Action 联合类型
107
171
  */
108
- export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction;
172
+ export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction | ItemRewardAction;
109
173
  /**
110
174
  * 促销相关运算符
111
175
  */
@@ -170,6 +234,8 @@ export interface PromotionProduct {
170
234
  quantity: number;
171
235
  /** 原价 */
172
236
  original_price?: number;
237
+ /** 内部字段:编辑态订单行只允许参与 ITEM_REWARD,避免旧促销误算历史行 */
238
+ _promotionOnlyForItemReward?: boolean;
173
239
  }
174
240
  /**
175
241
  * 促销活动适配器转换结果
@@ -195,7 +261,7 @@ export interface PromotionTransformResult {
195
261
  /**
196
262
  * Action 详情联合类型
197
263
  */
198
- export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail;
264
+ export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail | ItemRewardActionDetail;
199
265
  /**
200
266
  * X件Y元 Action 详情
201
267
  */
@@ -226,6 +292,28 @@ export interface BuyXGetYFreeActionDetail {
226
292
  /** 可选的赠品列表 */
227
293
  giftProducts: ProductIdentifier[];
228
294
  }
295
+ /**
296
+ * 商品奖励 Action 详情
297
+ */
298
+ export interface ItemRewardActionDetail {
299
+ type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
300
+ /** 奖励方式 */
301
+ rewardMethod: ItemRewardMethod;
302
+ /** 奖励值:percent_off/amount_off/fixed_price 使用,free 为 0 */
303
+ rewardValue: number;
304
+ /** 奖励数量规则 */
305
+ quantityRule: ItemRewardQuantityRule;
306
+ /** 每满足 N 个条件商品;默认 1 */
307
+ triggerQuantity: number;
308
+ /** 奖励 Y 个目标商品;默认 1 */
309
+ rewardQuantity: number;
310
+ /** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
311
+ maxRewardQuantity?: number;
312
+ /** 奖励对象,本期支持指定商品/变体 */
313
+ rewardTargets: ProductIdentifier[];
314
+ /** 目标商品超额时的选择规则 */
315
+ targetSelection: ItemRewardTargetSelection;
316
+ }
229
317
  /**
230
318
  * X件Y元 - 业务层计算结果
231
319
  *
@@ -16,6 +16,8 @@ export var PROMOTION_ACTION_TYPES = {
16
16
  X_ITEMS_FOR_Y_PRICE: 'X_ITEMS_FOR_Y_PRICE',
17
17
  /** 买X送Y(买X件送Y件,可累计) */
18
18
  BUY_X_GET_Y_FREE: 'BUY_X_GET_Y_FREE',
19
+ /** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
20
+ ITEM_REWARD: 'ITEM_REWARD',
19
21
  /** 固定折扣 */
20
22
  DISCOUNT_RATE: 'DISCOUNT_RATE',
21
23
  /** 固定减价 */
@@ -54,6 +56,41 @@ export var PROMOTION_ACTION_TYPES = {
54
56
  * 买X送Y - Action Config
55
57
  */
56
58
 
59
+ /**
60
+ * 商品奖励优惠方式
61
+ *
62
+ * - free: 目标商品最终价为 0
63
+ * - percent_off: 目标商品按百分比折扣,rewardValue 为 0-100
64
+ * - amount_off: 每个目标商品固定减免 rewardValue
65
+ * - fixed_price: 目标商品改为固定价 rewardValue
66
+ */
67
+
68
+ /**
69
+ * 商品奖励数量规则
70
+ *
71
+ * - per_condition_quantity: 每满足 N 个条件商品,奖励 Y 个目标商品
72
+ * - all_targets: 满足条件后奖励全部目标商品
73
+ * - max_per_order: 满足条件后每单最多奖励固定数量目标商品
74
+ */
75
+
76
+ /** 商品奖励目标选择规则 */
77
+
78
+ /**
79
+ * 商品奖励 - Action Value
80
+ *
81
+ * @example
82
+ * value: {
83
+ * rewardMethod: 'free',
84
+ * quantityRule: 'per_condition_quantity',
85
+ * triggerQuantity: 1,
86
+ * rewardQuantity: 1,
87
+ * }
88
+ */
89
+
90
+ /**
91
+ * 商品奖励 - Action Config
92
+ */
93
+
57
94
  // ============================================
58
95
  // 商品标识
59
96
  // ============================================
@@ -78,6 +115,10 @@ export var PROMOTION_ACTION_TYPES = {
78
115
  * 买X送Y Action
79
116
  */
80
117
 
118
+ /**
119
+ * 商品奖励 Action
120
+ */
121
+
81
122
  /**
82
123
  * 促销活动 Action 联合类型
83
124
  */
@@ -146,6 +187,10 @@ var obj = {
146
187
  * 买X送Y Action 详情
147
188
  */
148
189
 
190
+ /**
191
+ * 商品奖励 Action 详情
192
+ */
193
+
149
194
  // ============================================
150
195
  // 业务层输出类型(供参考)
151
196
  // ============================================
@@ -190,7 +190,7 @@ function synthesizeProductResourceFromBooking(booking) {
190
190
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
191
191
  */
192
192
  export function buildCacheItemFromOrderLine(input) {
193
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref12, _booking$id;
193
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref12, _booking$id;
194
194
  var product = input.product,
195
195
  booking = input.booking,
196
196
  sourceProduct = input.sourceProduct;
@@ -257,7 +257,7 @@ export function buildCacheItemFromOrderLine(input) {
257
257
  if (Array.isArray(booking.relation_forms)) {
258
258
  extend.relation_forms = booking.relation_forms;
259
259
  }
260
- var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
260
+ var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
261
261
  id: resolvedId,
262
262
  product_id: resolvedId,
263
263
  extension_type: (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
@@ -265,7 +265,9 @@ export function buildCacheItemFromOrderLine(input) {
265
265
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
266
266
  selling_price: product.selling_price,
267
267
  original_price: product.original_price
268
- }, productOptionString ? {
268
+ }, Number(((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1 ? {
269
+ product_sku: JSON.parse(JSON.stringify(product.product_sku))
270
+ } : {}), productOptionString ? {
269
271
  product_option_string: productOptionString
270
272
  } : {}), {}, {
271
273
  _extend: extend,
@@ -75,7 +75,7 @@ function mapOrderBundleToOtherBundle(bundle) {
75
75
  });
76
76
  }
77
77
  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;
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;
79
79
  var product = input.product,
80
80
  sourceProduct = input.sourceProduct;
81
81
  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;
@@ -127,7 +127,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
127
127
  extend.skuValue = JSON.parse(JSON.stringify(originExtend.skuValue || originExtend._skuValue));
128
128
  extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
129
129
  }
130
- return _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
130
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
131
131
  id: resolvedId,
132
132
  product_id: resolvedId,
133
133
  _id: uid,
@@ -141,7 +141,10 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
141
141
  } : {}), {}, {
142
142
  note: product.note,
143
143
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
144
- discount_list: discountList,
144
+ discount_list: discountList
145
+ }, Number(((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1 ? {
146
+ product_sku: JSON.parse(JSON.stringify(product.product_sku))
147
+ } : {}), {}, {
145
148
  new: 0,
146
149
  autoClose: true,
147
150
  _extend: extend
@@ -27,6 +27,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
27
27
  fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
28
28
  getOpenData(): OpenDataConfig | null;
29
29
  getLastFetchedAt(): number | null;
30
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
31
+ clearCache(): void;
30
32
  checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
31
33
  storeChange(): void;
32
34
  }
@@ -166,6 +166,14 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
166
166
  var _this$store$lastFetch;
167
167
  return (_this$store$lastFetch = this.store.lastFetchedAt) !== null && _this$store$lastFetch !== void 0 ? _this$store$lastFetch : null;
168
168
  }
169
+
170
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
171
+ }, {
172
+ key: "clearCache",
173
+ value: function clearCache() {
174
+ this.store.data = null;
175
+ this.store.lastFetchedAt = null;
176
+ }
169
177
  }, {
170
178
  key: "checkAvailability",
171
179
  value: function checkAvailability(scheduleModule) {
@@ -85,6 +85,10 @@ function isPaidPaymentRecord(payment) {
85
85
  function isCommittedVoucherPaymentRecord(payment) {
86
86
  return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
87
87
  }
88
+ function getVoucherPaymentLifecycleKey(payment) {
89
+ if (!isVoucherPaymentRecord(payment)) return null;
90
+ return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
91
+ }
88
92
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
89
93
  _inherits(OrderModule, _BaseModule);
90
94
  var _super = _createSuper(OrderModule);
@@ -3630,14 +3634,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3630
3634
  }).map(function (payment) {
3631
3635
  return String(payment.order_payment_id);
3632
3636
  }));
3633
- var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
3634
- return String(payment.voucher_id);
3637
+ var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
3638
+ return getVoucherPaymentLifecycleKey(payment);
3639
+ }).filter(function (key) {
3640
+ return key !== null;
3635
3641
  }));
3636
3642
  var replaceableVouchers = mappedVouchers.filter(function (payment) {
3637
3643
  if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
3638
3644
  return false;
3639
3645
  }
3640
- if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
3646
+ var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
3647
+ if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
3641
3648
  return false;
3642
3649
  }
3643
3650
  return true;
@@ -4851,7 +4858,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4851
4858
  key: "saveTempOrderAsDraft",
4852
4859
  value: function () {
4853
4860
  var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4854
- var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4861
+ var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4855
4862
  var tempOrder, latestSummary, payload;
4856
4863
  return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4857
4864
  while (1) switch (_context34.prev = _context34.next) {
@@ -4883,7 +4890,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4883
4890
  tempOrder: tempOrder,
4884
4891
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
4885
4892
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4886
- businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4893
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
4887
4894
  channel: params === null || params === void 0 ? void 0 : params.channel,
4888
4895
  type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
4889
4896
  summary: latestSummary,
@@ -4964,7 +4971,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4964
4971
  key: "runSubmitTempOrder",
4965
4972
  value: function () {
4966
4973
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4967
- var _params$cacheId3, _this$otherParams10, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4974
+ var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4968
4975
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4969
4976
  return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4970
4977
  while (1) switch (_context37.prev = _context37.next) {
@@ -5026,7 +5033,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5026
5033
  tempOrder: tempOrder,
5027
5034
  cacheId: effectiveCacheId,
5028
5035
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5029
- businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5036
+ businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5030
5037
  channel: params === null || params === void 0 ? void 0 : params.channel,
5031
5038
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
5032
5039
  summary: latestSummary,
@@ -6058,7 +6065,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6058
6065
  _step24;
6059
6066
  try {
6060
6067
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6061
- var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
6068
+ var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
6062
6069
  var _step24$value = _slicedToArray(_step24.value, 2),
6063
6070
  index = _step24$value[0],
6064
6071
  product = _step24$value[1];
@@ -6066,7 +6073,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6066
6073
  if (!uid) continue;
6067
6074
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6068
6075
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
6069
- var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
6076
+ var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
6070
6077
  var originSnapshot = cloneDeep(origin);
6071
6078
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
6072
6079
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -6195,10 +6202,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6195
6202
  }, {
6196
6203
  key: "normalizeHydratedProductOptionItem",
6197
6204
  value: function normalizeHydratedProductOptionItem(optionItem) {
6198
- var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
6199
- var rawNum = (_ref79 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref79 !== void 0 ? _ref79 : 1;
6205
+ var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
6206
+ var rawNum = (_ref78 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1;
6200
6207
  var parsedNum = Number(rawNum);
6201
- var rawPrice = (_ref80 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref80 !== void 0 ? _ref80 : 0;
6208
+ var rawPrice = (_ref79 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref79 !== void 0 ? _ref79 : 0;
6202
6209
  var parsedPrice = Number(rawPrice);
6203
6210
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
6204
6211
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6339,10 +6346,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6339
6346
  _step29;
6340
6347
  try {
6341
6348
  for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6342
- var _ref81, _bundle$num3;
6349
+ var _ref80, _bundle$num3;
6343
6350
  var bundle = _step29.value;
6344
6351
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
6345
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref81 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1) || 1).toNumber();
6352
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
6346
6353
  var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6347
6354
  _step30;
6348
6355
  try {
@@ -533,7 +533,8 @@ export function resolveEffectivePerUnitDiscount(product) {
533
533
  return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
534
534
  }, 0);
535
535
  var hasPromoDiscountItem = discountList.some(function (item) {
536
- return (item === null || item === void 0 ? void 0 : item.type) === 'promotion';
536
+ var _item$metadata, _item$metadata2;
537
+ return (item === null || item === void 0 ? void 0 : item.type) === 'promotion' || (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
537
538
  });
538
539
  if (hasPromoDiscountItem) return fromList;
539
540
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
@@ -2009,7 +2009,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2009
2009
  baseValue = amount.div(roundingInterval);
2010
2010
  console.log("[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ".concat(amount.toString(), ", \u95F4\u9694: ").concat(intervalValue, ", \u57FA\u7840\u503C: ").concat(baseValue.toString(), ", \u89C4\u5219: ").concat(rule));
2011
2011
  _context26.t0 = rule;
2012
- _context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
2012
+ _context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_rounding_midpoint_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
2013
2013
  break;
2014
2014
  case 13:
2015
2015
  // 标准舍入(中点向上)
@@ -40,11 +40,11 @@ export declare enum RoundingRule {
40
40
  /** 标准舍入(中点向上) */
41
41
  Standard = "standard_rounding",
42
42
  /** 标准舍入(中点向下) */
43
- StandardDown = "standard_down",
43
+ StandardDown = "standard_rounding_midpoint_down",
44
44
  /** 总是向上舍入 */
45
- AlwaysUp = "always_up",
45
+ AlwaysUp = "round_up",
46
46
  /** 总是向下舍入 */
47
- AlwaysDown = "always_down"
47
+ AlwaysDown = "round_down"
48
48
  }
49
49
  /**
50
50
  * 舍入结果
@@ -340,6 +340,8 @@ export interface CashPayment {
340
340
  processCashPayment: (amount: number, orderUuid: string) => Promise<void>;
341
341
  /** 获取现金余额 */
342
342
  getCashBalance: () => Promise<number>;
343
+ /** 根据币种面额生成现金快捷金额。 */
344
+ getRecommendedAmount: (money: number, currency: string) => number[];
343
345
  }
344
346
  /**
345
347
  * Eftpos支付接口
@@ -365,6 +367,56 @@ export interface WalletStoredInitData {
365
367
  noApplicableVoucher: any[];
366
368
  products: any[];
367
369
  }
370
+ export type WalletAssetId = string | number;
371
+ export type WalletAssetSelectionSource = 'manual' | 'scan';
372
+ export type WalletAssetsStatus = 'idle' | 'loading' | 'ready' | 'error';
373
+ /**
374
+ * 购物车与结账共享的钱包资产状态。
375
+ *
376
+ * 原始券字段完整保留在 items / selectedItems 中,Payment 只补充统一的
377
+ * 可用性、选择和加载状态,不在此层引入 UI ViewModel。
378
+ */
379
+ export interface WalletAssetsState {
380
+ status: WalletAssetsStatus;
381
+ items: any[];
382
+ selectedIds: WalletAssetId[];
383
+ selectedItems: any[];
384
+ committedIds: WalletAssetId[];
385
+ selectionSources: Record<string, WalletAssetSelectionSource>;
386
+ totalSelectedAmount: number;
387
+ customerId?: string | number;
388
+ error: string | null;
389
+ revision: number;
390
+ }
391
+ /**
392
+ * Shared Wallet Assets 的可序列化运行时快照。
393
+ *
394
+ * state 供购物车 / Checkout 直接恢复展示与选择;searchResults 和
395
+ * calculationContext 用于商品变化后继续重验扫码搜索过的 Wallet。
396
+ */
397
+ export interface WalletAssetsSnapshot {
398
+ state: WalletAssetsState;
399
+ searchResults: SearchIdentificationCodeItem[];
400
+ walletParams: WalletDeductionRecommendParams | null;
401
+ calculationContext: {
402
+ orderTotalAmount: number;
403
+ products: any[];
404
+ };
405
+ }
406
+ export interface RefreshWalletAssetsOptions {
407
+ /** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
408
+ preserveSelection?: boolean;
409
+ }
410
+ export interface SelectWalletAssetOptions {
411
+ selected: boolean;
412
+ source?: WalletAssetSelectionSource;
413
+ }
414
+ export interface ScanWalletAssetResult {
415
+ type: SearchIdentificationCodeResult['type'];
416
+ asset?: any;
417
+ selected: boolean;
418
+ state: WalletAssetsState;
419
+ }
368
420
  export interface WalletPassPayment {
369
421
  /** 生成钱包API默认参数 */
370
422
  generateWalletParams: (businessData: WalletInitBusinessData) => WalletDeductionRecommendParams;
@@ -416,6 +468,22 @@ export interface WalletPassPayment {
416
468
  processWalletPayment: (amount: number, orderUuid: string, voucherId?: string) => Promise<void>;
417
469
  /** 获取钱包余额 */
418
470
  getWalletBalance: (voucherId: string) => Promise<number>;
471
+ /** 刷新购物车/结账共享的钱包资产,刷新本身不会默认选券。 */
472
+ refreshWalletAssetsFromBusinessAsync: (businessData: WalletInitBusinessData, options?: RefreshWalletAssetsOptions) => Promise<WalletAssetsState>;
473
+ /** 获取共享钱包资产状态快照。 */
474
+ getWalletAssetsState: () => WalletAssetsState;
475
+ /** 导出供 Shared Checkout 跨运行时传递的 Wallet Assets 快照。 */
476
+ exportWalletAssetsSnapshot: () => WalletAssetsSnapshot;
477
+ /** 恢复 Shared Checkout 传回的 Wallet Assets 快照。 */
478
+ importWalletAssetsSnapshot: (snapshot: WalletAssetsSnapshot) => WalletAssetsState;
479
+ /** 设置单张钱包资产的选择状态并重新计算其实际抵扣额。 */
480
+ selectWalletAsset: (assetId: WalletAssetId, options: SelectWalletAssetOptions) => WalletAssetsState;
481
+ /** 精确搜索钱包资产;仅当前券可用时自动选择。 */
482
+ scanWalletAssetAsync: (code: string) => Promise<ScanWalletAssetResult>;
483
+ /** 清空未确认的钱包资产选择。 */
484
+ clearWalletAssetSelection: () => WalletAssetsState;
485
+ /** 同步订单中已经支付、不可撤销的钱包资产。 */
486
+ setCommittedWalletAssets: (committedIds: WalletAssetId[], committedAssets?: any[]) => WalletAssetsState;
419
487
  }
420
488
  /**
421
489
  * 支付模块API接口
@@ -608,7 +676,8 @@ export declare enum WalletPassHooks {
608
676
  OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted",
609
677
  OnWalletInitializationStarted = "wallet:onWalletInitializationStarted",
610
678
  OnWalletInitializationCompleted = "wallet:onWalletInitializationCompleted",
611
- OnWalletInitializationFailed = "wallet:onWalletInitializationFailed"
679
+ OnWalletInitializationFailed = "wallet:onWalletInitializationFailed",
680
+ OnWalletAssetsStateChanged = "wallet:onWalletAssetsStateChanged"
612
681
  }
613
682
  /**
614
683
  * 支付钩子事件(统一接口)
@@ -40,9 +40,9 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
40
40
  */
41
41
  export var RoundingRule = /*#__PURE__*/function (RoundingRule) {
42
42
  RoundingRule["Standard"] = "standard_rounding";
43
- RoundingRule["StandardDown"] = "standard_down";
44
- RoundingRule["AlwaysUp"] = "always_up";
45
- RoundingRule["AlwaysDown"] = "always_down";
43
+ RoundingRule["StandardDown"] = "standard_rounding_midpoint_down";
44
+ RoundingRule["AlwaysUp"] = "round_up";
45
+ RoundingRule["AlwaysDown"] = "round_down";
46
46
  return RoundingRule;
47
47
  }({});
48
48
 
@@ -123,6 +123,20 @@ export var RoundingInterval = /*#__PURE__*/function (RoundingInterval) {
123
123
  * 钱包支付接口
124
124
  */
125
125
 
126
+ /**
127
+ * 购物车与结账共享的钱包资产状态。
128
+ *
129
+ * 原始券字段完整保留在 items / selectedItems 中,Payment 只补充统一的
130
+ * 可用性、选择和加载状态,不在此层引入 UI ViewModel。
131
+ */
132
+
133
+ /**
134
+ * Shared Wallet Assets 的可序列化运行时快照。
135
+ *
136
+ * state 供购物车 / Checkout 直接恢复展示与选择;searchResults 和
137
+ * calculationContext 用于商品变化后继续重验扫码搜索过的 Wallet。
138
+ */
139
+
126
140
  /**
127
141
  * 支付模块API接口
128
142
  */
@@ -184,6 +198,7 @@ export var WalletPassHooks = /*#__PURE__*/function (WalletPassHooks) {
184
198
  WalletPassHooks["OnWalletInitializationStarted"] = "wallet:onWalletInitializationStarted";
185
199
  WalletPassHooks["OnWalletInitializationCompleted"] = "wallet:onWalletInitializationCompleted";
186
200
  WalletPassHooks["OnWalletInitializationFailed"] = "wallet:onWalletInitializationFailed";
201
+ WalletPassHooks["OnWalletAssetsStateChanged"] = "wallet:onWalletAssetsStateChanged";
187
202
  return WalletPassHooks;
188
203
  }({});
189
204
 
@@ -1,4 +1,4 @@
1
- import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData } from './types';
1
+ import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData, WalletAssetId, WalletAssetsSnapshot, WalletAssetsState, RefreshWalletAssetsOptions, SelectWalletAssetOptions, ScanWalletAssetResult } from './types';
2
2
  import type { PaymentModule } from './index';
3
3
  /**
4
4
  * 钱包支付实现
@@ -10,12 +10,22 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
10
10
  private searchResults;
11
11
  private walletParams;
12
12
  private walletInitData;
13
+ private walletAssetsState;
14
+ private walletAssetsRequestSequence;
15
+ private walletAssetsCalculationContext;
13
16
  constructor(paymentModule: PaymentModule);
14
17
  /**
15
18
  * 发送事件的辅助方法
16
19
  * 支持使用WalletPassHooks或PaymentHooks
17
20
  */
18
21
  private emitEvent;
22
+ private publishWalletAssetsState;
23
+ private recalculateWalletAssets;
24
+ /**
25
+ * 使用最新订单参数重验扫码搜索过的支付类 Wallet 资产。
26
+ * 请求失败或暂时无匹配结果时保留旧资产,避免商品变化造成列表闪空。
27
+ */
28
+ private revalidateSearchedWalletAssets;
19
29
  /**
20
30
  * 生成钱包API默认参数
21
31
  * 根据业务数据生成标准的钱包API参数,并存储在模块中
@@ -73,6 +83,20 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
73
83
  searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
74
84
  noCache?: boolean;
75
85
  }): Promise<SearchIdentificationCodeResult>;
86
+ /**
87
+ * 刷新购物车与结账共享的钱包资产。
88
+ *
89
+ * 与 legacy initializeWalletDataFromBusinessAsync 不同,这里维护选择状态;
90
+ * 推荐结果只作为可用性/金额计算输入,不会自动成为 selectedIds。
91
+ */
92
+ refreshWalletAssetsFromBusinessAsync(businessData: WalletInitBusinessData, options?: RefreshWalletAssetsOptions): Promise<WalletAssetsState>;
93
+ getWalletAssetsState(): WalletAssetsState;
94
+ exportWalletAssetsSnapshot(): WalletAssetsSnapshot;
95
+ importWalletAssetsSnapshot(snapshot: WalletAssetsSnapshot): WalletAssetsState;
96
+ selectWalletAsset(assetId: WalletAssetId, options: SelectWalletAssetOptions): WalletAssetsState;
97
+ scanWalletAssetAsync(code: string): Promise<ScanWalletAssetResult>;
98
+ clearWalletAssetSelection(): WalletAssetsState;
99
+ setCommittedWalletAssets(committedIds: WalletAssetId[], committedAssets?: any[]): WalletAssetsState;
76
100
  processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
77
101
  getWalletBalance(voucherId: string): Promise<number>;
78
102
  /**