@pisell/pisellos 0.0.567 → 0.0.568

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 (228) hide show
  1. package/dist/core/index.js +6 -9
  2. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  3. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  4. package/dist/model/strategy/adapter/walletPass/utils.js +0 -3
  5. package/dist/model/strategy/strategy-example.js +5 -19
  6. package/dist/modules/Cart/index.js +0 -3
  7. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  8. package/dist/modules/Date/index.js +1 -5
  9. package/dist/modules/Discount/index.js +1 -4
  10. package/dist/modules/OpenData/index.js +0 -2
  11. package/dist/modules/Order/index.d.ts +1 -1
  12. package/dist/modules/Order/index.js +14 -41
  13. package/dist/modules/Payment/index.js +142 -270
  14. package/dist/modules/Payment/walletpass.js +4 -5
  15. package/dist/modules/Rules/index.js +0 -7
  16. package/dist/modules/Schedule/utils.js +0 -1
  17. package/dist/modules/Step/index.js +0 -1
  18. package/dist/plugins/request.js +1 -4
  19. package/dist/plugins/window.js +2 -6
  20. package/dist/server/index.js +88 -121
  21. package/dist/server/modules/menu/index.js +32 -41
  22. package/dist/server/modules/products/index.js +29 -49
  23. package/dist/server/modules/quotation/index.js +29 -38
  24. package/dist/server/modules/resource/index.js +3 -4
  25. package/dist/server/modules/schedule/index.js +32 -40
  26. package/dist/server/utils/product.js +0 -1
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingByStep/index.js +7 -59
  29. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  30. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  31. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  32. package/dist/solution/BookingTicket/index.d.ts +1 -1
  33. package/dist/solution/BookingTicket/index.js +5 -7
  34. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  35. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  36. package/dist/solution/BuyTickets/index.js +9 -12
  37. package/dist/solution/Checkout/index.js +177 -246
  38. package/dist/solution/Checkout/utils/index.js +4 -16
  39. package/dist/solution/RegisterAndLogin/index.js +30 -76
  40. package/dist/solution/ScanOrder/index.js +50 -60
  41. package/dist/solution/ShopDiscount/index.js +2 -7
  42. package/dist/solution/VenueBooking/index.d.ts +5 -0
  43. package/dist/solution/VenueBooking/index.js +364 -327
  44. package/dist/utils/task.js +15 -18
  45. package/dist/utils/watch.js +0 -1
  46. package/lib/apis/picoding.js +2 -0
  47. package/lib/core/index.js +130 -131
  48. package/lib/effects/index.js +46 -57
  49. package/lib/index.js +92 -53
  50. package/lib/model/index.js +14 -21
  51. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  53. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  54. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  55. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  56. package/lib/model/strategy/adapter/index.js +100 -64
  57. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  58. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  59. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  60. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  61. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  62. package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +381 -231
  64. package/lib/model/strategy/adapter/promotion/examples.js +139 -159
  65. package/lib/model/strategy/adapter/promotion/index.js +1 -49
  66. package/lib/model/strategy/adapter/promotion/type.js +199 -35
  67. package/lib/model/strategy/adapter/type.js +4 -16
  68. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
  69. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  70. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  71. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  72. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  73. package/lib/model/strategy/adapter/walletPass/utils.js +652 -402
  74. package/lib/model/strategy/engine.js +270 -168
  75. package/lib/model/strategy/index.js +49 -34
  76. package/lib/model/strategy/strategy-example.js +243 -239
  77. package/lib/model/strategy/type.js +100 -40
  78. package/lib/modules/Account/index.js +39 -53
  79. package/lib/modules/Account/types.js +20 -33
  80. package/lib/modules/AccountList/index.js +116 -154
  81. package/lib/modules/AccountList/types.js +30 -31
  82. package/lib/modules/AccountList/utils.js +18 -30
  83. package/lib/modules/BaseModule.js +22 -45
  84. package/lib/modules/Cart/index.js +170 -124
  85. package/lib/modules/Cart/types.js +46 -51
  86. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  87. package/lib/modules/Cart/utils/cartDate.js +56 -61
  88. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  89. package/lib/modules/Cart/utils/cartNote.js +27 -32
  90. package/lib/modules/Cart/utils/cartProduct.js +306 -241
  91. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  92. package/lib/modules/Cart/utils/cartResource.js +72 -78
  93. package/lib/modules/Cart/utils/changePrice.js +26 -62
  94. package/lib/modules/Cart/utils/index.js +106 -48
  95. package/lib/modules/Customer/constants.js +13 -34
  96. package/lib/modules/Customer/index.js +216 -153
  97. package/lib/modules/Customer/types.js +38 -35
  98. package/lib/modules/Date/index.js +116 -115
  99. package/lib/modules/Date/types.js +16 -28
  100. package/lib/modules/Date/utils.js +174 -123
  101. package/lib/modules/Discount/index.js +117 -113
  102. package/lib/modules/Discount/types.js +9 -31
  103. package/lib/modules/Guests/index.js +30 -56
  104. package/lib/modules/Guests/types.js +23 -33
  105. package/lib/modules/Holder/index.js +209 -189
  106. package/lib/modules/Holder/types.js +4 -16
  107. package/lib/modules/Holder/utils.js +20 -49
  108. package/lib/modules/OpenData/index.js +63 -74
  109. package/lib/modules/OpenData/types.js +4 -16
  110. package/lib/modules/OpenData/utils.js +44 -78
  111. package/lib/modules/Order/index.d.ts +1 -1
  112. package/lib/modules/Order/index.js +332 -320
  113. package/lib/modules/Order/types.js +24 -33
  114. package/lib/modules/Order/utils.js +350 -284
  115. package/lib/modules/Payment/cash.js +20 -33
  116. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  117. package/lib/modules/Payment/eftpos.js +16 -30
  118. package/lib/modules/Payment/index.js +566 -432
  119. package/lib/modules/Payment/mx51.js +1 -0
  120. package/lib/modules/Payment/types.js +216 -107
  121. package/lib/modules/Payment/utils.js +50 -47
  122. package/lib/modules/Payment/walletpass.js +221 -203
  123. package/lib/modules/Product/index.js +51 -46
  124. package/lib/modules/Product/types.js +4 -16
  125. package/lib/modules/Product/utils.js +32 -33
  126. package/lib/modules/ProductList/index.js +111 -110
  127. package/lib/modules/ProductList/types.js +9 -31
  128. package/lib/modules/Quotation/index.js +60 -82
  129. package/lib/modules/Quotation/types.js +4 -16
  130. package/lib/modules/Resource/index.js +27 -59
  131. package/lib/modules/Resource/types.js +22 -32
  132. package/lib/modules/Resource/utils.js +30 -38
  133. package/lib/modules/Rules/index.js +1172 -872
  134. package/lib/modules/Rules/types.js +17 -40
  135. package/lib/modules/SalesSummary/index.js +59 -68
  136. package/lib/modules/SalesSummary/types.js +4 -16
  137. package/lib/modules/SalesSummary/utils.js +176 -193
  138. package/lib/modules/ScanOrderLogger/index.js +59 -79
  139. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  140. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  141. package/lib/modules/ScanOrderLogger/types.js +4 -16
  142. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -167
  143. package/lib/modules/Schedule/index.js +97 -107
  144. package/lib/modules/Schedule/type.js +4 -16
  145. package/lib/modules/Schedule/types.js +4 -16
  146. package/lib/modules/Schedule/utils.js +433 -291
  147. package/lib/modules/Step/index.js +40 -52
  148. package/lib/modules/Step/tyeps.js +4 -16
  149. package/lib/modules/Summary/index.js +66 -70
  150. package/lib/modules/Summary/types.js +4 -16
  151. package/lib/modules/Summary/utils.js +782 -429
  152. package/lib/modules/index.js +212 -57
  153. package/lib/plugins/app.js +4 -16
  154. package/lib/plugins/index.js +36 -25
  155. package/lib/plugins/request.js +137 -126
  156. package/lib/plugins/shopStore.js +4 -16
  157. package/lib/plugins/user.js +4 -16
  158. package/lib/plugins/window.js +171 -179
  159. package/lib/server/index.js +882 -623
  160. package/lib/server/modules/index.js +85 -59
  161. package/lib/server/modules/menu/index.js +146 -122
  162. package/lib/server/modules/menu/types.js +18 -31
  163. package/lib/server/modules/order/index.js +195 -231
  164. package/lib/server/modules/order/types.js +107 -32
  165. package/lib/server/modules/order/utils/filterBookings.js +174 -140
  166. package/lib/server/modules/order/utils/filterOrders.js +89 -60
  167. package/lib/server/modules/products/index.js +430 -335
  168. package/lib/server/modules/products/types.js +41 -34
  169. package/lib/server/modules/quotation/index.js +76 -77
  170. package/lib/server/modules/quotation/types.js +21 -31
  171. package/lib/server/modules/resource/index.js +216 -187
  172. package/lib/server/modules/resource/types.js +42 -33
  173. package/lib/server/modules/schedule/index.js +134 -119
  174. package/lib/server/modules/schedule/types.js +14 -21
  175. package/lib/server/modules/schedule/utils.js +334 -163
  176. package/lib/server/types.js +4 -16
  177. package/lib/server/utils/index.js +25 -23
  178. package/lib/server/utils/product.js +196 -139
  179. package/lib/server/utils/schedule.js +34 -41
  180. package/lib/server/utils/time.js +40 -49
  181. package/lib/solution/BookingByStep/index.d.ts +1 -1
  182. package/lib/solution/BookingByStep/index.js +1530 -1343
  183. package/lib/solution/BookingByStep/types.js +40 -99
  184. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  185. package/lib/solution/BookingByStep/utils/products.js +42 -52
  186. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  187. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  188. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  189. package/lib/solution/BookingTicket/index.d.ts +1 -1
  190. package/lib/solution/BookingTicket/index.js +147 -122
  191. package/lib/solution/BookingTicket/types.js +38 -64
  192. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +64 -80
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.js +82 -80
  194. package/lib/solution/BookingTicket/utils/scan/index.js +90 -94
  195. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  196. package/lib/solution/BuyTickets/index.js +67 -70
  197. package/lib/solution/BuyTickets/types.js +22 -38
  198. package/lib/solution/Checkout/index.js +1451 -1158
  199. package/lib/solution/Checkout/types.js +91 -61
  200. package/lib/solution/Checkout/utils/index.js +227 -158
  201. package/lib/solution/PlaceOrder/index.js +55 -0
  202. package/lib/solution/RegisterAndLogin/config.js +493 -460
  203. package/lib/solution/RegisterAndLogin/index.js +633 -630
  204. package/lib/solution/RegisterAndLogin/types.js +189 -76
  205. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  206. package/lib/solution/Sales/index.js +218 -200
  207. package/lib/solution/Sales/types.js +27 -33
  208. package/lib/solution/ScanOrder/index.js +803 -840
  209. package/lib/solution/ScanOrder/types.js +34 -34
  210. package/lib/solution/ScanOrder/utils.js +372 -331
  211. package/lib/solution/ShopDiscount/index.js +230 -236
  212. package/lib/solution/ShopDiscount/types.js +15 -37
  213. package/lib/solution/ShopDiscount/utils.js +309 -172
  214. package/lib/solution/VenueBooking/index.d.ts +5 -0
  215. package/lib/solution/VenueBooking/index.js +886 -929
  216. package/lib/solution/VenueBooking/types.js +20 -40
  217. package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
  218. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  219. package/lib/solution/VenueBooking/utils/slotMerge.js +88 -106
  220. package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
  221. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
  222. package/lib/solution/VenueBooking/utils.js +130 -67
  223. package/lib/solution/index.js +102 -37
  224. package/lib/store/createStore.js +32 -29
  225. package/lib/types/index.js +4 -16
  226. package/lib/utils/task.js +36 -36
  227. package/lib/utils/watch.js +81 -47
  228. package/package.json +2 -1
@@ -1,144 +1,157 @@
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);
1
+ "use strict";
19
2
 
20
- // src/modules/Customer/index.ts
21
- var Customer_exports = {};
22
- __export(Customer_exports, {
23
- CustomerModule: () => CustomerModule
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
24
5
  });
25
- module.exports = __toCommonJS(Customer_exports);
26
- var import_lodash_es = require("lodash-es");
27
- var import_BaseModule = require("../BaseModule");
28
- var import_plugins = require("../../plugins");
29
- var import_constants = require("./constants");
30
- __reExport(Customer_exports, require("./types"), module.exports);
31
- var CustomerModule = class extends import_BaseModule.BaseModule {
6
+ var _exportNames = {
7
+ CustomerModule: true
8
+ };
9
+ exports.CustomerModule = void 0;
10
+ var _lodashEs = require("lodash-es");
11
+ var _BaseModule = require("../BaseModule");
12
+ var _plugins = require("../../plugins");
13
+ var _constants = require("./constants");
14
+ var _types = require("./types");
15
+ Object.keys(_types).forEach(function (key) {
16
+ if (key === "default" || key === "__esModule") return;
17
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
+ if (key in exports && exports[key] === _types[key]) return;
19
+ Object.defineProperty(exports, key, {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _types[key];
23
+ }
24
+ });
25
+ });
26
+ class CustomerModule extends _BaseModule.BaseModule {
27
+ defaultName = 'customer';
28
+ defaultVersion = '1.0.0';
29
+ store = {
30
+ customerList: [],
31
+ selectedCustomer: null,
32
+ total: 0,
33
+ currentPage: 1,
34
+ pageSize: _constants.DEFAULT_PAGE_SIZE,
35
+ loading: false,
36
+ error: null,
37
+ hasMore: true,
38
+ loadingMore: false,
39
+ searchParams: {}
40
+ };
41
+ request;
42
+ cacheId;
43
+ openCache = false;
44
+ fatherModule;
45
+ otherParams = {};
32
46
  constructor(name, version) {
33
47
  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
- this.otherParams = {};
50
48
  }
51
49
  async initialize(core, options) {
52
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
53
50
  this.core = core;
54
- this.store = options == null ? void 0 : options.store;
55
- this.request = this.core.getPlugin("request");
56
- this.otherParams = (options == null ? void 0 : options.otherParams) || {};
57
- if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.customerList)) {
58
- const customerList = (0, import_lodash_es.cloneDeep)(options.initialState.customerList || []);
51
+ this.store = options?.store;
52
+ this.request = this.core.getPlugin('request');
53
+ this.otherParams = options?.otherParams || {};
54
+
55
+ // 初始化状态
56
+ if (Array.isArray(options?.initialState?.customerList)) {
57
+ const customerList = (0, _lodashEs.cloneDeep)(options.initialState.customerList || []);
59
58
  this.store.customerList = customerList;
60
59
  } else {
61
60
  this.store.customerList = [];
62
61
  }
63
- if ((_b = options == null ? void 0 : options.initialState) == null ? void 0 : _b.selectedCustomer) {
64
- this.store.selectedCustomer = (0, import_lodash_es.cloneDeep)(options.initialState.selectedCustomer);
62
+ if (options?.initialState?.selectedCustomer) {
63
+ this.store.selectedCustomer = (0, _lodashEs.cloneDeep)(options.initialState.selectedCustomer);
65
64
  } else {
66
65
  this.store.selectedCustomer = null;
67
66
  }
68
- if (typeof ((_c = options == null ? void 0 : options.initialState) == null ? void 0 : _c.total) === "number") {
67
+ if (typeof options?.initialState?.total === 'number') {
69
68
  this.store.total = options.initialState.total;
70
69
  } else {
71
70
  this.store.total = 0;
72
71
  }
73
- if (typeof ((_d = options == null ? void 0 : options.initialState) == null ? void 0 : _d.currentPage) === "number") {
72
+ if (typeof options?.initialState?.currentPage === 'number') {
74
73
  this.store.currentPage = options.initialState.currentPage;
75
74
  } else {
76
75
  this.store.currentPage = 1;
77
76
  }
78
- if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number") {
77
+ if (typeof options?.initialState?.pageSize === 'number') {
79
78
  this.store.pageSize = options.initialState.pageSize;
80
79
  } else {
81
- this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
80
+ this.store.pageSize = _constants.DEFAULT_PAGE_SIZE;
82
81
  }
83
- this.store.hasMore = ((_f = options == null ? void 0 : options.initialState) == null ? void 0 : _f.hasMore) ?? true;
84
- this.store.loadingMore = ((_g = options == null ? void 0 : options.initialState) == null ? void 0 : _g.loadingMore) ?? false;
85
- this.store.searchParams = ((_h = options == null ? void 0 : options.initialState) == null ? void 0 : _h.searchParams) ?? {};
86
- if ((_i = options == null ? void 0 : options.otherParams) == null ? void 0 : _i.cacheId) {
82
+
83
+ // 初始化滚动加载相关状态
84
+ this.store.hasMore = options?.initialState?.hasMore ?? true;
85
+ this.store.loadingMore = options?.initialState?.loadingMore ?? false;
86
+ this.store.searchParams = options?.initialState?.searchParams ?? {};
87
+
88
+ // 缓存配置
89
+ if (options?.otherParams?.cacheId) {
87
90
  this.openCache = options.otherParams.openCache;
88
91
  this.cacheId = options.otherParams.cacheId;
89
92
  }
90
- if ((_j = options == null ? void 0 : options.otherParams) == null ? void 0 : _j.fatherModule) {
93
+ if (options?.otherParams?.fatherModule) {
91
94
  this.fatherModule = options.otherParams.fatherModule;
92
95
  }
93
96
  }
97
+
94
98
  /**
95
99
  * 获取客户列表数据(内部方法)
96
100
  * @param params 查询参数
97
101
  * @returns API响应数据
98
102
  */
99
103
  async fetchCustomerListData(params = {}) {
100
- var _a, _b, _c, _d;
101
- let url = "/customer/select-list";
102
- if ((_a = this.otherParams) == null ? void 0 : _a.isFranchisee) {
103
- url = "/franchisee/customer/select-list";
104
+ let url = '/customer/select-list';
105
+ // 如果是加盟子店铺,则使用加盟商的客户列表接口
106
+ if (this.otherParams?.isFranchisee) {
107
+ url = '/franchisee/customer/select-list';
104
108
  }
105
- const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ..._otherParams } = params;
109
+ const {
110
+ skip = 1,
111
+ num = _constants.DEFAULT_PAGE_SIZE,
112
+ search,
113
+ ..._otherParams
114
+ } = params;
106
115
  const queryParams = {
107
116
  skip,
108
117
  num,
109
- sort_by: import_constants.SORT_BY,
110
- with: ["latestWalletDetail.wallet", "contactsInfo", "formRecord"],
118
+ sort_by: _constants.SORT_BY,
119
+ with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord'],
111
120
  search_wallet_flag: 1,
112
121
  search_wallet_pass_flag: 1,
113
- ...search && { search },
122
+ ...(search && {
123
+ search
124
+ }),
114
125
  ..._otherParams
115
126
  };
116
127
  const res = await this.request.get(url, queryParams, {
117
128
  cache: {
118
- mode: import_plugins.RequestModeENUM.REMOTE_LOCAL,
129
+ mode: _plugins.RequestModeENUM.REMOTE_LOCAL,
119
130
  type: "memory"
120
131
  }
121
132
  });
122
- if ((res == null ? void 0 : res.code) !== 200) {
123
- throw new Error(res == null ? void 0 : res.message);
133
+ if (res?.code !== 200) {
134
+ throw new Error(res?.message);
124
135
  }
125
- let _customerList = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.list) || [];
126
- if (((_c = this.otherParams) == null ? void 0 : _c.isFranchisee) && (_customerList == null ? void 0 : _customerList.length) > 0) {
127
- _customerList = _customerList == null ? void 0 : _customerList.map((item) => {
136
+
137
+ // 如果是加盟子店铺,查询的接口返回的数据都是总店的客户数据,需要加上标识
138
+ let _customerList = res?.data?.list || [];
139
+ if (this.otherParams?.isFranchisee && _customerList?.length > 0) {
140
+ _customerList = _customerList?.map(item => {
128
141
  return {
129
- ...item || {},
130
- is_franchisor_customer: 1
131
- // 标识是总店的客户
142
+ ...(item || {}),
143
+ is_franchisor_customer: 1 // 标识是总店的客户
132
144
  };
133
145
  });
134
146
  }
135
147
  return {
136
148
  customerList: _customerList,
137
- total: ((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.count) || 0,
149
+ total: res?.data?.count || 0,
138
150
  page: skip,
139
151
  pageSize: num
140
152
  };
141
153
  }
154
+
142
155
  /**
143
156
  * 处理客户列表操作的错误(内部方法)
144
157
  * @param error 错误对象
@@ -147,11 +160,9 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
147
160
  async handleCustomerListError(error, operation) {
148
161
  console.error(`Failed to ${operation}:`, error);
149
162
  this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
150
- await this.core.effects.emit(
151
- `${this.name}:onCustomerListError`,
152
- this.store.error
153
- );
163
+ await this.core.effects.emit(`${this.name}:onCustomerListError`, this.store.error);
154
164
  }
165
+
155
166
  /**
156
167
  * 获取客户列表
157
168
  * @param params 查询参数
@@ -161,18 +172,34 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
161
172
  try {
162
173
  this.store.loading = true;
163
174
  this.store.error = null;
164
- const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
165
- const { skip, num, ...searchParams } = params;
166
- this.store.searchParams = (0, import_lodash_es.cloneDeep)(searchParams);
175
+ const {
176
+ customerList,
177
+ total,
178
+ page,
179
+ pageSize
180
+ } = await this.fetchCustomerListData(params);
181
+
182
+ // 保存搜索条件(排除skip和num)
183
+ const {
184
+ skip,
185
+ num,
186
+ ...searchParams
187
+ } = params;
188
+ this.store.searchParams = (0, _lodashEs.cloneDeep)(searchParams);
189
+
190
+ // 更新分页状态
167
191
  this.store.currentPage = page;
168
192
  this.store.pageSize = pageSize;
169
193
  this.store.total = total;
194
+
195
+ // 计算是否还有更多数据
170
196
  this.store.hasMore = page * pageSize < total;
171
- this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
172
- await this.core.effects.emit(
173
- `${this.name}:onCustomerListUpdate`,
174
- this.store
175
- );
197
+
198
+ // 设置客户列表(替换模式)
199
+ this.store.customerList = (0, _lodashEs.cloneDeep)(customerList);
200
+ await this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
201
+
202
+ // 触发分页变化事件
176
203
  this.triggerPaginationChange({
177
204
  page,
178
205
  pageSize,
@@ -187,37 +214,37 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
187
214
  };
188
215
  return response;
189
216
  } catch (error) {
190
- await this.handleCustomerListError(error, "fetch customer list");
217
+ await this.handleCustomerListError(error, 'fetch customer list');
191
218
  throw error;
192
219
  } finally {
193
220
  this.store.loading = false;
194
221
  this.storeChange();
195
222
  }
196
223
  }
224
+
197
225
  /**
198
226
  * 设置客户列表
199
227
  * @param customers 客户列表
200
228
  * @param total 总数
201
229
  */
202
230
  setCustomerList(customers, total) {
203
- this.store.customerList = (0, import_lodash_es.cloneDeep)(customers);
204
- if (typeof total === "number") {
231
+ this.store.customerList = (0, _lodashEs.cloneDeep)(customers);
232
+ if (typeof total === 'number') {
205
233
  this.store.total = total;
206
234
  }
207
235
  this.storeChange();
208
236
  }
237
+
209
238
  /**
210
239
  * 设置当前选择的客户
211
240
  * @param customer 选择的客户
212
241
  */
213
242
  setSelectedCustomer(customer) {
214
- this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
215
- this.core.effects.emit(
216
- `${this.name}:onCustomerSelected`,
217
- this.store.selectedCustomer
218
- );
243
+ this.store.selectedCustomer = !customer ? _constants.DEFAULT_CUSTOMER : (0, _lodashEs.cloneDeep)(customer);
244
+ this.core.effects.emit(`${this.name}:onCustomerSelected`, this.store.selectedCustomer);
219
245
  this.storeChange();
220
246
  }
247
+
221
248
  /**
222
249
  * 获取当前选择的客户
223
250
  * @returns 当前选择的客户
@@ -225,6 +252,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
225
252
  getSelectedCustomer() {
226
253
  return this.store.selectedCustomer;
227
254
  }
255
+
228
256
  /**
229
257
  * 获取客户列表
230
258
  * @returns 客户列表
@@ -232,14 +260,16 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
232
260
  getCustomers() {
233
261
  return [...this.store.customerList];
234
262
  }
263
+
235
264
  /**
236
265
  * 根据ID查找客户
237
266
  * @param id 客户ID
238
267
  * @returns 客户信息
239
268
  */
240
269
  getCustomerById(id) {
241
- return this.store.customerList.find((customer) => customer.id === id) || null;
270
+ return this.store.customerList.find(customer => customer.id === id) || null;
242
271
  }
272
+
243
273
  /**
244
274
  * 清空客户列表
245
275
  */
@@ -248,37 +278,43 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
248
278
  this.store.selectedCustomer = null;
249
279
  this.store.total = 0;
250
280
  this.store.currentPage = 1;
251
- this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
281
+ this.store.pageSize = _constants.DEFAULT_PAGE_SIZE;
252
282
  this.store.hasMore = true;
253
283
  this.store.loadingMore = false;
254
284
  this.store.searchParams = {};
255
- this.core.effects.emit(
256
- `${this.name}:onCustomerListUpdate`,
257
- this.store
258
- );
285
+ this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
259
286
  this.storeChange();
260
287
  }
288
+
261
289
  /**
262
290
  * 添加客户到列表第一位
263
291
  * @param customer 要添加的客户信息
264
292
  */
265
293
  addCustomerToFirst(customer) {
266
- const newCustomer = (0, import_lodash_es.cloneDeep)(customer);
294
+ // 深拷贝客户对象以避免引用问题
295
+ const newCustomer = (0, _lodashEs.cloneDeep)(customer);
296
+
297
+ // 将客户添加到列表第一位
267
298
  this.store.customerList = [newCustomer, ...this.store.customerList];
299
+
300
+ // 更新总数
268
301
  this.store.total += 1;
269
- this.core.effects.emit(
270
- `${this.name}:onCustomerListUpdate`,
271
- this.store
272
- );
302
+
303
+ // 触发客户列表更新事件
304
+ this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
305
+
306
+ // 保存状态变化
273
307
  this.storeChange();
274
308
  }
309
+
275
310
  /**
276
311
  * 获取当前状态
277
312
  * @returns 当前状态
278
313
  */
279
314
  getState() {
280
- return (0, import_lodash_es.cloneDeep)(this.store);
315
+ return (0, _lodashEs.cloneDeep)(this.store);
281
316
  }
317
+
282
318
  /**
283
319
  * 获取分页信息
284
320
  * @returns 分页信息
@@ -291,16 +327,15 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
291
327
  totalPages: Math.ceil(this.store.total / this.store.pageSize)
292
328
  };
293
329
  }
330
+
294
331
  /**
295
332
  * 触发分页变化事件
296
333
  * @param pagination 分页信息
297
334
  */
298
335
  triggerPaginationChange(pagination) {
299
- this.core.effects.emit(
300
- `${this.name}:onPaginationChange`,
301
- pagination
302
- );
336
+ this.core.effects.emit(`${this.name}:onPaginationChange`, pagination);
303
337
  }
338
+
304
339
  /**
305
340
  * 设置分页信息
306
341
  * @param page 页码
@@ -310,6 +345,8 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
310
345
  this.store.currentPage = page;
311
346
  this.store.pageSize = pageSize;
312
347
  this.storeChange();
348
+
349
+ // 触发分页变化事件
313
350
  this.triggerPaginationChange({
314
351
  page,
315
352
  pageSize,
@@ -317,6 +354,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
317
354
  totalPages: Math.ceil(this.store.total / pageSize)
318
355
  });
319
356
  }
357
+
320
358
  /**
321
359
  * 便捷方法:切换分页并自动获取数据
322
360
  * @param page 页码
@@ -325,21 +363,28 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
325
363
  */
326
364
  async changeCustomerPage(page, pageSize) {
327
365
  const targetPageSize = pageSize || this.store.pageSize;
366
+
367
+ // 先更新分页状态
328
368
  this.setPaginationInfo(page, targetPageSize);
369
+
370
+ // skip直接使用page,num使用pageSize
329
371
  const skip = page;
330
372
  const num = targetPageSize;
373
+
374
+ // 自动调用获取客户列表,使用存储的搜索条件
331
375
  return await this.getCustomerList({
332
376
  skip,
333
377
  num,
334
- ...this.store.searchParams
335
- // 使用存储的搜索条件
378
+ ...this.store.searchParams // 使用存储的搜索条件
336
379
  });
337
380
  }
381
+
338
382
  /**
339
383
  * 滚动加载更多客户数据 - 数据会追加到现有列表中
340
384
  * @returns 客户列表响应
341
385
  */
342
386
  async loadMoreCustomers() {
387
+ // 如果没有更多数据或正在加载,直接返回
343
388
  if (!this.store.hasMore || this.store.loadingMore) {
344
389
  return {
345
390
  list: [],
@@ -348,34 +393,46 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
348
393
  pageSize: this.store.pageSize
349
394
  };
350
395
  }
396
+
397
+ // 计算下一页
351
398
  const nextPage = this.store.currentPage + 1;
352
399
  try {
353
400
  this.store.loadingMore = true;
354
401
  this.store.error = null;
355
- const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
402
+
403
+ // 使用公共方法获取数据,传入存储的搜索条件
404
+ const {
405
+ customerList: newCustomers,
406
+ total,
407
+ page,
408
+ pageSize
409
+ } = await this.fetchCustomerListData({
356
410
  skip: nextPage,
357
411
  num: this.store.pageSize,
358
- ...this.store.searchParams
359
- // 使用存储的搜索条件
412
+ ...this.store.searchParams // 使用存储的搜索条件
360
413
  });
361
- const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
414
+
415
+ // 将新数据追加到现有列表(追加模式)
416
+ const updatedCustomerList = [...this.store.customerList, ...(0, _lodashEs.cloneDeep)(newCustomers)];
417
+
418
+ // 更新状态
362
419
  this.store.customerList = updatedCustomerList;
363
420
  this.store.currentPage = page;
364
421
  this.store.total = total;
365
422
  this.store.hasMore = page * pageSize < total;
366
- await this.core.effects.emit(
367
- `${this.name}:onScrollLoadMore`,
368
- {
369
- newCustomers,
370
- allCustomers: this.store.customerList,
371
- currentPage: page,
372
- hasMore: this.store.hasMore
373
- }
374
- );
375
- await this.core.effects.emit(
376
- `${this.name}:onCustomerListUpdate`,
377
- this.store
378
- );
423
+
424
+ // 触发滚动加载特定事件
425
+ await this.core.effects.emit(`${this.name}:onScrollLoadMore`, {
426
+ newCustomers,
427
+ allCustomers: this.store.customerList,
428
+ currentPage: page,
429
+ hasMore: this.store.hasMore
430
+ });
431
+
432
+ // 触发通用更新事件
433
+ await this.core.effects.emit(`${this.name}:onCustomerListUpdate`, this.store);
434
+
435
+ // 触发分页变化事件
379
436
  this.triggerPaginationChange({
380
437
  page,
381
438
  pageSize,
@@ -391,39 +448,45 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
391
448
  };
392
449
  return response;
393
450
  } catch (error) {
394
- await this.handleCustomerListError(error, "load more customers");
451
+ await this.handleCustomerListError(error, 'load more customers');
395
452
  throw error;
396
453
  } finally {
397
454
  this.store.loadingMore = false;
398
455
  this.storeChange();
399
456
  }
400
457
  }
458
+
401
459
  /**
402
460
  * 重置并重新开始滚动加载
403
461
  * @param params 查询参数
404
462
  * @returns 客户列表响应
405
463
  */
406
464
  async resetAndLoadCustomers(params = {}) {
465
+ // 重置状态
407
466
  this.store.customerList = [];
408
467
  this.store.currentPage = 1;
409
468
  this.store.hasMore = true;
410
469
  this.store.loadingMore = false;
470
+
471
+ // 使用第一页参数
411
472
  const resetParams = {
412
473
  ...params,
413
474
  skip: 1,
414
475
  num: params.num || this.store.pageSize
415
476
  };
477
+
478
+ // 调用普通的获取列表方法
416
479
  const response = await this.getCustomerList(resetParams);
417
- await this.core.effects.emit(
418
- `${this.name}:onScrollLoadComplete`,
419
- {
420
- customers: this.store.customerList,
421
- total: this.store.total,
422
- hasMore: this.store.hasMore
423
- }
424
- );
480
+
481
+ // 触发滚动加载完成事件
482
+ await this.core.effects.emit(`${this.name}:onScrollLoadComplete`, {
483
+ customers: this.store.customerList,
484
+ total: this.store.total,
485
+ hasMore: this.store.hasMore
486
+ });
425
487
  return response;
426
488
  }
489
+
427
490
  /**
428
491
  * 检查是否还有更多数据可以加载
429
492
  * @returns 是否还有更多数据
@@ -431,30 +494,30 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
431
494
  hasMoreCustomers() {
432
495
  return this.store.hasMore && !this.store.loadingMore;
433
496
  }
497
+
434
498
  /**
435
499
  * 获取当前的搜索条件
436
500
  * @returns 当前搜索条件
437
501
  */
438
502
  getCurrentSearchParams() {
439
- return (0, import_lodash_es.cloneDeep)(this.store.searchParams);
503
+ return (0, _lodashEs.cloneDeep)(this.store.searchParams);
440
504
  }
505
+
441
506
  /**
442
507
  * 缓存状态变化
443
508
  */
444
509
  storeChange() {
445
510
  if (this.openCache) {
446
- const store = (0, import_lodash_es.cloneDeep)(this.store);
511
+ const store = (0, _lodashEs.cloneDeep)(this.store);
447
512
  this.checkSaveCache({
448
513
  cacheId: this.cacheId,
449
514
  fatherModule: this.fatherModule,
450
515
  store,
451
- cacheKey: ["customerList", "selectedCustomer", "total", "currentPage", "pageSize", "hasMore", "loadingMore", "searchParams"]
516
+ cacheKey: ['customerList', 'selectedCustomer', 'total', 'currentPage', 'pageSize', 'hasMore', 'loadingMore', 'searchParams']
452
517
  });
453
518
  }
454
519
  }
455
- };
456
- // Annotate the CommonJS export names for ESM import in node:
457
- 0 && (module.exports = {
458
- CustomerModule,
459
- ...require("./types")
460
- });
520
+ }
521
+
522
+ // 导出类型和模块
523
+ exports.CustomerModule = CustomerModule;