@pisell/pisellos 0.0.402 → 0.0.403

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.
@@ -22,4 +22,6 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
22
22
  */
23
23
  getProtocol(protocolId: string): Promise<any>;
24
24
  storeChange(): void;
25
+ private getTaxforUtils;
26
+ private getSurchargeforUtils;
25
27
  }
@@ -16,7 +16,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
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
18
  import { BaseModule } from "../BaseModule";
19
- import { calculatePriceDetails } from "./utils";
19
+ import { ScheduleModule } from "../Schedule";
20
+ import { calculatePriceDetails, getSurcharge, getTax } from "./utils";
20
21
  export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
21
22
  _inherits(SummaryModule, _BaseModule);
22
23
  var _super = _createSuper(SummaryModule);
@@ -165,6 +166,43 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
165
166
  });
166
167
  }
167
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.toNumber(),
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
+ var surchargeList = this.store.surchargeList;
190
+ var surchargeAmount = getSurcharge({
191
+ service: items,
192
+ addons: [],
193
+ bookingDetail: null,
194
+ bookingId: undefined
195
+ }, {
196
+ isEdit: false,
197
+ isInScheduleByDate: ScheduleModule.isInScheduleByDate,
198
+ surcharge_list: surchargeList,
199
+ scheduleById: {}
200
+ });
201
+ return {
202
+ surchargeList: surchargeList,
203
+ surchargeAmount: surchargeAmount
204
+ };
205
+ }
168
206
  }]);
169
207
  return SummaryModule;
170
208
  }(BaseModule);
@@ -7,6 +7,49 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], i
7
7
  * @param item
8
8
  */
9
9
  export declare const getBundleDiscountList: (bundle: any[]) => any[];
10
+ /**
11
+ * 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
12
+ *
13
+ * - **折扣前税费**:`originTax`
14
+ * - **折扣后税费**:`tax`(会考虑 `computed.shopDiscount` 对每个商品的分摊影响)
15
+ * - **税率/是否含税**:优先取 `bookingDetail.tax_rate` / `bookingDetail.is_price_include_tax`,取不到再回退到 `options.tax_rate` / `options.is_price_include_tax`
16
+ *
17
+ * **副作用(会修改入参商品对象)**:
18
+ * - 主商品:写入 `item.original_tax_fee` / `item.tax_fee`(四舍五入保留两位)
19
+ * - bundle 原价子商品:写入 `bundleItem.original_tax_fee` / `bundleItem.tax_fee`
20
+ * - 加时商品(`relation_details`):写入 `atItem.tax_fee`
21
+ * - 税费舍入差值:追加到最后一个“含税商品”的 `tax_fee_rounding_remainder` / `original_tax_fee_rounding_remainder`
22
+ *
23
+ * @param params 入参集合(RORO)
24
+ * @param params.service 服务商品数组(主商品)。通常是购物车商品结构(可能包含 `bundle` / `relation_details`)
25
+ * @param params.addons 附加商品数组(可选)。结构同商品数组
26
+ * @param params.bookingDetail 订单详情(编辑/详情场景用于读取后端税率配置),可选
27
+ * @param params.bookingId 订单/预约 ID(编辑/详情场景识别用),可选
28
+ * @param options 计算选项
29
+ * @param options.isEdit 是否处于“编辑中”。当前实现不强依赖该值(历史逻辑保留),但建议按真实状态传入
30
+ * @param options.computed 预计算结果(用于折扣分摊)
31
+ * @param options.computed.productExpectAmount 商品期望总金额(用于按比例分摊折扣)
32
+ * @param options.computed.shopDiscount 店铺折扣总额(用于按比例分摊到商品)
33
+ * @param options.tax_rate 管理端税率(百分比,如 5 表示 5%)。仅当 `bookingDetail.tax_rate` 不存在时生效
34
+ * @param options.is_price_include_tax 是否含税:`0` 不含税、`1` 含税。仅当 `bookingDetail.is_price_include_tax` 不存在时生效
35
+ * @returns 税费汇总(number,金额单位与商品价格一致,四舍五入保留两位)
36
+ * @returns.originTax 折扣前税费合计
37
+ * @returns.tax 折扣后税费合计
38
+ */
39
+ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
40
+ service?: any;
41
+ addons?: any;
42
+ bookingDetail?: any;
43
+ bookingId?: number | undefined;
44
+ }, options: {
45
+ isEdit: boolean;
46
+ computed: Record<string, number>;
47
+ tax_rate?: number;
48
+ is_price_include_tax?: number;
49
+ } & Record<string, any>) => {
50
+ originTax: number;
51
+ tax: number;
52
+ };
10
53
  /**
11
54
  * 计算商品小计(不含其他费用)
12
55
  * @param items - 购物车商品数组
@@ -38,14 +81,52 @@ export declare const calculateDeposit: (items: CartItem[]) => {
38
81
  protocols: any[];
39
82
  hasDeposit: never;
40
83
  } | undefined;
84
+ /**
85
+ * 计算订单附加费金额(订单级别合计)。
86
+ *
87
+ * - **详情未编辑**(`!options.isEdit && bookingId`)且存在后端详情时:直接返回 `bookingDetail.surcharge_fee`
88
+ * - **新增/编辑**时:对 `surcharge`(通常为 `getSurcharge` 的返回值)按 `item.value` 求和
89
+ *
90
+ * @param params 入参集合(RORO)
91
+ * @param params.bookingDetail 订单详情(详情未编辑时用于读取后端的 `surcharge_fee`),可选
92
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
93
+ * @param surcharge 附加费列表(通常来自 `getSurcharge`),元素结构至少包含 `value: number`
94
+ * @param options 计算选项
95
+ * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
96
+ * @returns 订单附加费金额(number,金额单位与商品价格一致)
97
+ */
41
98
  export declare const getSurchargeAmount: ({ bookingDetail, bookingId }: {
42
99
  bookingDetail?: any;
43
100
  bookingId?: number | undefined;
44
101
  }, surcharge: any[], options: any) => any;
45
102
  /**
46
103
  * 订单附加费各项信息
47
- * @param state
48
- * @param options 包含 ScheduleModule 和其他附加费计算所需参数
104
+ *
105
+ * - **详情未编辑**(`!options.isEdit && bookingId`)时:直接返回 `bookingDetail.surcharge`(后端计算结果)
106
+ * - **新增/编辑**时:按 `options.surcharge_list` 逐条配置计算本次订单的附加费
107
+ *
108
+ * 规则要点:
109
+ * - 匹配范围包含:主商品(`service`)、原价 bundle 子商品(`item.bundle`)、加时商品(`item.relation_details`)、以及 addons(`addons.value`)
110
+ * - 固定附加费 `fixed`:只加一次,再按商品数量分摊(向下取整保留两位),剩余小数会以 `surcharge_rounding_remainder` 形式抹平到最后一个商品
111
+ * - 百分比附加费 `percentage`:按每个商品(价格 * 数量)分别计算再累加
112
+ * - 当 `open_product === 0`:不回写到商品,只在订单级别累加;否则会把单品附加费回写到商品
113
+ *
114
+ * **副作用(可能修改入参商品对象)**:
115
+ * - 当 `open_product !== 0` 时:写入 `item.surcharge_fee`(单品单数量附加费,保留两位、向下取整)
116
+ * - 写入 `item.relation_surcharge_ids`(关联到的 surcharge 配置 id 列表)
117
+ * - 写入 `item.surcharge_rounding_remainder`(用于抹平固定附加费/总额舍入差)
118
+ *
119
+ * @param params 入参集合(RORO)
120
+ * @param params.service 服务商品数组(主商品)。元素可能包含 `bundle` / `relation_details`
121
+ * @param params.addons 附加商品容器。当前实现读取 `addons.value` 作为商品数组(所以通常传 `{ value: CartItem[] }`)
122
+ * @param params.bookingDetail 订单详情(详情未编辑时用于直接取后端的 surcharge 列表),可选
123
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
124
+ * @param options 计算选项
125
+ * @param options.isEdit 是否处于“编辑中”。`false` 且存在 `bookingId` 时会走详情直取逻辑
126
+ * @param options.surcharge_list 附加费配置列表(后端下发)。缺失/为空则返回空数组
127
+ * @param options.isInScheduleByDate 判断日期是否落在某个 schedule 内的方法(通常来自 ScheduleModule)
128
+ * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
129
+ * @returns 附加费列表(仅返回金额 > 0 的项)
49
130
  */
50
131
  export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId }: {
51
132
  service: any;
@@ -105,12 +105,35 @@ var getProductDiscountProductDiscountDifference = function getProductDiscountPro
105
105
  };
106
106
 
107
107
  /**
108
- * 税费
109
- * @param state
110
- * @param options 包含 isEdit、computed 和其他税费计算所需参数
111
- * @returns
108
+ * 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
109
+ *
110
+ * - **折扣前税费**:`originTax`
111
+ * - **折扣后税费**:`tax`(会考虑 `computed.shopDiscount` 对每个商品的分摊影响)
112
+ * - **税率/是否含税**:优先取 `bookingDetail.tax_rate` / `bookingDetail.is_price_include_tax`,取不到再回退到 `options.tax_rate` / `options.is_price_include_tax`
113
+ *
114
+ * **副作用(会修改入参商品对象)**:
115
+ * - 主商品:写入 `item.original_tax_fee` / `item.tax_fee`(四舍五入保留两位)
116
+ * - bundle 原价子商品:写入 `bundleItem.original_tax_fee` / `bundleItem.tax_fee`
117
+ * - 加时商品(`relation_details`):写入 `atItem.tax_fee`
118
+ * - 税费舍入差值:追加到最后一个“含税商品”的 `tax_fee_rounding_remainder` / `original_tax_fee_rounding_remainder`
119
+ *
120
+ * @param params 入参集合(RORO)
121
+ * @param params.service 服务商品数组(主商品)。通常是购物车商品结构(可能包含 `bundle` / `relation_details`)
122
+ * @param params.addons 附加商品数组(可选)。结构同商品数组
123
+ * @param params.bookingDetail 订单详情(编辑/详情场景用于读取后端税率配置),可选
124
+ * @param params.bookingId 订单/预约 ID(编辑/详情场景识别用),可选
125
+ * @param options 计算选项
126
+ * @param options.isEdit 是否处于“编辑中”。当前实现不强依赖该值(历史逻辑保留),但建议按真实状态传入
127
+ * @param options.computed 预计算结果(用于折扣分摊)
128
+ * @param options.computed.productExpectAmount 商品期望总金额(用于按比例分摊折扣)
129
+ * @param options.computed.shopDiscount 店铺折扣总额(用于按比例分摊到商品)
130
+ * @param options.tax_rate 管理端税率(百分比,如 5 表示 5%)。仅当 `bookingDetail.tax_rate` 不存在时生效
131
+ * @param options.is_price_include_tax 是否含税:`0` 不含税、`1` 含税。仅当 `bookingDetail.is_price_include_tax` 不存在时生效
132
+ * @returns 税费汇总(number,金额单位与商品价格一致,四舍五入保留两位)
133
+ * @returns.originTax 折扣前税费合计
134
+ * @returns.tax 折扣后税费合计
112
135
  */
113
- var getTax = function getTax(_ref, options) {
136
+ export var getTax = function getTax(_ref, options) {
114
137
  var service = _ref.service,
115
138
  addons = _ref.addons,
116
139
  bookingDetail = _ref.bookingDetail,
@@ -119,7 +142,6 @@ var getTax = function getTax(_ref, options) {
119
142
  computed = options.computed,
120
143
  tax_rate = options.tax_rate,
121
144
  is_price_include_tax = options.is_price_include_tax;
122
- debugger;
123
145
 
124
146
  // 详情时未编辑的状态下, 取后端的值
125
147
  // if (!isEdit) {
@@ -586,7 +608,20 @@ export var calculateDeposit = function calculateDeposit(items) {
586
608
  return undefined;
587
609
  };
588
610
 
589
- // 订单附加费
611
+ /**
612
+ * 计算订单附加费金额(订单级别合计)。
613
+ *
614
+ * - **详情未编辑**(`!options.isEdit && bookingId`)且存在后端详情时:直接返回 `bookingDetail.surcharge_fee`
615
+ * - **新增/编辑**时:对 `surcharge`(通常为 `getSurcharge` 的返回值)按 `item.value` 求和
616
+ *
617
+ * @param params 入参集合(RORO)
618
+ * @param params.bookingDetail 订单详情(详情未编辑时用于读取后端的 `surcharge_fee`),可选
619
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
620
+ * @param surcharge 附加费列表(通常来自 `getSurcharge`),元素结构至少包含 `value: number`
621
+ * @param options 计算选项
622
+ * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
623
+ * @returns 订单附加费金额(number,金额单位与商品价格一致)
624
+ */
590
625
  export var getSurchargeAmount = function getSurchargeAmount(_ref6, surcharge, options) {
591
626
  var bookingDetail = _ref6.bookingDetail,
592
627
  bookingId = _ref6.bookingId;
@@ -749,8 +784,32 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
749
784
 
750
785
  /**
751
786
  * 订单附加费各项信息
752
- * @param state
753
- * @param options 包含 ScheduleModule 和其他附加费计算所需参数
787
+ *
788
+ * - **详情未编辑**(`!options.isEdit && bookingId`)时:直接返回 `bookingDetail.surcharge`(后端计算结果)
789
+ * - **新增/编辑**时:按 `options.surcharge_list` 逐条配置计算本次订单的附加费
790
+ *
791
+ * 规则要点:
792
+ * - 匹配范围包含:主商品(`service`)、原价 bundle 子商品(`item.bundle`)、加时商品(`item.relation_details`)、以及 addons(`addons.value`)
793
+ * - 固定附加费 `fixed`:只加一次,再按商品数量分摊(向下取整保留两位),剩余小数会以 `surcharge_rounding_remainder` 形式抹平到最后一个商品
794
+ * - 百分比附加费 `percentage`:按每个商品(价格 * 数量)分别计算再累加
795
+ * - 当 `open_product === 0`:不回写到商品,只在订单级别累加;否则会把单品附加费回写到商品
796
+ *
797
+ * **副作用(可能修改入参商品对象)**:
798
+ * - 当 `open_product !== 0` 时:写入 `item.surcharge_fee`(单品单数量附加费,保留两位、向下取整)
799
+ * - 写入 `item.relation_surcharge_ids`(关联到的 surcharge 配置 id 列表)
800
+ * - 写入 `item.surcharge_rounding_remainder`(用于抹平固定附加费/总额舍入差)
801
+ *
802
+ * @param params 入参集合(RORO)
803
+ * @param params.service 服务商品数组(主商品)。元素可能包含 `bundle` / `relation_details`
804
+ * @param params.addons 附加商品容器。当前实现读取 `addons.value` 作为商品数组(所以通常传 `{ value: CartItem[] }`)
805
+ * @param params.bookingDetail 订单详情(详情未编辑时用于直接取后端的 surcharge 列表),可选
806
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
807
+ * @param options 计算选项
808
+ * @param options.isEdit 是否处于“编辑中”。`false` 且存在 `bookingId` 时会走详情直取逻辑
809
+ * @param options.surcharge_list 附加费配置列表(后端下发)。缺失/为空则返回空数组
810
+ * @param options.isInScheduleByDate 判断日期是否落在某个 schedule 内的方法(通常来自 ScheduleModule)
811
+ * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
812
+ * @returns 附加费列表(仅返回金额 > 0 的项)
754
813
  */
755
814
  export var getSurcharge = function getSurcharge(_ref10, options) {
756
815
  var service = _ref10.service,
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
360
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
@@ -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 客户状态
@@ -22,4 +22,6 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
22
22
  */
23
23
  getProtocol(protocolId: string): Promise<any>;
24
24
  storeChange(): void;
25
+ private getTaxforUtils;
26
+ private getSurchargeforUtils;
25
27
  }
@@ -23,6 +23,7 @@ __export(Summary_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(Summary_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
+ var import_Schedule = require("../Schedule");
26
27
  var import_utils = require("./utils");
27
28
  var SummaryModule = class extends import_BaseModule.BaseModule {
28
29
  constructor(name, version) {
@@ -87,6 +88,25 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
87
88
  });
88
89
  }
89
90
  }
91
+ getTaxforUtils(items, shopInfo, subtotal) {
92
+ return (0, import_utils.getTax)({ service: items, bookingDetail: null, bookingId: void 0 }, {
93
+ computed: {
94
+ productExpectAmount: subtotal.toNumber(),
95
+ shopDiscount: 0
96
+ },
97
+ isEdit: false,
98
+ tax_rate: shopInfo == null ? void 0 : shopInfo.tax_rate,
99
+ is_price_include_tax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
100
+ });
101
+ }
102
+ getSurchargeforUtils(items) {
103
+ const surchargeList = this.store.surchargeList;
104
+ const surchargeAmount = (0, import_utils.getSurcharge)({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate: import_Schedule.ScheduleModule.isInScheduleByDate, surcharge_list: surchargeList, scheduleById: {} });
105
+ return {
106
+ surchargeList,
107
+ surchargeAmount
108
+ };
109
+ }
90
110
  };
91
111
  // Annotate the CommonJS export names for ESM import in node:
92
112
  0 && (module.exports = {
@@ -7,6 +7,49 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], i
7
7
  * @param item
8
8
  */
9
9
  export declare const getBundleDiscountList: (bundle: any[]) => any[];
10
+ /**
11
+ * 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
12
+ *
13
+ * - **折扣前税费**:`originTax`
14
+ * - **折扣后税费**:`tax`(会考虑 `computed.shopDiscount` 对每个商品的分摊影响)
15
+ * - **税率/是否含税**:优先取 `bookingDetail.tax_rate` / `bookingDetail.is_price_include_tax`,取不到再回退到 `options.tax_rate` / `options.is_price_include_tax`
16
+ *
17
+ * **副作用(会修改入参商品对象)**:
18
+ * - 主商品:写入 `item.original_tax_fee` / `item.tax_fee`(四舍五入保留两位)
19
+ * - bundle 原价子商品:写入 `bundleItem.original_tax_fee` / `bundleItem.tax_fee`
20
+ * - 加时商品(`relation_details`):写入 `atItem.tax_fee`
21
+ * - 税费舍入差值:追加到最后一个“含税商品”的 `tax_fee_rounding_remainder` / `original_tax_fee_rounding_remainder`
22
+ *
23
+ * @param params 入参集合(RORO)
24
+ * @param params.service 服务商品数组(主商品)。通常是购物车商品结构(可能包含 `bundle` / `relation_details`)
25
+ * @param params.addons 附加商品数组(可选)。结构同商品数组
26
+ * @param params.bookingDetail 订单详情(编辑/详情场景用于读取后端税率配置),可选
27
+ * @param params.bookingId 订单/预约 ID(编辑/详情场景识别用),可选
28
+ * @param options 计算选项
29
+ * @param options.isEdit 是否处于“编辑中”。当前实现不强依赖该值(历史逻辑保留),但建议按真实状态传入
30
+ * @param options.computed 预计算结果(用于折扣分摊)
31
+ * @param options.computed.productExpectAmount 商品期望总金额(用于按比例分摊折扣)
32
+ * @param options.computed.shopDiscount 店铺折扣总额(用于按比例分摊到商品)
33
+ * @param options.tax_rate 管理端税率(百分比,如 5 表示 5%)。仅当 `bookingDetail.tax_rate` 不存在时生效
34
+ * @param options.is_price_include_tax 是否含税:`0` 不含税、`1` 含税。仅当 `bookingDetail.is_price_include_tax` 不存在时生效
35
+ * @returns 税费汇总(number,金额单位与商品价格一致,四舍五入保留两位)
36
+ * @returns.originTax 折扣前税费合计
37
+ * @returns.tax 折扣后税费合计
38
+ */
39
+ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
40
+ service?: any;
41
+ addons?: any;
42
+ bookingDetail?: any;
43
+ bookingId?: number | undefined;
44
+ }, options: {
45
+ isEdit: boolean;
46
+ computed: Record<string, number>;
47
+ tax_rate?: number;
48
+ is_price_include_tax?: number;
49
+ } & Record<string, any>) => {
50
+ originTax: number;
51
+ tax: number;
52
+ };
10
53
  /**
11
54
  * 计算商品小计(不含其他费用)
12
55
  * @param items - 购物车商品数组
@@ -38,14 +81,52 @@ export declare const calculateDeposit: (items: CartItem[]) => {
38
81
  protocols: any[];
39
82
  hasDeposit: never;
40
83
  } | undefined;
84
+ /**
85
+ * 计算订单附加费金额(订单级别合计)。
86
+ *
87
+ * - **详情未编辑**(`!options.isEdit && bookingId`)且存在后端详情时:直接返回 `bookingDetail.surcharge_fee`
88
+ * - **新增/编辑**时:对 `surcharge`(通常为 `getSurcharge` 的返回值)按 `item.value` 求和
89
+ *
90
+ * @param params 入参集合(RORO)
91
+ * @param params.bookingDetail 订单详情(详情未编辑时用于读取后端的 `surcharge_fee`),可选
92
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
93
+ * @param surcharge 附加费列表(通常来自 `getSurcharge`),元素结构至少包含 `value: number`
94
+ * @param options 计算选项
95
+ * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
96
+ * @returns 订单附加费金额(number,金额单位与商品价格一致)
97
+ */
41
98
  export declare const getSurchargeAmount: ({ bookingDetail, bookingId }: {
42
99
  bookingDetail?: any;
43
100
  bookingId?: number | undefined;
44
101
  }, surcharge: any[], options: any) => any;
45
102
  /**
46
103
  * 订单附加费各项信息
47
- * @param state
48
- * @param options 包含 ScheduleModule 和其他附加费计算所需参数
104
+ *
105
+ * - **详情未编辑**(`!options.isEdit && bookingId`)时:直接返回 `bookingDetail.surcharge`(后端计算结果)
106
+ * - **新增/编辑**时:按 `options.surcharge_list` 逐条配置计算本次订单的附加费
107
+ *
108
+ * 规则要点:
109
+ * - 匹配范围包含:主商品(`service`)、原价 bundle 子商品(`item.bundle`)、加时商品(`item.relation_details`)、以及 addons(`addons.value`)
110
+ * - 固定附加费 `fixed`:只加一次,再按商品数量分摊(向下取整保留两位),剩余小数会以 `surcharge_rounding_remainder` 形式抹平到最后一个商品
111
+ * - 百分比附加费 `percentage`:按每个商品(价格 * 数量)分别计算再累加
112
+ * - 当 `open_product === 0`:不回写到商品,只在订单级别累加;否则会把单品附加费回写到商品
113
+ *
114
+ * **副作用(可能修改入参商品对象)**:
115
+ * - 当 `open_product !== 0` 时:写入 `item.surcharge_fee`(单品单数量附加费,保留两位、向下取整)
116
+ * - 写入 `item.relation_surcharge_ids`(关联到的 surcharge 配置 id 列表)
117
+ * - 写入 `item.surcharge_rounding_remainder`(用于抹平固定附加费/总额舍入差)
118
+ *
119
+ * @param params 入参集合(RORO)
120
+ * @param params.service 服务商品数组(主商品)。元素可能包含 `bundle` / `relation_details`
121
+ * @param params.addons 附加商品容器。当前实现读取 `addons.value` 作为商品数组(所以通常传 `{ value: CartItem[] }`)
122
+ * @param params.bookingDetail 订单详情(详情未编辑时用于直接取后端的 surcharge 列表),可选
123
+ * @param params.bookingId 订单/预约 ID(详情未编辑时生效),可选
124
+ * @param options 计算选项
125
+ * @param options.isEdit 是否处于“编辑中”。`false` 且存在 `bookingId` 时会走详情直取逻辑
126
+ * @param options.surcharge_list 附加费配置列表(后端下发)。缺失/为空则返回空数组
127
+ * @param options.isInScheduleByDate 判断日期是否落在某个 schedule 内的方法(通常来自 ScheduleModule)
128
+ * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
129
+ * @returns 附加费列表(仅返回金额 > 0 的项)
49
130
  */
50
131
  export declare const getSurcharge: ({ service, addons, bookingDetail, bookingId }: {
51
132
  service: any;
@@ -36,7 +36,8 @@ __export(utils_exports, {
36
36
  calculateTaxFee: () => calculateTaxFee,
37
37
  getBundleDiscountList: () => getBundleDiscountList,
38
38
  getSurcharge: () => getSurcharge,
39
- getSurchargeAmount: () => getSurchargeAmount
39
+ getSurchargeAmount: () => getSurchargeAmount,
40
+ getTax: () => getTax
40
41
  });
41
42
  module.exports = __toCommonJS(utils_exports);
42
43
  var import_decimal = __toESM(require("decimal.js"));
@@ -94,7 +95,6 @@ var getProductDiscountProductDiscountDifference = (item) => {
94
95
  };
95
96
  var getTax = ({ service, addons, bookingDetail, bookingId }, options) => {
96
97
  const { isEdit, computed, tax_rate, is_price_include_tax } = options;
97
- debugger;
98
98
  let totalOriginTax = new import_decimal.default(0);
99
99
  let totalTax = new import_decimal.default(0);
100
100
  if (service || addons) {
@@ -717,5 +717,6 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
717
717
  calculateTaxFee,
718
718
  getBundleDiscountList,
719
719
  getSurcharge,
720
- getSurchargeAmount
720
+ getSurchargeAmount,
721
+ getTax
721
722
  });
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
360
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
@@ -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.402",
4
+ "version": "0.0.403",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",