@pisell/pisellos 3.0.55 → 3.0.57

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 (268) hide show
  1. package/dist/core/index.js +2 -1
  2. package/dist/effects/index.d.ts +4 -3
  3. package/dist/effects/index.js +15 -6
  4. package/dist/modules/AccountList/index.d.ts +7 -1
  5. package/dist/modules/AccountList/index.js +81 -14
  6. package/dist/modules/AccountList/types.d.ts +28 -0
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/Cart/index.js +1 -1
  9. package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
  10. package/dist/modules/Cart/utils/changePrice.js +1 -1
  11. package/dist/modules/Customer/constants.d.ts +7 -0
  12. package/dist/modules/Customer/constants.js +12 -0
  13. package/dist/modules/Customer/index.d.ts +122 -0
  14. package/dist/modules/Customer/index.js +697 -0
  15. package/dist/modules/Customer/types.d.ts +146 -0
  16. package/dist/modules/Customer/types.js +41 -0
  17. package/dist/modules/Payment/cash.d.ts +11 -0
  18. package/dist/modules/Payment/cash.js +78 -0
  19. package/dist/modules/Payment/eftpos.d.ts +11 -0
  20. package/dist/modules/Payment/eftpos.js +80 -0
  21. package/dist/modules/Payment/index.d.ts +273 -9
  22. package/dist/modules/Payment/index.js +2525 -109
  23. package/dist/modules/Payment/types.d.ts +382 -30
  24. package/dist/modules/Payment/types.js +116 -14
  25. package/dist/modules/Payment/wallet.d.ts +11 -0
  26. package/dist/modules/Payment/wallet.js +78 -0
  27. package/dist/modules/Payment/walletpass.d.ts +0 -0
  28. package/dist/modules/Payment/walletpass.js +0 -0
  29. package/dist/modules/ProductList/index.d.ts +14 -3
  30. package/dist/modules/ProductList/index.js +58 -44
  31. package/dist/modules/ProductList/types.d.ts +0 -1
  32. package/dist/modules/Rules/index.js +27 -14
  33. package/dist/modules/Rules/types.d.ts +1 -0
  34. package/dist/modules/index.d.ts +1 -0
  35. package/dist/modules/index.js +1 -0
  36. package/dist/plugins/app-types/app/app.d.ts +83 -0
  37. package/dist/plugins/app-types/app/const.d.ts +4 -0
  38. package/dist/plugins/app-types/app/index.d.ts +14 -0
  39. package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
  40. package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
  41. package/dist/plugins/app-types/config.d.ts +3 -0
  42. package/dist/plugins/app-types/cookie/index.d.ts +13 -0
  43. package/dist/plugins/app-types/data/index.d.ts +8 -0
  44. package/dist/plugins/app-types/history/config.d.ts +24 -0
  45. package/dist/plugins/app-types/history/index.d.ts +20 -0
  46. package/dist/plugins/app-types/history/type.d.ts +2 -0
  47. package/dist/plugins/app-types/hooks/index.d.ts +12 -0
  48. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  49. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  50. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  51. package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  52. package/dist/plugins/app-types/index.d.ts +6 -0
  53. package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
  54. package/dist/plugins/app-types/locales/en.d.ts +3 -0
  55. package/dist/plugins/app-types/locales/index.d.ts +37 -0
  56. package/dist/plugins/app-types/locales/original.d.ts +3 -0
  57. package/dist/plugins/app-types/locales/type.d.ts +19 -0
  58. package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
  59. package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
  60. package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
  61. package/dist/plugins/app-types/logger/index.d.ts +122 -0
  62. package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
  63. package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
  64. package/dist/plugins/app-types/models/global.d.ts +32 -0
  65. package/dist/plugins/app-types/models/index.d.ts +45 -0
  66. package/dist/plugins/app-types/models/type.d.ts +2 -0
  67. package/dist/plugins/app-types/package.json +15 -0
  68. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  69. package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
  70. package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
  71. package/dist/plugins/app-types/request/cache.d.ts +46 -0
  72. package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
  73. package/dist/plugins/app-types/request/config.d.ts +3 -0
  74. package/dist/plugins/app-types/request/constants.d.ts +2 -0
  75. package/dist/plugins/app-types/request/index.d.ts +24 -0
  76. package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
  77. package/dist/plugins/app-types/request/type.d.ts +41 -0
  78. package/dist/plugins/app-types/request/utils.d.ts +46 -0
  79. package/dist/plugins/app-types/routes/config.d.ts +7 -0
  80. package/dist/plugins/app-types/routes/index.d.ts +28 -0
  81. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  82. package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
  83. package/dist/plugins/app-types/socket/constants.d.ts +33 -0
  84. package/dist/plugins/app-types/socket/events.d.ts +31 -0
  85. package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
  86. package/dist/plugins/app-types/socket/index.d.ts +61 -0
  87. package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
  88. package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
  89. package/dist/plugins/app-types/socket/socket.d.ts +129 -0
  90. package/dist/plugins/app-types/socket/types.d.ts +85 -0
  91. package/dist/plugins/app-types/storage/index.d.ts +17 -0
  92. package/dist/plugins/app-types/tasks/index.d.ts +77 -0
  93. package/dist/plugins/app-types/tasks/type.d.ts +62 -0
  94. package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
  95. package/dist/plugins/app-types/type.d.ts +2 -0
  96. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  97. package/dist/plugins/app-types/variables/config.d.ts +3 -0
  98. package/dist/plugins/app-types/variables/index.d.ts +6 -0
  99. package/dist/plugins/app-types/variables/type.d.ts +2 -0
  100. package/dist/plugins/app-types/website/index.d.ts +6 -0
  101. package/dist/plugins/app.d.ts +8 -0
  102. package/dist/plugins/app.js +1 -0
  103. package/dist/plugins/window.d.ts +1 -0
  104. package/dist/solution/BookingByStep/index.js +59 -35
  105. package/dist/solution/BookingByStep/types.d.ts +3 -2
  106. package/dist/solution/BookingTicket/index.d.ts +172 -0
  107. package/dist/solution/BookingTicket/index.js +665 -0
  108. package/dist/solution/BookingTicket/types.d.ts +68 -0
  109. package/dist/solution/BookingTicket/types.js +43 -0
  110. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  111. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
  112. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
  113. package/dist/solution/BookingTicket/utils/scan/handleScan.js +174 -0
  114. package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  115. package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
  116. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  117. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  118. package/dist/solution/BuyTickets/index.d.ts +2 -2
  119. package/dist/solution/BuyTickets/index.js +1 -1
  120. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  121. package/dist/solution/Checkout/index.d.ts +181 -0
  122. package/dist/solution/Checkout/index.js +1596 -0
  123. package/dist/solution/Checkout/types.d.ts +550 -0
  124. package/dist/solution/Checkout/types.js +132 -0
  125. package/dist/solution/Checkout/utils/index.d.ts +73 -0
  126. package/dist/solution/Checkout/utils/index.js +371 -0
  127. package/dist/solution/ShopDiscount/index.js +4 -2
  128. package/dist/solution/index.d.ts +2 -0
  129. package/dist/solution/index.js +3 -1
  130. package/dist/types/index.d.ts +3 -1
  131. package/dist/utils/task.d.ts +40 -0
  132. package/dist/utils/task.js +171 -0
  133. package/dist/utils/watch.d.ts +102 -0
  134. package/dist/utils/watch.js +294 -0
  135. package/lib/core/index.js +1 -1
  136. package/lib/effects/index.d.ts +4 -3
  137. package/lib/effects/index.js +4 -1
  138. package/lib/modules/AccountList/index.d.ts +7 -1
  139. package/lib/modules/AccountList/index.js +27 -0
  140. package/lib/modules/AccountList/types.d.ts +28 -0
  141. package/lib/modules/Cart/index.js +1 -1
  142. package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
  143. package/lib/modules/Cart/utils/changePrice.js +1 -1
  144. package/lib/modules/Customer/constants.d.ts +7 -0
  145. package/lib/modules/Customer/constants.js +39 -0
  146. package/lib/modules/Customer/index.d.ts +122 -0
  147. package/lib/modules/Customer/index.js +440 -0
  148. package/lib/modules/Customer/types.d.ts +146 -0
  149. package/lib/modules/Customer/types.js +37 -0
  150. package/lib/modules/Payment/cash.d.ts +11 -0
  151. package/lib/modules/Payment/cash.js +51 -0
  152. package/lib/modules/Payment/eftpos.d.ts +11 -0
  153. package/lib/modules/Payment/eftpos.js +51 -0
  154. package/lib/modules/Payment/index.d.ts +273 -9
  155. package/lib/modules/Payment/index.js +1285 -50
  156. package/lib/modules/Payment/types.d.ts +382 -30
  157. package/lib/modules/Payment/types.js +41 -6
  158. package/lib/modules/Payment/wallet.d.ts +11 -0
  159. package/lib/modules/Payment/wallet.js +51 -0
  160. package/lib/modules/Payment/walletpass.d.ts +0 -0
  161. package/lib/modules/Payment/walletpass.js +0 -0
  162. package/lib/modules/ProductList/index.d.ts +14 -3
  163. package/lib/modules/ProductList/index.js +42 -28
  164. package/lib/modules/ProductList/types.d.ts +0 -1
  165. package/lib/modules/Rules/index.js +20 -12
  166. package/lib/modules/Rules/types.d.ts +1 -0
  167. package/lib/modules/index.d.ts +1 -0
  168. package/lib/modules/index.js +2 -0
  169. package/lib/plugins/app-types/app/app.d.ts +83 -0
  170. package/lib/plugins/app-types/app/const.d.ts +4 -0
  171. package/lib/plugins/app-types/app/index.d.ts +14 -0
  172. package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
  173. package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
  174. package/lib/plugins/app-types/config.d.ts +3 -0
  175. package/lib/plugins/app-types/cookie/index.d.ts +13 -0
  176. package/lib/plugins/app-types/data/index.d.ts +8 -0
  177. package/lib/plugins/app-types/history/config.d.ts +24 -0
  178. package/lib/plugins/app-types/history/index.d.ts +20 -0
  179. package/lib/plugins/app-types/history/type.d.ts +2 -0
  180. package/lib/plugins/app-types/hooks/index.d.ts +12 -0
  181. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  182. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  183. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  184. package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  185. package/lib/plugins/app-types/index.d.ts +6 -0
  186. package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
  187. package/lib/plugins/app-types/locales/en.d.ts +3 -0
  188. package/lib/plugins/app-types/locales/index.d.ts +37 -0
  189. package/lib/plugins/app-types/locales/original.d.ts +3 -0
  190. package/lib/plugins/app-types/locales/type.d.ts +19 -0
  191. package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
  192. package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
  193. package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
  194. package/lib/plugins/app-types/logger/index.d.ts +122 -0
  195. package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
  196. package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
  197. package/lib/plugins/app-types/models/global.d.ts +32 -0
  198. package/lib/plugins/app-types/models/index.d.ts +45 -0
  199. package/lib/plugins/app-types/models/type.d.ts +2 -0
  200. package/lib/plugins/app-types/package.json +15 -0
  201. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  202. package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
  203. package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
  204. package/lib/plugins/app-types/request/cache.d.ts +46 -0
  205. package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
  206. package/lib/plugins/app-types/request/config.d.ts +3 -0
  207. package/lib/plugins/app-types/request/constants.d.ts +2 -0
  208. package/lib/plugins/app-types/request/index.d.ts +24 -0
  209. package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
  210. package/lib/plugins/app-types/request/type.d.ts +41 -0
  211. package/lib/plugins/app-types/request/utils.d.ts +46 -0
  212. package/lib/plugins/app-types/routes/config.d.ts +7 -0
  213. package/lib/plugins/app-types/routes/index.d.ts +28 -0
  214. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  215. package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
  216. package/lib/plugins/app-types/socket/constants.d.ts +33 -0
  217. package/lib/plugins/app-types/socket/events.d.ts +31 -0
  218. package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
  219. package/lib/plugins/app-types/socket/index.d.ts +61 -0
  220. package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
  221. package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
  222. package/lib/plugins/app-types/socket/socket.d.ts +129 -0
  223. package/lib/plugins/app-types/socket/types.d.ts +85 -0
  224. package/lib/plugins/app-types/storage/index.d.ts +17 -0
  225. package/lib/plugins/app-types/tasks/index.d.ts +77 -0
  226. package/lib/plugins/app-types/tasks/type.d.ts +62 -0
  227. package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
  228. package/lib/plugins/app-types/type.d.ts +2 -0
  229. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  230. package/lib/plugins/app-types/variables/config.d.ts +3 -0
  231. package/lib/plugins/app-types/variables/index.d.ts +6 -0
  232. package/lib/plugins/app-types/variables/type.d.ts +2 -0
  233. package/lib/plugins/app-types/website/index.d.ts +6 -0
  234. package/lib/plugins/app.d.ts +8 -0
  235. package/lib/plugins/app.js +17 -0
  236. package/lib/plugins/window.d.ts +1 -0
  237. package/lib/solution/BookingByStep/index.js +40 -29
  238. package/lib/solution/BookingByStep/types.d.ts +3 -2
  239. package/lib/solution/BookingTicket/index.d.ts +172 -0
  240. package/lib/solution/BookingTicket/index.js +399 -0
  241. package/lib/solution/BookingTicket/types.d.ts +68 -0
  242. package/lib/solution/BookingTicket/types.js +72 -0
  243. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  244. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
  245. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
  246. package/lib/solution/BookingTicket/utils/scan/handleScan.js +125 -0
  247. package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  248. package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
  249. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  250. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  251. package/lib/solution/BuyTickets/index.d.ts +2 -2
  252. package/lib/solution/BuyTickets/index.js +1 -1
  253. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  254. package/lib/solution/Checkout/index.d.ts +181 -0
  255. package/lib/solution/Checkout/index.js +864 -0
  256. package/lib/solution/Checkout/types.d.ts +550 -0
  257. package/lib/solution/Checkout/types.js +75 -0
  258. package/lib/solution/Checkout/utils/index.d.ts +73 -0
  259. package/lib/solution/Checkout/utils/index.js +266 -0
  260. package/lib/solution/ShopDiscount/index.js +2 -1
  261. package/lib/solution/index.d.ts +2 -0
  262. package/lib/solution/index.js +5 -1
  263. package/lib/types/index.d.ts +3 -1
  264. package/lib/utils/task.d.ts +40 -0
  265. package/lib/utils/task.js +109 -0
  266. package/lib/utils/watch.d.ts +102 -0
  267. package/lib/utils/watch.js +217 -0
  268. package/package.json +4 -2
@@ -288,6 +288,33 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
288
288
  );
289
289
  return accountModules;
290
290
  }
291
+ /**
292
+ * 获取客户列表
293
+ * @param params 查询参数
294
+ * @returns 客户列表
295
+ */
296
+ async getCustomerList(params = {}) {
297
+ const url = "/customer/es/data";
298
+ const { page = 1, pageSize = 20, keyword, ...otherParams } = params;
299
+ try {
300
+ this.store.isLoading = true;
301
+ this.store.error = null;
302
+ const queryParams = {
303
+ page,
304
+ pageSize,
305
+ ...keyword && { keyword },
306
+ ...otherParams
307
+ };
308
+ const res = await this.request.get(url, queryParams);
309
+ return (res == null ? void 0 : res.data) || [];
310
+ } catch (error) {
311
+ console.error("Failed to fetch customer list:", error);
312
+ this.store.error = error instanceof Error ? error.message : "Failed to fetch customer list";
313
+ throw error;
314
+ } finally {
315
+ this.store.isLoading = false;
316
+ }
317
+ }
291
318
  /**
292
319
  * 获取holder类型账户列表
293
320
  * @param params
@@ -67,3 +67,31 @@ export interface IHolder {
67
67
  main_field: string;
68
68
  customer_cover?: string;
69
69
  }
70
+ /**
71
+ * 获取客户列表参数
72
+ */
73
+ export interface IGetCustomerListParams {
74
+ /** 页码 */
75
+ page?: number;
76
+ /** 每页数量 */
77
+ pageSize?: number;
78
+ /** 搜索关键词 */
79
+ keyword?: string;
80
+ /** 其他筛选参数 */
81
+ [key: string]: any;
82
+ }
83
+ /**
84
+ * 客户数据
85
+ */
86
+ export interface ICustomer {
87
+ /** 客户ID */
88
+ id: string | number;
89
+ /** 客户姓名 */
90
+ name: string;
91
+ /** 客户电话 */
92
+ phone?: string;
93
+ /** 客户邮箱 */
94
+ email?: string;
95
+ /** 其他客户信息 */
96
+ [key: string]: any;
97
+ }
@@ -31,7 +31,7 @@ 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
33
  constructor(name, version) {
34
- super(name, version);
34
+ super(name || "cart", version || "1.0.0");
35
35
  // 提供给 baseModule 用的默认名称 和 默认版本
36
36
  this.defaultName = "cart";
37
37
  this.defaultVersion = "1.0.0";
@@ -1,3 +1,3 @@
1
- import { Product } from "../../Product";
1
+ import { ProductData } 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, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
3
+ export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<ProductData | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
@@ -40,7 +40,7 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
40
40
  const cartProduct = await getProduct(
41
41
  item.id
42
42
  );
43
- let productInfo = cartProduct == null ? void 0 : cartProduct.getData();
43
+ let productInfo = cartProduct;
44
44
  if (!productInfo) {
45
45
  productInfo = item._productOrigin;
46
46
  }
@@ -0,0 +1,7 @@
1
+ export declare const SORT_BY = "id";
2
+ export declare const DEFAULT_PAGE_SIZE = 20;
3
+ export declare const DEFAULT_CUSTOMER: {
4
+ id: number;
5
+ nickname: string;
6
+ name: string;
7
+ };
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Customer/constants.ts
20
+ var constants_exports = {};
21
+ __export(constants_exports, {
22
+ DEFAULT_CUSTOMER: () => DEFAULT_CUSTOMER,
23
+ DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
24
+ SORT_BY: () => SORT_BY
25
+ });
26
+ module.exports = __toCommonJS(constants_exports);
27
+ var SORT_BY = "id";
28
+ var DEFAULT_PAGE_SIZE = 20;
29
+ var DEFAULT_CUSTOMER = {
30
+ "id": 1,
31
+ "nickname": "Select a customer",
32
+ "name": "选择一个客户"
33
+ };
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ DEFAULT_CUSTOMER,
37
+ DEFAULT_PAGE_SIZE,
38
+ SORT_BY
39
+ });
@@ -0,0 +1,122 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { CustomerState, ShopCustomer, ShopGetCustomerListParams, CustomerModuleAPI, IPaginationInfo, ICustomerListResponse } from './types';
4
+ export declare class CustomerModule extends BaseModule implements Module, CustomerModuleAPI {
5
+ protected defaultName: string;
6
+ protected defaultVersion: string;
7
+ private store;
8
+ private request;
9
+ private cacheId;
10
+ private openCache;
11
+ private fatherModule;
12
+ constructor(name?: string, version?: string);
13
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
+ /**
15
+ * 获取客户列表数据(内部方法)
16
+ * @param params 查询参数
17
+ * @returns API响应数据
18
+ */
19
+ private fetchCustomerListData;
20
+ /**
21
+ * 处理客户列表操作的错误(内部方法)
22
+ * @param error 错误对象
23
+ * @param operation 操作名称
24
+ */
25
+ private handleCustomerListError;
26
+ /**
27
+ * 获取客户列表
28
+ * @param params 查询参数
29
+ * @returns 客户列表响应
30
+ */
31
+ getCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
32
+ /**
33
+ * 设置客户列表
34
+ * @param customers 客户列表
35
+ * @param total 总数
36
+ */
37
+ setCustomerList(customers: ShopCustomer[], total?: number): void;
38
+ /**
39
+ * 设置当前选择的客户
40
+ * @param customer 选择的客户
41
+ */
42
+ setSelectedCustomer(customer: ShopCustomer | null): void;
43
+ /**
44
+ * 获取当前选择的客户
45
+ * @returns 当前选择的客户
46
+ */
47
+ getSelectedCustomer(): ShopCustomer | null;
48
+ /**
49
+ * 获取客户列表
50
+ * @returns 客户列表
51
+ */
52
+ getCustomers(): ShopCustomer[];
53
+ /**
54
+ * 根据ID查找客户
55
+ * @param id 客户ID
56
+ * @returns 客户信息
57
+ */
58
+ getCustomerById(id: string | number): ShopCustomer | null;
59
+ /**
60
+ * 清空客户列表
61
+ */
62
+ clearCustomers(): void;
63
+ /**
64
+ * 添加客户到列表第一位
65
+ * @param customer 要添加的客户信息
66
+ */
67
+ addCustomerToFirst(customer: ShopCustomer): void;
68
+ /**
69
+ * 获取当前状态
70
+ * @returns 当前状态
71
+ */
72
+ getState(): CustomerState;
73
+ /**
74
+ * 获取分页信息
75
+ * @returns 分页信息
76
+ */
77
+ getPaginationInfo(): IPaginationInfo;
78
+ /**
79
+ * 触发分页变化事件
80
+ * @param pagination 分页信息
81
+ */
82
+ triggerPaginationChange(pagination: IPaginationInfo): void;
83
+ /**
84
+ * 设置分页信息
85
+ * @param page 页码
86
+ * @param pageSize 每页数量
87
+ */
88
+ setPaginationInfo(page: number, pageSize: number): void;
89
+ /**
90
+ * 便捷方法:切换分页并自动获取数据
91
+ * @param page 页码
92
+ * @param pageSize 每页数量(可选,不传则使用当前pageSize)
93
+ * @returns 客户列表响应
94
+ */
95
+ changeCustomerPage(page: number, pageSize?: number): Promise<ICustomerListResponse>;
96
+ /**
97
+ * 滚动加载更多客户数据 - 数据会追加到现有列表中
98
+ * @returns 客户列表响应
99
+ */
100
+ loadMoreCustomers(): Promise<ICustomerListResponse>;
101
+ /**
102
+ * 重置并重新开始滚动加载
103
+ * @param params 查询参数
104
+ * @returns 客户列表响应
105
+ */
106
+ resetAndLoadCustomers(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
107
+ /**
108
+ * 检查是否还有更多数据可以加载
109
+ * @returns 是否还有更多数据
110
+ */
111
+ hasMoreCustomers(): boolean;
112
+ /**
113
+ * 获取当前的搜索条件
114
+ * @returns 当前搜索条件
115
+ */
116
+ getCurrentSearchParams(): Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
117
+ /**
118
+ * 缓存状态变化
119
+ */
120
+ private storeChange;
121
+ }
122
+ export * from './types';
@@ -0,0 +1,440 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/Customer/index.ts
21
+ var Customer_exports = {};
22
+ __export(Customer_exports, {
23
+ CustomerModule: () => CustomerModule
24
+ });
25
+ module.exports = __toCommonJS(Customer_exports);
26
+ var import_lodash_es = require("lodash-es");
27
+ var import_BaseModule = require("../BaseModule");
28
+ var import_types = require("./types");
29
+ var import_constants = require("./constants");
30
+ __reExport(Customer_exports, require("./types"), module.exports);
31
+ var CustomerModule = class extends import_BaseModule.BaseModule {
32
+ constructor(name, version) {
33
+ super(name, version);
34
+ this.defaultName = "customer";
35
+ this.defaultVersion = "1.0.0";
36
+ this.store = {
37
+ customerList: [],
38
+ selectedCustomer: null,
39
+ total: 0,
40
+ currentPage: 1,
41
+ pageSize: import_constants.DEFAULT_PAGE_SIZE,
42
+ loading: false,
43
+ error: null,
44
+ hasMore: true,
45
+ loadingMore: false,
46
+ searchParams: {}
47
+ };
48
+ this.openCache = false;
49
+ }
50
+ async initialize(core, options) {
51
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
52
+ this.core = core;
53
+ this.store = options == null ? void 0 : options.store;
54
+ this.request = this.core.getPlugin("request");
55
+ if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.customerList)) {
56
+ const customerList = (0, import_lodash_es.cloneDeep)(options.initialState.customerList || []);
57
+ this.store.customerList = customerList;
58
+ } else {
59
+ this.store.customerList = [];
60
+ }
61
+ if ((_b = options == null ? void 0 : options.initialState) == null ? void 0 : _b.selectedCustomer) {
62
+ this.store.selectedCustomer = (0, import_lodash_es.cloneDeep)(options.initialState.selectedCustomer);
63
+ } else {
64
+ this.store.selectedCustomer = null;
65
+ }
66
+ if (typeof ((_c = options == null ? void 0 : options.initialState) == null ? void 0 : _c.total) === "number") {
67
+ this.store.total = options.initialState.total;
68
+ } else {
69
+ this.store.total = 0;
70
+ }
71
+ if (typeof ((_d = options == null ? void 0 : options.initialState) == null ? void 0 : _d.currentPage) === "number") {
72
+ this.store.currentPage = options.initialState.currentPage;
73
+ } else {
74
+ this.store.currentPage = 1;
75
+ }
76
+ if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number") {
77
+ this.store.pageSize = options.initialState.pageSize;
78
+ } else {
79
+ this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
80
+ }
81
+ this.store.hasMore = ((_f = options == null ? void 0 : options.initialState) == null ? void 0 : _f.hasMore) ?? true;
82
+ this.store.loadingMore = ((_g = options == null ? void 0 : options.initialState) == null ? void 0 : _g.loadingMore) ?? false;
83
+ this.store.searchParams = ((_h = options == null ? void 0 : options.initialState) == null ? void 0 : _h.searchParams) ?? {};
84
+ if ((_i = options == null ? void 0 : options.otherParams) == null ? void 0 : _i.cacheId) {
85
+ this.openCache = options.otherParams.openCache;
86
+ this.cacheId = options.otherParams.cacheId;
87
+ }
88
+ if ((_j = options == null ? void 0 : options.otherParams) == null ? void 0 : _j.fatherModule) {
89
+ this.fatherModule = options.otherParams.fatherModule;
90
+ }
91
+ }
92
+ /**
93
+ * 获取客户列表数据(内部方法)
94
+ * @param params 查询参数
95
+ * @returns API响应数据
96
+ */
97
+ async fetchCustomerListData(params = {}) {
98
+ var _a, _b;
99
+ const url = "/customer/select-list";
100
+ const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ...otherParams } = params;
101
+ const queryParams = {
102
+ skip,
103
+ num,
104
+ sort_by: import_constants.SORT_BY,
105
+ with: ["latestWalletDetail.wallet"],
106
+ search_wallet_flag: 1,
107
+ search_wallet_pass_flag: 1,
108
+ ...search && { search },
109
+ ...otherParams
110
+ };
111
+ const res = await this.request.get(url, queryParams);
112
+ if ((res == null ? void 0 : res.code) !== 200) {
113
+ throw new Error(res == null ? void 0 : res.message);
114
+ }
115
+ return {
116
+ customerList: ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [],
117
+ total: ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.count) || 0,
118
+ page: skip,
119
+ pageSize: num
120
+ };
121
+ }
122
+ /**
123
+ * 处理客户列表操作的错误(内部方法)
124
+ * @param error 错误对象
125
+ * @param operation 操作名称
126
+ */
127
+ async handleCustomerListError(error, operation) {
128
+ console.error(`Failed to ${operation}:`, error);
129
+ this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
130
+ await this.core.effects.emit(
131
+ import_types.CustomerHooks.OnCustomerListError,
132
+ this.store.error
133
+ );
134
+ }
135
+ /**
136
+ * 获取客户列表
137
+ * @param params 查询参数
138
+ * @returns 客户列表响应
139
+ */
140
+ async getCustomerList(params = {}) {
141
+ try {
142
+ this.store.loading = true;
143
+ this.store.error = null;
144
+ const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
145
+ const { skip, num, ...searchParams } = params;
146
+ this.store.searchParams = (0, import_lodash_es.cloneDeep)(searchParams);
147
+ this.store.currentPage = page;
148
+ this.store.pageSize = pageSize;
149
+ this.store.total = total;
150
+ this.store.hasMore = page * pageSize < total;
151
+ this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
152
+ await this.core.effects.emit(
153
+ import_types.CustomerHooks.OnCustomerListUpdate,
154
+ this.store
155
+ );
156
+ this.triggerPaginationChange({
157
+ page,
158
+ pageSize,
159
+ total,
160
+ totalPages: Math.ceil(total / pageSize)
161
+ });
162
+ const response = {
163
+ list: customerList,
164
+ total,
165
+ page,
166
+ pageSize
167
+ };
168
+ return response;
169
+ } catch (error) {
170
+ await this.handleCustomerListError(error, "fetch customer list");
171
+ throw error;
172
+ } finally {
173
+ this.store.loading = false;
174
+ this.storeChange();
175
+ }
176
+ }
177
+ /**
178
+ * 设置客户列表
179
+ * @param customers 客户列表
180
+ * @param total 总数
181
+ */
182
+ setCustomerList(customers, total) {
183
+ this.store.customerList = (0, import_lodash_es.cloneDeep)(customers);
184
+ if (typeof total === "number") {
185
+ this.store.total = total;
186
+ }
187
+ this.storeChange();
188
+ }
189
+ /**
190
+ * 设置当前选择的客户
191
+ * @param customer 选择的客户
192
+ */
193
+ setSelectedCustomer(customer) {
194
+ this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
195
+ this.core.effects.emit(
196
+ import_types.CustomerHooks.OnCustomerSelected,
197
+ this.store.selectedCustomer
198
+ );
199
+ this.storeChange();
200
+ }
201
+ /**
202
+ * 获取当前选择的客户
203
+ * @returns 当前选择的客户
204
+ */
205
+ getSelectedCustomer() {
206
+ return this.store.selectedCustomer;
207
+ }
208
+ /**
209
+ * 获取客户列表
210
+ * @returns 客户列表
211
+ */
212
+ getCustomers() {
213
+ return [...this.store.customerList];
214
+ }
215
+ /**
216
+ * 根据ID查找客户
217
+ * @param id 客户ID
218
+ * @returns 客户信息
219
+ */
220
+ getCustomerById(id) {
221
+ return this.store.customerList.find((customer) => customer.id === id) || null;
222
+ }
223
+ /**
224
+ * 清空客户列表
225
+ */
226
+ clearCustomers() {
227
+ this.store.customerList = [];
228
+ this.store.selectedCustomer = null;
229
+ this.store.total = 0;
230
+ this.store.currentPage = 1;
231
+ this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
232
+ this.store.hasMore = true;
233
+ this.store.loadingMore = false;
234
+ this.store.searchParams = {};
235
+ this.core.effects.emit(
236
+ import_types.CustomerHooks.OnCustomerListUpdate,
237
+ this.store
238
+ );
239
+ this.storeChange();
240
+ }
241
+ /**
242
+ * 添加客户到列表第一位
243
+ * @param customer 要添加的客户信息
244
+ */
245
+ addCustomerToFirst(customer) {
246
+ const newCustomer = (0, import_lodash_es.cloneDeep)(customer);
247
+ this.store.customerList = [newCustomer, ...this.store.customerList];
248
+ this.store.total += 1;
249
+ this.core.effects.emit(
250
+ import_types.CustomerHooks.OnCustomerListUpdate,
251
+ this.store
252
+ );
253
+ this.storeChange();
254
+ }
255
+ /**
256
+ * 获取当前状态
257
+ * @returns 当前状态
258
+ */
259
+ getState() {
260
+ return (0, import_lodash_es.cloneDeep)(this.store);
261
+ }
262
+ /**
263
+ * 获取分页信息
264
+ * @returns 分页信息
265
+ */
266
+ getPaginationInfo() {
267
+ return {
268
+ page: this.store.currentPage,
269
+ pageSize: this.store.pageSize,
270
+ total: this.store.total,
271
+ totalPages: Math.ceil(this.store.total / this.store.pageSize)
272
+ };
273
+ }
274
+ /**
275
+ * 触发分页变化事件
276
+ * @param pagination 分页信息
277
+ */
278
+ triggerPaginationChange(pagination) {
279
+ this.core.effects.emit(
280
+ import_types.CustomerHooks.OnPaginationChange,
281
+ pagination
282
+ );
283
+ }
284
+ /**
285
+ * 设置分页信息
286
+ * @param page 页码
287
+ * @param pageSize 每页数量
288
+ */
289
+ setPaginationInfo(page, pageSize) {
290
+ this.store.currentPage = page;
291
+ this.store.pageSize = pageSize;
292
+ this.storeChange();
293
+ this.triggerPaginationChange({
294
+ page,
295
+ pageSize,
296
+ total: this.store.total,
297
+ totalPages: Math.ceil(this.store.total / pageSize)
298
+ });
299
+ }
300
+ /**
301
+ * 便捷方法:切换分页并自动获取数据
302
+ * @param page 页码
303
+ * @param pageSize 每页数量(可选,不传则使用当前pageSize)
304
+ * @returns 客户列表响应
305
+ */
306
+ async changeCustomerPage(page, pageSize) {
307
+ const targetPageSize = pageSize || this.store.pageSize;
308
+ this.setPaginationInfo(page, targetPageSize);
309
+ const skip = page;
310
+ const num = targetPageSize;
311
+ return await this.getCustomerList({
312
+ skip,
313
+ num,
314
+ ...this.store.searchParams
315
+ // 使用存储的搜索条件
316
+ });
317
+ }
318
+ /**
319
+ * 滚动加载更多客户数据 - 数据会追加到现有列表中
320
+ * @returns 客户列表响应
321
+ */
322
+ async loadMoreCustomers() {
323
+ if (!this.store.hasMore || this.store.loadingMore) {
324
+ return {
325
+ list: [],
326
+ total: this.store.total,
327
+ page: this.store.currentPage,
328
+ pageSize: this.store.pageSize
329
+ };
330
+ }
331
+ const nextPage = this.store.currentPage + 1;
332
+ try {
333
+ this.store.loadingMore = true;
334
+ this.store.error = null;
335
+ const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
336
+ skip: nextPage,
337
+ num: this.store.pageSize,
338
+ ...this.store.searchParams
339
+ // 使用存储的搜索条件
340
+ });
341
+ const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
342
+ this.store.customerList = updatedCustomerList;
343
+ this.store.currentPage = page;
344
+ this.store.total = total;
345
+ this.store.hasMore = page * pageSize < total;
346
+ await this.core.effects.emit(
347
+ import_types.CustomerHooks.OnScrollLoadMore,
348
+ {
349
+ newCustomers,
350
+ allCustomers: this.store.customerList,
351
+ currentPage: page,
352
+ hasMore: this.store.hasMore
353
+ }
354
+ );
355
+ await this.core.effects.emit(
356
+ import_types.CustomerHooks.OnCustomerListUpdate,
357
+ this.store
358
+ );
359
+ this.triggerPaginationChange({
360
+ page,
361
+ pageSize,
362
+ total,
363
+ totalPages: Math.ceil(total / pageSize)
364
+ });
365
+ const response = {
366
+ list: newCustomers,
367
+ // 返回新加载的数据
368
+ total,
369
+ page,
370
+ pageSize
371
+ };
372
+ return response;
373
+ } catch (error) {
374
+ await this.handleCustomerListError(error, "load more customers");
375
+ throw error;
376
+ } finally {
377
+ this.store.loadingMore = false;
378
+ this.storeChange();
379
+ }
380
+ }
381
+ /**
382
+ * 重置并重新开始滚动加载
383
+ * @param params 查询参数
384
+ * @returns 客户列表响应
385
+ */
386
+ async resetAndLoadCustomers(params = {}) {
387
+ this.store.customerList = [];
388
+ this.store.currentPage = 1;
389
+ this.store.hasMore = true;
390
+ this.store.loadingMore = false;
391
+ const resetParams = {
392
+ ...params,
393
+ skip: 1,
394
+ num: params.num || this.store.pageSize
395
+ };
396
+ const response = await this.getCustomerList(resetParams);
397
+ await this.core.effects.emit(
398
+ import_types.CustomerHooks.OnScrollLoadComplete,
399
+ {
400
+ customers: this.store.customerList,
401
+ total: this.store.total,
402
+ hasMore: this.store.hasMore
403
+ }
404
+ );
405
+ return response;
406
+ }
407
+ /**
408
+ * 检查是否还有更多数据可以加载
409
+ * @returns 是否还有更多数据
410
+ */
411
+ hasMoreCustomers() {
412
+ return this.store.hasMore && !this.store.loadingMore;
413
+ }
414
+ /**
415
+ * 获取当前的搜索条件
416
+ * @returns 当前搜索条件
417
+ */
418
+ getCurrentSearchParams() {
419
+ return (0, import_lodash_es.cloneDeep)(this.store.searchParams);
420
+ }
421
+ /**
422
+ * 缓存状态变化
423
+ */
424
+ storeChange() {
425
+ if (this.openCache) {
426
+ const store = (0, import_lodash_es.cloneDeep)(this.store);
427
+ this.checkSaveCache({
428
+ cacheId: this.cacheId,
429
+ fatherModule: this.fatherModule,
430
+ store,
431
+ cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize", "hasMore", "loadingMore", "searchParams"]
432
+ });
433
+ }
434
+ }
435
+ };
436
+ // Annotate the CommonJS export names for ESM import in node:
437
+ 0 && (module.exports = {
438
+ CustomerModule,
439
+ ...require("./types")
440
+ });