@pisell/pisellos 0.0.202 → 0.0.207

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/effects/index.d.ts +1 -1
  2. package/dist/modules/Order/index.js +4 -1
  3. package/dist/modules/Order/utils.d.ts +12 -0
  4. package/dist/modules/Order/utils.js +39 -0
  5. package/dist/modules/Rules/types.d.ts +1 -1
  6. package/dist/modules/Schedule/type.d.ts +7 -7
  7. package/dist/modules/Schedule/types.d.ts +9 -9
  8. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  9. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  10. package/dist/types/index.d.ts +1 -1
  11. package/lib/core/index.js +27 -28
  12. package/lib/effects/index.d.ts +1 -1
  13. package/lib/effects/index.js +3 -7
  14. package/lib/modules/Account/index.js +9 -10
  15. package/lib/modules/AccountList/index.js +14 -11
  16. package/lib/modules/BaseModule.js +6 -3
  17. package/lib/modules/Cart/index.js +14 -9
  18. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  19. package/lib/modules/Date/index.js +8 -4
  20. package/lib/modules/Date/types.js +1 -0
  21. package/lib/modules/Discount/index.js +11 -6
  22. package/lib/modules/Guests/index.js +10 -15
  23. package/lib/modules/Order/index.js +6 -2
  24. package/lib/modules/Order/utils.d.ts +12 -0
  25. package/lib/modules/Order/utils.js +19 -2
  26. package/lib/modules/Payment/cash.js +1 -1
  27. package/lib/modules/Payment/eftpos.js +1 -1
  28. package/lib/modules/Payment/index.js +98 -86
  29. package/lib/modules/Payment/wallet.js +1 -1
  30. package/lib/modules/Product/index.js +6 -5
  31. package/lib/modules/ProductList/index.js +5 -4
  32. package/lib/modules/Resource/index.js +8 -12
  33. package/lib/modules/Rules/index.js +10 -13
  34. package/lib/modules/Rules/types.d.ts +1 -1
  35. package/lib/modules/Schedule/index.js +8 -5
  36. package/lib/modules/Schedule/type.d.ts +7 -7
  37. package/lib/modules/Schedule/types.d.ts +9 -9
  38. package/lib/modules/Schedule/utils.js +2 -4
  39. package/lib/modules/Step/index.js +7 -4
  40. package/lib/modules/Summary/index.js +9 -4
  41. package/lib/plugins/request.js +34 -33
  42. package/lib/plugins/window.js +101 -113
  43. package/lib/solution/BookingByStep/index.js +44 -69
  44. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  45. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  46. package/lib/solution/BookingByStep/utils/timeslots.js +6 -12
  47. package/lib/solution/BuyTickets/index.js +15 -15
  48. package/lib/solution/ShopDiscount/index.js +15 -11
  49. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  50. package/lib/types/index.d.ts +1 -1
  51. package/package.json +1 -1
@@ -37,11 +37,16 @@ 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;
40
48
  constructor(name, version) {
41
49
  super(name, version);
42
- this.defaultName = "discount";
43
- this.defaultVersion = "1.0.0";
44
- this.openCache = false;
45
50
  }
46
51
  async initialize(core, options) {
47
52
  var _a, _b, _c;
@@ -62,10 +67,10 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
62
67
  this.request = core.getPlugin("request");
63
68
  this.window = core.getPlugin("window");
64
69
  if (!this.request) {
65
- throw new Error("discount模块需要 request 插件支持");
70
+ throw new Error("discount\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
66
71
  }
67
72
  if (!this.window) {
68
- throw new Error("discount模块需要 window 插件支持");
73
+ throw new Error("discount\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
69
74
  }
70
75
  }
71
76
  async setDiscountList(discountList) {
@@ -130,7 +135,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
130
135
  this.store.discountList = [];
131
136
  this.core.effects.offByModuleDestroy(this.name);
132
137
  await this.core.effects.emit(import_types.DiscountHooks.OnDestroy, {});
133
- console.log("[Discount] 已销毁");
138
+ console.log("[Discount] \u5DF2\u9500\u6BC1");
134
139
  }
135
140
  async clear() {
136
141
  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
+ };
28
33
  constructor(name, version) {
29
34
  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,8 +46,7 @@ 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)
50
- return;
49
+ if (index === -1) return;
51
50
  this.state.list[index] = {
52
51
  ...this.state.list[index],
53
52
  ...updates
@@ -60,8 +59,7 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
60
59
  }
61
60
  async removeGuest(id) {
62
61
  const index = this.state.list.findIndex((g) => g.id === id);
63
- if (index === -1)
64
- return;
62
+ if (index === -1) return;
65
63
  const [removed] = this.state.list.splice(index, 1);
66
64
  await this.core.effects.emit(import_types.GuestHooks.OnGuestRemove, removed);
67
65
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
@@ -74,19 +72,16 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
74
72
  }
75
73
  async addItemToGuest(guestId, item) {
76
74
  const guest = this.state.list.find((g) => g.id === guestId);
77
- if (!guest)
78
- return;
75
+ if (!guest) return;
79
76
  guest.items.push(item);
80
77
  await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
81
78
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
82
79
  }
83
80
  async removeItemFromGuest(guestId, itemId) {
84
81
  const guest = this.state.list.find((g) => g.id === guestId);
85
- if (!guest)
86
- return;
82
+ if (!guest) return;
87
83
  const index = guest.items.findIndex((i) => i.id === itemId);
88
- if (index === -1)
89
- return;
84
+ if (index === -1) return;
90
85
  guest.items.splice(index, 1);
91
86
  await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
92
87
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
@@ -26,10 +26,12 @@ 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;
29
33
  constructor(name, version) {
30
34
  super(name, version);
31
- this.defaultName = "order";
32
- this.defaultVersion = "1.0.0";
33
35
  }
34
36
  async initialize(core, options) {
35
37
  this.core = core;
@@ -65,6 +67,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
65
67
  order.relation_forms.push(...relationForms);
66
68
  delete item._origin.relation_forms;
67
69
  } else {
70
+ const relationForms = (0, import_utils.mergeRelationForms)(item._origin.relation_forms || []);
71
+ item._origin.relation_forms = relationForms;
68
72
  order.bookings.push(item._origin);
69
73
  }
70
74
  if (item == null ? void 0 : item.deposit) {
@@ -8,3 +8,15 @@ export declare const generateDuration: (cartItem: CartItem) => {
8
8
  duration: number;
9
9
  durationType: string;
10
10
  };
11
+ /**
12
+ * 合并关联表单
13
+ * @param relationForms 关联表单
14
+ * @returns 合并后的关联表单
15
+ */
16
+ export declare const mergeRelationForms: (relationForms: {
17
+ form_id: number;
18
+ form_record_ids: number[];
19
+ }[]) => {
20
+ form_id: number;
21
+ form_record_ids: number[];
22
+ }[];
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/modules/Order/utils.ts
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
- generateDuration: () => generateDuration
32
+ generateDuration: () => generateDuration,
33
+ mergeRelationForms: () => mergeRelationForms
33
34
  });
34
35
  module.exports = __toCommonJS(utils_exports);
35
36
  var import_dayjs = __toESM(require("dayjs"));
@@ -39,7 +40,23 @@ var generateDuration = (cartItem) => {
39
40
  const duration = endDate.diff(startDate, "minutes");
40
41
  return { duration, durationType: "minutes" };
41
42
  };
43
+ var mergeRelationForms = (relationForms) => {
44
+ return Object.values(
45
+ relationForms.reduce((acc, cur) => {
46
+ const { form_id, form_record_ids } = cur;
47
+ if (!acc[form_id]) {
48
+ acc[form_id] = { form_id, form_record_ids: [] };
49
+ }
50
+ const ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
51
+ const validIds = ids.filter((id) => id != null);
52
+ acc[form_id].form_record_ids.push(...validIds);
53
+ acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
54
+ return acc;
55
+ }, {})
56
+ ).filter((item) => item.form_record_ids.length > 0);
57
+ };
42
58
  // Annotate the CommonJS export names for ESM import in node:
43
59
  0 && (module.exports = {
44
- generateDuration
60
+ generateDuration,
61
+ mergeRelationForms
45
62
  });
@@ -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("现金支付方式未找到");
32
+ throw new Error("\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
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支付方式未找到");
32
+ throw new Error("Eftpos\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
33
33
  }
34
34
  const paymentItem = {
35
35
  amount: amount.toString(),