@pisell/pisellos 0.0.13 → 0.0.15

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.
@@ -231,12 +231,14 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
231
231
  }
232
232
  return childAcc;
233
233
  }, []);
234
-
235
234
  // 合并渲染
236
235
  item.renderList = optional_resource.concat(default_resource);
237
236
  // renderList里 times 的每一项需要匹配一下当前时间,如果 times 里最小的end_at小于当前时间,则这个资源应该从 renderList 删除
238
237
  item.renderList = item.renderList.filter(function (d) {
239
- return dayjs(d.times[0].end_at).isAfter(dayjs());
238
+ var latestTime = d.times.reduce(function (latest, current) {
239
+ return dayjs(current.end_at).isAfter(dayjs(latest.end_at)) ? current : latest;
240
+ }, d.times[0]);
241
+ return dayjs(latestTime.end_at).isAfter(dayjs());
240
242
  });
241
243
  item.form_id = form_id;
242
244
  acc.push(item);
@@ -5,13 +5,12 @@ export * from "./types";
5
5
  /**
6
6
  * 购物车模块实现
7
7
  */
8
- export declare class CartModule extends BaseModule implements Module {
8
+ export declare class CartModule extends BaseModule implements Module, CartModuleAPI {
9
9
  protected defaultName: string;
10
10
  protected defaultVersion: string;
11
11
  private request;
12
12
  private window;
13
13
  private store;
14
- exports: CartModuleAPI;
15
14
  constructor(name?: string, version?: string);
16
15
  /**
17
16
  * 初始化购物车模块
@@ -25,17 +24,36 @@ export declare class CartModule extends BaseModule implements Module {
25
24
  * 更新购物车信息
26
25
  */
27
26
  updateItem(params: IUpdateItemParams): Promise<void>;
27
+ /**
28
+ * 格式化数据到购物车
29
+ */
30
+ formatCartItem(params: IUpdateItemParams): CartItem;
28
31
  /**
29
32
  * 批量设置购物车数据
30
33
  */
31
34
  batchSetItems(items: CartItem[]): Promise<void>;
32
- getItemCount(): number;
33
- getTotalPrice(): number;
35
+ /**
36
+ * 获取购物车商品
37
+ */
34
38
  getItems(): CartItem[];
39
+ /**
40
+ * 根据账户ID获取购物车
41
+ */
42
+ getCartByAccount(account_id: string | number): CartItem[];
43
+ /**
44
+ * 移除购物车商品
45
+ */
35
46
  removeItem(id: string): Promise<void>;
36
- storeTemp(key: string, value: any): Promise<void>;
37
- getTemp(key?: string): any;
38
- clear(): void;
47
+ /**
48
+ * 根据账户ID清除购物车
49
+ */
39
50
  clearCartByAccount(account_id: string): void;
40
- getCartByAccount(account_id: string | number): CartItem[];
51
+ /**
52
+ * 清除购物车商品中的信息
53
+ */
54
+ deleteCartItemInfo(types: "resource" | "time"): void;
55
+ /**
56
+ * 清除购物车
57
+ */
58
+ clear(): void;
41
59
  }
@@ -24,8 +24,8 @@ __export(Cart_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(Cart_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
- var import_types = require("./types");
28
27
  var import_utils = require("./utils");
28
+ var import_lodash_es = require("lodash-es");
29
29
  __reExport(Cart_exports, require("./types"), module.exports);
30
30
  var CartModule = class extends import_BaseModule.BaseModule {
31
31
  constructor(name, version) {
@@ -33,15 +33,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
33
33
  // 提供给 baseModule 用的默认名称 和 默认版本
34
34
  this.defaultName = "cart";
35
35
  this.defaultVersion = "1.0.0";
36
- // 导出的模块 API
37
- this.exports = {
38
- addItem: this.addItem.bind(this),
39
- getItemCount: this.getItemCount.bind(this),
40
- getTotalPrice: this.getTotalPrice.bind(this),
41
- getItems: this.getItems.bind(this),
42
- updateItem: this.updateItem.bind(this),
43
- removeItem: this.removeItem.bind(this)
44
- };
45
36
  }
46
37
  /**
47
38
  * 初始化购物车模块
@@ -58,7 +49,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
58
49
  if (!this.window) {
59
50
  throw new Error("购物车模块需要 window 插件支持");
60
51
  }
61
- this.store.temp = {};
62
52
  console.log("[CartModule] 初始化完成");
63
53
  }
64
54
  /**
@@ -68,10 +58,10 @@ var CartModule = class extends import_BaseModule.BaseModule {
68
58
  const { account, product, bundle, options } = params;
69
59
  let cartItem = {
70
60
  _id: (0, import_utils.getUniqueId)(),
71
- _origin: (0, import_utils.createCartItemOrigin)(),
72
- _productOrigin: product
61
+ _origin: (0, import_utils.createCartItemOrigin)()
73
62
  };
74
63
  if (product) {
64
+ cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
75
65
  cartItem = (0, import_utils.formatProductToCartItem)({ cartItem, product, bundle, options });
76
66
  }
77
67
  if (account) {
@@ -79,84 +69,109 @@ var CartModule = class extends import_BaseModule.BaseModule {
79
69
  }
80
70
  const items = [...this.store.list, cartItem];
81
71
  this.store.list = items;
82
- await this.core.effects.emit(import_types.CartHooks.OnAddItem, cartItem);
83
- await this.core.effects.emit(`${this.name}:changed`, items);
72
+ await this.core.effects.emit(`${this.name}:onAddItem`, cartItem);
84
73
  }
85
74
  /**
86
75
  * 更新购物车信息
87
76
  */
88
77
  async updateItem(params) {
89
- var _a;
90
- const { _id, cartItem, account, product, resources, note } = params;
78
+ try {
79
+ const tempCartItem = this.formatCartItem(params);
80
+ const items = this.store.list.map((item) => {
81
+ if (item._id === (tempCartItem == null ? void 0 : tempCartItem._id)) {
82
+ return tempCartItem;
83
+ }
84
+ return item;
85
+ });
86
+ this.store.list = [...items];
87
+ await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
88
+ } catch (error) {
89
+ console.error("[CartModule] 更新购物车商品失败", error);
90
+ }
91
+ }
92
+ /**
93
+ * 格式化数据到购物车
94
+ */
95
+ formatCartItem(params) {
96
+ const { _id, cartItem, account, product, discounts, resources, note } = params;
91
97
  let tempCartItem = this.store.list.find((i) => i._id === _id);
92
98
  if (!tempCartItem) {
93
- console.warn("[CartModule] 更新购物车商品失败,商品不存在");
94
- return;
99
+ throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
95
100
  }
96
101
  if (cartItem) {
97
102
  tempCartItem = cartItem;
98
103
  }
99
104
  if (product) {
105
+ tempCartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
100
106
  tempCartItem = (0, import_utils.formatProductToCartItem)({ cartItem: tempCartItem, product });
101
107
  }
108
+ if (discounts) {
109
+ tempCartItem = (0, import_utils.formatDiscountToCartItem)({ cartItem: tempCartItem, discounts });
110
+ }
102
111
  if (account) {
103
112
  tempCartItem = (0, import_utils.formatAccountToCartItem)({ cartItem: tempCartItem, account });
104
113
  }
105
114
  if (resources) {
106
115
  tempCartItem = (0, import_utils.formatResourceToCartItem)({ cartItem: tempCartItem, resources });
107
116
  }
108
- if (note && ((_a = tempCartItem._origin) == null ? void 0 : _a.product)) {
109
- tempCartItem.note = note;
110
- tempCartItem._origin.product.note = note;
117
+ if (note) {
118
+ tempCartItem = (0, import_utils.formatNoteToCartItem)({ cartItem: tempCartItem, note });
111
119
  }
112
- const items = this.store.list.map((item) => {
113
- if (item._id === (tempCartItem == null ? void 0 : tempCartItem._id)) {
114
- return tempCartItem;
115
- }
116
- return item;
117
- });
118
- this.store.list = items;
119
- await this.core.effects.emit(`${this.name}:changed`, items);
120
+ return tempCartItem;
120
121
  }
121
122
  /**
122
123
  * 批量设置购物车数据
123
124
  */
124
125
  async batchSetItems(items) {
125
- this.store.list = items || [];
126
- }
127
- getItemCount() {
128
- return this.store.list.length;
129
- }
130
- getTotalPrice() {
131
- return 0;
126
+ this.store.list = [...items || []];
132
127
  }
128
+ /**
129
+ * 获取购物车商品
130
+ */
133
131
  getItems() {
134
132
  return this.store.list;
135
133
  }
134
+ /**
135
+ * 根据账户ID获取购物车
136
+ */
137
+ getCartByAccount(account_id) {
138
+ return this.store.list.filter((item) => item.holder_id === account_id);
139
+ }
140
+ /**
141
+ * 移除购物车商品
142
+ */
136
143
  async removeItem(id) {
137
144
  const items = this.store.list.filter((i) => i._id !== id);
138
145
  this.store.list = items;
139
- await this.core.effects.emit(import_types.CartHooks.OnCartRemove, items);
146
+ await this.core.effects.emit(`${this.name}:onRemoveItem`, items);
140
147
  }
141
- async storeTemp(key, value) {
142
- this.store.temp[key] = value;
143
- await this.core.effects.emit(`${this.name}:changed`, this.store.temp);
148
+ /**
149
+ * 根据账户ID清除购物车
150
+ */
151
+ clearCartByAccount(account_id) {
152
+ const items = this.store.list.filter((item) => item.holder_id !== account_id);
153
+ this.store.list = [...items || []];
144
154
  }
145
- getTemp(key) {
146
- if (!key) {
147
- return this.store.temp;
148
- }
149
- return this.store.temp[key];
155
+ /**
156
+ * 清除购物车商品中的信息
157
+ */
158
+ deleteCartItemInfo(types) {
159
+ const list = this.store.list.map((item) => {
160
+ if (types === "resource") {
161
+ item = (0, import_utils.deleteResourceFromCartItem)(item);
162
+ } else if (types === "time") {
163
+ item = (0, import_utils.deleteTimeFromCartItem)(item);
164
+ }
165
+ return item;
166
+ });
167
+ this.store.list = [...list];
150
168
  }
169
+ /**
170
+ * 清除购物车
171
+ */
151
172
  clear() {
152
173
  this.store.list = [];
153
174
  }
154
- clearCartByAccount(account_id) {
155
- this.store.list = this.store.list.filter((item) => item.holder_id !== account_id);
156
- }
157
- getCartByAccount(account_id) {
158
- return this.store.list.filter((item) => item.holder_id === account_id);
159
- }
160
175
  };
161
176
  // Annotate the CommonJS export names for ESM import in node:
162
177
  0 && (module.exports = {
@@ -7,6 +7,26 @@ export declare enum CartHooks {
7
7
  OnCartUpdateItem = "card:onCartUpdateItem",
8
8
  OnCartRemove = "card:onCartRemove"
9
9
  }
10
+ export interface CartModuleAPI {
11
+ /** 添加商品到购物车 */
12
+ addItem: (item: IAddItemParams) => Promise<void>;
13
+ /** 获取购物车商品 */
14
+ getItems: () => CartItem[];
15
+ /** 更新购物车商品 */
16
+ updateItem: (params: IUpdateItemParams) => Promise<void>;
17
+ /** 格式化购物车商品 */
18
+ formatCartItem: (params: IUpdateItemParams) => CartItem;
19
+ /** 批量设置购物车商品 */
20
+ batchSetItems: (items: CartItem[]) => Promise<void>;
21
+ /** 移除购物车商品 */
22
+ removeItem: (id: string) => Promise<void>;
23
+ /** 根据账户ID清除购物车 */
24
+ clearCartByAccount: (account_id: string) => void;
25
+ /** 根据账户ID获取购物车 */
26
+ getCartByAccount: (account_id: string) => CartItem[];
27
+ /** 清除购物车 */
28
+ clear: () => void;
29
+ }
10
30
  /**
11
31
  * 购物车商品接口
12
32
  */
@@ -67,26 +87,15 @@ export interface CartItem {
67
87
  /** 原始数据 */
68
88
  _origin: any;
69
89
  /** 商品原始数据 */
70
- _productOrigin: ProductData;
90
+ _productOrigin?: ProductData;
91
+ /** 资源原始数据 */
92
+ _resourceOrigin?: Resource[];
71
93
  }
72
94
  /**
73
95
  * 购物车状态接口
74
96
  */
75
97
  export interface CartState {
76
98
  list: CartItem[];
77
- total: number;
78
- temp: Record<string, any>;
79
- }
80
- /**
81
- * 购物车模块 API
82
- */
83
- export interface CartModuleAPI {
84
- addItem: (item: IAddItemParams) => Promise<void>;
85
- getItemCount: () => number;
86
- getTotalPrice: () => number;
87
- getItems: () => CartItem[];
88
- updateItem: (params: IUpdateItemParams) => Promise<void>;
89
- removeItem: (id: string) => Promise<void>;
90
99
  }
91
100
  /**
92
101
  * 添加商品到购物车参数
@@ -108,13 +117,15 @@ export interface IAddItemParams {
108
117
  */
109
118
  export interface IUpdateItemParams {
110
119
  /** 购物车_id字段 */
111
- _id?: string;
120
+ _id: string;
112
121
  /** 购物车商品 */
113
122
  cartItem?: CartItem;
114
123
  /** 账户 */
115
124
  account?: Account;
116
125
  /** 商品 */
117
126
  product?: ProductData;
127
+ /** 折扣列表 */
128
+ discounts?: IDiscount[];
118
129
  /** 数量 */
119
130
  quantity?: number;
120
131
  /** 资源 */
@@ -122,3 +133,13 @@ export interface IUpdateItemParams {
122
133
  /** 备注 */
123
134
  note?: string;
124
135
  }
136
+ /**
137
+ * 折扣
138
+ */
139
+ export interface IDiscount {
140
+ amount?: number;
141
+ type?: string;
142
+ resource_id?: string;
143
+ title?: any;
144
+ original_amount?: number;
145
+ }
@@ -1,7 +1,7 @@
1
1
  import { Account } from "../Account";
2
2
  import { ProductData } from "../Product/types";
3
3
  import { Resource } from "../Resource/types";
4
- import { CartItem } from "./types";
4
+ import { CartItem, IDiscount } from "./types";
5
5
  /**
6
6
  * 生成一个唯一的 ID
7
7
  */
@@ -46,6 +46,24 @@ export declare const formatProductToCartItemOrigin: (params: {
46
46
  bundle?: any;
47
47
  options?: any;
48
48
  }) => any;
49
+ /**
50
+ * 格式化折扣到购物车
51
+ * @param params 参数
52
+ * @returns 格式化后的购物车
53
+ */
54
+ export declare const formatDiscountToCartItem: (params: {
55
+ cartItem: CartItem;
56
+ discounts: IDiscount[];
57
+ }) => CartItem;
58
+ /**
59
+ * 格式化折扣到购物车原始数据
60
+ * @param params 参数
61
+ * @returns 格式化后的购物车原始数据
62
+ */
63
+ export declare const formatDiscountToCartItemOrigin: (params: {
64
+ cartItem: CartItem;
65
+ discounts: IDiscount[];
66
+ }) => any;
49
67
  /**
50
68
  * 格式化账户到购物车
51
69
  * @param account 账户
@@ -72,6 +90,36 @@ export declare const formatResourceToCartItemOrigin: (params: {
72
90
  cartItem: CartItem;
73
91
  resources: Resource[];
74
92
  }) => any;
93
+ /**
94
+ * 从购物车中删除资源相关信息
95
+ * @param cartItem 购物车
96
+ * @returns 删除后的购物车
97
+ */
98
+ export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
99
+ /**
100
+ * 从购物车中删除时间
101
+ * @param cartItem 购物车
102
+ * @returns 删除后的购物车
103
+ */
104
+ export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
105
+ /**
106
+ * 格式化备注到购物车
107
+ * @param params 参数
108
+ * @returns 格式化后的购物车
109
+ */
110
+ export declare const formatNoteToCartItem: (params: {
111
+ cartItem: CartItem;
112
+ note: string;
113
+ }) => CartItem;
114
+ /**
115
+ * 格式化备注到购物车原始数据
116
+ * @param params 参数
117
+ * @returns 格式化后的购物车原始数据
118
+ */
119
+ export declare const formatNoteToCartItemOrigin: (params: {
120
+ cartItem: CartItem;
121
+ note: string;
122
+ }) => any;
75
123
  /**
76
124
  * 格式化套餐规格信息
77
125
  * @param options 套餐规格信息
@@ -30,10 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
32
  createCartItemOrigin: () => createCartItemOrigin,
33
+ deleteResourceFromCartItem: () => deleteResourceFromCartItem,
34
+ deleteTimeFromCartItem: () => deleteTimeFromCartItem,
33
35
  formatAccountToCartItem: () => formatAccountToCartItem,
34
36
  formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin,
35
37
  formatBundle: () => formatBundle,
36
38
  formatBundleToOrigin: () => formatBundleToOrigin,
39
+ formatDiscountToCartItem: () => formatDiscountToCartItem,
40
+ formatDiscountToCartItemOrigin: () => formatDiscountToCartItemOrigin,
41
+ formatNoteToCartItem: () => formatNoteToCartItem,
42
+ formatNoteToCartItemOrigin: () => formatNoteToCartItemOrigin,
37
43
  formatOptions: () => formatOptions,
38
44
  formatOptionsToOrigin: () => formatOptionsToOrigin,
39
45
  formatProductToCartItem: () => formatProductToCartItem,
@@ -142,6 +148,23 @@ var formatProductToCartItemOrigin = (params) => {
142
148
  }
143
149
  return origin;
144
150
  };
151
+ var formatDiscountToCartItem = (params) => {
152
+ const { cartItem } = params;
153
+ const oringin = formatDiscountToCartItemOrigin(params);
154
+ cartItem._origin = oringin;
155
+ return cartItem;
156
+ };
157
+ var formatDiscountToCartItemOrigin = (params) => {
158
+ const { cartItem, discounts } = params;
159
+ const origin = cartItem._origin;
160
+ if (discounts && (discounts == null ? void 0 : discounts.length)) {
161
+ if (!origin.product) {
162
+ origin.product = {};
163
+ }
164
+ origin.product.discount_list = discounts;
165
+ }
166
+ return origin;
167
+ };
145
168
  var formatAccountToCartItem = (params) => {
146
169
  const { cartItem, account } = params;
147
170
  if (account) {
@@ -175,6 +198,7 @@ var formatResourceToCartItem = (params) => {
175
198
  }
176
199
  const oringin = formatResourceToCartItemOrigin(params);
177
200
  cartItem._origin = oringin;
201
+ cartItem._resourceOrigin = resources;
178
202
  return cartItem;
179
203
  };
180
204
  var formatResourceToCartItemOrigin = (params) => {
@@ -205,6 +229,50 @@ var formatResourceToCartItemOrigin = (params) => {
205
229
  }
206
230
  return origin;
207
231
  };
232
+ var deleteResourceFromCartItem = (cartItem) => {
233
+ cartItem.resource_id = void 0;
234
+ cartItem.relation_form_name = void 0;
235
+ cartItem.start_date = void 0;
236
+ cartItem.start_time = void 0;
237
+ cartItem.end_date = void 0;
238
+ cartItem.end_time = void 0;
239
+ delete cartItem._resourceOrigin;
240
+ cartItem._origin.resources = null;
241
+ cartItem._origin.select_date = null;
242
+ cartItem._origin.start_date = null;
243
+ cartItem._origin.start_time = null;
244
+ cartItem._origin.end_date = null;
245
+ cartItem._origin.end_time = null;
246
+ return cartItem;
247
+ };
248
+ var deleteTimeFromCartItem = (cartItem) => {
249
+ cartItem.start_date = void 0;
250
+ cartItem.start_time = void 0;
251
+ cartItem.end_date = void 0;
252
+ cartItem.end_time = void 0;
253
+ cartItem._origin.select_date = null;
254
+ cartItem._origin.start_date = null;
255
+ cartItem._origin.start_time = null;
256
+ cartItem._origin.end_date = null;
257
+ cartItem._origin.end_time = null;
258
+ return cartItem;
259
+ };
260
+ var formatNoteToCartItem = (params) => {
261
+ const { cartItem, note } = params;
262
+ cartItem.note = note;
263
+ const oringin = formatNoteToCartItemOrigin(params);
264
+ cartItem._origin = oringin;
265
+ return cartItem;
266
+ };
267
+ var formatNoteToCartItemOrigin = (params) => {
268
+ const { cartItem, note } = params;
269
+ const origin = cartItem._origin;
270
+ if (!origin.product) {
271
+ origin.product = {};
272
+ }
273
+ origin.product.note = note;
274
+ return origin;
275
+ };
208
276
  var formatOptions = (options) => {
209
277
  if (!(options == null ? void 0 : options.length))
210
278
  return [];
@@ -303,10 +371,16 @@ var getProductOriginTotalPrice = (params) => {
303
371
  // Annotate the CommonJS export names for ESM import in node:
304
372
  0 && (module.exports = {
305
373
  createCartItemOrigin,
374
+ deleteResourceFromCartItem,
375
+ deleteTimeFromCartItem,
306
376
  formatAccountToCartItem,
307
377
  formatAccountToCartItemOrigin,
308
378
  formatBundle,
309
379
  formatBundleToOrigin,
380
+ formatDiscountToCartItem,
381
+ formatDiscountToCartItemOrigin,
382
+ formatNoteToCartItem,
383
+ formatNoteToCartItemOrigin,
310
384
  formatOptions,
311
385
  formatOptionsToOrigin,
312
386
  formatProductToCartItem,
@@ -45,6 +45,9 @@ var DateModule = class extends import_BaseModule.BaseModule {
45
45
  this.core = core;
46
46
  this.store = options.store;
47
47
  this.request = this.core.getPlugin("request");
48
+ if (!this.request) {
49
+ throw new Error("DateModule 需要 request 插件支持");
50
+ }
48
51
  }
49
52
  setDateRange(dateRange) {
50
53
  this.store.dateRange = dateRange;
@@ -184,10 +184,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
184
184
  const discountDetail = {
185
185
  amount: product.price,
186
186
  type: selectedDiscount.tag,
187
- resource_id: selectedDiscount.id,
188
- title: selectedDiscount.format_title,
189
- original_amount: product.origin_total,
190
- product_id: selectedDiscount.product_id
187
+ discount: {
188
+ resource_id: selectedDiscount.id,
189
+ title: selectedDiscount.format_title,
190
+ original_amount: product.origin_total,
191
+ product_id: selectedDiscount.product_id
192
+ }
191
193
  };
192
194
  appliedProducts.push(discountDetail);
193
195
  appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
@@ -34,6 +34,9 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
34
34
  this.core = core;
35
35
  this.store = options.store;
36
36
  this.shopStore = this.core.getPlugin("shopStore");
37
+ if (!this.shopStore) {
38
+ throw new Error("SummaryModule 需要 shopStore 插件支持");
39
+ }
37
40
  }
38
41
  async getSummary(cartItems) {
39
42
  var _a, _b;
@@ -52,9 +52,8 @@ var calculateSubtotal = (items) => {
52
52
  return "0.00";
53
53
  }
54
54
  const subtotal = items.reduce((sum, item) => {
55
- const price = new import_decimal.default(item.price || 0);
56
- const quantity = new import_decimal.default(item.num || 1);
57
- return sum.plus(price.times(quantity));
55
+ const cartItemTotalPrice = new import_decimal.default(item.total || 0);
56
+ return sum.plus(cartItemTotalPrice);
58
57
  }, new import_decimal.default(0));
59
58
  return subtotal.toFixed(2);
60
59
  };
@@ -64,9 +63,9 @@ var calculateTaxFee = (shopInfo, items) => {
64
63
  }
65
64
  const { is_price_include_tax, tax_rate } = shopInfo || {};
66
65
  const totalTaxFee = items.reduce((sum, item) => {
67
- const price = new import_decimal.default(item.price || 0);
66
+ const cartItemTotalPrice = new import_decimal.default(item.total || 0);
68
67
  const taxRate = new import_decimal.default(tax_rate || 0).div(100);
69
- const productTaxRate = price.times(taxRate).times((item == null ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
68
+ const productTaxRate = cartItemTotalPrice.times(taxRate).times((item == null ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
70
69
  return sum.plus(productTaxRate);
71
70
  }, new import_decimal.default(0));
72
71
  return totalTaxFee;
@@ -1,7 +1,7 @@
1
1
  import { Module, PisellCore } from "../../types";
2
2
  import { BaseModule } from "../../modules/BaseModule";
3
3
  import { BookingByStepState } from "./types";
4
- import { IUpdateItemParams, ProductData } from "../../modules";
4
+ import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
5
5
  import { Account } from "../../modules/Account/types";
6
6
  import { IStep } from "../../modules/Step/tyeps";
7
7
  import { TimeSliceItem } from "./utils/resources";
@@ -25,7 +25,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
25
25
  back(): void;
26
26
  gotoStep(index: number): void;
27
27
  getStepList(): IStep[];
28
- getStoreCart(key?: string): Promise<any>;
29
28
  loadProducts({ category_ids, product_ids, collection, }: {
30
29
  category_ids?: number[];
31
30
  product_ids?: number[];
@@ -40,7 +39,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
40
39
  removeAccount(id: string): void;
41
40
  setDateRange(dateRange: ITime[]): Promise<void>;
42
41
  getRangeDate(): Promise<string>;
43
- getCart(): Promise<import("../../modules").CartItem[]>;
42
+ getCart(): Promise<CartItem[]>;
44
43
  getAvailableDate(params?: {
45
44
  products?: ProductData[];
46
45
  startDate?: string;
@@ -67,9 +66,17 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
67
66
  }): Promise<void>;
68
67
  getOtherParams(): Promise<Record<string, any>>;
69
68
  updateCart(params: IUpdateItemParams): void;
70
- deleteCart(product_id: string): void;
69
+ deleteCart(cartItemId: string): void;
71
70
  clearCart(): void;
72
71
  clearCartByAccount(account_id: string): void;
72
+ /**
73
+ * 批量更新购物车
74
+ */
75
+ batchUpdateCart(paramsList: IUpdateItemParams[]): void;
76
+ /**
77
+ * 从购物车中按类别删除信息
78
+ */
79
+ deleteCartItemInfo(types: "resource" | "time"): void;
73
80
  destory(): void;
74
81
  getResourcesList(): any[];
75
82
  getResourceTimeSlot({ product, resources, currentResourceId, }: {