@pisell/pisellos 2.1.78 → 2.1.80

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.
@@ -146,6 +146,8 @@ export interface CartItem {
146
146
  _optionsOrigin?: any[];
147
147
  /** 操作系统提示 */
148
148
  osWarnTips?: string[];
149
+ /** 金额差值 */
150
+ totalDifference?: number;
149
151
  }
150
152
  /**
151
153
  * 购物车状态接口
@@ -13,6 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
13
13
  import Decimal from 'decimal.js';
14
14
  import { isNormalProduct } from "../../Product/utils";
15
15
  import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
16
+ import { calcDiscountListDifference } from "../../Summary/utils";
16
17
 
17
18
  /**
18
19
  * @title 处理组合商品
@@ -69,6 +70,11 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
69
70
  num: num,
70
71
  discounts: discounts
71
72
  });
73
+ cartItem.totalDifference = getTotalDifference({
74
+ product: product,
75
+ bundle: bundle,
76
+ discounts: discounts
77
+ });
72
78
  cartItem.summaryTotal = cartItem.total * (num || 1);
73
79
  cartItem.origin_total = getProductOriginTotalPrice({
74
80
  product: product,
@@ -218,6 +224,19 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
218
224
  }
219
225
  return Math.max(0, price);
220
226
  };
227
+ var getTotalDifference = function getTotalDifference(params) {
228
+ var bundle = params.bundle,
229
+ discounts = params.discounts;
230
+ var bundleDiscountList = [];
231
+ if (bundle !== null && bundle !== void 0 && bundle.length) {
232
+ bundle.forEach(function (currentValue) {
233
+ bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((currentValue === null || currentValue === void 0 ? void 0 : currentValue.discount_list) || []));
234
+ });
235
+ }
236
+ var allDiscounts = [].concat(_toConsumableArray(discounts || []), bundleDiscountList);
237
+ var productDiscountProductDiscountDifference = calcDiscountListDifference(allDiscounts);
238
+ return productDiscountProductDiscountDifference || 0;
239
+ };
221
240
 
222
241
  /**
223
242
  * 获取商品原始总价
@@ -304,7 +323,8 @@ export var formatBundle = function formatBundle(bundle) {
304
323
  options: formatOptions(item === null || item === void 0 ? void 0 : item.option),
305
324
  _bundle_product_id: item._bundle_product_id,
306
325
  discount_list: item.discount_list,
307
- originBundleItem: item.originBundleItem || item
326
+ originBundleItem: item.originBundleItem || item,
327
+ is_charge_tax: item === null || item === void 0 ? void 0 : item.is_charge_tax
308
328
  };
309
329
  });
310
330
  };
@@ -694,7 +694,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
694
694
  // 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
695
695
  var applicableProducts = [];
696
696
  sortedFlattenedList.forEach(function (flatItem) {
697
- var _flatItem$parentProdu2, _product$price, _ref5, _flatItem$original_pr;
697
+ var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref5, _flatItem$original_pr;
698
698
  // 🔥 检查该商品是否被其他专属折扣卡占用
699
699
  var occupyingDiscountId = occupiedItems.get(flatItem._id);
700
700
  if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
@@ -718,7 +718,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
718
718
  }
719
719
 
720
720
  // 对于 bundle 子商品,quantity 需要乘以主商品的购买数量
721
- var quantity = flatItem.type === 'main' ? product.quantity || 1 : (product.num || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.quantity) || 1);
721
+ var quantity = flatItem.type === 'main' ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.num) || ((_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.quantity) || 1);
722
722
 
723
723
  // 对于主商品:使用 price
724
724
  // 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
@@ -733,8 +733,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
733
733
 
734
734
  // 子商品需要传递主商品数量
735
735
  if (flatItem.type === 'bundle') {
736
- var _flatItem$parentProdu3;
737
- productData.parentQuantity = ((_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.quantity) || 1;
736
+ var _flatItem$parentProdu4;
737
+ productData.parentQuantity = ((_flatItem$parentProdu4 = flatItem.parentProduct) === null || _flatItem$parentProdu4 === void 0 ? void 0 : _flatItem$parentProdu4.quantity) || 1;
738
738
  }
739
739
  applicableProducts.push(productData);
740
740
  });
@@ -761,7 +761,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
761
761
  product = flatItem.product;
762
762
  originProduct = flatItem.originProduct;
763
763
  } else {
764
- var _flatItem$parentProdu4;
764
+ var _flatItem$parentProdu5;
765
765
  // bundle子商品:构造虚拟商品对象
766
766
  product = {
767
767
  _id: flatItem._id,
@@ -773,7 +773,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
773
773
  origin_total: flatItem.origin_total,
774
774
  booking_id: flatItem.booking_id,
775
775
  discount_list: flatItem.discount_list || [],
776
- startDate: (_flatItem$parentProdu4 = flatItem.parentProduct) === null || _flatItem$parentProdu4 === void 0 ? void 0 : _flatItem$parentProdu4.startDate
776
+ startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
777
777
  };
778
778
  originProduct = flatItem.originProduct;
779
779
  }
@@ -851,7 +851,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
851
851
  product = flatItem.product;
852
852
  originProduct = flatItem.originProduct;
853
853
  } else {
854
- var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu5;
854
+ var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu6;
855
855
  // bundle子商品
856
856
  product = {
857
857
  _id: flatItem._id,
@@ -864,7 +864,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
864
864
  origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem6 = flatItem.bundleItem) === null || _flatItem$bundleItem6 === void 0 ? void 0 : _flatItem$bundleItem6.original_price,
865
865
  booking_id: flatItem.booking_id,
866
866
  discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || [],
867
- startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
867
+ startDate: (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate
868
868
  };
869
869
  originProduct = flatItem.originProduct;
870
870
  }
@@ -976,11 +976,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
976
976
  }
977
977
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
978
978
  if (flatItem.type === 'bundle') {
979
- var _product$discount_lis7, _flatItem$parentProdu6;
979
+ var _product$discount_lis7, _flatItem$parentProdu7;
980
980
  if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
981
981
  var _item$discount2;
982
982
  return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
983
- }) || (_flatItem$parentProdu6 = flatItem.parentProduct) !== null && _flatItem$parentProdu6 !== void 0 && (_flatItem$parentProdu6 = _flatItem$parentProdu6.discount_list) !== null && _flatItem$parentProdu6 !== void 0 && _flatItem$parentProdu6.some(function (item) {
983
+ }) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
984
984
  var _item$discount3;
985
985
  return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
986
986
  })) {
@@ -1002,14 +1002,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1002
1002
  }
1003
1003
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
1004
1004
  if (flatItem.type === 'bundle') {
1005
- var _product$discount_lis9, _flatItem$parentProdu7;
1005
+ var _product$discount_lis9, _flatItem$parentProdu8;
1006
1006
  if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
1007
1007
  var _options$selectedList2;
1008
1008
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
1009
1009
  var _item$discount5;
1010
1010
  return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
1011
1011
  });
1012
- }) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
1012
+ }) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
1013
1013
  var _options$selectedList3;
1014
1014
  return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
1015
1015
  var _item$discount6;
@@ -1265,7 +1265,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1265
1265
  }));
1266
1266
  }
1267
1267
  } else {
1268
- var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu8;
1268
+ var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
1269
1269
  // 折扣卡:不拆分数量,直接应用
1270
1270
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
1271
1271
  usedDiscounts.set(_selectedDiscount3.id, true);
@@ -1311,7 +1311,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1311
1311
  }, _productDiscountDifference !== undefined && {
1312
1312
  product_discount_difference: _productDiscountDifference
1313
1313
  }),
1314
- _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu8 = flatItem.parentProduct) === null || _flatItem$parentProdu8 === void 0 ? void 0 : _flatItem$parentProdu8.num) || 1)
1314
+ _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
1315
1315
  };
1316
1316
 
1317
1317
  // 记录实际应用的折扣
@@ -13,6 +13,7 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
13
13
  private fatherModule;
14
14
  constructor(name?: string, version?: string);
15
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
+ getSurchargeList(): Promise<void>;
16
17
  getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
17
18
  /**
18
19
  * 获取协议
@@ -21,4 +22,6 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
21
22
  */
22
23
  getProtocol(protocolId: string): Promise<any>;
23
24
  storeChange(): void;
25
+ private getTaxforUtils;
26
+ private getSurchargeforUtils;
24
27
  }
@@ -15,8 +15,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
15
15
  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; }
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
+ import Decimal from 'decimal.js';
18
19
  import { BaseModule } from "../BaseModule";
19
- import { calculatePriceDetails } from "./utils";
20
+ import { ScheduleModule } from "../Schedule";
21
+ import { calculatePriceDetails, getSurcharge, getSurchargeAmount, getTax } from "./utils";
20
22
  export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
21
23
  _inherits(SummaryModule, _BaseModule);
22
24
  var _super = _createSuper(SummaryModule);
@@ -62,6 +64,9 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
62
64
  }
63
65
  throw new Error('SummaryModule 需要 shopStore 插件支持');
64
66
  case 9:
67
+ // 加载当前店铺附加费
68
+ this.getSurchargeList();
69
+ case 10:
65
70
  case "end":
66
71
  return _context.stop();
67
72
  }
@@ -72,24 +77,53 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
72
77
  }
73
78
  return initialize;
74
79
  }()
80
+ }, {
81
+ key: "getSurchargeList",
82
+ value: function () {
83
+ var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
84
+ var surchargeList;
85
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
86
+ while (1) switch (_context2.prev = _context2.next) {
87
+ case 0:
88
+ _context2.next = 2;
89
+ return this.request.get('/order/custom-surcharge/available', {
90
+ channel: 'online-store',
91
+ is_assemble_product_data: 1,
92
+ is_assemble_schedule_data: 1,
93
+ with: ['relationSchedule']
94
+ });
95
+ case 2:
96
+ surchargeList = _context2.sent;
97
+ this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
98
+ case 4:
99
+ case "end":
100
+ return _context2.stop();
101
+ }
102
+ }, _callee2, this);
103
+ }));
104
+ function getSurchargeList() {
105
+ return _getSurchargeList.apply(this, arguments);
106
+ }
107
+ return getSurchargeList;
108
+ }()
75
109
  }, {
76
110
  key: "getSummary",
77
111
  value: function () {
78
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cartItems) {
112
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(cartItems) {
79
113
  var _this$shopStore$get;
80
114
  var shopInfo, summary;
81
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
82
- while (1) switch (_context2.prev = _context2.next) {
115
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
116
+ while (1) switch (_context3.prev = _context3.next) {
83
117
  case 0:
84
118
  shopInfo = ((_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.shop) || {};
85
- summary = calculatePriceDetails(shopInfo, cartItems);
119
+ summary = calculatePriceDetails(shopInfo, cartItems, ScheduleModule.isInScheduleByDate, this.store.surchargeList);
86
120
  this.store.summary = summary;
87
- return _context2.abrupt("return", this.store.summary);
121
+ return _context3.abrupt("return", this.store.summary);
88
122
  case 4:
89
123
  case "end":
90
- return _context2.stop();
124
+ return _context3.stop();
91
125
  }
92
- }, _callee2, this);
126
+ }, _callee3, this);
93
127
  }));
94
128
  function getSummary(_x3) {
95
129
  return _getSummary.apply(this, arguments);
@@ -104,16 +138,16 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
104
138
  }, {
105
139
  key: "getProtocol",
106
140
  value: (function () {
107
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(protocolId) {
108
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
109
- while (1) switch (_context3.prev = _context3.next) {
141
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(protocolId) {
142
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
143
+ while (1) switch (_context4.prev = _context4.next) {
110
144
  case 0:
111
- return _context3.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
145
+ return _context4.abrupt("return", this.request.get("/shop-policy/".concat(protocolId)));
112
146
  case 1:
113
147
  case "end":
114
- return _context3.stop();
148
+ return _context4.stop();
115
149
  }
116
- }, _callee3, this);
150
+ }, _callee4, this);
117
151
  }));
118
152
  function getProtocol(_x4) {
119
153
  return _getProtocol.apply(this, arguments);
@@ -132,6 +166,49 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
132
166
  });
133
167
  }
134
168
  }
169
+ }, {
170
+ key: "getTaxforUtils",
171
+ value: function getTaxforUtils(items, shopInfo, subtotal) {
172
+ return getTax({
173
+ service: items,
174
+ bookingDetail: null,
175
+ bookingId: undefined
176
+ }, {
177
+ computed: {
178
+ productExpectAmount: subtotal,
179
+ shopDiscount: 0
180
+ },
181
+ isEdit: false,
182
+ tax_rate: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_rate,
183
+ is_price_include_tax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax
184
+ });
185
+ }
186
+ }, {
187
+ key: "getSurchargeforUtils",
188
+ value: function getSurchargeforUtils(items) {
189
+ // const surchargeList = this.store.surchargeList;
190
+ var surchargeList = getSurcharge({
191
+ service: items,
192
+ addons: [],
193
+ bookingDetail: null,
194
+ bookingId: undefined
195
+ }, {
196
+ isEdit: false,
197
+ isInScheduleByDate: ScheduleModule.isInScheduleByDate,
198
+ surcharge_list: this.store.surchargeList,
199
+ scheduleById: {}
200
+ });
201
+ var surchargeAmount = new Decimal(getSurchargeAmount({
202
+ bookingDetail: null,
203
+ bookingId: undefined
204
+ }, surchargeList, {
205
+ isEdit: false
206
+ }));
207
+ return {
208
+ surchargeList: surchargeList,
209
+ surchargeAmount: surchargeAmount.toFixed(2)
210
+ };
211
+ }
135
212
  }]);
136
213
  return SummaryModule;
137
214
  }(BaseModule);
@@ -1,5 +1,6 @@
1
1
  import { CartItem } from '../Cart/types';
2
2
  export interface ISummaryState {
3
+ surchargeList: any[];
3
4
  summary: {
4
5
  /** 商品总价 */
5
6
  subtotal: string | number;
@@ -11,6 +12,12 @@ export interface ISummaryState {
11
12
  totalTaxFee?: string | number;
12
13
  /** 商品价格是否包含费率 */
13
14
  isPriceIncludeTax?: 0 | 1;
15
+ /** 附加费金额 */
16
+ surchargeAmount?: string | number;
17
+ /** 附加费列表 */
18
+ surcharge?: any[];
19
+ /** 税率 */
20
+ taxRate?: string | number;
14
21
  /** 定金 */
15
22
  deposit?: {
16
23
  /** 定金总价 */
@@ -1,12 +1,57 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import { CartItem } from '../Cart/types';
3
3
  import { ISummaryState } from './types';
4
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], isInScheduleByDate: any, surchargeList: any[]) => ISummaryState['summary'];
5
5
  /**
6
6
  * 获取子商品折扣信息
7
7
  * @param item
8
8
  */
9
9
  export declare const getBundleDiscountList: (bundle: any[]) => any[];
10
+ export declare const calcDiscountListDifference: (discountList: any[]) => any;
11
+ export declare const getProductDiscountProductDiscountDifference: (item: CartItem) => any;
12
+ /**
13
+ * 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
14
+ *
15
+ * - **折扣前税费**:`originTax`
16
+ * - **折扣后税费**:`tax`(会考虑 `computed.shopDiscount` 对每个商品的分摊影响)
17
+ * - **税率/是否含税**:优先取 `bookingDetail.tax_rate` / `bookingDetail.is_price_include_tax`,取不到再回退到 `options.tax_rate` / `options.is_price_include_tax`
18
+ *
19
+ * **副作用(会修改入参商品对象)**:
20
+ * - 主商品:写入 `item.original_tax_fee` / `item.tax_fee`(四舍五入保留两位)
21
+ * - bundle 原价子商品:写入 `bundleItem.original_tax_fee` / `bundleItem.tax_fee`
22
+ * - 加时商品(`relation_details`):写入 `atItem.tax_fee`
23
+ * - 税费舍入差值:追加到最后一个“含税商品”的 `tax_fee_rounding_remainder` / `original_tax_fee_rounding_remainder`
24
+ *
25
+ * @param params 入参集合(RORO)
26
+ * @param params.service 服务商品数组(主商品)。通常是购物车商品结构(可能包含 `bundle` / `relation_details`)
27
+ * @param params.addons 附加商品数组(可选)。结构同商品数组
28
+ * @param params.bookingDetail 订单详情(编辑/详情场景用于读取后端税率配置),可选
29
+ * @param params.bookingId 订单/预约 ID(编辑/详情场景识别用),可选
30
+ * @param options 计算选项
31
+ * @param options.isEdit 是否处于“编辑中”。当前实现不强依赖该值(历史逻辑保留),但建议按真实状态传入
32
+ * @param options.computed 预计算结果(用于折扣分摊)
33
+ * @param options.computed.productExpectAmount 商品期望总金额(用于按比例分摊折扣)
34
+ * @param options.computed.shopDiscount 店铺折扣总额(用于按比例分摊到商品)
35
+ * @param options.tax_rate 管理端税率(百分比,如 5 表示 5%)。仅当 `bookingDetail.tax_rate` 不存在时生效
36
+ * @param options.is_price_include_tax 是否含税:`0` 不含税、`1` 含税。仅当 `bookingDetail.is_price_include_tax` 不存在时生效
37
+ * @returns 税费汇总(number,金额单位与商品价格一致,四舍五入保留两位)
38
+ * @returns.originTax 折扣前税费合计
39
+ * @returns.tax 折扣后税费合计
40
+ */
41
+ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
42
+ service?: any;
43
+ addons?: any;
44
+ bookingDetail?: any;
45
+ bookingId?: number | undefined;
46
+ }, options: {
47
+ isEdit: boolean;
48
+ computed: Record<string, number | string>;
49
+ tax_rate?: number;
50
+ is_price_include_tax?: number;
51
+ } & Record<string, any>) => {
52
+ originTax: number;
53
+ tax: number;
54
+ };
10
55
  /**
11
56
  * 计算商品小计(不含其他费用)
12
57
  * @param items - 购物车商品数组
@@ -32,3 +77,61 @@ export declare const calculateDeposit: (items: CartItem[]) => {
32
77
  protocols: any[];
33
78
  hasDeposit: never;
34
79
  } | undefined;
80
+ /**
81
+ * 计算订单附加费金额(订单级别合计)。
82
+ *
83
+ * - **详情未编辑**(`!options.isEdit && bookingId`)且存在后端详情时:直接返回 `bookingDetail.surcharge_fee`
84
+ * - **新增/编辑**时:对 `surcharge`(通常为 `getSurcharge` 的返回值)按 `item.value` 求和
85
+ *
86
+ * @param params 入参集合(RORO)
87
+ * @param params.bookingDetail 订单详情(详情未编辑时用于读取后端的 `surcharge_fee`),可选
88
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
89
+ * @param surcharge 附加费列表(通常来自 `getSurcharge`),元素结构至少包含 `value: number`
90
+ * @param options 计算选项
91
+ * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
92
+ * @returns 订单附加费金额(number,金额单位与商品价格一致)
93
+ */
94
+ export declare const getSurchargeAmount: ({ bookingDetail, bookingId }: {
95
+ bookingDetail?: any;
96
+ bookingId?: number | undefined;
97
+ }, surcharge: any[], options: any) => any;
98
+ /**
99
+ * 订单附加费各项信息
100
+ *
101
+ * - **详情未编辑**(`!options.isEdit && bookingId`)时:直接返回 `bookingDetail.surcharge`(后端计算结果)
102
+ * - **新增/编辑**时:按 `options.surcharge_list` 逐条配置计算本次订单的附加费
103
+ *
104
+ * 规则要点:
105
+ * - 匹配范围包含:主商品(`service`)、原价 bundle 子商品(`item.bundle`)、加时商品(`item.relation_details`)、以及 addons(`addons.value`)
106
+ * - 固定附加费 `fixed`:只加一次,再按商品数量分摊(向下取整保留两位),剩余小数会以 `surcharge_rounding_remainder` 形式抹平到最后一个商品
107
+ * - 百分比附加费 `percentage`:按每个商品(价格 * 数量)分别计算再累加
108
+ * - 当 `open_product === 0`:不回写到商品,只在订单级别累加;否则会把单品附加费回写到商品
109
+ *
110
+ * **副作用(可能修改入参商品对象)**:
111
+ * - 当 `open_product !== 0` 时:写入 `item.surcharge_fee`(单品单数量附加费,保留两位、向下取整)
112
+ * - 写入 `item.relation_surcharge_ids`(关联到的 surcharge 配置 id 列表)
113
+ * - 写入 `item.surcharge_rounding_remainder`(用于抹平固定附加费/总额舍入差)
114
+ *
115
+ * @param params 入参集合(RORO)
116
+ * @param params.service 服务商品数组(主商品)。元素可能包含 `bundle` / `relation_details`
117
+ * @param params.addons 附加商品容器。当前实现读取 `addons.value` 作为商品数组(所以通常传 `{ value: CartItem[] }`)
118
+ * @param params.bookingDetail 订单详情(详情未编辑时用于直接取后端的 surcharge 列表),可选
119
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
120
+ * @param options 计算选项
121
+ * @param options.isEdit 是否处于“编辑中”。`false` 且存在 `bookingId` 时会走详情直取逻辑
122
+ * @param options.surcharge_list 附加费配置列表(后端下发)。缺失/为空则返回空数组
123
+ * @param options.isInScheduleByDate 判断日期是否落在某个 schedule 内的方法(通常来自 ScheduleModule)
124
+ * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
125
+ * @returns 附加费列表(仅返回金额 > 0 的项)
126
+ */
127
+ export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId }: {
128
+ service: any;
129
+ addons: any;
130
+ bookingDetail?: any;
131
+ bookingId?: number | undefined;
132
+ }, options: {
133
+ isEdit: boolean;
134
+ isInScheduleByDate: any;
135
+ surcharge_list?: any[];
136
+ scheduleById?: Record<string, any>;
137
+ } & Record<string, any>) => any;