@pisell/pisellos 0.0.9 → 0.0.11

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 (136) hide show
  1. package/dist/core/index.js +4 -1
  2. package/dist/effects/index.d.ts +1 -1
  3. package/dist/effects/index.js +3 -3
  4. package/dist/modules/Account/index.d.ts +5 -3
  5. package/dist/modules/Account/index.js +23 -36
  6. package/dist/modules/Account/types.d.ts +2 -1
  7. package/dist/modules/AccountList/index.d.ts +2 -0
  8. package/dist/modules/AccountList/index.js +34 -11
  9. package/dist/modules/Cart/index.d.ts +17 -11
  10. package/dist/modules/Cart/index.js +179 -121
  11. package/dist/modules/Cart/types.d.ts +98 -9
  12. package/dist/modules/Cart/types.js +8 -0
  13. package/dist/modules/Cart/utils.d.ts +114 -0
  14. package/dist/modules/Cart/utils.js +345 -0
  15. package/dist/modules/Date/index.d.ts +11 -12
  16. package/dist/modules/Date/index.js +104 -60
  17. package/dist/modules/Date/types.d.ts +51 -20
  18. package/dist/modules/Date/types.js +2 -5
  19. package/dist/modules/Date/utils.d.ts +35 -0
  20. package/dist/modules/Date/utils.js +211 -0
  21. package/dist/modules/Discount/index.d.ts +26 -0
  22. package/dist/modules/Discount/index.js +234 -0
  23. package/dist/modules/Discount/types.d.ts +66 -0
  24. package/dist/modules/Discount/types.js +5 -0
  25. package/dist/modules/Order/index.d.ts +16 -12
  26. package/dist/modules/Order/index.js +38 -166
  27. package/dist/modules/Order/types.d.ts +18 -41
  28. package/dist/modules/Order/types.js +0 -14
  29. package/dist/modules/Payment/index.d.ts +0 -2
  30. package/dist/modules/Payment/index.js +45 -76
  31. package/dist/modules/Payment/types.d.ts +0 -2
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +50 -1
  34. package/dist/modules/ProductList/index.d.ts +1 -0
  35. package/dist/modules/ProductList/index.js +23 -2
  36. package/dist/modules/ProductList/types.d.ts +1 -0
  37. package/dist/modules/Resource/types.d.ts +6 -2
  38. package/dist/modules/Rules/index.d.ts +32 -0
  39. package/dist/modules/Rules/index.js +423 -0
  40. package/dist/modules/Rules/types.d.ts +46 -0
  41. package/dist/modules/Rules/types.js +5 -0
  42. package/dist/modules/Summary/index.d.ts +13 -0
  43. package/dist/modules/Summary/index.js +80 -0
  44. package/dist/modules/Summary/types.d.ts +13 -0
  45. package/dist/modules/Summary/types.js +1 -0
  46. package/dist/modules/Summary/utils.d.ts +19 -0
  47. package/dist/modules/Summary/utils.js +56 -0
  48. package/dist/plugins/index.d.ts +3 -2
  49. package/dist/plugins/index.js +2 -1
  50. package/dist/plugins/request.d.ts +4 -3
  51. package/dist/plugins/request.js +30 -30
  52. package/dist/plugins/shopStore.d.ts +4 -0
  53. package/dist/plugins/shopStore.js +1 -0
  54. package/dist/solution/BookingByStep/index.d.ts +73 -10
  55. package/dist/solution/BookingByStep/index.js +641 -74
  56. package/dist/solution/BookingByStep/types.d.ts +2 -0
  57. package/dist/solution/BookingByStep/types.js +11 -8
  58. package/dist/solution/BookingByStep/utils/products.d.ts +11 -0
  59. package/dist/solution/BookingByStep/utils/products.js +47 -0
  60. package/dist/solution/BookingByStep/utils/resources.d.ts +59 -10
  61. package/dist/solution/BookingByStep/utils/resources.js +144 -79
  62. package/dist/solution/ShopDiscount/index.d.ts +50 -0
  63. package/dist/solution/ShopDiscount/index.js +546 -0
  64. package/dist/solution/ShopDiscount/types.d.ts +24 -0
  65. package/dist/solution/ShopDiscount/types.js +10 -0
  66. package/dist/solution/ShopDiscount/utils.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/utils.js +7 -0
  68. package/dist/solution/index.d.ts +1 -0
  69. package/dist/solution/index.js +2 -1
  70. package/lib/core/index.js +1 -1
  71. package/lib/effects/index.d.ts +1 -1
  72. package/lib/effects/index.js +1 -1
  73. package/lib/modules/Account/index.d.ts +5 -3
  74. package/lib/modules/Account/index.js +14 -3
  75. package/lib/modules/Account/types.d.ts +2 -1
  76. package/lib/modules/AccountList/index.d.ts +2 -0
  77. package/lib/modules/AccountList/index.js +17 -0
  78. package/lib/modules/Cart/index.d.ts +17 -11
  79. package/lib/modules/Cart/index.js +72 -21
  80. package/lib/modules/Cart/types.d.ts +98 -9
  81. package/lib/modules/Cart/utils.d.ts +114 -0
  82. package/lib/modules/Cart/utils.js +320 -0
  83. package/lib/modules/Date/index.d.ts +11 -12
  84. package/lib/modules/Date/index.js +50 -31
  85. package/lib/modules/Date/types.d.ts +51 -20
  86. package/lib/modules/Date/types.js +0 -4
  87. package/lib/modules/Date/utils.d.ts +35 -0
  88. package/lib/modules/Date/utils.js +167 -0
  89. package/lib/modules/Discount/index.d.ts +26 -0
  90. package/lib/modules/Discount/index.js +118 -0
  91. package/lib/modules/Discount/types.d.ts +66 -0
  92. package/lib/modules/Discount/types.js +33 -0
  93. package/lib/modules/Order/index.d.ts +16 -12
  94. package/lib/modules/Order/index.js +23 -51
  95. package/lib/modules/Order/types.d.ts +18 -41
  96. package/lib/modules/Payment/index.d.ts +0 -2
  97. package/lib/modules/Payment/index.js +6 -17
  98. package/lib/modules/Payment/types.d.ts +0 -2
  99. package/lib/modules/Product/types.d.ts +50 -1
  100. package/lib/modules/ProductList/index.d.ts +1 -0
  101. package/lib/modules/ProductList/index.js +6 -1
  102. package/lib/modules/ProductList/types.d.ts +1 -0
  103. package/lib/modules/Resource/types.d.ts +6 -2
  104. package/lib/modules/Rules/index.d.ts +32 -0
  105. package/lib/modules/Rules/index.js +283 -0
  106. package/lib/modules/Rules/types.d.ts +46 -0
  107. package/lib/modules/Rules/types.js +33 -0
  108. package/lib/modules/Summary/index.d.ts +13 -0
  109. package/lib/modules/Summary/index.js +49 -0
  110. package/lib/modules/Summary/types.d.ts +13 -0
  111. package/lib/modules/Summary/types.js +17 -0
  112. package/lib/modules/Summary/utils.d.ts +19 -0
  113. package/lib/modules/Summary/utils.js +79 -0
  114. package/lib/plugins/index.d.ts +3 -2
  115. package/lib/plugins/index.js +3 -1
  116. package/lib/plugins/request.d.ts +4 -3
  117. package/lib/plugins/request.js +4 -20
  118. package/lib/plugins/shopStore.d.ts +4 -0
  119. package/lib/plugins/shopStore.js +17 -0
  120. package/lib/solution/BookingByStep/index.d.ts +73 -10
  121. package/lib/solution/BookingByStep/index.js +452 -20
  122. package/lib/solution/BookingByStep/types.d.ts +2 -0
  123. package/lib/solution/BookingByStep/types.js +3 -0
  124. package/lib/solution/BookingByStep/utils/products.d.ts +11 -0
  125. package/lib/solution/BookingByStep/utils/products.js +60 -0
  126. package/lib/solution/BookingByStep/utils/resources.d.ts +59 -10
  127. package/lib/solution/BookingByStep/utils/resources.js +106 -49
  128. package/lib/solution/ShopDiscount/index.d.ts +50 -0
  129. package/lib/solution/ShopDiscount/index.js +321 -0
  130. package/lib/solution/ShopDiscount/types.d.ts +24 -0
  131. package/lib/solution/ShopDiscount/types.js +38 -0
  132. package/lib/solution/ShopDiscount/utils.d.ts +1 -0
  133. package/lib/solution/ShopDiscount/utils.js +32 -0
  134. package/lib/solution/index.d.ts +1 -0
  135. package/lib/solution/index.js +3 -1
  136. package/package.json +8 -7
@@ -0,0 +1,79 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/Summary/utils.ts
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ calculatePriceDetails: () => calculatePriceDetails,
33
+ calculateSubtotal: () => calculateSubtotal,
34
+ calculateTaxFee: () => calculateTaxFee
35
+ });
36
+ module.exports = __toCommonJS(utils_exports);
37
+ var import_decimal = __toESM(require("decimal.js"));
38
+ var calculatePriceDetails = (shopInfo, items) => {
39
+ const subtotal = new import_decimal.default(calculateSubtotal(items));
40
+ const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
41
+ const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee);
42
+ return {
43
+ subtotal: subtotal.toFixed(2),
44
+ total: total.toFixed(2),
45
+ taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
46
+ totalTaxFee: totalTaxFee.toFixed(2),
47
+ isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
48
+ };
49
+ };
50
+ var calculateSubtotal = (items) => {
51
+ if (!(items == null ? void 0 : items.length)) {
52
+ return "0.00";
53
+ }
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));
58
+ }, new import_decimal.default(0));
59
+ return subtotal.toFixed(2);
60
+ };
61
+ var calculateTaxFee = (shopInfo, items) => {
62
+ if (!(items == null ? void 0 : items.length)) {
63
+ return "0.00";
64
+ }
65
+ const { is_price_include_tax, tax_rate } = shopInfo || {};
66
+ const totalTaxFee = items.reduce((sum, item) => {
67
+ const price = new import_decimal.default(item.price || 0);
68
+ 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));
70
+ return sum.plus(productTaxRate);
71
+ }, new import_decimal.default(0));
72
+ return totalTaxFee;
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ calculatePriceDetails,
77
+ calculateSubtotal,
78
+ calculateTaxFee
79
+ });
@@ -1,2 +1,3 @@
1
- export * from './request';
2
- export * from './window';
1
+ export * from "./request";
2
+ export * from "./window";
3
+ export * from "./shopStore";
@@ -18,8 +18,10 @@ var plugins_exports = {};
18
18
  module.exports = __toCommonJS(plugins_exports);
19
19
  __reExport(plugins_exports, require("./request"), module.exports);
20
20
  __reExport(plugins_exports, require("./window"), module.exports);
21
+ __reExport(plugins_exports, require("./shopStore"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./request"),
24
- ...require("./window")
25
+ ...require("./window"),
26
+ ...require("./shopStore")
25
27
  });
@@ -1,4 +1,4 @@
1
- import { Plugin } from '../types';
1
+ import { Plugin } from "../types";
2
2
  /**
3
3
  * RequestPlugin 接口定义
4
4
  */
@@ -40,14 +40,15 @@ export interface RequestPlugin extends Plugin {
40
40
  */
41
41
  export interface RequestOptions {
42
42
  url?: string;
43
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
43
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
44
44
  headers?: Record<string, string>;
45
45
  data?: any;
46
46
  body?: any;
47
47
  params?: Record<string, string | number | boolean>;
48
48
  timeout?: number;
49
- responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
49
+ responseType?: "json" | "text" | "arraybuffer" | "blob";
50
50
  withCredentials?: boolean;
51
+ useCache?: boolean;
51
52
  }
52
53
  /**
53
54
  * 响应接口
@@ -148,10 +148,7 @@ var RequestPluginImpl = class {
148
148
  try {
149
149
  config = await Promise.resolve(interceptor(config));
150
150
  } catch (error) {
151
- const requestError = error instanceof RequestError ? error : new RequestError(
152
- error instanceof Error ? error.message : "请求拦截器错误",
153
- config
154
- );
151
+ const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "请求拦截器错误", config);
155
152
  let processedError = requestError;
156
153
  for (const errorInterceptor of this.interceptors.error) {
157
154
  try {
@@ -169,12 +166,7 @@ var RequestPluginImpl = class {
169
166
  try {
170
167
  processedResponse = await Promise.resolve(interceptor(processedResponse));
171
168
  } catch (error) {
172
- const requestError = error instanceof RequestError ? error : new RequestError(
173
- error instanceof Error ? error.message : "响应拦截器错误",
174
- config,
175
- null,
176
- response
177
- );
169
+ const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "响应拦截器错误", config, null, response);
178
170
  let processedError = requestError;
179
171
  for (const errorInterceptor of this.interceptors.error) {
180
172
  try {
@@ -187,10 +179,7 @@ var RequestPluginImpl = class {
187
179
  }
188
180
  return processedResponse.data;
189
181
  } catch (error) {
190
- const requestError = error instanceof RequestError ? error : new RequestError(
191
- error instanceof Error ? error.message : "请求错误",
192
- config
193
- );
182
+ const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "请求错误", config);
194
183
  let processedError = requestError;
195
184
  for (const errorInterceptor of this.interceptors.error) {
196
185
  try {
@@ -275,12 +264,7 @@ var RequestPluginImpl = class {
275
264
  config
276
265
  };
277
266
  if (!response.ok) {
278
- throw new RequestError(
279
- `请求失败,状态码: ${response.status}`,
280
- config,
281
- fetchOptions,
282
- result
283
- );
267
+ throw new RequestError(`请求失败,状态码: ${response.status}`, config, fetchOptions, result);
284
268
  }
285
269
  return result;
286
270
  } finally {
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "../types";
2
+ export interface ShopStorePlugin extends Plugin {
3
+ get(model: string): any;
4
+ }
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/plugins/shopStore.ts
16
+ var shopStore_exports = {};
17
+ module.exports = __toCommonJS(shopStore_exports);
@@ -1,14 +1,18 @@
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
5
  import { Account } from "../../modules/Account/types";
5
6
  import { IStep } from "../../modules/Step/tyeps";
7
+ import { TimeSliceItem } from "./utils/resources";
8
+ import { ITime } from "../../modules/Date/types";
6
9
  export declare class BookingByStepImpl extends BaseModule implements Module {
7
10
  protected defaultName: string;
8
11
  protected defaultVersion: string;
9
12
  isSolution: boolean;
10
13
  private request;
11
14
  private window;
15
+ private shopStore;
12
16
  private store;
13
17
  private otherParams;
14
18
  initialize(core: PisellCore, options: any): Promise<void>;
@@ -18,21 +22,42 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
18
22
  step: IStep;
19
23
  };
20
24
  next(): void;
25
+ back(): void;
26
+ gotoStep(index: number): void;
27
+ getStepList(): IStep[];
21
28
  getStoreCart(key?: string): Promise<any>;
22
- loadProducts({ category_ids, product_ids }: {
29
+ loadProducts({ category_ids, product_ids, collection, }: {
23
30
  category_ids?: number[];
24
31
  product_ids?: number[];
25
- }): Promise<void>;
26
- storeProducts(productData: any[]): Promise<void>;
32
+ collection?: number | string[];
33
+ }): Promise<any>;
34
+ storeProduct(productData: ProductData): Promise<void>;
27
35
  addAccount(accounts: Account[]): Promise<void>;
28
- getAccounts(): Promise<import("../../modules/Account").AccountModule[]>;
29
- setDateRange(dateRange: string[]): Promise<void>;
36
+ getAccounts(): Promise<(Account | null)[]>;
37
+ checkHasLoginAccount(): boolean;
38
+ setActiveAccount(id: string): void;
39
+ getActiveAccount(): Account | null;
40
+ removeAccount(id: string): void;
41
+ setDateRange(dateRange: ITime[]): Promise<void>;
30
42
  getRangeDate(): Promise<string>;
31
- getAvailableDate(): Promise<void>;
32
- getResourceTimeslot(): Promise<void>;
33
- getProducts(): Promise<import("../../modules").ProductData[]>;
34
- storeResources(resources: any[]): Promise<void>;
35
- setLoginAccount(account: Account): Promise<void>;
43
+ getCart(): Promise<import("../../modules").CartItem[]>;
44
+ getAvailableDate(params?: {
45
+ products?: ProductData[];
46
+ startDate?: string;
47
+ endDate?: string;
48
+ }): Promise<ITime[]>;
49
+ /**
50
+ * 获取购物车汇总信息
51
+ */
52
+ getSummary(): Promise<{
53
+ subtotal: string | number;
54
+ total: string | number;
55
+ taxTitle?: string | undefined;
56
+ totalTaxFee?: string | number | undefined;
57
+ isPriceIncludeTax?: 0 | 1 | undefined;
58
+ }>;
59
+ getProducts(): Promise<ProductData[]>;
60
+ setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
36
61
  generateCartData(): Promise<void>;
37
62
  submitOrder(): Promise<void>;
38
63
  pay(): Promise<void>;
@@ -41,4 +66,42 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
41
66
  cover?: boolean;
42
67
  }): Promise<void>;
43
68
  getOtherParams(): Promise<Record<string, any>>;
69
+ updateCart(params: IUpdateItemParams): void;
70
+ deleteCart(product_id: string): void;
71
+ clearCart(): void;
72
+ clearCartByAccount(account_id: string): void;
73
+ destory(): void;
74
+ getResourcesList(): any[];
75
+ getResourceTimeSlot({ product, resources, currentResourceId, }: {
76
+ product: ProductData;
77
+ resources: any[];
78
+ currentResourceId: number;
79
+ }): TimeSliceItem[];
80
+ autoSelectResource({ resourceProductData, resources, timeSlots, }: {
81
+ resourceProductData: any;
82
+ resources: any[];
83
+ timeSlots?: TimeSliceItem;
84
+ }): {
85
+ selectedResource: any;
86
+ timeSlots?: undefined;
87
+ } | {
88
+ timeSlots: any[];
89
+ selectedResource: any;
90
+ } | undefined;
91
+ autoSelectAccountResources({ holder_id, resources_code, timeSlots, }: {
92
+ holder_id: string;
93
+ resources_code: string | number;
94
+ timeSlots?: TimeSliceItem;
95
+ }): {
96
+ selectedResource: any;
97
+ timeSlots?: undefined;
98
+ } | {
99
+ timeSlots: any[];
100
+ selectedResource: any;
101
+ } | undefined;
102
+ autoSelectAllProductResources(resources_code: string, timeSlots?: TimeSliceItem): {
103
+ errorList: any[];
104
+ };
105
+ getTimeSlotByAllResources(resources_code: string): any[];
106
+ submitTimeSlot(timeSlots: TimeSliceItem): void;
44
107
  }