@pisell/pisellos 0.10.7 → 0.10.9

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 (124) hide show
  1. package/dist/core/index.js +0 -1
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  4. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  6. package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
  7. package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
  9. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  10. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  11. package/dist/modules/Customer/index.d.ts +4 -0
  12. package/dist/modules/Customer/index.js +91 -59
  13. package/dist/modules/Customer/types.d.ts +2 -0
  14. package/dist/modules/Discount/index.d.ts +2 -0
  15. package/dist/modules/Discount/index.js +38 -5
  16. package/dist/modules/Discount/types.d.ts +11 -0
  17. package/dist/modules/Order/index.d.ts +32 -6
  18. package/dist/modules/Order/index.js +1165 -819
  19. package/dist/modules/Order/types.d.ts +32 -4
  20. package/dist/modules/Order/types.js +11 -0
  21. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  22. package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
  23. package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
  24. package/dist/modules/Order/utils/virtualSettlement.js +271 -0
  25. package/dist/modules/Order/utils.js +89 -48
  26. package/dist/modules/Payment/types.d.ts +2 -0
  27. package/dist/modules/Payment/utils.js +4 -1
  28. package/dist/modules/Payment/walletpass.d.ts +11 -0
  29. package/dist/modules/Payment/walletpass.js +235 -60
  30. package/dist/modules/Product/types.d.ts +23 -0
  31. package/dist/modules/ProductList/index.d.ts +15 -2
  32. package/dist/modules/ProductList/index.js +92 -13
  33. package/dist/modules/Rules/index.js +125 -52
  34. package/dist/modules/SalesSummary/index.d.ts +1 -0
  35. package/dist/modules/SalesSummary/index.js +4 -3
  36. package/dist/modules/SalesSummary/types.d.ts +1 -0
  37. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  38. package/dist/modules/SalesSummary/utils.js +28 -2
  39. package/dist/server/index.d.ts +15 -0
  40. package/dist/server/index.js +894 -781
  41. package/dist/server/modules/order/index.d.ts +2 -0
  42. package/dist/server/modules/order/index.js +261 -96
  43. package/dist/server/modules/order/types.d.ts +1 -1
  44. package/dist/server/utils/small-ticket.js +2 -1
  45. package/dist/solution/BaseSales/index.d.ts +41 -7
  46. package/dist/solution/BaseSales/index.js +1405 -974
  47. package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
  48. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
  50. package/dist/solution/BaseSales/utils.js +31 -20
  51. package/dist/solution/BookingByStep/index.d.ts +3 -3
  52. package/dist/solution/BookingTicket/index.d.ts +5 -1
  53. package/dist/solution/BookingTicket/index.js +221 -162
  54. package/dist/solution/BookingTicket/types.d.ts +3 -0
  55. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  56. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  57. package/dist/solution/Sales/index.d.ts +1 -0
  58. package/dist/solution/Sales/index.js +16 -2
  59. package/dist/solution/ScanOrder/index.js +25 -64
  60. package/dist/solution/ScanOrder/utils.js +31 -20
  61. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  62. package/dist/solution/UnifiedBookingSales/index.js +51 -39
  63. package/lib/core/index.js +0 -1
  64. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  65. package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
  66. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  67. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  68. package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
  69. package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
  70. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
  71. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  72. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  73. package/lib/modules/Customer/index.d.ts +4 -0
  74. package/lib/modules/Customer/index.js +11 -0
  75. package/lib/modules/Customer/types.d.ts +2 -0
  76. package/lib/modules/Discount/index.d.ts +2 -0
  77. package/lib/modules/Discount/index.js +37 -3
  78. package/lib/modules/Discount/types.d.ts +11 -0
  79. package/lib/modules/Order/index.d.ts +32 -6
  80. package/lib/modules/Order/index.js +518 -148
  81. package/lib/modules/Order/types.d.ts +32 -4
  82. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
  83. package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
  84. package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
  85. package/lib/modules/Order/utils/virtualSettlement.js +300 -0
  86. package/lib/modules/Order/utils.js +65 -21
  87. package/lib/modules/Payment/types.d.ts +2 -0
  88. package/lib/modules/Payment/utils.js +5 -1
  89. package/lib/modules/Payment/walletpass.d.ts +11 -0
  90. package/lib/modules/Payment/walletpass.js +198 -17
  91. package/lib/modules/Product/types.d.ts +23 -0
  92. package/lib/modules/ProductList/index.d.ts +15 -2
  93. package/lib/modules/ProductList/index.js +85 -3
  94. package/lib/modules/Rules/index.js +100 -20
  95. package/lib/modules/SalesSummary/index.d.ts +1 -0
  96. package/lib/modules/SalesSummary/index.js +10 -2
  97. package/lib/modules/SalesSummary/types.d.ts +1 -0
  98. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  99. package/lib/modules/SalesSummary/utils.js +30 -2
  100. package/lib/server/index.d.ts +15 -0
  101. package/lib/server/index.js +105 -14
  102. package/lib/server/modules/order/index.d.ts +2 -0
  103. package/lib/server/modules/order/index.js +75 -5
  104. package/lib/server/modules/order/types.d.ts +1 -1
  105. package/lib/server/utils/small-ticket.js +1 -1
  106. package/lib/solution/BaseSales/index.d.ts +41 -7
  107. package/lib/solution/BaseSales/index.js +325 -39
  108. package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
  109. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  110. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
  111. package/lib/solution/BaseSales/utils.js +29 -18
  112. package/lib/solution/BookingByStep/index.d.ts +3 -3
  113. package/lib/solution/BookingTicket/index.d.ts +5 -1
  114. package/lib/solution/BookingTicket/index.js +31 -6
  115. package/lib/solution/BookingTicket/types.d.ts +3 -0
  116. package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
  117. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  118. package/lib/solution/Sales/index.d.ts +1 -0
  119. package/lib/solution/Sales/index.js +15 -3
  120. package/lib/solution/ScanOrder/index.js +17 -54
  121. package/lib/solution/ScanOrder/utils.js +29 -18
  122. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  123. package/lib/solution/UnifiedBookingSales/index.js +35 -26
  124. package/package.json +1 -1
@@ -0,0 +1,271 @@
1
+ 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; }
2
+ 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; }
3
+ 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); }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
12
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ 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); }
20
+ import Decimal from 'decimal.js';
21
+ export function resolveSettlementDisplayValue(value) {
22
+ var _ref, _ref2, _ref3, _ref4, _ref5, _localized$auto;
23
+ if (value === undefined || value === null) return '';
24
+ if (typeof value === 'string' || typeof value === 'number') {
25
+ return String(value);
26
+ }
27
+ var localized = value;
28
+ return String((_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_localized$auto = localized.auto) !== null && _localized$auto !== void 0 ? _localized$auto : localized.default) !== null && _ref5 !== void 0 ? _ref5 : localized.original) !== null && _ref4 !== void 0 ? _ref4 : localized.en) !== null && _ref3 !== void 0 ? _ref3 : localized['zh-CN']) !== null && _ref2 !== void 0 ? _ref2 : localized['zh-HK']) !== null && _ref !== void 0 ? _ref : '');
29
+ }
30
+ export var OrderSettlementConflictError = /*#__PURE__*/function (_Error) {
31
+ _inherits(OrderSettlementConflictError, _Error);
32
+ var _super = _createSuper(OrderSettlementConflictError);
33
+ function OrderSettlementConflictError(currentSettlementKey, incomingSettlementKey) {
34
+ var _this;
35
+ _classCallCheck(this, OrderSettlementConflictError);
36
+ _this = _super.call(this, 'Different currencies and WalletPass units cannot be mixed in one cart.');
37
+ _defineProperty(_assertThisInitialized(_this), "code", 'ORDER_SETTLEMENT_CONFLICT');
38
+ _this.currentSettlementKey = currentSettlementKey;
39
+ _this.incomingSettlementKey = incomingSettlementKey;
40
+ _this.name = 'OrderSettlementConflictError';
41
+ return _this;
42
+ }
43
+ return _createClass(OrderSettlementConflictError);
44
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
45
+ export var VirtualCurrencyAssetNotFoundError = /*#__PURE__*/function (_Error2) {
46
+ _inherits(VirtualCurrencyAssetNotFoundError, _Error2);
47
+ var _super2 = _createSuper(VirtualCurrencyAssetNotFoundError);
48
+ function VirtualCurrencyAssetNotFoundError(currencyProductId) {
49
+ var _this2;
50
+ _classCallCheck(this, VirtualCurrencyAssetNotFoundError);
51
+ _this2 = _super2.call(this, 'No matching virtual currency card is available.');
52
+ _defineProperty(_assertThisInitialized(_this2), "code", 'VIRTUAL_CURRENCY_ASSET_NOT_FOUND');
53
+ _this2.currencyProductId = currencyProductId;
54
+ _this2.name = 'VirtualCurrencyAssetNotFoundError';
55
+ return _this2;
56
+ }
57
+ return _createClass(VirtualCurrencyAssetNotFoundError);
58
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
59
+ export var VirtualCurrencyBalanceError = /*#__PURE__*/function (_Error3) {
60
+ _inherits(VirtualCurrencyBalanceError, _Error3);
61
+ var _super3 = _createSuper(VirtualCurrencyBalanceError);
62
+ function VirtualCurrencyBalanceError(balance, requiredAmount) {
63
+ var _this3;
64
+ _classCallCheck(this, VirtualCurrencyBalanceError);
65
+ _this3 = _super3.call(this, 'Insufficient virtual currency balance.');
66
+ _defineProperty(_assertThisInitialized(_this3), "code", 'VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT');
67
+ _this3.balance = balance;
68
+ _this3.requiredAmount = requiredAmount;
69
+ _this3.name = 'VirtualCurrencyBalanceError';
70
+ return _this3;
71
+ }
72
+ return _createClass(VirtualCurrencyBalanceError);
73
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
74
+ export function getSelectedSettlementSnapshot(product) {
75
+ var _product$metadata;
76
+ var snapshot = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.selected_settlement_snapshot;
77
+ if (!snapshot || _typeof(snapshot) !== 'object') return null;
78
+ if (snapshot.settlement_type !== 'legal_currency' && snapshot.settlement_type !== 'virtual_currency') {
79
+ return null;
80
+ }
81
+ return snapshot;
82
+ }
83
+ export function getTempOrderSettlementSnapshot(tempOrder) {
84
+ var _tempOrder$metadata, _tempOrder$products;
85
+ var snapshot = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.cart_settlement_snapshot;
86
+ if (snapshot && _typeof(snapshot) === 'object' && (snapshot.settlement_type === 'legal_currency' || snapshot.settlement_type === 'virtual_currency')) {
87
+ return snapshot;
88
+ }
89
+ return getSelectedSettlementSnapshot(tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products[0]);
90
+ }
91
+ export function isVirtualSettlementProduct(product) {
92
+ var _getSelectedSettlemen;
93
+ return ((_getSelectedSettlemen = getSelectedSettlementSnapshot(product)) === null || _getSelectedSettlemen === void 0 ? void 0 : _getSelectedSettlemen.settlement_type) === 'virtual_currency';
94
+ }
95
+ export function getSettlementKey(snapshot) {
96
+ if (!snapshot) return null;
97
+ if (snapshot.settlement_type === 'legal_currency') return 'legal_currency';
98
+ var currencyProductId = Number(snapshot.currency_product_id);
99
+ return Number.isFinite(currencyProductId) && currencyProductId > 0 ? "virtual_currency:".concat(currencyProductId) : null;
100
+ }
101
+ export function getTempOrderSettlementKey(tempOrder) {
102
+ var _tempOrder$products2, _tempOrder$metadata2;
103
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products2 = tempOrder.products) !== null && _tempOrder$products2 !== void 0 && _tempOrder$products2.length)) return null;
104
+ var storedKey = (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.cart_settlement_key;
105
+ if (typeof storedKey === 'string' && storedKey) return storedKey;
106
+ return getSettlementKey(getTempOrderSettlementSnapshot(tempOrder)) || 'legal_currency';
107
+ }
108
+ export function isVirtualSettlementOrder(tempOrder) {
109
+ var _getTempOrderSettleme;
110
+ return ((_getTempOrderSettleme = getTempOrderSettlementKey(tempOrder)) === null || _getTempOrderSettleme === void 0 ? void 0 : _getTempOrderSettleme.startsWith('virtual_currency:')) === true;
111
+ }
112
+
113
+ /**
114
+ * 详情展示识别同时支持已提交订单的 currency_settlement_config。
115
+ * cart_settlement_* 是交易过程内部状态,服务端详情不保证返回。
116
+ */
117
+ export function isVirtualSettlementDisplayOrder(tempOrder) {
118
+ var _tempOrder$metadata3;
119
+ return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata3 = tempOrder.metadata) === null || _tempOrder$metadata3 === void 0 || (_tempOrder$metadata3 = _tempOrder$metadata3.currency_settlement_config) === null || _tempOrder$metadata3 === void 0 ? void 0 : _tempOrder$metadata3.settlement_type) === 'virtual_currency' || isVirtualSettlementOrder(tempOrder);
120
+ }
121
+ function getLegalCurrencySnapshot(tempOrder) {
122
+ var _tempOrder$metadata4;
123
+ var snapshot = (_tempOrder$metadata4 = tempOrder.metadata) === null || _tempOrder$metadata4 === void 0 ? void 0 : _tempOrder$metadata4.legal_currency_snapshot;
124
+ if (!snapshot || _typeof(snapshot) !== 'object') return null;
125
+ return {
126
+ currency_code: String(snapshot.currency_code || ''),
127
+ currency_symbol: String(snapshot.currency_symbol || ''),
128
+ currency_format: String(snapshot.currency_format || 'symbol_first')
129
+ };
130
+ }
131
+ function captureLegalCurrencySnapshot(tempOrder) {
132
+ tempOrder.metadata = tempOrder.metadata || {};
133
+ if (getLegalCurrencySnapshot(tempOrder)) return;
134
+ tempOrder.metadata.legal_currency_snapshot = {
135
+ currency_code: String(tempOrder.currency_code || ''),
136
+ currency_symbol: String(tempOrder.currency_symbol || ''),
137
+ currency_format: String(tempOrder.currency_format || 'symbol_first')
138
+ };
139
+ }
140
+
141
+ /**
142
+ * 将购物车锁定的结算单位提升为订单级状态。
143
+ * 商品行快照只负责价格归一化;展示与提交统一读取 tempOrder.currency_*。
144
+ */
145
+ export function applyTempOrderSettlementState(tempOrder, snapshot) {
146
+ tempOrder.metadata = tempOrder.metadata || {};
147
+ var settlementKey = getSettlementKey(snapshot) || 'legal_currency';
148
+ if (snapshot.settlement_type === 'virtual_currency') {
149
+ captureLegalCurrencySnapshot(tempOrder);
150
+ var _currencyProductId = Number(snapshot.currency_product_id);
151
+ tempOrder.metadata.currency_settlement_config = {
152
+ settlement_type: 'virtual_currency',
153
+ settlement_ids: Number.isFinite(_currencyProductId) && _currencyProductId > 0 ? [_currencyProductId] : []
154
+ };
155
+ } else {
156
+ delete tempOrder.metadata.currency_settlement_config;
157
+ }
158
+ tempOrder.metadata.cart_settlement_key = settlementKey;
159
+ tempOrder.metadata.cart_settlement_snapshot = _objectSpread({}, snapshot);
160
+ tempOrder.currency_code = resolveSettlementDisplayValue(snapshot.unit_label) || tempOrder.currency_code;
161
+ tempOrder.currency_symbol = resolveSettlementDisplayValue(snapshot.symbol) || tempOrder.currency_symbol;
162
+ tempOrder.currency_format = String(snapshot.amount_format || tempOrder.currency_format || 'symbol_first');
163
+ }
164
+
165
+ /** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
166
+ export function releaseTempOrderSettlementState(tempOrder) {
167
+ tempOrder.metadata = tempOrder.metadata || {};
168
+ var legalCurrency = getLegalCurrencySnapshot(tempOrder);
169
+ if (legalCurrency) {
170
+ tempOrder.currency_code = legalCurrency.currency_code;
171
+ tempOrder.currency_symbol = legalCurrency.currency_symbol;
172
+ tempOrder.currency_format = legalCurrency.currency_format;
173
+ }
174
+ delete tempOrder.metadata.cart_settlement_key;
175
+ delete tempOrder.metadata.cart_settlement_snapshot;
176
+ delete tempOrder.metadata.currency_settlement_config;
177
+ }
178
+ function toMoney(value) {
179
+ try {
180
+ return new Decimal(String(value !== null && value !== void 0 ? value : 0)).toDecimalPlaces(2).toFixed(2);
181
+ } catch (_unused) {
182
+ return '0.00';
183
+ }
184
+ }
185
+ function zeroOptions(options) {
186
+ if (!Array.isArray(options)) return [];
187
+ return options.map(function (option) {
188
+ return _objectSpread(_objectSpread({}, option), {}, {
189
+ add_price: 0
190
+ });
191
+ });
192
+ }
193
+ function zeroBundles(bundles) {
194
+ if (!Array.isArray(bundles)) return [];
195
+ return bundles.map(function (bundle) {
196
+ return _objectSpread(_objectSpread({}, bundle), {}, {
197
+ price: 0,
198
+ custom_price: 0,
199
+ bundle_selling_price: 0,
200
+ bundle_payment_price: 0,
201
+ surcharge_fee: 0,
202
+ tax_fee: 0,
203
+ original_tax_fee: 0,
204
+ is_charge_tax: 0,
205
+ discount_list: [],
206
+ relation_surcharge_ids: [],
207
+ option: zeroOptions(bundle === null || bundle === void 0 ? void 0 : bundle.option),
208
+ metadata: _objectSpread(_objectSpread({}, (bundle === null || bundle === void 0 ? void 0 : bundle.metadata) || {}), {}, {
209
+ surcharge_fee: '0.00',
210
+ relation_surcharge_ids: [],
211
+ product_discount_difference: '',
212
+ tax_fee_rounding_remainder: '0.00',
213
+ surcharge_rounding_remainder: '0.00'
214
+ })
215
+ });
216
+ });
217
+ }
218
+
219
+ /**
220
+ * 将已选择虚拟币的订单商品行固化为最终价语义。
221
+ * 函数幂等,可安全用于加车、合并、hydrate 和提交前兜底。
222
+ */
223
+ export function normalizeVirtualSettlementOrderProduct(product) {
224
+ var _product$product_sku;
225
+ var snapshot = getSelectedSettlementSnapshot(product);
226
+ if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.settlement_type) !== 'virtual_currency') return product;
227
+ var virtualPrice = toMoney(snapshot.price);
228
+ var metadata = _objectSpread(_objectSpread({}, product.metadata || {}), {}, {
229
+ source_product_price: virtualPrice,
230
+ main_product_original_price: virtualPrice,
231
+ main_product_selling_price: virtualPrice,
232
+ main_product_attached_bundle_selling_price: virtualPrice,
233
+ main_product_attached_bundle_payment_price: virtualPrice,
234
+ main_product_attached_bundle_surcharge_fee: '0.00',
235
+ main_product_attached_bundle_tax_fee: '0.00',
236
+ surcharge_rounding_remainder: '0.00',
237
+ tax_fee_rounding_remainder: '0.00',
238
+ relation_surcharge_ids: [],
239
+ average_discount_amount_rate: '1',
240
+ product_discount_difference: '',
241
+ discountable_flag: 0,
242
+ price_schema_version: 2,
243
+ selected_settlement_snapshot: _objectSpread(_objectSpread({}, snapshot), {}, {
244
+ price: virtualPrice
245
+ })
246
+ });
247
+ return _objectSpread(_objectSpread({}, product), {}, {
248
+ selling_price: virtualPrice,
249
+ original_price: virtualPrice,
250
+ payment_price: virtualPrice,
251
+ discount_list: [],
252
+ is_charge_tax: 0,
253
+ tax_fee: '0.00',
254
+ original_tax_fee: 0,
255
+ tax_fee_rounding_remainder: 0,
256
+ original_tax_fee_rounding_remainder: 0,
257
+ surcharge_fee: '0.00',
258
+ surcharge_rounding_remainder: 0,
259
+ relation_surcharge_ids: [],
260
+ product_sku: _objectSpread(_objectSpread({}, product.product_sku || {}), {}, {
261
+ option: zeroOptions((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option)
262
+ }),
263
+ product_bundle: zeroBundles(product.product_bundle),
264
+ metadata: metadata
265
+ });
266
+ }
267
+ export function normalizeVirtualSettlementProducts(products) {
268
+ return (products || []).map(function (product) {
269
+ return normalizeVirtualSettlementOrderProduct(product);
270
+ });
271
+ }
@@ -2,7 +2,7 @@ var _excluded = ["custom_product_bundle_map_id"],
2
2
  _excluded2 = ["unique_identification_number"],
3
3
  _excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
4
4
  _excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
5
- _excluded5 = ["collect_pax", "table_occupancy_duration"];
5
+ _excluded5 = ["collect_pax", "table_occupancy_duration", "cart_settlement_key", "cart_settlement_snapshot", "legal_currency_snapshot"];
6
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -814,9 +814,9 @@ function normalizeSubmitPlatform(platform) {
814
814
  if (lower === 'h5') return 'H5';
815
815
  return value;
816
816
  }
817
-
818
817
  // 后端 checkout 协议字段 option_group_item_id;tempOrder 内部也保持同一字段名。
819
818
  function formatSubmitOptionItems(options) {
819
+ var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
820
820
  if (!Array.isArray(options)) return [];
821
821
  return options.map(function (d) {
822
822
  var _d$add_price;
@@ -826,7 +826,11 @@ function formatSubmitOptionItems(options) {
826
826
  option_group_id: d === null || d === void 0 ? void 0 : d.option_group_id
827
827
  });
828
828
  var addPrice = (_d$add_price = d === null || d === void 0 ? void 0 : d.add_price) !== null && _d$add_price !== void 0 ? _d$add_price : d === null || d === void 0 ? void 0 : d.price;
829
- if (addPrice !== undefined) option.add_price = String(addPrice);
829
+ if (formatOptions.virtualSettlementMode) {
830
+ option.add_price = 0;
831
+ } else if (addPrice !== undefined) {
832
+ option.add_price = String(addPrice);
833
+ }
830
834
  delete option.price;
831
835
  return option;
832
836
  });
@@ -845,6 +849,7 @@ function toMoneyString(value) {
845
849
 
846
850
  // 出站补齐:只输出后端 checkout 协议字段,运行时/详情展示字段不进入 bundle payload。
847
851
  function formatSubmitBundleItems(bundle) {
852
+ var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
848
853
  if (!Array.isArray(bundle)) return [];
849
854
  return bundle.map(function (b) {
850
855
  var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
@@ -855,10 +860,10 @@ function formatSubmitBundleItems(bundle) {
855
860
 
856
861
  // bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
857
862
  // markup/原价维持原值;与后端口径一致(price 仍为毛价)。
858
- var sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
863
+ var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
859
864
  // payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
860
- var paymentPrice = rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
861
- var priceValue = (_ref25 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref25 !== void 0 ? _ref25 : rawBundle.bundle_selling_price;
865
+ var paymentPrice = formatOptions.virtualSettlementMode ? '0.00' : rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
866
+ var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref25 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref25 !== void 0 ? _ref25 : rawBundle.bundle_selling_price;
862
867
  var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
863
868
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
864
869
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
@@ -866,7 +871,7 @@ function formatSubmitBundleItems(bundle) {
866
871
  var bundleMapId = resolveSubmitBundleMapId(rawBundle);
867
872
  var hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
868
873
  return {
869
- is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
874
+ is_charge_tax: formatOptions.virtualSettlementMode ? 0 : (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
870
875
  bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
871
876
  num: num,
872
877
  quantity: toBundleNumber((_rawBundle$quantity = rawBundle.quantity) !== null && _rawBundle$quantity !== void 0 ? _rawBundle$quantity : rawBundle.num, num),
@@ -877,7 +882,7 @@ function formatSubmitBundleItems(bundle) {
877
882
  price_type_ext: (_ref27 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref27 !== void 0 ? _ref27 : '',
878
883
  bundle_selling_price: sellingPrice,
879
884
  bundle_payment_price: paymentPrice,
880
- option: formatSubmitOptionItems(rawBundle.option),
885
+ option: formatSubmitOptionItems(rawBundle.option, formatOptions),
881
886
  bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
882
887
  bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
883
888
  bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
@@ -885,9 +890,9 @@ function formatSubmitBundleItems(bundle) {
885
890
  metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
886
891
  custom_product_bundle_map_id: bundleMapId
887
892
  } : {}), {}, {
888
- surcharge_fee: surchargeFee,
889
- relation_surcharge_ids: relationSurchargeIds,
890
- product_discount_difference: productDiscountDifference
893
+ surcharge_fee: formatOptions.virtualSettlementMode ? '0.00' : surchargeFee,
894
+ relation_surcharge_ids: formatOptions.virtualSettlementMode ? [] : relationSurchargeIds,
895
+ product_discount_difference: formatOptions.virtualSettlementMode ? '' : productDiscountDifference
891
896
  })
892
897
  };
893
898
  });
@@ -907,10 +912,11 @@ function formatSubmitBundleItems(bundle) {
907
912
  * - `metadata.main_product_selling_price`:含 option、含主商品折扣。
908
913
  * - `metadata.price_schema_version`:schema 版本号(当前 = 2),用于跨端协商价格口径。
909
914
  *
910
- * 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
915
+ * 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
911
916
  */
912
917
  function normalizeSubmitProduct(product) {
913
- var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
918
+ var _ref29, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
919
+ var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
914
920
  var _ref28 = product,
915
921
  _runtimeUid = _ref28.unique_identification_number,
916
922
  submitProduct = _objectWithoutProperties(_ref28, _excluded2);
@@ -925,11 +931,15 @@ function normalizeSubmitProduct(product) {
925
931
  delete productRest["product_".concat('option', "_item")];
926
932
  var rawMetadata = submitProduct.metadata || {};
927
933
  var bookingUid = rawMetadata.booking_uid;
934
+ // 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
935
+ // 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
936
+ var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
937
+ var bundleEdit = (_ref29 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref29 !== void 0 ? _ref29 : hasProductBundle ? 0 : undefined;
928
938
  var cleanMetadata = {};
929
939
  if (rawMetadata.unique_identification_number) {
930
940
  cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
931
941
  }
932
- var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
942
+ var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'price_schema_version', 'parent_unique_identification_number', 'product_add_schedule_time', 'data_variant_ids'];
933
943
  for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
934
944
  var key = _priceMetaKeys[_i];
935
945
  if (rawMetadata[key] !== undefined) {
@@ -946,20 +956,45 @@ function normalizeSubmitProduct(product) {
946
956
  if (rawMetadata.holder_config !== undefined) {
947
957
  cleanMetadata.holder_config = rawMetadata.holder_config;
948
958
  }
959
+ var virtualPrice = toMoneyString((_rawMetadata$selected = (_rawMetadata$selected2 = rawMetadata.selected_settlement_snapshot) === null || _rawMetadata$selected2 === void 0 ? void 0 : _rawMetadata$selected2.price) !== null && _rawMetadata$selected !== void 0 ? _rawMetadata$selected : submitProduct.selling_price);
960
+ if (formatOptions.virtualSettlementMode) {
961
+ Object.assign(cleanMetadata, {
962
+ source_product_price: virtualPrice,
963
+ main_product_original_price: virtualPrice,
964
+ main_product_selling_price: virtualPrice,
965
+ main_product_attached_bundle_selling_price: virtualPrice,
966
+ main_product_attached_bundle_payment_price: virtualPrice,
967
+ main_product_attached_bundle_surcharge_fee: '0.00',
968
+ main_product_attached_bundle_tax_fee: '0.00',
969
+ surcharge_rounding_remainder: '0.00',
970
+ tax_fee_rounding_remainder: '0.00',
971
+ relation_surcharge_ids: [],
972
+ average_discount_amount_rate: '1',
973
+ product_discount_difference: '',
974
+ discountable_flag: 0,
975
+ price_schema_version: 2
976
+ });
977
+ }
949
978
  var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
950
- option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
979
+ option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option, formatOptions)
951
980
  });
952
- return _objectSpread(_objectSpread(_objectSpread({}, productRest), bookingUid ? {
981
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, productRest), formatOptions.virtualSettlementMode ? {
982
+ selling_price: virtualPrice,
983
+ original_price: virtualPrice,
984
+ is_charge_tax: 0
985
+ } : {}), bookingUid ? {
953
986
  booking_uid: bookingUid
987
+ } : {}), bundleEdit !== undefined ? {
988
+ bundle_edit: bundleEdit
954
989
  } : {}), {}, {
955
990
  product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
956
991
  product_sku: productSku,
957
- discount_list: collectSubmitProductDiscountList(submitProduct),
958
- product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
992
+ discount_list: formatOptions.virtualSettlementMode ? [] : collectSubmitProductDiscountList(submitProduct),
993
+ product_bundle: formatSubmitBundleItems(submitProduct.product_bundle, formatOptions),
959
994
  metadata: cleanMetadata,
960
995
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
961
996
  // 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
962
- payment_price: (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
997
+ payment_price: formatOptions.virtualSettlementMode ? virtualPrice : (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
963
998
  });
964
999
  }
965
1000
  var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
@@ -1080,7 +1115,7 @@ export function createDefaultTempOrder(params) {
1080
1115
  };
1081
1116
  }
1082
1117
  export function buildSubmitPayload(params) {
1083
- var _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref30, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
1118
+ var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref31, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
1084
1119
  var tempOrder = params.tempOrder,
1085
1120
  cacheId = params.cacheId,
1086
1121
  _params$now = params.now,
@@ -1093,26 +1128,27 @@ export function buildSubmitPayload(params) {
1093
1128
  enhance = params.enhance;
1094
1129
  var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
1095
1130
  var bookingUuid = createUuidV4();
1096
- var _ref29 = tempOrder,
1097
- _extend = _ref29._extend,
1098
- _relationId = _ref29.relation_id,
1099
- _tableFormId = _ref29.table_form_id,
1100
- _resourceId = _ref29.resource_id,
1101
- _summary = _ref29.summary,
1102
- _lastOrderInfo = _ref29.lastOrderInfo,
1103
- _paidAmount = _ref29.paid_amount,
1104
- _shopId = _ref29.shop_id,
1105
- _shopNote = _ref29.shop_note,
1106
- _shopServiceType = _ref29.shop_service_type,
1107
- _startTime = _ref29.start_time,
1108
- _customer = _ref29.customer,
1109
- _discountList = _ref29.discount_list,
1110
- _rootTaxFee = _ref29.tax_fee,
1111
- _totalAmount = _ref29.total_amount,
1112
- _totalRefundAmount = _ref29.total_refund_amount,
1113
- _createDate = _ref29.create_date,
1114
- _holderId = _ref29.holder_id,
1115
- tempOrderRest = _objectWithoutProperties(_ref29, _excluded4);
1131
+ var virtualSettlementMode = ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.settlement_type) === 'virtual_currency';
1132
+ var _ref30 = tempOrder,
1133
+ _extend = _ref30._extend,
1134
+ _relationId = _ref30.relation_id,
1135
+ _tableFormId = _ref30.table_form_id,
1136
+ _resourceId = _ref30.resource_id,
1137
+ _summary = _ref30.summary,
1138
+ _lastOrderInfo = _ref30.lastOrderInfo,
1139
+ _paidAmount = _ref30.paid_amount,
1140
+ _shopId = _ref30.shop_id,
1141
+ _shopNote = _ref30.shop_note,
1142
+ _shopServiceType = _ref30.shop_service_type,
1143
+ _startTime = _ref30.start_time,
1144
+ _customer = _ref30.customer,
1145
+ _discountList = _ref30.discount_list,
1146
+ _rootTaxFee = _ref30.tax_fee,
1147
+ _totalAmount = _ref30.total_amount,
1148
+ _totalRefundAmount = _ref30.total_refund_amount,
1149
+ _createDate = _ref30.create_date,
1150
+ _holderId = _ref30.holder_id,
1151
+ tempOrderRest = _objectWithoutProperties(_ref30, _excluded4);
1116
1152
  var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
1117
1153
  if (!submitType) {
1118
1154
  var _tempOrder$bookings;
@@ -1137,7 +1173,7 @@ export function buildSubmitPayload(params) {
1137
1173
  type: submitType,
1138
1174
  business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
1139
1175
  sales_channel: tempOrder.sales_channel || 'my_pisel',
1140
- order_sales_channel: (_ref30 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref30 !== void 0 ? _ref30 : 'online_store',
1176
+ order_sales_channel: (_ref31 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref31 !== void 0 ? _ref31 : 'online_store',
1141
1177
  status: tempOrder.status || 'normal',
1142
1178
  payment_status: tempOrder.payment_status || 'payment_processing',
1143
1179
  // shipping_status: tempOrder.shipping_status || 'unfulfilled',
@@ -1163,14 +1199,19 @@ export function buildSubmitPayload(params) {
1163
1199
  // holder: tempOrder.holder || null,
1164
1200
  summary: summary || tempOrder.summary || createEmptySummary(),
1165
1201
  metadata: function () {
1166
- var _ref31 = tempOrder.metadata || {},
1167
- _collectPax = _ref31.collect_pax,
1168
- _tableOccupancyDuration = _ref31.table_occupancy_duration,
1169
- rest = _objectWithoutProperties(_ref31, _excluded5);
1202
+ var _ref32 = tempOrder.metadata || {},
1203
+ _collectPax = _ref32.collect_pax,
1204
+ _tableOccupancyDuration = _ref32.table_occupancy_duration,
1205
+ _cartSettlementKey = _ref32.cart_settlement_key,
1206
+ _cartSettlementSnapshot = _ref32.cart_settlement_snapshot,
1207
+ _legalCurrencySnapshot = _ref32.legal_currency_snapshot,
1208
+ rest = _objectWithoutProperties(_ref32, _excluded5);
1170
1209
  return _objectSpread({}, rest);
1171
1210
  }(),
1172
1211
  products: (tempOrder.products || []).map(function (product) {
1173
- return normalizeSubmitProduct(product);
1212
+ return normalizeSubmitProduct(product, {
1213
+ virtualSettlementMode: virtualSettlementMode
1214
+ });
1174
1215
  })
1175
1216
  });
1176
1217
  if (!enhance) return payload;
@@ -1374,8 +1415,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
1374
1415
  return tempOrder._extend.productsByUid[uid].origin;
1375
1416
  }
1376
1417
  var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
1377
- var _ref32, _item$product_id, _ref33, _product$product_id;
1378
- return item === product || getOrderProductLineUid(item) === uid || String((_ref32 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref32 !== void 0 ? _ref32 : '') === String((_ref33 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref33 !== void 0 ? _ref33 : '');
1418
+ var _ref33, _item$product_id, _ref34, _product$product_id;
1419
+ return item === product || getOrderProductLineUid(item) === uid || String((_ref33 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref33 !== void 0 ? _ref33 : '') === String((_ref34 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref34 !== void 0 ? _ref34 : '');
1379
1420
  });
1380
1421
  var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
1381
1422
  return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[matchedUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin) || null : null;
@@ -486,6 +486,8 @@ export interface WalletPassPayment {
486
486
  importWalletAssetsSnapshot: (snapshot: WalletAssetsSnapshot) => WalletAssetsState;
487
487
  /** 设置单张钱包资产的选择状态并重新计算其实际抵扣额。 */
488
488
  selectWalletAsset: (assetId: WalletAssetId, options: SelectWalletAssetOptions) => WalletAssetsState;
489
+ /** 更新已选钱包资产的手动使用金额,并保持原有选择顺序重新计算。 */
490
+ updateWalletAssetAmount: (assetId: WalletAssetId, amount: number) => WalletAssetsState;
489
491
  /** 精确搜索钱包资产;仅当前券可用时自动选择。 */
490
492
  scanWalletAssetAsync: (code: string) => Promise<ScanWalletAssetResult>;
491
493
  /** 清空未确认的钱包资产选择。 */
@@ -12,9 +12,12 @@ export var getAvailableMaxAmount = function getAvailableMaxAmount(data) {
12
12
  */
13
13
  export var formatWalletPassList2PreparePayments = function formatWalletPassList2PreparePayments(list) {
14
14
  var formatted = (list || []).map(function (item) {
15
+ var _ref, _item$actualDeduction;
15
16
  return {
16
17
  voucher_id: item.id || 0,
17
- amount: Number(item.edit_current_amount || getAvailableMaxAmount(item)) || 0,
18
+ // 前端策略重算后的 actualDeduction 才是最终可同步金额;
19
+ // edit_current_amount 只是用户请求值,仍可能被策略和订单剩余金额裁剪。
20
+ amount: Number((_ref = (_item$actualDeduction = item.actualDeduction) !== null && _item$actualDeduction !== void 0 ? _item$actualDeduction : item.edit_current_amount) !== null && _ref !== void 0 ? _ref : getAvailableMaxAmount(item)) || 0,
18
21
  tag: item.tag || '',
19
22
  wallet_pass_usage_unit: item.wallet_pass_usage_unit || {},
20
23
  wallet_pass_use_value: item.wallet_pass_use_value || undefined
@@ -24,6 +24,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
24
24
  private emitEvent;
25
25
  private publishWalletAssetsState;
26
26
  private recalculateWalletAssets;
27
+ /**
28
+ * 搜索接口只返回后端 Wallet Pass 数据,不包含前端策略 config。
29
+ * 在资产进入共享选择状态前补齐策略结果,避免增量重算回退到接口状态。
30
+ */
31
+ private formatSearchedWalletPaymentAssets;
27
32
  /** 获取当前缓存中所有支付类 Wallet 资产的扫码 code。 */
28
33
  private getSearchedWalletAssetCodes;
29
34
  /**
@@ -106,7 +111,13 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
106
111
  getWalletAssetsState(): WalletAssetsState;
107
112
  exportWalletAssetsSnapshot(): WalletAssetsSnapshot;
108
113
  importWalletAssetsSnapshot(snapshot: WalletAssetsSnapshot): WalletAssetsState;
114
+ private updateWalletAssetEditAmountInCaches;
109
115
  selectWalletAsset(assetId: WalletAssetId, options: SelectWalletAssetOptions): WalletAssetsState;
116
+ /**
117
+ * 更新已选资产的手动金额。只允许在当前实际抵扣额内向下调整,
118
+ * 金额为 0 时沿用 legacy 行为取消选择。
119
+ */
120
+ updateWalletAssetAmount(assetId: WalletAssetId, amount: number): WalletAssetsState;
110
121
  scanWalletAssetAsync(code: string): Promise<ScanWalletAssetResult>;
111
122
  clearWalletAssetSelection(): WalletAssetsState;
112
123
  setCommittedWalletAssets(committedIds: WalletAssetId[], committedAssets?: any[]): WalletAssetsState;