@pisell/pisellos 2.2.171 → 2.2.172

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 (156) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.d.ts +6 -0
  32. package/dist/modules/Customer/index.js +129 -83
  33. package/dist/modules/Customer/types.d.ts +2 -0
  34. package/dist/modules/Discount/index.d.ts +2 -4
  35. package/dist/modules/Discount/index.js +8 -93
  36. package/dist/modules/Discount/types.d.ts +1 -7
  37. package/dist/modules/Order/index.d.ts +47 -16
  38. package/dist/modules/Order/index.js +743 -334
  39. package/dist/modules/Order/types.d.ts +57 -17
  40. package/dist/modules/Order/types.js +2 -0
  41. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  42. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  43. package/dist/modules/Order/utils.d.ts +23 -1
  44. package/dist/modules/Order/utils.js +139 -30
  45. package/dist/modules/Quotation/index.js +16 -5
  46. package/dist/modules/Rules/index.d.ts +4 -0
  47. package/dist/modules/Rules/index.js +26 -10
  48. package/dist/modules/SalesSummary/index.js +4 -2
  49. package/dist/modules/Schedule/index.js +6 -2
  50. package/dist/modules/index.d.ts +1 -0
  51. package/dist/modules/index.js +2 -1
  52. package/dist/server/index.js +10 -6
  53. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  54. package/dist/server/modules/products/index.js +9 -8
  55. package/dist/server/modules/schedule/index.js +13 -6
  56. package/dist/solution/BaseSales/index.d.ts +65 -7
  57. package/dist/solution/BaseSales/index.js +1066 -315
  58. package/dist/solution/BaseSales/types.d.ts +53 -1
  59. package/dist/solution/BaseSales/types.js +3 -1
  60. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  61. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  62. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
  63. package/dist/solution/BaseSales/utils.js +46 -8
  64. package/dist/solution/BookingTicket/index.d.ts +134 -2
  65. package/dist/solution/BookingTicket/index.js +768 -175
  66. package/dist/solution/BookingTicket/types.d.ts +2 -0
  67. package/dist/solution/BookingTicket/types.js +3 -0
  68. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  69. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  70. package/dist/solution/ScanOrder/index.d.ts +9 -3
  71. package/dist/solution/ScanOrder/index.js +231 -128
  72. package/dist/solution/ScanOrder/utils.js +46 -8
  73. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  74. package/dist/solution/ShopDiscount/index.js +18 -23
  75. package/dist/solution/VenueBooking/index.d.ts +5 -9
  76. package/dist/solution/VenueBooking/index.js +103 -55
  77. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  78. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  79. package/lib/modules/BookingContext/index.d.ts +37 -0
  80. package/lib/modules/BookingContext/index.js +297 -0
  81. package/lib/modules/BookingContext/types.d.ts +102 -0
  82. package/lib/modules/BookingContext/types.js +34 -0
  83. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  84. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
  85. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  86. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  87. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  88. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  89. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  90. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  91. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  92. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  93. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  94. package/lib/modules/BookingContext/utils/index.js +43 -0
  95. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  96. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  97. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  98. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  99. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  100. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  101. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  102. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  103. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  104. package/lib/modules/BookingContext/utils/resources.js +377 -0
  105. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  106. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  107. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  108. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  109. package/lib/modules/Customer/index.d.ts +6 -0
  110. package/lib/modules/Customer/index.js +26 -11
  111. package/lib/modules/Customer/types.d.ts +2 -0
  112. package/lib/modules/Discount/index.d.ts +2 -4
  113. package/lib/modules/Discount/index.js +8 -63
  114. package/lib/modules/Discount/types.d.ts +1 -7
  115. package/lib/modules/Order/index.d.ts +47 -16
  116. package/lib/modules/Order/index.js +389 -90
  117. package/lib/modules/Order/types.d.ts +57 -17
  118. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  119. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  120. package/lib/modules/Order/utils.d.ts +23 -1
  121. package/lib/modules/Order/utils.js +145 -21
  122. package/lib/modules/Quotation/index.js +17 -6
  123. package/lib/modules/Rules/index.d.ts +4 -0
  124. package/lib/modules/Rules/index.js +22 -14
  125. package/lib/modules/SalesSummary/index.js +4 -2
  126. package/lib/modules/Schedule/index.js +3 -1
  127. package/lib/modules/index.d.ts +1 -0
  128. package/lib/modules/index.js +3 -1
  129. package/lib/server/index.js +2 -0
  130. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  131. package/lib/server/modules/products/index.js +8 -9
  132. package/lib/server/modules/schedule/index.js +2 -1
  133. package/lib/solution/BaseSales/index.d.ts +65 -7
  134. package/lib/solution/BaseSales/index.js +492 -20
  135. package/lib/solution/BaseSales/types.d.ts +53 -1
  136. package/lib/solution/BaseSales/types.js +3 -1
  137. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  138. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  139. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
  140. package/lib/solution/BaseSales/utils.js +46 -6
  141. package/lib/solution/BookingTicket/index.d.ts +134 -2
  142. package/lib/solution/BookingTicket/index.js +341 -8
  143. package/lib/solution/BookingTicket/types.d.ts +2 -0
  144. package/lib/solution/BookingTicket/types.js +6 -0
  145. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  146. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  147. package/lib/solution/ScanOrder/index.d.ts +9 -3
  148. package/lib/solution/ScanOrder/index.js +147 -66
  149. package/lib/solution/ScanOrder/utils.js +46 -6
  150. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  151. package/lib/solution/ShopDiscount/index.js +2 -4
  152. package/lib/solution/VenueBooking/index.d.ts +5 -9
  153. package/lib/solution/VenueBooking/index.js +50 -14
  154. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  155. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  156. package/package.json +2 -2
@@ -95,7 +95,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
95
95
  } else {
96
96
  this.store.currentPage = 1;
97
97
  }
98
- if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number') {
98
+ if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number' && options.initialState.pageSize > 1) {
99
99
  this.store.pageSize = options.initialState.pageSize;
100
100
  } else {
101
101
  this.store.pageSize = DEFAULT_PAGE_SIZE;
@@ -236,6 +236,52 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
236
236
  }
237
237
  return handleCustomerListError;
238
238
  }()
239
+ /**
240
+ * 查询客户列表但不写入 customerList / pagination 状态。
241
+ *
242
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
243
+ */
244
+ )
245
+ }, {
246
+ key: "queryCustomerList",
247
+ value: (function () {
248
+ var _queryCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
249
+ var params,
250
+ _yield$this$fetchCust,
251
+ customerList,
252
+ total,
253
+ page,
254
+ pageSize,
255
+ _args4 = arguments;
256
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
257
+ while (1) switch (_context4.prev = _context4.next) {
258
+ case 0:
259
+ params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
260
+ _context4.next = 3;
261
+ return this.fetchCustomerListData(params);
262
+ case 3:
263
+ _yield$this$fetchCust = _context4.sent;
264
+ customerList = _yield$this$fetchCust.customerList;
265
+ total = _yield$this$fetchCust.total;
266
+ page = _yield$this$fetchCust.page;
267
+ pageSize = _yield$this$fetchCust.pageSize;
268
+ return _context4.abrupt("return", {
269
+ list: customerList,
270
+ total: total,
271
+ page: page,
272
+ pageSize: pageSize
273
+ });
274
+ case 9:
275
+ case "end":
276
+ return _context4.stop();
277
+ }
278
+ }, _callee4, this);
279
+ }));
280
+ function queryCustomerList() {
281
+ return _queryCustomerList.apply(this, arguments);
282
+ }
283
+ return queryCustomerList;
284
+ }()
239
285
  /**
240
286
  * 获取客户列表
241
287
  * @param params 查询参数
@@ -245,9 +291,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
245
291
  }, {
246
292
  key: "getCustomerList",
247
293
  value: (function () {
248
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
294
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
249
295
  var params,
250
- _yield$this$fetchCust,
296
+ _yield$this$fetchCust2,
251
297
  customerList,
252
298
  total,
253
299
  page,
@@ -256,22 +302,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
256
302
  num,
257
303
  searchParams,
258
304
  response,
259
- _args4 = arguments;
260
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
261
- while (1) switch (_context4.prev = _context4.next) {
305
+ _args5 = arguments;
306
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
307
+ while (1) switch (_context5.prev = _context5.next) {
262
308
  case 0:
263
- params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
264
- _context4.prev = 1;
309
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
310
+ _context5.prev = 1;
265
311
  this.store.loading = true;
266
312
  this.store.error = null;
267
- _context4.next = 6;
313
+ _context5.next = 6;
268
314
  return this.fetchCustomerListData(params);
269
315
  case 6:
270
- _yield$this$fetchCust = _context4.sent;
271
- customerList = _yield$this$fetchCust.customerList;
272
- total = _yield$this$fetchCust.total;
273
- page = _yield$this$fetchCust.page;
274
- pageSize = _yield$this$fetchCust.pageSize;
316
+ _yield$this$fetchCust2 = _context5.sent;
317
+ customerList = _yield$this$fetchCust2.customerList;
318
+ total = _yield$this$fetchCust2.total;
319
+ page = _yield$this$fetchCust2.page;
320
+ pageSize = _yield$this$fetchCust2.pageSize;
275
321
  // 保存搜索条件(排除skip和num)
276
322
  skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
277
323
  this.store.searchParams = cloneDeep(searchParams);
@@ -286,9 +332,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
286
332
 
287
333
  // 设置客户列表(替换模式)
288
334
  this.store.customerList = cloneDeep(customerList);
289
- _context4.next = 20;
290
- return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
291
- case 20:
335
+
292
336
  // 触发分页变化事件
293
337
  this.triggerPaginationChange({
294
338
  page: page,
@@ -302,24 +346,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
302
346
  page: page,
303
347
  pageSize: pageSize
304
348
  };
305
- return _context4.abrupt("return", response);
306
- case 25:
307
- _context4.prev = 25;
308
- _context4.t0 = _context4["catch"](1);
309
- _context4.next = 29;
310
- return this.handleCustomerListError(_context4.t0, 'fetch customer list');
311
- case 29:
312
- throw _context4.t0;
313
- case 30:
314
- _context4.prev = 30;
349
+ return _context5.abrupt("return", response);
350
+ case 23:
351
+ _context5.prev = 23;
352
+ _context5.t0 = _context5["catch"](1);
353
+ _context5.next = 27;
354
+ return this.handleCustomerListError(_context5.t0, 'fetch customer list');
355
+ case 27:
356
+ throw _context5.t0;
357
+ case 28:
358
+ _context5.prev = 28;
315
359
  this.store.loading = false;
316
360
  this.storeChange();
317
- return _context4.finish(30);
361
+ _context5.next = 33;
362
+ return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
363
+ case 33:
364
+ return _context5.finish(28);
318
365
  case 34:
319
366
  case "end":
320
- return _context4.stop();
367
+ return _context5.stop();
321
368
  }
322
- }, _callee4, this, [[1, 25, 30, 34]]);
369
+ }, _callee5, this, [[1, 23, 28, 34]]);
323
370
  }));
324
371
  function getCustomerList() {
325
372
  return _getCustomerList.apply(this, arguments);
@@ -493,10 +540,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
493
540
  }, {
494
541
  key: "changeCustomerPage",
495
542
  value: (function () {
496
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
543
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, pageSize) {
497
544
  var targetPageSize, skip, num;
498
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
499
- while (1) switch (_context5.prev = _context5.next) {
545
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
546
+ while (1) switch (_context6.prev = _context6.next) {
500
547
  case 0:
501
548
  targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
502
549
  this.setPaginationInfo(page, targetPageSize);
@@ -504,18 +551,18 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
504
551
  // skip直接使用page,num使用pageSize
505
552
  skip = page;
506
553
  num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
507
- _context5.next = 6;
554
+ _context6.next = 6;
508
555
  return this.getCustomerList(_objectSpread({
509
556
  skip: skip,
510
557
  num: num
511
558
  }, this.store.searchParams));
512
559
  case 6:
513
- return _context5.abrupt("return", _context5.sent);
560
+ return _context6.abrupt("return", _context6.sent);
514
561
  case 7:
515
562
  case "end":
516
- return _context5.stop();
563
+ return _context6.stop();
517
564
  }
518
- }, _callee5, this);
565
+ }, _callee6, this);
519
566
  }));
520
567
  function changeCustomerPage(_x5, _x6) {
521
568
  return _changeCustomerPage.apply(this, arguments);
@@ -530,16 +577,16 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
530
577
  }, {
531
578
  key: "loadMoreCustomers",
532
579
  value: (function () {
533
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
534
- var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
535
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
536
- while (1) switch (_context6.prev = _context6.next) {
580
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
581
+ var nextPage, loadMoreParams, _yield$this$fetchCust3, newCustomers, total, page, pageSize, updatedCustomerList, response;
582
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
583
+ while (1) switch (_context7.prev = _context7.next) {
537
584
  case 0:
538
585
  if (!(!this.store.hasMore || this.store.loadingMore)) {
539
- _context6.next = 2;
586
+ _context7.next = 2;
540
587
  break;
541
588
  }
542
- return _context6.abrupt("return", {
589
+ return _context7.abrupt("return", {
543
590
  list: [],
544
591
  total: this.store.total,
545
592
  page: this.store.currentPage,
@@ -548,22 +595,21 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
548
595
  case 2:
549
596
  // 计算下一页
550
597
  nextPage = this.store.currentPage + 1;
551
- _context6.prev = 3;
598
+ _context7.prev = 3;
552
599
  this.store.loadingMore = true;
553
600
  this.store.error = null;
554
-
555
- // 使用公共方法获取数据,传入存储的搜索条件
556
- _context6.next = 8;
557
- return this.fetchCustomerListData(_objectSpread({
601
+ loadMoreParams = _objectSpread({
558
602
  skip: nextPage,
559
603
  num: this.store.pageSize
560
- }, this.store.searchParams));
561
- case 8:
562
- _yield$this$fetchCust2 = _context6.sent;
563
- newCustomers = _yield$this$fetchCust2.customerList;
564
- total = _yield$this$fetchCust2.total;
565
- page = _yield$this$fetchCust2.page;
566
- pageSize = _yield$this$fetchCust2.pageSize;
604
+ }, this.store.searchParams); // 使用公共方法获取数据,传入存储的搜索条件
605
+ _context7.next = 9;
606
+ return this.fetchCustomerListData(loadMoreParams);
607
+ case 9:
608
+ _yield$this$fetchCust3 = _context7.sent;
609
+ newCustomers = _yield$this$fetchCust3.customerList;
610
+ total = _yield$this$fetchCust3.total;
611
+ page = _yield$this$fetchCust3.page;
612
+ pageSize = _yield$this$fetchCust3.pageSize;
567
613
  // 将新数据追加到现有列表(追加模式)
568
614
  updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
569
615
  this.store.customerList = updatedCustomerList;
@@ -572,17 +618,14 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
572
618
  this.store.hasMore = page * pageSize < total;
573
619
 
574
620
  // 触发滚动加载特定事件
575
- _context6.next = 20;
621
+ _context7.next = 21;
576
622
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
577
623
  newCustomers: newCustomers,
578
624
  allCustomers: this.store.customerList,
579
625
  currentPage: page,
580
626
  hasMore: this.store.hasMore
581
627
  });
582
- case 20:
583
- _context6.next = 22;
584
- return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
585
- case 22:
628
+ case 21:
586
629
  // 触发分页变化事件
587
630
  this.triggerPaginationChange({
588
631
  page: page,
@@ -597,24 +640,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
597
640
  page: page,
598
641
  pageSize: pageSize
599
642
  };
600
- return _context6.abrupt("return", response);
601
- case 27:
602
- _context6.prev = 27;
603
- _context6.t0 = _context6["catch"](3);
604
- _context6.next = 31;
605
- return this.handleCustomerListError(_context6.t0, 'load more customers');
643
+ return _context7.abrupt("return", response);
644
+ case 26:
645
+ _context7.prev = 26;
646
+ _context7.t0 = _context7["catch"](3);
647
+ _context7.next = 30;
648
+ return this.handleCustomerListError(_context7.t0, 'load more customers');
649
+ case 30:
650
+ throw _context7.t0;
606
651
  case 31:
607
- throw _context6.t0;
608
- case 32:
609
- _context6.prev = 32;
652
+ _context7.prev = 31;
610
653
  this.store.loadingMore = false;
611
654
  this.storeChange();
612
- return _context6.finish(32);
655
+ _context7.next = 36;
656
+ return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
613
657
  case 36:
658
+ return _context7.finish(31);
659
+ case 37:
614
660
  case "end":
615
- return _context6.stop();
661
+ return _context7.stop();
616
662
  }
617
- }, _callee6, this, [[3, 27, 32, 36]]);
663
+ }, _callee7, this, [[3, 26, 31, 37]]);
618
664
  }));
619
665
  function loadMoreCustomers() {
620
666
  return _loadMoreCustomers.apply(this, arguments);
@@ -630,15 +676,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
630
676
  }, {
631
677
  key: "resetAndLoadCustomers",
632
678
  value: (function () {
633
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
679
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
634
680
  var params,
635
681
  resetParams,
636
682
  response,
637
- _args7 = arguments;
638
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
639
- while (1) switch (_context7.prev = _context7.next) {
683
+ _args8 = arguments;
684
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
685
+ while (1) switch (_context8.prev = _context8.next) {
640
686
  case 0:
641
- params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
687
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
642
688
  // 重置状态
643
689
  this.store.customerList = [];
644
690
  this.store.currentPage = 1;
@@ -650,23 +696,23 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
650
696
  skip: 1,
651
697
  num: params.num || this.store.pageSize
652
698
  }); // 调用普通的获取列表方法
653
- _context7.next = 8;
699
+ _context8.next = 8;
654
700
  return this.getCustomerList(resetParams);
655
701
  case 8:
656
- response = _context7.sent;
657
- _context7.next = 11;
702
+ response = _context8.sent;
703
+ _context8.next = 11;
658
704
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
659
705
  customers: this.store.customerList,
660
706
  total: this.store.total,
661
707
  hasMore: this.store.hasMore
662
708
  });
663
709
  case 11:
664
- return _context7.abrupt("return", response);
710
+ return _context8.abrupt("return", response);
665
711
  case 12:
666
712
  case "end":
667
- return _context7.stop();
713
+ return _context8.stop();
668
714
  }
669
- }, _callee7, this);
715
+ }, _callee8, this);
670
716
  }));
671
717
  function resetAndLoadCustomers() {
672
718
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -110,6 +110,8 @@ export interface CustomerState {
110
110
  export interface CustomerModuleAPI {
111
111
  /** 获取客户列表 */
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
+ /** 查询客户列表但不更新列表分页状态 */
114
+ queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
115
  /** 设置客户列表 */
114
116
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
115
117
  /** 设置当前选择的客户 */
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
3
+ import { Discount, DiscountModuleAPI } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -28,11 +28,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
28
28
  batchSearch(code: string, options?: {
29
29
  customerId?: number;
30
30
  orderId?: number;
31
- }): Promise<DiscountWithReason>;
31
+ }): Promise<Discount[]>;
32
32
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
33
33
  private checkUsageCreditsLimit;
34
- filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
35
- private checkUsageCreditsLimitWithFailKey;
36
34
  uniqueByProductId(discountList: Discount[]): Discount[];
37
35
  filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
38
36
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
@@ -154,7 +154,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
154
154
  value: function () {
155
155
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
156
156
  var _prepareConfig$data, _prepareConfig$data2;
157
- var prepareConfig, goodPassList;
157
+ var prepareConfig, rawDiscountList, goodPassList;
158
158
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
159
159
  while (1) switch (_context4.prev = _context4.next) {
160
160
  case 0:
@@ -162,9 +162,10 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
162
162
  return this.request.post("/order/prepare/config", params);
163
163
  case 2:
164
164
  prepareConfig = _context4.sent;
165
- goodPassList = this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []))) || []; // this.setDiscountList(goodPassList);
165
+ rawDiscountList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []));
166
+ goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
166
167
  return _context4.abrupt("return", goodPassList);
167
- case 5:
168
+ case 6:
168
169
  case "end":
169
170
  return _context4.stop();
170
171
  }
@@ -179,7 +180,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
179
180
  key: "batchSearch",
180
181
  value: function () {
181
182
  var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
182
- var _ref, customerId, orderId, result, resultDiscountWithReason;
183
+ var _ref, customerId, orderId, result, resultDiscountList;
183
184
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
184
185
  while (1) switch (_context5.prev = _context5.next) {
185
186
  case 0:
@@ -189,7 +190,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
189
190
  code: code,
190
191
  translate_flag: 1,
191
192
  tags: ['good_pass', 'product_discount_card'],
192
- // available: 1,
193
+ available: 1,
193
194
  relation_product: 1,
194
195
  with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
195
196
  order_behavior_count: 1,
@@ -197,13 +198,12 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
197
198
  }, orderId ? {
198
199
  order_behavior_count_order_id: orderId
199
200
  } : {}), {}, {
200
- unified_status_info_flag: 1,
201
201
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
202
202
  }));
203
203
  case 3:
204
204
  result = _context5.sent;
205
- resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result === null || result === void 0 ? void 0 : result.data) || []) || [];
206
- return _context5.abrupt("return", resultDiscountWithReason);
205
+ resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
206
+ return _context5.abrupt("return", resultDiscountList);
207
207
  case 6:
208
208
  case "end":
209
209
  return _context5.stop();
@@ -283,91 +283,6 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
283
283
  return true;
284
284
  }
285
285
 
286
- // 过滤启用且可用的优惠券,并返回校验失败原因
287
- }, {
288
- key: "filterEnabledDiscountListWithReason",
289
- value: function filterEnabledDiscountListWithReason(discountList) {
290
- var _this3 = this;
291
- var lists = discountList.filter(function (discount) {
292
- return discount.limit_status === 'enable';
293
- }).filter(function (discount) {
294
- var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
295
- return remaining;
296
- }).map(function (discount) {
297
- var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
298
- return _objectSpread(_objectSpread({}, discount), {}, {
299
- usageLimitFailKey: limitFailKey
300
- });
301
- });
302
-
303
- // 可用的列表
304
- var availableLists = lists.filter(function (item) {
305
- return !item.usageLimitFailKey && item.unified_available_status !== 0;
306
- });
307
- // 不可用数据
308
- var currentFailDiscount = lists.find(function (item) {
309
- return item.usageLimitFailKey;
310
- });
311
- return {
312
- discountList: availableLists,
313
- unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
314
- };
315
- }
316
-
317
- // 检查使用次数限制,并返回校验失败原因
318
- }, {
319
- key: "checkUsageCreditsLimitWithFailKey",
320
- value: function checkUsageCreditsLimitWithFailKey(discount) {
321
- if (!discount.extension_data || discount.extension_data.length === 0) {
322
- return null;
323
- }
324
- var usageCreditsData = discount.extension_data.find(function (data) {
325
- return data.field_key === 'usage_credits';
326
- });
327
- if (!usageCreditsData) {
328
- return null;
329
- }
330
- var value = usageCreditsData.value;
331
-
332
- // 总次数限制
333
- if (value.total_credits && value.total_credits > 0) {
334
- if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
335
- return 'total_credits';
336
- }
337
- }
338
-
339
- // 单用户限制
340
- if (value.per_user_limit && value.per_user_limit > 0) {
341
- if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
342
- return 'per_user_limit';
343
- }
344
- }
345
-
346
- // 单日限制
347
- if (value.max_per_day && value.max_per_day > 0) {
348
- if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
349
- return 'max_per_day';
350
- }
351
- }
352
-
353
- // 单周限制
354
- if (value.max_per_week && value.max_per_week > 0) {
355
- if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
356
- return 'max_per_week';
357
- }
358
- }
359
-
360
- // 单月限制
361
- if (value.max_per_month && value.max_per_month > 0) {
362
- if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
363
- return 'max_per_month';
364
- }
365
- }
366
-
367
- // 全部通过
368
- return null;
369
- }
370
-
371
286
  // 根据productIds去重
372
287
  }, {
373
288
  key: "uniqueByProductId",
@@ -63,11 +63,6 @@ interface UsageCreditsValue {
63
63
  max_per_week: number;
64
64
  max_per_month: number;
65
65
  }
66
- export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
- export interface DiscountWithReason {
68
- discountList: Discount[];
69
- unavailableReasonKey: DiscountFilterRejectKey | null;
70
- }
71
66
  interface ExtensionData {
72
67
  id: number;
73
68
  shop_id: number;
@@ -140,6 +135,7 @@ export interface Discount {
140
135
  appliedProductDetails: ApplicableProductDetails[];
141
136
  isDisabledForProductUsed?: boolean;
142
137
  amount?: number;
138
+ customer_id?: number | string | null;
143
139
  extension_data?: ExtensionData[];
144
140
  total_order_behavior_count?: number;
145
141
  today_order_behavior_count?: number;
@@ -152,8 +148,6 @@ export interface Discount {
152
148
  num?: number;
153
149
  start_date?: string;
154
150
  start_time?: string;
155
- usageLimitFailKey?: string | null;
156
- unified_available_status?: number | undefined | null;
157
151
  }
158
152
  export interface DiscountState {
159
153
  discountList: Discount[];