@pisell/pisellos 0.0.207 → 0.0.209

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 (58) hide show
  1. package/dist/effects/index.d.ts +1 -1
  2. package/dist/modules/Cart/index.d.ts +1 -0
  3. package/dist/modules/Cart/index.js +42 -14
  4. package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
  5. package/dist/modules/Cart/utils/changePrice.js +8 -3
  6. package/dist/modules/Order/index.js +2 -2
  7. package/dist/modules/Rules/index.js +5 -5
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +1 -0
  12. package/dist/solution/BookingByStep/index.js +10 -5
  13. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  14. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  15. package/dist/types/index.d.ts +1 -1
  16. package/lib/core/index.js +28 -27
  17. package/lib/effects/index.d.ts +1 -1
  18. package/lib/effects/index.js +7 -3
  19. package/lib/modules/Account/index.js +10 -9
  20. package/lib/modules/AccountList/index.js +11 -14
  21. package/lib/modules/BaseModule.js +3 -6
  22. package/lib/modules/Cart/index.d.ts +1 -0
  23. package/lib/modules/Cart/index.js +19 -14
  24. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  25. package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
  26. package/lib/modules/Cart/utils/changePrice.js +5 -1
  27. package/lib/modules/Date/index.js +4 -8
  28. package/lib/modules/Date/types.js +0 -1
  29. package/lib/modules/Discount/index.js +6 -11
  30. package/lib/modules/Guests/index.js +15 -10
  31. package/lib/modules/Order/index.js +4 -6
  32. package/lib/modules/Payment/cash.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +86 -98
  35. package/lib/modules/Payment/wallet.js +1 -1
  36. package/lib/modules/Product/index.js +5 -6
  37. package/lib/modules/ProductList/index.js +4 -5
  38. package/lib/modules/Resource/index.js +12 -8
  39. package/lib/modules/Rules/index.js +17 -14
  40. package/lib/modules/Rules/types.d.ts +1 -1
  41. package/lib/modules/Schedule/index.js +5 -8
  42. package/lib/modules/Schedule/type.d.ts +7 -7
  43. package/lib/modules/Schedule/types.d.ts +9 -9
  44. package/lib/modules/Schedule/utils.js +4 -2
  45. package/lib/modules/Step/index.js +4 -7
  46. package/lib/modules/Summary/index.js +4 -9
  47. package/lib/plugins/request.js +33 -34
  48. package/lib/plugins/window.js +113 -101
  49. package/lib/solution/BookingByStep/index.d.ts +1 -0
  50. package/lib/solution/BookingByStep/index.js +79 -53
  51. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  52. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  53. package/lib/solution/BookingByStep/utils/timeslots.js +12 -6
  54. package/lib/solution/BuyTickets/index.js +15 -15
  55. package/lib/solution/ShopDiscount/index.js +11 -15
  56. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  57. package/lib/types/index.d.ts +1 -1
  58. package/package.json +1 -1
@@ -27,16 +27,16 @@ var import_BaseModule = require("../BaseModule");
27
27
  var import_types = require("./types");
28
28
  __reExport(Account_exports, require("./types"), module.exports);
29
29
  var AccountModule = class extends import_BaseModule.BaseModule {
30
- defaultName = "account";
31
- defaultVersion = "1.0.0";
32
- isGuest = false;
33
- store = {
34
- accountInfo: null,
35
- isLoggedIn: false,
36
- active: false
37
- };
38
30
  constructor(name, version) {
39
31
  super(name, version);
32
+ this.defaultName = "account";
33
+ this.defaultVersion = "1.0.0";
34
+ this.isGuest = false;
35
+ this.store = {
36
+ accountInfo: null,
37
+ isLoggedIn: false,
38
+ active: false
39
+ };
40
40
  }
41
41
  async initialize(core, options) {
42
42
  this.core = core;
@@ -65,7 +65,8 @@ var AccountModule = class extends import_BaseModule.BaseModule {
65
65
  return this.store.accountInfo;
66
66
  }
67
67
  async updateProfile(updates) {
68
- if (!this.store.accountInfo) return;
68
+ if (!this.store.accountInfo)
69
+ return;
69
70
  this.store.accountInfo = {
70
71
  ...this.store.accountInfo,
71
72
  ...updates
@@ -28,22 +28,19 @@ var import_BaseModule = require("../BaseModule");
28
28
  var import_types = require("./types");
29
29
  var import_utils = require("./utils");
30
30
  var AccountListModule = class extends import_BaseModule.BaseModule {
31
- defaultName = "accountList";
32
- defaultVersion = "1.0.0";
33
- store = {
34
- accountList: [],
35
- // 账号的纯数据列表
36
- accounts: [],
37
- // 账号的 module 列表
38
- isLoading: false,
39
- error: null
40
- };
41
- request;
42
- cacheId;
43
- openCache = false;
44
- fatherModule;
45
31
  constructor(name, version) {
46
32
  super(name, version);
33
+ this.defaultName = "accountList";
34
+ this.defaultVersion = "1.0.0";
35
+ this.store = {
36
+ accountList: [],
37
+ // 账号的纯数据列表
38
+ accounts: [],
39
+ // 账号的 module 列表
40
+ isLoading: false,
41
+ error: null
42
+ };
43
+ this.openCache = false;
47
44
  }
48
45
  async initialize(core, options) {
49
46
  var _a, _b, _c;
@@ -23,13 +23,10 @@ __export(BaseModule_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(BaseModule_exports);
25
25
  var BaseModule = class {
26
- defaultName = "baseModule";
27
- defaultVersion = "1.0.0";
28
- name;
29
- version;
30
- isSolution = false;
31
- core;
32
26
  constructor(name, version) {
27
+ this.defaultName = "baseModule";
28
+ this.defaultVersion = "1.0.0";
29
+ this.isSolution = false;
33
30
  this.name = name || this.defaultName;
34
31
  this.version = version || this.defaultVersion;
35
32
  }
@@ -28,6 +28,7 @@ export declare class CartModule extends BaseModule implements Module, CartModule
28
28
  * 更新购物车信息
29
29
  */
30
30
  updateItem(params: IUpdateItemParams): Promise<void>;
31
+ updateItemInitInfo(params: IUpdateItemParams): Promise<void>;
31
32
  /**
32
33
  * 格式化数据到购物车
33
34
  */
@@ -30,17 +30,12 @@ var import_lodash_es = require("lodash-es");
30
30
  var import_utils2 = require("../Product/utils");
31
31
  __reExport(Cart_exports, require("./types"), module.exports);
32
32
  var CartModule = class extends import_BaseModule.BaseModule {
33
- // 提供给 baseModule 用的默认名称 和 默认版本
34
- defaultName = "cart";
35
- defaultVersion = "1.0.0";
36
- request;
37
- window;
38
- store;
39
- cacheId;
40
- openCache = false;
41
- fatherModule;
42
33
  constructor(name, version) {
43
34
  super(name || "cart", version || "1.0.0");
35
+ // 提供给 baseModule 用的默认名称 和 默认版本
36
+ this.defaultName = "cart";
37
+ this.defaultVersion = "1.0.0";
38
+ this.openCache = false;
44
39
  }
45
40
  /**
46
41
  * 初始化购物车模块
@@ -65,12 +60,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
65
60
  this.request = core.getPlugin("request");
66
61
  this.window = core.getPlugin("window");
67
62
  if (!this.request) {
68
- throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
63
+ throw new Error("购物车模块需要 request 插件支持");
69
64
  }
70
65
  if (!this.window) {
71
- throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
66
+ throw new Error("购物车模块需要 window 插件支持");
72
67
  }
73
- console.log("[CartModule] \u521D\u59CB\u5316\u5B8C\u6210");
68
+ console.log("[CartModule] 初始化完成");
74
69
  }
75
70
  /**
76
71
  * 添加商品到购物车
@@ -121,7 +116,17 @@ var CartModule = class extends import_BaseModule.BaseModule {
121
116
  this.store.list = [...items];
122
117
  await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
123
118
  } catch (error) {
124
- console.error("[CartModule] \u66F4\u65B0\u8D2D\u7269\u8F66\u5546\u54C1\u5931\u8D25", error);
119
+ console.error("[CartModule] 更新购物车商品失败", error);
120
+ }
121
+ }
122
+ // 更新购物车中商品的初始信息
123
+ // 为什么会有这个操作,主要服务于报价单和商品券
124
+ // 商品券那边会使用 init 的 price 做计算,而报价单那边就需要修改 init 的 price 来辅助商品计算
125
+ async updateItemInitInfo(params) {
126
+ const { _id, product } = params;
127
+ const cartItem = this.store.list.find((i) => i._id === _id);
128
+ if (cartItem) {
129
+ cartItem._productInit = (0, import_lodash_es.cloneDeep)(product);
125
130
  }
126
131
  }
127
132
  /**
@@ -147,7 +152,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
147
152
  quantity = (tempCartItem == null ? void 0 : tempCartItem.num) || 1;
148
153
  }
149
154
  if (!tempCartItem) {
150
- throw new Error("[CartModule] \u683C\u5F0F\u5316\u6570\u636E\u5230\u8D2D\u7269\u8F66\u5931\u8D25\uFF0C\u5546\u54C1\u4E0D\u5B58\u5728");
155
+ throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
151
156
  }
152
157
  if (cartItem) {
153
158
  tempCartItem = cartItem;
@@ -211,7 +211,8 @@ var getProductOriginTotalPrice = (params) => {
211
211
  return price;
212
212
  };
213
213
  var formatOptions = (options) => {
214
- if (!(options == null ? void 0 : options.length)) return [];
214
+ if (!(options == null ? void 0 : options.length))
215
+ return [];
215
216
  return options.map((item) => {
216
217
  return {
217
218
  id: item == null ? void 0 : item.id,
@@ -236,7 +237,8 @@ var formatOptionsToOrigin = (options) => {
236
237
  });
237
238
  };
238
239
  var formatBundle = (bundle) => {
239
- if (!(bundle == null ? void 0 : bundle.length)) return [];
240
+ if (!(bundle == null ? void 0 : bundle.length))
241
+ return [];
240
242
  return bundle.map((item) => {
241
243
  return {
242
244
  id: item == null ? void 0 : item.id,
@@ -252,7 +254,8 @@ var formatBundle = (bundle) => {
252
254
  });
253
255
  };
254
256
  var formatBundleToOrigin = (bundle) => {
255
- if (!(bundle == null ? void 0 : bundle.length)) return [];
257
+ if (!(bundle == null ? void 0 : bundle.length))
258
+ return [];
256
259
  return bundle.map((d) => {
257
260
  return {
258
261
  bundle_group_id: d.group_id,
@@ -1,3 +1,3 @@
1
1
  import { Product } from "../../Product";
2
2
  import { CartItem, IUpdateItemParams } from "../types";
3
- export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void): Promise<void>;
3
+ export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
@@ -33,7 +33,7 @@ __export(changePrice_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(changePrice_exports);
35
35
  var import_decimal = __toESM(require("decimal.js"));
36
- async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart) {
36
+ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
37
37
  var _a, _b;
38
38
  for (const item of cartItems) {
39
39
  const targetProduct = priceData.find((n) => n.id === item.id);
@@ -81,6 +81,10 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
81
81
  return n;
82
82
  });
83
83
  }
84
+ updateItemInitInfo({
85
+ _id: item._id,
86
+ product: productInfo
87
+ });
84
88
  updateCart({
85
89
  _id: item._id,
86
90
  product: productInfo,
@@ -36,15 +36,11 @@ var import_BaseModule = require("../BaseModule");
36
36
  var import_utils = require("./utils");
37
37
  var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
38
38
  var DateModule = class extends import_BaseModule.BaseModule {
39
- defaultName = "date";
40
- defaultVersion = "1.0.0";
41
- store;
42
- request;
43
- cacheId;
44
- openCache = false;
45
- fatherModule;
46
39
  constructor(name, version) {
47
40
  super(name, version);
41
+ this.defaultName = "date";
42
+ this.defaultVersion = "1.0.0";
43
+ this.openCache = false;
48
44
  }
49
45
  async initialize(core, options) {
50
46
  var _a, _b;
@@ -56,7 +52,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
56
52
  this.store.dateList = options.initialState.dateList;
57
53
  }
58
54
  if (!this.request) {
59
- throw new Error("DateModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
55
+ throw new Error("DateModule 需要 request 插件支持");
60
56
  }
61
57
  if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
62
58
  this.openCache = options.otherParams.openCache;
@@ -23,7 +23,6 @@ __export(types_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(types_exports);
25
25
  var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
26
- return DateHooks2;
27
26
  })(DateHooks || {});
28
27
  // Annotate the CommonJS export names for ESM import in node:
29
28
  0 && (module.exports = {
@@ -37,16 +37,11 @@ var import_BaseModule = require("../BaseModule");
37
37
  var import_types = require("./types");
38
38
  var import_decimal = __toESM(require("decimal.js"));
39
39
  var DiscountModule = class extends import_BaseModule.BaseModule {
40
- defaultName = "discount";
41
- defaultVersion = "1.0.0";
42
- request;
43
- window;
44
- store;
45
- cacheId;
46
- openCache = false;
47
- fatherModule;
48
40
  constructor(name, version) {
49
41
  super(name, version);
42
+ this.defaultName = "discount";
43
+ this.defaultVersion = "1.0.0";
44
+ this.openCache = false;
50
45
  }
51
46
  async initialize(core, options) {
52
47
  var _a, _b, _c;
@@ -67,10 +62,10 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
67
62
  this.request = core.getPlugin("request");
68
63
  this.window = core.getPlugin("window");
69
64
  if (!this.request) {
70
- throw new Error("discount\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
65
+ throw new Error("discount模块需要 request 插件支持");
71
66
  }
72
67
  if (!this.window) {
73
- throw new Error("discount\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
68
+ throw new Error("discount模块需要 window 插件支持");
74
69
  }
75
70
  }
76
71
  async setDiscountList(discountList) {
@@ -135,7 +130,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
135
130
  this.store.discountList = [];
136
131
  this.core.effects.offByModuleDestroy(this.name);
137
132
  await this.core.effects.emit(import_types.DiscountHooks.OnDestroy, {});
138
- console.log("[Discount] \u5DF2\u9500\u6BC1");
133
+ console.log("[Discount] 已销毁");
139
134
  }
140
135
  async clear() {
141
136
  this.store.discountList = [];
@@ -25,13 +25,13 @@ module.exports = __toCommonJS(Guests_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_types = require("./types");
27
27
  var GuestListModule = class extends import_BaseModule.BaseModule {
28
- defaultName = "guestList";
29
- defaultVersion = "1.0.0";
30
- state = {
31
- list: []
32
- };
33
28
  constructor(name, version) {
34
29
  super(name, version);
30
+ this.defaultName = "guestList";
31
+ this.defaultVersion = "1.0.0";
32
+ this.state = {
33
+ list: []
34
+ };
35
35
  }
36
36
  async initialize(core, options) {
37
37
  this.core = core;
@@ -46,7 +46,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
46
46
  }
47
47
  async updateGuest(id, updates) {
48
48
  const index = this.state.list.findIndex((g) => g.id === id);
49
- if (index === -1) return;
49
+ if (index === -1)
50
+ return;
50
51
  this.state.list[index] = {
51
52
  ...this.state.list[index],
52
53
  ...updates
@@ -59,7 +60,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
59
60
  }
60
61
  async removeGuest(id) {
61
62
  const index = this.state.list.findIndex((g) => g.id === id);
62
- if (index === -1) return;
63
+ if (index === -1)
64
+ return;
63
65
  const [removed] = this.state.list.splice(index, 1);
64
66
  await this.core.effects.emit(import_types.GuestHooks.OnGuestRemove, removed);
65
67
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
@@ -72,16 +74,19 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
72
74
  }
73
75
  async addItemToGuest(guestId, item) {
74
76
  const guest = this.state.list.find((g) => g.id === guestId);
75
- if (!guest) return;
77
+ if (!guest)
78
+ return;
76
79
  guest.items.push(item);
77
80
  await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
78
81
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
79
82
  }
80
83
  async removeItemFromGuest(guestId, itemId) {
81
84
  const guest = this.state.list.find((g) => g.id === guestId);
82
- if (!guest) return;
85
+ if (!guest)
86
+ return;
83
87
  const index = guest.items.findIndex((i) => i.id === itemId);
84
- if (index === -1) return;
88
+ if (index === -1)
89
+ return;
85
90
  guest.items.splice(index, 1);
86
91
  await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
87
92
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
@@ -26,12 +26,10 @@ var import_BaseModule = require("../BaseModule");
26
26
  var import_utils = require("./utils");
27
27
  var import_utils2 = require("../Product/utils");
28
28
  var OrderModule = class extends import_BaseModule.BaseModule {
29
- defaultName = "order";
30
- defaultVersion = "1.0.0";
31
- store;
32
- request;
33
29
  constructor(name, version) {
34
30
  super(name, version);
31
+ this.defaultName = "order";
32
+ this.defaultVersion = "1.0.0";
35
33
  }
36
34
  async initialize(core, options) {
37
35
  this.core = core;
@@ -41,9 +39,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
41
39
  createOrder(params) {
42
40
  var _a;
43
41
  const order = {
44
- type: params.type || "appointment_booking",
42
+ type: (params == null ? void 0 : params.type) || "appointment_booking",
45
43
  // 要从外面拿,virtual
46
- platform: params.platform === "pc" ? "PC" : "H5",
44
+ platform: (params == null ? void 0 : params.platform) === "pc" ? "PC" : "H5",
47
45
  sales_channel: "my_pisel",
48
46
  order_sales_channel: "online_store",
49
47
  bookings: [],
@@ -29,7 +29,7 @@ var CashPaymentImpl = class {
29
29
  async processCashPayment(amount, orderUuid) {
30
30
  const cashMethod = await this.paymentModule.getCashPaymentMethod();
31
31
  if (!cashMethod) {
32
- throw new Error("\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
32
+ throw new Error("现金支付方式未找到");
33
33
  }
34
34
  const paymentItem = {
35
35
  amount: amount.toString(),
@@ -29,7 +29,7 @@ var EftposPaymentImpl = class {
29
29
  async processEftposPayment(amount, orderUuid) {
30
30
  const eftposMethod = await this.paymentModule.getEftposPaymentMethod();
31
31
  if (!eftposMethod) {
32
- throw new Error("Eftpos\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
32
+ throw new Error("Eftpos支付方式未找到");
33
33
  }
34
34
  const paymentItem = {
35
35
  amount: amount.toString(),