@pisell/pisellos 0.0.400 → 0.0.401

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.
@@ -114,8 +114,8 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
114
114
  while (1) switch (_context3.prev = _context3.next) {
115
115
  case 0:
116
116
  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) || {};
117
- scheduleModule = this.core.getModule('appointmentBooking_schedule');
118
- summary = calculatePriceDetails(shopInfo, cartItems, scheduleModule, this.store.surchargeList);
117
+ scheduleModule = this.core.getModule('appointmentBooking_schedule'); //@ts-ignore
118
+ summary = calculatePriceDetails(shopInfo, cartItems, scheduleModule === null || scheduleModule === void 0 ? void 0 : scheduleModule.isInScheduleByDate, this.store.surchargeList);
119
119
  this.store.summary = summary;
120
120
  return _context3.abrupt("return", this.store.summary);
121
121
  case 5:
@@ -16,6 +16,10 @@ export interface ISummaryState {
16
16
  isPriceIncludeTax?: 0 | 1;
17
17
  /** 附加费金额 */
18
18
  surchargeAmount?: string | number;
19
+ /** 附加费列表 */
20
+ surcharge?: any[];
21
+ /** 税率 */
22
+ taxRate?: string | number;
19
23
  /** 定金 */
20
24
  deposit?: {
21
25
  /** 定金总价 */
@@ -1,8 +1,7 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import { CartItem } from '../Cart/types';
3
3
  import { ISummaryState } from './types';
4
- import { ScheduleModule } from '../Schedule';
5
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], scheduleModule: ScheduleModule, surchargeList: any[]) => ISummaryState['summary'];
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], isInScheduleByDate: any, surchargeList: any[]) => ISummaryState['summary'];
6
5
  /**
7
6
  * 获取子商品折扣信息
8
7
  * @param item
@@ -55,7 +54,7 @@ export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId
55
54
  bookingId?: number | undefined;
56
55
  }, options: {
57
56
  isEdit: boolean;
58
- ScheduleModule: any;
57
+ isInScheduleByDate: any;
59
58
  surcharge_list?: any[];
60
59
  scheduleById?: Record<string, any>;
61
60
  } & Record<string, any>) => any;
@@ -1,7 +1,13 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
4
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
5
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
5
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
12
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -10,10 +16,18 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
10
16
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
17
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
18
  import Decimal from 'decimal.js';
13
- export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items, scheduleModule, surchargeList) {
19
+ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items, isInScheduleByDate, surchargeList) {
14
20
  var subtotal = new Decimal(calculateSubtotal(items));
15
21
  var subOriginTotal = new Decimal(calculateOriginSubtotal(items));
16
22
  var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
23
+ // 税费
24
+ // const { tax, originTax } = getTax({ service: items, bookingDetail: null, bookingId: undefined }, {
25
+ // computed: {
26
+ // productExpectAmount: subtotal.toNumber(),
27
+ // shopDiscount: 0,
28
+ // },
29
+ // isEdit: false,
30
+ // });
17
31
  // 订单附加费列表
18
32
  var surcharge = getSurcharge({
19
33
  service: items,
@@ -22,7 +36,7 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
22
36
  bookingId: undefined
23
37
  }, {
24
38
  isEdit: false,
25
- ScheduleModule: scheduleModule,
39
+ isInScheduleByDate: isInScheduleByDate,
26
40
  surcharge_list: surchargeList,
27
41
  scheduleById: {}
28
42
  });
@@ -47,8 +61,10 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
47
61
  total: total.toFixed(2),
48
62
  originTotal: originTotal.toFixed(2),
49
63
  taxTitle: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_title,
64
+ taxRate: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_rate,
50
65
  totalTaxFee: totalTaxFee.toFixed(2),
51
66
  isPriceIncludeTax: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.is_price_include_tax,
67
+ surcharge: surcharge,
52
68
  surchargeAmount: surchargeAmount.toFixed(2),
53
69
  deposit: deposit
54
70
  };
@@ -82,6 +98,395 @@ var getProductDiscountProductDiscountDifference = function getProductDiscountPro
82
98
  }, 0);
83
99
  };
84
100
 
101
+ /**
102
+ * 税费
103
+ * @param state
104
+ * @param options 包含 isEdit、computed 和其他税费计算所需参数
105
+ * @returns
106
+ */
107
+ var getTax = function getTax(_ref, options) {
108
+ var service = _ref.service,
109
+ addons = _ref.addons,
110
+ bookingDetail = _ref.bookingDetail,
111
+ bookingId = _ref.bookingId;
112
+ var isEdit = options.isEdit,
113
+ computed = options.computed,
114
+ tax_rate = options.tax_rate,
115
+ is_price_include_tax = options.is_price_include_tax;
116
+
117
+ // 详情时未编辑的状态下, 取后端的值
118
+ if (!isEdit) {
119
+ return {
120
+ tax: Number(bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.tax_fee) || 0
121
+ };
122
+ }
123
+ var totalOriginTax = new Decimal(0);
124
+ var totalTax = new Decimal(0);
125
+ if (service || addons) {
126
+ // 处理服务商品
127
+ if (service !== null && service !== void 0 && service.length) {
128
+ var serviceResult = processItemsTax(service, {
129
+ bookingDetail: bookingDetail,
130
+ bookingId: bookingId
131
+ }, {
132
+ tax_rate: tax_rate,
133
+ is_price_include_tax: is_price_include_tax,
134
+ computed: computed
135
+ });
136
+ totalOriginTax = totalOriginTax.plus(serviceResult.originTax);
137
+ totalTax = totalTax.plus(serviceResult.tax);
138
+ }
139
+
140
+ // 处理附加商品
141
+ if (addons !== null && addons !== void 0 && addons.length) {
142
+ var addonsResult = processItemsTax(addons, {
143
+ bookingDetail: bookingDetail,
144
+ bookingId: bookingId
145
+ }, {
146
+ tax_rate: tax_rate,
147
+ is_price_include_tax: is_price_include_tax,
148
+ computed: computed
149
+ });
150
+ totalOriginTax = totalOriginTax.plus(addonsResult.originTax);
151
+ totalTax = totalTax.plus(addonsResult.tax);
152
+ }
153
+ }
154
+ return {
155
+ originTax: totalOriginTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber(),
156
+ tax: totalTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber()
157
+ };
158
+ };
159
+
160
+ /**
161
+ * 处理商品税费计算(折扣前后)
162
+ * 支持税费舍入差值追加到最后一个含税商品的 tax_fee_rounding_remainder / original_tax_fee_rounding_remainder 字段
163
+ * @param items 商品数组
164
+ * @param state 状态
165
+ * @param options 选项
166
+ * @param computed 计算结果
167
+ * @returns 累积的税费信息
168
+ */
169
+ var processItemsTax = function processItemsTax(items, _ref2, options) {
170
+ var bookingDetail = _ref2.bookingDetail,
171
+ bookingId = _ref2.bookingId;
172
+ var tax_rate = options.tax_rate,
173
+ is_price_include_tax = options.is_price_include_tax,
174
+ computed = options.computed;
175
+ var shopDiscount = computed.shopDiscount,
176
+ productExpectAmount = computed.productExpectAmount;
177
+
178
+ // 精确税费累加(不四舍五入)
179
+ var preciseOriginTax = new Decimal(0);
180
+ var preciseTax = new Decimal(0);
181
+ // 四舍五入后的税费累加
182
+ var roundedOriginTax = new Decimal(0);
183
+ var roundedTax = new Decimal(0);
184
+
185
+ /**
186
+ * 最后一个含税商品的引用(按物理位置)
187
+ * 用于追加税费舍入差值
188
+ */
189
+ var lastTaxableItem = null;
190
+ var _iterator = _createForOfIteratorHelper(items),
191
+ _step;
192
+ try {
193
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
194
+ var _item$_extend$other;
195
+ var item = _step.value;
196
+ var quantity = new Decimal(item.num || 1);
197
+ var unitPrice = new Decimal(item.total || 0);
198
+ var mainProductPrice = new Decimal(getMainProductTotal(item) || 0);
199
+
200
+ // 计算原始税费(折扣前)- 单个商品(精确值)
201
+ var originalTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, item), {}, {
202
+ total: mainProductPrice.add((item === null || item === void 0 ? void 0 : item.surcharge_fee) || 0).toNumber(),
203
+ quantity: 1
204
+ }), {
205
+ bookingDetail: bookingDetail,
206
+ bookingId: bookingId
207
+ }, {
208
+ tax_rate: tax_rate,
209
+ is_price_include_tax: is_price_include_tax
210
+ });
211
+
212
+ // 计算平摊到该商品的折扣
213
+ var itemDiscount = new Decimal(0);
214
+ if (productExpectAmount > 0) {
215
+ itemDiscount = unitPrice.dividedBy(productExpectAmount).times(shopDiscount);
216
+ }
217
+
218
+ // 按比例计算主商品应分摊的折扣
219
+ var mainItemDiscount = new Decimal(0);
220
+ if (unitPrice.greaterThan(0)) {
221
+ mainItemDiscount = mainProductPrice.dividedBy(productExpectAmount).times(shopDiscount);
222
+ }
223
+ var mainItemDiscountedUnitPrice = mainProductPrice.minus(mainItemDiscount).add((item === null || item === void 0 ? void 0 : item.surcharge_fee) || 0);
224
+
225
+ // 计算折后税费(折扣后)- 主商品的税费(精确值)
226
+ var maxDiscountedTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, item), {}, {
227
+ total: mainItemDiscountedUnitPrice.toNumber(),
228
+ price: item.total,
229
+ quantity: 1
230
+ }), {
231
+ bookingDetail: bookingDetail,
232
+ bookingId: bookingId
233
+ }, {
234
+ tax_rate: tax_rate,
235
+ is_price_include_tax: is_price_include_tax
236
+ });
237
+
238
+ // 四舍五入后的值
239
+ var maxDiscountedTaxPerItemRounded = maxDiscountedTaxPerItemPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
240
+
241
+ // 保存到商品扩展信息中(保留两位小数)
242
+ item.main_product_attached_bundle_tax_fee = maxDiscountedTaxPerItemRounded.toNumber();
243
+
244
+ // 如果主商品有税费,记录为最后一个含税商品
245
+ if (maxDiscountedTaxPerItemPrecise.gt(0)) {
246
+ lastTaxableItem = {
247
+ type: 'main',
248
+ item: item
249
+ };
250
+ }
251
+
252
+ // 注意:加时商品独立计算,不考虑主商品数量
253
+ var addTimePreciseTax = new Decimal(0);
254
+ var addTimeRoundedTax = new Decimal(0);
255
+ if (Array.isArray(item.relation_details)) {
256
+ var _iterator2 = _createForOfIteratorHelper(item.relation_details),
257
+ _step2;
258
+ try {
259
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
260
+ var atItem = _step2.value;
261
+ // 计算单件加时商品折扣后价格
262
+ var _originTotal = new Decimal(atItem.selling_price || atItem.price || 0);
263
+ var _discountedTotal = _originTotal;
264
+ if (productExpectAmount > 0) {
265
+ _discountedTotal = _originTotal.minus(_originTotal.dividedBy(productExpectAmount).times(shopDiscount));
266
+ }
267
+ var addTimeTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, atItem), {}, {
268
+ total: _discountedTotal.add((atItem === null || atItem === void 0 ? void 0 : atItem.surcharge_fee) || 0).toNumber(),
269
+ quantity: atItem.product_quantity || atItem.num || 1
270
+ }), {
271
+ bookingDetail: bookingDetail,
272
+ bookingId: bookingId
273
+ }, {
274
+ tax_rate: tax_rate,
275
+ is_price_include_tax: is_price_include_tax
276
+ });
277
+ var addTimeTaxPerItemRounded = addTimeTaxPerItemPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
278
+
279
+ // 保存到加时商品上(四舍五入后的值)
280
+ atItem.tax_fee = addTimeTaxPerItemRounded.toNumber();
281
+ addTimePreciseTax = addTimePreciseTax.plus(addTimeTaxPerItemPrecise);
282
+ addTimeRoundedTax = addTimeRoundedTax.plus(addTimeTaxPerItemRounded);
283
+
284
+ // 如果加时商品有税费,记录为最后一个含税商品
285
+ if (addTimeTaxPerItemPrecise.gt(0)) {
286
+ lastTaxableItem = {
287
+ type: 'addTime',
288
+ item: atItem
289
+ };
290
+ }
291
+ }
292
+ } catch (err) {
293
+ _iterator2.e(err);
294
+ } finally {
295
+ _iterator2.f();
296
+ }
297
+ }
298
+
299
+ // 处理 bundle 子商品(仅原价子商品)
300
+ var bundlePreciseOriginTax = new Decimal(0);
301
+ var bundlePreciseTax = new Decimal(0);
302
+ var bundleRoundedOriginTax = new Decimal(0);
303
+ var bundleRoundedTax = new Decimal(0);
304
+ if (Array.isArray((_item$_extend$other = item._extend.other) === null || _item$_extend$other === void 0 ? void 0 : _item$_extend$other.bundle)) {
305
+ var _iterator3 = _createForOfIteratorHelper(item._extend.other.bundle),
306
+ _step3;
307
+ try {
308
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
309
+ var bundleItem = _step3.value;
310
+ // 只处理原价的子商品
311
+ if (getBundleItemIsOriginalPrice(bundleItem)) {
312
+ var _ref3, _bundleItem$bundle_se;
313
+ var bundleQuantity = new Decimal(bundleItem.quantity || 1);
314
+ var bundleUnitPrice = new Decimal((_ref3 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
315
+
316
+ // 计算原始税费(折扣前)- 单个商品(精确值)
317
+ var bundleOriginalTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, bundleItem), {}, {
318
+ total: bundleUnitPrice.add((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.surcharge_fee) || 0).toNumber(),
319
+ quantity: 1
320
+ }), {
321
+ bookingDetail: bookingDetail,
322
+ bookingId: bookingId
323
+ }, {
324
+ tax_rate: tax_rate,
325
+ is_price_include_tax: is_price_include_tax
326
+ });
327
+
328
+ // 计算平摊到该bundle商品的折扣
329
+ var bundleItemDiscount = new Decimal(0);
330
+ if (productExpectAmount > 0) {
331
+ bundleItemDiscount = bundleUnitPrice.dividedBy(productExpectAmount).times(shopDiscount);
332
+ }
333
+
334
+ // bundle商品折后单价
335
+ var bundleDiscountedUnitPrice = bundleUnitPrice.minus(bundleItemDiscount).add((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.surcharge_fee) || 0);
336
+
337
+ // 计算折后税费(折扣后)- 单个商品(精确值)
338
+ var bundleDiscountedTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, bundleItem), {}, {
339
+ total: bundleDiscountedUnitPrice.toNumber(),
340
+ quantity: 1
341
+ }), {
342
+ bookingDetail: bookingDetail,
343
+ bookingId: bookingId
344
+ }, {
345
+ tax_rate: tax_rate,
346
+ is_price_include_tax: is_price_include_tax
347
+ });
348
+
349
+ // 四舍五入后的值
350
+ var bundleOriginalTaxPerItemRounded = bundleOriginalTaxPerItemPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
351
+ var bundleDiscountedTaxPerItemRounded = bundleDiscountedTaxPerItemPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
352
+
353
+ // 保存到bundle商品上(单个商品的税费,四舍五入后)
354
+ bundleItem.original_tax_fee = bundleOriginalTaxPerItemRounded.toNumber();
355
+ bundleItem.tax_fee = bundleDiscountedTaxPerItemRounded.toNumber();
356
+
357
+ // 累加bundle税费(需要乘以bundle数量)
358
+ bundlePreciseOriginTax = bundlePreciseOriginTax.plus(bundleOriginalTaxPerItemPrecise.times(bundleQuantity));
359
+ bundlePreciseTax = bundlePreciseTax.plus(bundleDiscountedTaxPerItemPrecise.times(bundleQuantity));
360
+ bundleRoundedOriginTax = bundleRoundedOriginTax.plus(bundleOriginalTaxPerItemRounded.times(bundleQuantity));
361
+ bundleRoundedTax = bundleRoundedTax.plus(bundleDiscountedTaxPerItemRounded.times(bundleQuantity));
362
+
363
+ // 如果bundle商品有税费,记录为最后一个含税商品
364
+ if (bundleDiscountedTaxPerItemPrecise.gt(0)) {
365
+ lastTaxableItem = {
366
+ type: 'bundle',
367
+ item: bundleItem
368
+ };
369
+ }
370
+ }
371
+ }
372
+ } catch (err) {
373
+ _iterator3.e(err);
374
+ } finally {
375
+ _iterator3.f();
376
+ }
377
+ }
378
+
379
+ // 主商品的原始税费和折后税费(精确值)
380
+ var originalTaxFeePrecise = originalTaxPerItemPrecise.plus(bundlePreciseOriginTax);
381
+ var taxFeePrecise = maxDiscountedTaxPerItemPrecise.plus(bundlePreciseTax);
382
+
383
+ // 主商品的原始税费和折后税费(四舍五入后)
384
+ var originalTaxFeeRounded = originalTaxPerItemPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).plus(bundleRoundedOriginTax);
385
+ var taxFeeRounded = maxDiscountedTaxPerItemRounded.plus(bundleRoundedTax);
386
+
387
+ // 保存到商品扩展信息中(四舍五入后的值)
388
+ item.original_tax_fee = originalTaxFeeRounded.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
389
+ item.tax_fee = taxFeeRounded.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
390
+
391
+ // 累加到总税费(乘以数量)
392
+ preciseOriginTax = preciseOriginTax.plus(originalTaxFeePrecise.times(quantity)).plus(addTimePreciseTax);
393
+ preciseTax = preciseTax.plus(taxFeePrecise.times(quantity)).plus(addTimePreciseTax);
394
+ roundedOriginTax = roundedOriginTax.plus(originalTaxFeeRounded.times(quantity)).plus(addTimeRoundedTax);
395
+ roundedTax = roundedTax.plus(taxFeeRounded.times(quantity)).plus(addTimeRoundedTax);
396
+ }
397
+
398
+ // 计算期望的总税费(精确累加后四舍五入)
399
+ } catch (err) {
400
+ _iterator.e(err);
401
+ } finally {
402
+ _iterator.f();
403
+ }
404
+ var expectedOriginTax = preciseOriginTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
405
+ var expectedTax = preciseTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
406
+
407
+ // 计算舍入差值
408
+ var originTaxRemainder = expectedOriginTax.minus(roundedOriginTax).toNumber();
409
+ var taxRemainder = expectedTax.minus(roundedTax).toNumber();
410
+
411
+ // 将差值追加到最后一个含税商品
412
+ if (lastTaxableItem) {
413
+ if (originTaxRemainder !== 0) {
414
+ if (lastTaxableItem.type === 'main') {
415
+ lastTaxableItem.item.original_tax_fee_rounding_remainder = originTaxRemainder;
416
+ } else {
417
+ lastTaxableItem.item.original_tax_fee_rounding_remainder = originTaxRemainder;
418
+ }
419
+ }
420
+ if (taxRemainder !== 0) {
421
+ if (lastTaxableItem.type === 'main') {
422
+ lastTaxableItem.item._extend.tax_fee_rounding_remainder = taxRemainder;
423
+ } else {
424
+ lastTaxableItem.item.tax_fee_rounding_remainder = taxRemainder;
425
+ }
426
+ }
427
+ }
428
+ return {
429
+ originTax: expectedOriginTax,
430
+ tax: expectedTax
431
+ };
432
+ };
433
+
434
+ /**
435
+ * 计算单个商品的税费(返回精确值,不四舍五入)
436
+ * @param item 商品信息
437
+ * @param state 状态
438
+ * @param options 选项
439
+ * @returns 精确的税费值(Decimal类型)
440
+ */
441
+ var getProductItemTax = function getProductItemTax(item, state, options) {
442
+ var _bookingDetail$tax_ra, _ref4, _bookingDetail$is_pri;
443
+ var bookingDetail = state.bookingDetail;
444
+ var tax_rate = options.tax_rate,
445
+ is_price_include_tax = options.is_price_include_tax;
446
+
447
+ // 折扣后的金额 = 商品金额 - 商品折扣
448
+ var productDiscountPrice = new Decimal(item.total || 0);
449
+ var quantity = new Decimal(item.num || 1);
450
+
451
+ // 如果商品金额小于或等于0,不计算税费
452
+ if (productDiscountPrice.lte(0)) {
453
+ return new Decimal(0);
454
+ }
455
+
456
+ // 优先从 bookingDetail 取税率和是否含税设置,取不到则从 options 中取(兼容新增模式)
457
+ // 注意:bookingDetail中的tax_rate不需要除以100,options 中的tax_rate需要除以100
458
+ var currentTaxRate = new Decimal((_bookingDetail$tax_ra = bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.tax_rate) !== null && _bookingDetail$tax_ra !== void 0 ? _bookingDetail$tax_ra : tax_rate ? tax_rate / 100 : 0);
459
+ var currentIsPriceIncludeTax = (_ref4 = (_bookingDetail$is_pri = bookingDetail === null || bookingDetail === void 0 ? void 0 : bookingDetail.is_price_include_tax) !== null && _bookingDetail$is_pri !== void 0 ? _bookingDetail$is_pri : is_price_include_tax) !== null && _ref4 !== void 0 ? _ref4 : 0;
460
+ var singleItemTax = new Decimal(0);
461
+
462
+ // 计算单个商品税费, 一次性商品 is_charge_tax 可能为空
463
+ if (item.is_charge_tax === 0 || !item.is_charge_tax) {
464
+ // 该商品不需要收税
465
+ singleItemTax = new Decimal(0);
466
+ } else {
467
+ // 该商品需要收税
468
+ if (currentIsPriceIncludeTax === 0) {
469
+ // 价格不含税:管理端填写的单价是不含税的价格
470
+ singleItemTax = productDiscountPrice.times(currentTaxRate);
471
+ } else {
472
+ // 价格含税:管理端填写的单价是含税的价格
473
+ // 含税总价 = 不含税价 + (不含税价 * 税率) = 不含税价 * (1 + 税率)
474
+ // 商品不含税价 = 含税总价 / (1 + 税率)
475
+ // 税 = 不含税价 * 税率
476
+ var divisor = new Decimal(1).plus(currentTaxRate);
477
+ if (divisor.lte(0)) {
478
+ // 如果 (1 + 税率) <= 0,说明税率异常,不计算税费
479
+ singleItemTax = new Decimal(0);
480
+ } else {
481
+ singleItemTax = productDiscountPrice.dividedBy(divisor).times(currentTaxRate);
482
+ }
483
+ }
484
+ }
485
+
486
+ // 结果 = 单个商品税费 × 数量(返回精确值,不四舍五入)
487
+ return singleItemTax.times(quantity);
488
+ };
489
+
85
490
  /**
86
491
  * 计算商品小计(不含其他费用)
87
492
  * @param items - 购物车商品数组
@@ -127,9 +532,9 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
127
532
  if (!(items !== null && items !== void 0 && items.length)) {
128
533
  return '0.00';
129
534
  }
130
- var _ref = shopInfo || {},
131
- is_price_include_tax = _ref.is_price_include_tax,
132
- tax_rate = _ref.tax_rate;
535
+ var _ref5 = shopInfo || {},
536
+ is_price_include_tax = _ref5.is_price_include_tax,
537
+ tax_rate = _ref5.tax_rate;
133
538
  var totalTaxFee = items.reduce(function (sum, item) {
134
539
  var cartItemTotalPrice = new Decimal(item.summaryTotal || 0);
135
540
  var taxRate = new Decimal(tax_rate || 0).div(100);
@@ -178,9 +583,9 @@ export var calculateDeposit = function calculateDeposit(items) {
178
583
  };
179
584
 
180
585
  // 订单附加费
181
- export var getSurchargeAmount = function getSurchargeAmount(_ref2, surcharge, options) {
182
- var bookingDetail = _ref2.bookingDetail,
183
- bookingId = _ref2.bookingId;
586
+ export var getSurchargeAmount = function getSurchargeAmount(_ref6, surcharge, options) {
587
+ var bookingDetail = _ref6.bookingDetail,
588
+ bookingId = _ref6.bookingId;
184
589
  var isEdit = options.isEdit;
185
590
  // 订单未变更过
186
591
  if (!isEdit) {
@@ -225,8 +630,8 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
225
630
  * 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
226
631
  */
227
632
  var getMainProductTotal = function getMainProductTotal(item) {
228
- var _ref3, _ref4, _item$main_product_se, _item$metadata;
229
- var total = new Decimal((_ref3 = (_ref4 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref4 !== void 0 ? _ref4 : item.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
633
+ var _ref7, _ref8, _item$main_product_se, _item$metadata;
634
+ var total = new Decimal((_ref7 = (_ref8 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : 0);
230
635
 
231
636
  // 单规格
232
637
  if (item !== null && item !== void 0 && item.option && Array.isArray(item === null || item === void 0 ? void 0 : item.option)) {
@@ -234,26 +639,26 @@ var getMainProductTotal = function getMainProductTotal(item) {
234
639
  return t.add(new Decimal(option.price || 0).mul(option.num || 1));
235
640
  }, new Decimal(0)));
236
641
  }
237
- var _iterator = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
238
- _step;
642
+ var _iterator4 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
643
+ _step4;
239
644
  try {
240
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
241
- var bundleItem = _step.value;
645
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
646
+ var bundleItem = _step4.value;
242
647
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
243
- var _ref5, _bundleItem$bundle_se;
648
+ var _ref9, _bundleItem$bundle_se2;
244
649
  // 子商品折扣金额
245
650
  var discountAmount = getDiscountAmount(bundleItem.discount_list);
246
651
  // 子商品价格
247
- var bundleItemPrice = new Decimal((_ref5 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
652
+ var bundleItemPrice = new Decimal((_ref9 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref9 !== void 0 ? _ref9 : 0);
248
653
  // todo: 套餐子商品后不需要处理 子商品价格 - 子商品折扣金额
249
654
  var bundleItemTotal = bundleItemPrice.minus(discountAmount);
250
655
  total = total.add(bundleItemTotal);
251
656
  }
252
657
  }
253
658
  } catch (err) {
254
- _iterator.e(err);
659
+ _iterator4.e(err);
255
660
  } finally {
256
- _iterator.f();
661
+ _iterator4.f();
257
662
  }
258
663
  return total.toNumber();
259
664
  };
@@ -262,13 +667,7 @@ var getMainProductTotal = function getMainProductTotal(item) {
262
667
  * 判断商品是否符合附加费条件
263
668
  */
264
669
  var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition(item, options) {
265
- var _options$ScheduleModu;
266
- if (!options.ScheduleModule) {
267
- console.warn('ScheduleModule not found!');
268
- return false;
269
- }
270
- //@ts-ignore
271
- var isInScheduleByDate = (_options$ScheduleModu = options.ScheduleModule) === null || _options$ScheduleModu === void 0 ? void 0 : _options$ScheduleModu.isInScheduleByDate;
670
+ var isInScheduleByDate = options === null || options === void 0 ? void 0 : options.isInScheduleByDate;
272
671
  var surchargeConfig = options.surchargeConfig,
273
672
  _options$scheduleById = options.scheduleById,
274
673
  scheduleById = _options$scheduleById === void 0 ? {} : _options$scheduleById;
@@ -349,13 +748,13 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
349
748
  * @param state
350
749
  * @param options 包含 ScheduleModule 和其他附加费计算所需参数
351
750
  */
352
- export var getSurcharge = function getSurcharge(_ref6, options) {
353
- var service = _ref6.service,
354
- addons = _ref6.addons,
355
- bookingDetail = _ref6.bookingDetail,
356
- bookingId = _ref6.bookingId;
751
+ export var getSurcharge = function getSurcharge(_ref10, options) {
752
+ var service = _ref10.service,
753
+ addons = _ref10.addons,
754
+ bookingDetail = _ref10.bookingDetail,
755
+ bookingId = _ref10.bookingId;
357
756
  var isEdit = options.isEdit,
358
- ScheduleModule = options.ScheduleModule,
757
+ isInScheduleByDate = options.isInScheduleByDate,
359
758
  surcharge_list = options.surcharge_list,
360
759
  scheduleById = options.scheduleById;
361
760
  // 编辑状态, 且未修改商品时直接从详情取出
@@ -408,11 +807,11 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
408
807
 
409
808
  // 检查service中符合条件的商品
410
809
  if (Array.isArray(service)) {
411
- var _iterator2 = _createForOfIteratorHelper(service),
412
- _step2;
810
+ var _iterator5 = _createForOfIteratorHelper(service),
811
+ _step5;
413
812
  try {
414
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
415
- var item = _step2.value;
813
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
814
+ var item = _step5.value;
416
815
  // 主商品符合附加费条件
417
816
  if (isProductMatchSurchargeCondition({
418
817
  isCustomItem: item.isCustomItem,
@@ -421,7 +820,7 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
421
820
  }, {
422
821
  surchargeConfig: surchargeConfig,
423
822
  scheduleById: scheduleById || {},
424
- ScheduleModule: ScheduleModule
823
+ isInScheduleByDate: isInScheduleByDate
425
824
  })) {
426
825
  // 主商品加价减价后的总价
427
826
  var total = getMainProductTotal(item);
@@ -438,11 +837,11 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
438
837
  });
439
838
  }
440
839
  // 遍历子商品 原价商品符合附加费条件
441
- var _iterator3 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
442
- _step3;
840
+ var _iterator6 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
841
+ _step6;
443
842
  try {
444
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
445
- var bundleItem = _step3.value;
843
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
844
+ var bundleItem = _step6.value;
446
845
  // bundle商品是原价且符合附加费条件
447
846
  if (getBundleItemIsOriginalPrice(bundleItem) && isProductMatchSurchargeCondition({
448
847
  isCustomItem: false,
@@ -451,13 +850,13 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
451
850
  }, {
452
851
  surchargeConfig: surchargeConfig,
453
852
  scheduleById: scheduleById || {},
454
- ScheduleModule: ScheduleModule
853
+ isInScheduleByDate: isInScheduleByDate
455
854
  })) {
456
- var _ref7, _bundleItem$bundle_se2;
855
+ var _ref11, _bundleItem$bundle_se3;
457
856
  var _mainQuantity = item.num || 1;
458
857
  matchedItems.push({
459
858
  isMain: false,
460
- total: Number((_ref7 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref7 !== void 0 ? _ref7 : 0),
859
+ total: Number((_ref11 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref11 !== void 0 ? _ref11 : 0),
461
860
  quantity: bundleItem.num || bundleItem.quantity || 1,
462
861
  item: bundleItem,
463
862
  mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
@@ -467,15 +866,15 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
467
866
 
468
867
  // 加时商品符合附加费条件
469
868
  } catch (err) {
470
- _iterator3.e(err);
869
+ _iterator6.e(err);
471
870
  } finally {
472
- _iterator3.f();
871
+ _iterator6.f();
473
872
  }
474
- var _iterator4 = _createForOfIteratorHelper(item.relation_details || []),
475
- _step4;
873
+ var _iterator7 = _createForOfIteratorHelper(item.relation_details || []),
874
+ _step7;
476
875
  try {
477
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
478
- var relationDetail = _step4.value;
876
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
877
+ var relationDetail = _step7.value;
479
878
  if (isProductMatchSurchargeCondition({
480
879
  isCustomItem: false,
481
880
  startDate: item.startDate,
@@ -483,7 +882,7 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
483
882
  }, {
484
883
  surchargeConfig: surchargeConfig,
485
884
  scheduleById: scheduleById || {},
486
- ScheduleModule: ScheduleModule
885
+ isInScheduleByDate: isInScheduleByDate
487
886
  })) {
488
887
  var _relationDetail$metad;
489
888
  matchedItems.push({
@@ -496,29 +895,29 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
496
895
  }
497
896
  }
498
897
  } catch (err) {
499
- _iterator4.e(err);
898
+ _iterator7.e(err);
500
899
  } finally {
501
- _iterator4.f();
900
+ _iterator7.f();
502
901
  }
503
902
  }
504
903
  } catch (err) {
505
- _iterator2.e(err);
904
+ _iterator5.e(err);
506
905
  } finally {
507
- _iterator2.f();
906
+ _iterator5.f();
508
907
  }
509
908
  }
510
909
 
511
910
  // 检查addons中符合条件的商品
512
911
  if (Array.isArray(addons === null || addons === void 0 ? void 0 : addons.value)) {
513
- var _iterator5 = _createForOfIteratorHelper(addons.value),
514
- _step5;
912
+ var _iterator8 = _createForOfIteratorHelper(addons.value),
913
+ _step8;
515
914
  try {
516
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
517
- var _item = _step5.value;
915
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
916
+ var _item = _step8.value;
518
917
  if (isProductMatchSurchargeCondition(_item, {
519
918
  surchargeConfig: surchargeConfig,
520
919
  scheduleById: scheduleById || {},
521
- ScheduleModule: ScheduleModule
920
+ isInScheduleByDate: isInScheduleByDate
522
921
  })) {
523
922
  matchedItems.push({
524
923
  isMain: true,
@@ -530,9 +929,9 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
530
929
  }
531
930
  }
532
931
  } catch (err) {
533
- _iterator5.e(err);
932
+ _iterator8.e(err);
534
933
  } finally {
535
- _iterator5.f();
934
+ _iterator8.f();
536
935
  }
537
936
  }
538
937
  var finalAmount = 0;
@@ -566,13 +965,13 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
566
965
  // 计算百分比附加费 - 对每个商品单独计算
567
966
  if (percentage && new Decimal(percentage).gt(0) || fixed) {
568
967
  var percentageRate = new Decimal(percentage);
569
- var _iterator6 = _createForOfIteratorHelper(matchedItems.entries()),
570
- _step6;
968
+ var _iterator9 = _createForOfIteratorHelper(matchedItems.entries()),
969
+ _step9;
571
970
  try {
572
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
573
- var _step6$value = _slicedToArray(_step6.value, 2),
574
- index = _step6$value[0],
575
- _item2 = _step6$value[1];
971
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
972
+ var _step9$value = _slicedToArray(_step9.value, 2),
973
+ index = _step9$value[0],
974
+ _item2 = _step9$value[1];
576
975
  var isLast = index === matchedItems.length - 1;
577
976
  // 对每个商品:max(0, 价格) * 数量 * 费率
578
977
  var itemPrice = new Decimal(Math.max(0, _item2.total || 0));
@@ -639,9 +1038,9 @@ export var getSurcharge = function getSurcharge(_ref6, options) {
639
1038
  }
640
1039
  }
641
1040
  } catch (err) {
642
- _iterator6.e(err);
1041
+ _iterator9.e(err);
643
1042
  } finally {
644
- _iterator6.f();
1043
+ _iterator9.f();
645
1044
  }
646
1045
  }
647
1046
 
@@ -149,6 +149,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
149
149
  totalTaxFee?: string | number | undefined;
150
150
  isPriceIncludeTax?: 0 | 1 | undefined;
151
151
  surchargeAmount?: string | number | undefined;
152
+ surcharge?: any[] | undefined;
153
+ taxRate?: string | number | undefined;
152
154
  deposit?: {
153
155
  total?: string | number | undefined;
154
156
  policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -65,7 +65,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
65
65
  var _a, _b;
66
66
  const shopInfo = ((_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.shop) || {};
67
67
  const scheduleModule = this.core.getModule("appointmentBooking_schedule");
68
- const summary = (0, import_utils.calculatePriceDetails)(shopInfo, cartItems, scheduleModule, this.store.surchargeList);
68
+ const summary = (0, import_utils.calculatePriceDetails)(shopInfo, cartItems, scheduleModule == null ? void 0 : scheduleModule.isInScheduleByDate, this.store.surchargeList);
69
69
  this.store.summary = summary;
70
70
  return this.store.summary;
71
71
  }
@@ -16,6 +16,10 @@ export interface ISummaryState {
16
16
  isPriceIncludeTax?: 0 | 1;
17
17
  /** 附加费金额 */
18
18
  surchargeAmount?: string | number;
19
+ /** 附加费列表 */
20
+ surcharge?: any[];
21
+ /** 税率 */
22
+ taxRate?: string | number;
19
23
  /** 定金 */
20
24
  deposit?: {
21
25
  /** 定金总价 */
@@ -1,8 +1,7 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import { CartItem } from '../Cart/types';
3
3
  import { ISummaryState } from './types';
4
- import { ScheduleModule } from '../Schedule';
5
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], scheduleModule: ScheduleModule, surchargeList: any[]) => ISummaryState['summary'];
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], isInScheduleByDate: any, surchargeList: any[]) => ISummaryState['summary'];
6
5
  /**
7
6
  * 获取子商品折扣信息
8
7
  * @param item
@@ -55,7 +54,7 @@ export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId
55
54
  bookingId?: number | undefined;
56
55
  }, options: {
57
56
  isEdit: boolean;
58
- ScheduleModule: any;
57
+ isInScheduleByDate: any;
59
58
  surcharge_list?: any[];
60
59
  scheduleById?: Record<string, any>;
61
60
  } & Record<string, any>) => any;
@@ -40,11 +40,11 @@ __export(utils_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(utils_exports);
42
42
  var import_decimal = __toESM(require("decimal.js"));
43
- var calculatePriceDetails = (shopInfo, items, scheduleModule, surchargeList) => {
43
+ var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList) => {
44
44
  const subtotal = new import_decimal.default(calculateSubtotal(items));
45
45
  const subOriginTotal = new import_decimal.default(calculateOriginSubtotal(items));
46
46
  const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
47
- const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, ScheduleModule: scheduleModule, surcharge_list: surchargeList, scheduleById: {} });
47
+ const surcharge = getSurcharge({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate, surcharge_list: surchargeList, scheduleById: {} });
48
48
  const surchargeAmount = new import_decimal.default(getSurchargeAmount({ bookingDetail: null, bookingId: void 0 }, surcharge, { isEdit: false }));
49
49
  const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee).plus(surchargeAmount);
50
50
  const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
@@ -54,8 +54,10 @@ var calculatePriceDetails = (shopInfo, items, scheduleModule, surchargeList) =>
54
54
  total: total.toFixed(2),
55
55
  originTotal: originTotal.toFixed(2),
56
56
  taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
57
+ taxRate: shopInfo == null ? void 0 : shopInfo.tax_rate,
57
58
  totalTaxFee: totalTaxFee.toFixed(2),
58
59
  isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax,
60
+ surcharge,
59
61
  surchargeAmount: surchargeAmount.toFixed(2),
60
62
  deposit
61
63
  };
@@ -189,12 +191,7 @@ var getMainProductTotal = (item) => {
189
191
  return total.toNumber();
190
192
  };
191
193
  var isProductMatchSurchargeCondition = (item, options) => {
192
- var _a;
193
- if (!options.ScheduleModule) {
194
- console.warn("ScheduleModule not found!");
195
- return false;
196
- }
197
- const isInScheduleByDate = (_a = options.ScheduleModule) == null ? void 0 : _a.isInScheduleByDate;
194
+ const isInScheduleByDate = options == null ? void 0 : options.isInScheduleByDate;
198
195
  const { surchargeConfig, scheduleById = {} } = options;
199
196
  const { startDate, product_id, isCustomItem } = item;
200
197
  const {
@@ -252,7 +249,7 @@ var isProductMatchSurchargeCondition = (item, options) => {
252
249
  };
253
250
  var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
254
251
  var _a, _b, _c;
255
- const { isEdit, ScheduleModule, surcharge_list, scheduleById } = options;
252
+ const { isEdit, isInScheduleByDate, surcharge_list, scheduleById } = options;
256
253
  if (!isEdit && bookingId) {
257
254
  if (Array.isArray(bookingDetail == null ? void 0 : bookingDetail.surcharge)) {
258
255
  return ((bookingDetail == null ? void 0 : bookingDetail.surcharge) || []).filter((d) => Number(d.amount) > 0).map(
@@ -304,7 +301,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
304
301
  {
305
302
  surchargeConfig,
306
303
  scheduleById: scheduleById || {},
307
- ScheduleModule
304
+ isInScheduleByDate
308
305
  }
309
306
  )) {
310
307
  const total = getMainProductTotal(item);
@@ -331,7 +328,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
331
328
  {
332
329
  surchargeConfig,
333
330
  scheduleById: scheduleById || {},
334
- ScheduleModule
331
+ isInScheduleByDate
335
332
  }
336
333
  )) {
337
334
  const mainQuantity = item.num || 1;
@@ -357,7 +354,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
357
354
  {
358
355
  surchargeConfig,
359
356
  scheduleById: scheduleById || {},
360
- ScheduleModule
357
+ isInScheduleByDate
361
358
  }
362
359
  )) {
363
360
  matchedItems.push({
@@ -379,7 +376,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
379
376
  if (isProductMatchSurchargeCondition(item, {
380
377
  surchargeConfig,
381
378
  scheduleById: scheduleById || {},
382
- ScheduleModule
379
+ isInScheduleByDate
383
380
  })) {
384
381
  matchedItems.push({
385
382
  isMain: true,
@@ -149,6 +149,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
149
149
  totalTaxFee?: string | number | undefined;
150
150
  isPriceIncludeTax?: 0 | 1 | undefined;
151
151
  surchargeAmount?: string | number | undefined;
152
+ surcharge?: any[] | undefined;
153
+ taxRate?: string | number | undefined;
152
154
  deposit?: {
153
155
  total?: string | number | undefined;
154
156
  policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.400",
4
+ "version": "0.0.401",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",