@pisell/pisellos 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/modules/AccountList/index.d.ts +5 -1
  2. package/dist/modules/AccountList/index.js +82 -36
  3. package/dist/modules/AccountList/types.d.ts +1 -0
  4. package/dist/modules/BaseModule.d.ts +6 -0
  5. package/dist/modules/BaseModule.js +41 -0
  6. package/dist/modules/Cart/index.d.ts +10 -2
  7. package/dist/modules/Cart/index.js +71 -34
  8. package/dist/modules/Cart/types.d.ts +2 -2
  9. package/dist/modules/Cart/utils.d.ts +12 -0
  10. package/dist/modules/Cart/utils.js +49 -0
  11. package/dist/modules/Date/index.d.ts +5 -0
  12. package/dist/modules/Date/index.js +35 -2
  13. package/dist/modules/Discount/index.d.ts +4 -0
  14. package/dist/modules/Discount/index.js +32 -4
  15. package/dist/modules/Discount/types.d.ts +3 -0
  16. package/dist/modules/Rules/index.js +7 -4
  17. package/dist/modules/Step/index.d.ts +4 -0
  18. package/dist/modules/Step/index.js +29 -1
  19. package/dist/modules/Summary/index.d.ts +4 -0
  20. package/dist/modules/Summary/index.js +28 -2
  21. package/dist/modules/Summary/utils.js +4 -5
  22. package/dist/solution/BookingByStep/index.d.ts +23 -4
  23. package/dist/solution/BookingByStep/index.js +152 -31
  24. package/dist/solution/BookingByStep/types.js +0 -3
  25. package/dist/solution/ShopDiscount/index.js +24 -3
  26. package/lib/modules/AccountList/index.d.ts +5 -1
  27. package/lib/modules/AccountList/index.js +33 -1
  28. package/lib/modules/AccountList/types.d.ts +1 -0
  29. package/lib/modules/BaseModule.d.ts +6 -0
  30. package/lib/modules/BaseModule.js +37 -0
  31. package/lib/modules/Cart/index.d.ts +10 -2
  32. package/lib/modules/Cart/index.js +42 -14
  33. package/lib/modules/Cart/types.d.ts +2 -2
  34. package/lib/modules/Cart/utils.d.ts +12 -0
  35. package/lib/modules/Cart/utils.js +33 -0
  36. package/lib/modules/Date/index.d.ts +5 -0
  37. package/lib/modules/Date/index.js +21 -0
  38. package/lib/modules/Discount/index.d.ts +4 -0
  39. package/lib/modules/Discount/index.js +19 -0
  40. package/lib/modules/Discount/types.d.ts +3 -0
  41. package/lib/modules/Rules/index.js +9 -4
  42. package/lib/modules/Step/index.d.ts +4 -0
  43. package/lib/modules/Step/index.js +19 -0
  44. package/lib/modules/Summary/index.d.ts +4 -0
  45. package/lib/modules/Summary/index.js +17 -0
  46. package/lib/modules/Summary/utils.js +4 -5
  47. package/lib/solution/BookingByStep/index.d.ts +23 -4
  48. package/lib/solution/BookingByStep/index.js +82 -21
  49. package/lib/solution/BookingByStep/types.js +0 -3
  50. package/lib/solution/ShopDiscount/index.js +21 -3
  51. package/package.json +1 -1
@@ -24,7 +24,6 @@ __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");
29
28
  var import_lodash_es = require("lodash-es");
30
29
  __reExport(Cart_exports, require("./types"), module.exports);
@@ -34,14 +33,27 @@ var CartModule = class extends import_BaseModule.BaseModule {
34
33
  // 提供给 baseModule 用的默认名称 和 默认版本
35
34
  this.defaultName = "cart";
36
35
  this.defaultVersion = "1.0.0";
36
+ this.openCache = false;
37
37
  }
38
38
  /**
39
39
  * 初始化购物车模块
40
40
  */
41
41
  async initialize(core, options) {
42
+ var _a, _b, _c;
42
43
  this.core = core;
43
44
  this.store = options.store;
44
- this.store.list = [];
45
+ if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
46
+ this.store.list = options.initialState.list;
47
+ } else {
48
+ this.store.list = [];
49
+ }
50
+ if ((_b = options.otherParams) == null ? void 0 : _b.cacheId) {
51
+ this.openCache = options.otherParams.openCache;
52
+ this.cacheId = options.otherParams.cacheId;
53
+ }
54
+ if ((_c = options.otherParams) == null ? void 0 : _c.fatherModule) {
55
+ this.fatherModule = options.otherParams.fatherModule;
56
+ }
45
57
  this.request = core.getPlugin("request");
46
58
  this.window = core.getPlugin("window");
47
59
  if (!this.request) {
@@ -50,7 +62,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
50
62
  if (!this.window) {
51
63
  throw new Error("购物车模块需要 window 插件支持");
52
64
  }
53
- this.store.temp = {};
54
65
  console.log("[CartModule] 初始化完成");
55
66
  }
56
67
  /**
@@ -71,8 +82,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
71
82
  }
72
83
  const items = [...this.store.list, cartItem];
73
84
  this.store.list = items;
74
- await this.core.effects.emit(import_types.CartHooks.OnAddItem, cartItem);
75
- await this.core.effects.emit(`${this.name}:changed`, items);
85
+ await this.core.effects.emit(`${this.name}:onAddItem`, cartItem);
76
86
  }
77
87
  /**
78
88
  * 更新购物车信息
@@ -87,8 +97,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
87
97
  return item;
88
98
  });
89
99
  this.store.list = [...items];
90
- await this.core.effects.emit(import_types.CartHooks.OnCartUpdateItem, tempCartItem);
91
- await this.core.effects.emit(`${this.name}:changed`, items);
100
+ await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
92
101
  } catch (error) {
93
102
  console.error("[CartModule] 更新购物车商品失败", error);
94
103
  }
@@ -127,8 +136,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
127
136
  * 批量设置购物车数据
128
137
  */
129
138
  async batchSetItems(items) {
130
- this.store.list = items || [];
131
- await this.core.effects.emit(`${this.name}:changed`, items);
139
+ this.store.list = [...items || []];
132
140
  }
133
141
  /**
134
142
  * 获取购物车商品
@@ -136,25 +144,40 @@ var CartModule = class extends import_BaseModule.BaseModule {
136
144
  getItems() {
137
145
  return this.store.list;
138
146
  }
147
+ /**
148
+ * 根据账户ID获取购物车
149
+ */
150
+ getCartByAccount(account_id) {
151
+ return this.store.list.filter((item) => item.holder_id === account_id);
152
+ }
139
153
  /**
140
154
  * 移除购物车商品
141
155
  */
142
156
  async removeItem(id) {
143
157
  const items = this.store.list.filter((i) => i._id !== id);
144
158
  this.store.list = items;
145
- await this.core.effects.emit(import_types.CartHooks.OnCartRemove, items);
159
+ await this.core.effects.emit(`${this.name}:onRemoveItem`, items);
146
160
  }
147
161
  /**
148
162
  * 根据账户ID清除购物车
149
163
  */
150
164
  clearCartByAccount(account_id) {
151
- this.store.list = this.store.list.filter((item) => item.holder_id !== account_id);
165
+ const items = this.store.list.filter((item) => item.holder_id !== account_id);
166
+ this.store.list = [...items || []];
152
167
  }
153
168
  /**
154
- * 根据账户ID获取购物车
169
+ * 清除购物车商品中的信息
155
170
  */
156
- getCartByAccount(account_id) {
157
- return this.store.list.filter((item) => item.holder_id === account_id);
171
+ deleteCartItemInfo(types) {
172
+ const list = this.store.list.map((item) => {
173
+ if (types === "resource") {
174
+ item = (0, import_utils.deleteResourceFromCartItem)(item);
175
+ } else if (types === "time") {
176
+ item = (0, import_utils.deleteTimeFromCartItem)(item);
177
+ }
178
+ return item;
179
+ });
180
+ this.store.list = [...list];
158
181
  }
159
182
  /**
160
183
  * 清除购物车
@@ -162,6 +185,11 @@ var CartModule = class extends import_BaseModule.BaseModule {
162
185
  clear() {
163
186
  this.store.list = [];
164
187
  }
188
+ storeChange() {
189
+ if (this.openCache) {
190
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["list"] });
191
+ }
192
+ }
165
193
  };
166
194
  // Annotate the CommonJS export names for ESM import in node:
167
195
  0 && (module.exports = {
@@ -88,14 +88,14 @@ export interface CartItem {
88
88
  _origin: any;
89
89
  /** 商品原始数据 */
90
90
  _productOrigin?: ProductData;
91
+ /** 资源原始数据 */
92
+ _resourceOrigin?: Resource[];
91
93
  }
92
94
  /**
93
95
  * 购物车状态接口
94
96
  */
95
97
  export interface CartState {
96
98
  list: CartItem[];
97
- total: number;
98
- temp: Record<string, any>;
99
99
  }
100
100
  /**
101
101
  * 添加商品到购物车参数
@@ -90,6 +90,18 @@ export declare const formatResourceToCartItemOrigin: (params: {
90
90
  cartItem: CartItem;
91
91
  resources: Resource[];
92
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;
93
105
  /**
94
106
  * 格式化备注到购物车
95
107
  * @param params 参数
@@ -30,6 +30,8 @@ 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,
@@ -196,6 +198,7 @@ var formatResourceToCartItem = (params) => {
196
198
  }
197
199
  const oringin = formatResourceToCartItemOrigin(params);
198
200
  cartItem._origin = oringin;
201
+ cartItem._resourceOrigin = resources;
199
202
  return cartItem;
200
203
  };
201
204
  var formatResourceToCartItemOrigin = (params) => {
@@ -226,6 +229,34 @@ var formatResourceToCartItemOrigin = (params) => {
226
229
  }
227
230
  return origin;
228
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
+ };
229
260
  var formatNoteToCartItem = (params) => {
230
261
  const { cartItem, note } = params;
231
262
  cartItem.note = note;
@@ -340,6 +371,8 @@ var getProductOriginTotalPrice = (params) => {
340
371
  // Annotate the CommonJS export names for ESM import in node:
341
372
  0 && (module.exports = {
342
373
  createCartItemOrigin,
374
+ deleteResourceFromCartItem,
375
+ deleteTimeFromCartItem,
343
376
  formatAccountToCartItem,
344
377
  formatAccountToCartItemOrigin,
345
378
  formatBundle,
@@ -6,6 +6,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
6
6
  protected defaultVersion: string;
7
7
  private store;
8
8
  private request;
9
+ private cacheId;
10
+ private openCache;
11
+ private fatherModule;
9
12
  constructor(name?: string, version?: string);
10
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
11
14
  setDateRange(dateRange: ITime[]): void;
@@ -13,4 +16,6 @@ export declare class DateModule extends BaseModule implements Module, DateModule
13
16
  getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
14
17
  getDateList(): Promise<ITime[]>;
15
18
  getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
19
+ clearDateRange(): void;
20
+ storeChange(): void;
16
21
  }
@@ -40,14 +40,27 @@ var DateModule = class extends import_BaseModule.BaseModule {
40
40
  super(name, version);
41
41
  this.defaultName = "date";
42
42
  this.defaultVersion = "1.0.0";
43
+ this.openCache = false;
43
44
  }
44
45
  async initialize(core, options) {
46
+ var _a, _b;
45
47
  this.core = core;
46
48
  this.store = options.store;
47
49
  this.request = this.core.getPlugin("request");
50
+ if (options.initialState) {
51
+ this.store.dateRange = options.initialState.dateRange;
52
+ this.store.dateList = options.initialState.dateList;
53
+ }
48
54
  if (!this.request) {
49
55
  throw new Error("DateModule 需要 request 插件支持");
50
56
  }
57
+ if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
58
+ this.openCache = options.otherParams.openCache;
59
+ this.cacheId = options.otherParams.cacheId;
60
+ }
61
+ if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
62
+ this.fatherModule = options.otherParams.fatherModule;
63
+ }
51
64
  }
52
65
  setDateRange(dateRange) {
53
66
  this.store.dateRange = dateRange;
@@ -90,6 +103,14 @@ var DateModule = class extends import_BaseModule.BaseModule {
90
103
  return (0, import_utils.disableAllDates)(dates);
91
104
  }
92
105
  }
106
+ clearDateRange() {
107
+ this.store.dateRange = [];
108
+ }
109
+ storeChange() {
110
+ if (this.openCache) {
111
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["dateRange", "dateList"] });
112
+ }
113
+ }
93
114
  };
94
115
  // Annotate the CommonJS export names for ESM import in node:
95
116
  0 && (module.exports = {
@@ -7,6 +7,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
7
7
  private request;
8
8
  private window;
9
9
  private store;
10
+ private cacheId;
11
+ private openCache;
12
+ private fatherModule;
10
13
  constructor(name?: string, version?: string);
11
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
12
15
  setDiscountList(discountList: Discount[]): Promise<void>;
@@ -23,4 +26,5 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
23
26
  calcDiscountApplicableProductTotalPrice(discount: Discount): number;
24
27
  destroy(): Promise<void>;
25
28
  clear(): Promise<void>;
29
+ storeChange(): void;
26
30
  }
@@ -30,10 +30,24 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
30
30
  super(name, version);
31
31
  this.defaultName = "discount";
32
32
  this.defaultVersion = "1.0.0";
33
+ this.openCache = false;
33
34
  }
34
35
  async initialize(core, options) {
36
+ var _a, _b, _c;
35
37
  this.core = core;
36
38
  this.store = options == null ? void 0 : options.store;
39
+ if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.discountList)) {
40
+ this.store.discountList = options == null ? void 0 : options.initialState.discountList;
41
+ } else {
42
+ this.store.discountList = [];
43
+ }
44
+ if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
45
+ this.openCache = options.otherParams.openCache;
46
+ this.cacheId = options.otherParams.cacheId;
47
+ }
48
+ if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
49
+ this.fatherModule = options.otherParams.fatherModule;
50
+ }
37
51
  this.request = core.getPlugin("request");
38
52
  this.window = core.getPlugin("window");
39
53
  if (!this.request) {
@@ -111,6 +125,11 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
111
125
  this.store.discountList = [];
112
126
  console.log("[Discount] clear");
113
127
  }
128
+ storeChange() {
129
+ if (this.openCache) {
130
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["discountList"] });
131
+ }
132
+ }
114
133
  };
115
134
  // Annotate the CommonJS export names for ESM import in node:
116
135
  0 && (module.exports = {
@@ -47,6 +47,9 @@ export interface Discount {
47
47
  resource_id?: number;
48
48
  savedAmount?: number;
49
49
  isEditMode?: boolean;
50
+ discount?: {
51
+ resource_id: number;
52
+ };
50
53
  isManualSelect?: boolean;
51
54
  isDisabled?: boolean;
52
55
  isSelected?: boolean;
@@ -71,7 +71,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
71
71
  const { discount_list } = this.hooks.getProduct(product);
72
72
  if (discount_list && discount_list.length > 0) {
73
73
  const usedNewDiscount = discount_list.some(
74
- (discount) => newDiscountIds.includes(discount.resource_id)
74
+ (discount) => {
75
+ var _a;
76
+ return newDiscountIds.includes((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id);
77
+ }
75
78
  );
76
79
  if (usedNewDiscount) {
77
80
  hasApplicableDiscount = true;
@@ -135,9 +138,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
135
138
  applicableProducts.push({
136
139
  amount: product.price,
137
140
  type: discount.tag,
138
- resource_id: discount.id,
139
- title: discount.format_title,
140
- original_amount: product.origin_total
141
+ discount: {
142
+ resource_id: discount.id,
143
+ title: discount.format_title,
144
+ original_amount: product.origin_total
145
+ }
141
146
  });
142
147
  discountApplicableProducts.set(discount.id, applicableProducts);
143
148
  }
@@ -5,6 +5,9 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
7
7
  private store;
8
+ private cacheId;
9
+ private openCache;
10
+ private fatherModule;
8
11
  constructor(name?: string, version?: string);
9
12
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
10
13
  init(steps: IStep[]): void;
@@ -16,4 +19,5 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
16
19
  prevStep(): void;
17
20
  nextStep(): void;
18
21
  gotoStep(stepIndex: number): void;
22
+ storeChange(): void;
19
23
  }
@@ -28,10 +28,24 @@ var StepModule = class extends import_BaseModule.BaseModule {
28
28
  super(name, version);
29
29
  this.defaultName = "step";
30
30
  this.defaultVersion = "1.0.0";
31
+ this.openCache = false;
31
32
  }
32
33
  async initialize(core, options) {
34
+ var _a, _b;
33
35
  this.core = core;
34
36
  this.store = options.store;
37
+ if (options.initialState) {
38
+ this.store.stepList = options.initialState.stepList;
39
+ this.store.currentStep = options.initialState.currentStep;
40
+ this.store.currentStepIndex = options.initialState.currentStepIndex;
41
+ }
42
+ if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
43
+ this.openCache = options.otherParams.openCache;
44
+ this.cacheId = options.otherParams.cacheId;
45
+ }
46
+ if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
47
+ this.fatherModule = options.otherParams.fatherModule;
48
+ }
35
49
  }
36
50
  init(steps) {
37
51
  this.setSteps(steps);
@@ -69,6 +83,11 @@ var StepModule = class extends import_BaseModule.BaseModule {
69
83
  gotoStep(stepIndex) {
70
84
  this.setCurrentStep(stepIndex);
71
85
  }
86
+ storeChange() {
87
+ if (this.openCache) {
88
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["currentStepIndex", "currentStep", "stepList"] });
89
+ }
90
+ }
72
91
  };
73
92
  // Annotate the CommonJS export names for ESM import in node:
74
93
  0 && (module.exports = {
@@ -7,7 +7,11 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
7
7
  protected defaultVersion: string;
8
8
  private shopStore;
9
9
  private store;
10
+ private cacheId;
11
+ private openCache;
12
+ private fatherModule;
10
13
  constructor(name?: string, version?: string);
11
14
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
12
15
  getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
16
+ storeChange(): void;
13
17
  }
@@ -29,11 +29,23 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
29
29
  super(name, version);
30
30
  this.defaultName = "summary";
31
31
  this.defaultVersion = "1.0.0";
32
+ this.openCache = false;
32
33
  }
33
34
  async initialize(core, options) {
35
+ var _a, _b;
34
36
  this.core = core;
35
37
  this.store = options.store;
36
38
  this.shopStore = this.core.getPlugin("shopStore");
39
+ if (options.initialState) {
40
+ this.store.summary = options.initialState.summary;
41
+ }
42
+ if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
43
+ this.openCache = options.otherParams.openCache;
44
+ this.cacheId = options.otherParams.cacheId;
45
+ }
46
+ if ((_b = options.otherParams) == null ? void 0 : _b.fatherModule) {
47
+ this.fatherModule = options.otherParams.fatherModule;
48
+ }
37
49
  if (!this.shopStore) {
38
50
  throw new Error("SummaryModule 需要 shopStore 插件支持");
39
51
  }
@@ -45,6 +57,11 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
45
57
  this.store.summary = summary;
46
58
  return this.store.summary;
47
59
  }
60
+ storeChange() {
61
+ if (this.openCache) {
62
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["summary"] });
63
+ }
64
+ }
48
65
  };
49
66
  // Annotate the CommonJS export names for ESM import in node:
50
67
  0 && (module.exports = {
@@ -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";
@@ -38,8 +38,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
38
38
  getActiveAccount(): Account | null;
39
39
  removeAccount(id: string): void;
40
40
  setDateRange(dateRange: ITime[]): Promise<void>;
41
- getRangeDate(): Promise<string>;
42
- getCart(): Promise<import("../../modules").CartItem[]>;
41
+ clearDateRange(): void;
42
+ getDateRange(): Promise<ITime[]>;
43
+ getCart(): Promise<CartItem[]>;
43
44
  getAvailableDate(params?: {
44
45
  products?: ProductData[];
45
46
  startDate?: string;
@@ -66,11 +67,27 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
66
67
  }): Promise<void>;
67
68
  getOtherParams(): Promise<Record<string, any>>;
68
69
  updateCart(params: IUpdateItemParams): void;
69
- deleteCart(product_id: string): void;
70
+ deleteCart(cartItemId: string): void;
70
71
  clearCart(): void;
71
72
  clearCartByAccount(account_id: string): void;
73
+ /**
74
+ * 批量更新购物车
75
+ */
76
+ batchUpdateCart(paramsList: IUpdateItemParams[]): void;
77
+ /**
78
+ * 从购物车中按类别删除信息
79
+ */
80
+ deleteCartItemInfo(types: "resource" | "time"): void;
72
81
  destory(): void;
73
82
  getResourcesList(): any[];
83
+ getResourcesListByCartItem(id: string | number): {
84
+ id: number | undefined;
85
+ _id: string;
86
+ product: ProductData | undefined;
87
+ resources: import("./utils/resources").ResourceItem[];
88
+ holder_id: string | number | undefined;
89
+ holder_name: string | undefined;
90
+ } | undefined;
74
91
  getResourceTimeSlot({ product, resources, currentResourceId, }: {
75
92
  product: ProductData;
76
93
  resources: any[];
@@ -103,4 +120,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
103
120
  };
104
121
  getTimeSlotByAllResources(resources_code: string): any[];
105
122
  submitTimeSlot(timeSlots: TimeSliceItem): void;
123
+ clearCache(): void;
124
+ clearCacheByModule(module: string): void;
106
125
  }