@pisell/pisellos 2.3.65 → 2.3.67

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 (52) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -65
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +1 -0
  4. package/dist/model/strategy/adapter/walletPass/utils.js +2 -0
  5. package/dist/modules/Customer/index.d.ts +0 -4
  6. package/dist/modules/Customer/index.js +59 -91
  7. package/dist/modules/Customer/types.d.ts +0 -2
  8. package/dist/modules/Payment/walletpass.js +5 -4
  9. package/dist/modules/Quotation/index.d.ts +6 -0
  10. package/dist/modules/Quotation/index.js +75 -19
  11. package/dist/plugins/request.d.ts +1 -0
  12. package/dist/server/index.d.ts +8 -2
  13. package/dist/server/index.js +209 -142
  14. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  15. package/dist/server/modules/floor-plan/index.js +240 -98
  16. package/dist/server/modules/menu/index.js +48 -23
  17. package/dist/server/modules/order/index.d.ts +17 -8
  18. package/dist/server/modules/order/index.js +506 -453
  19. package/dist/server/modules/products/index.d.ts +8 -2
  20. package/dist/server/modules/products/index.js +167 -75
  21. package/dist/server/modules/resource/index.js +21 -13
  22. package/dist/server/utils/small-ticket.js +1 -2
  23. package/dist/solution/BookingByStep/index.d.ts +1 -1
  24. package/dist/solution/BookingTicket/index.d.ts +0 -2
  25. package/dist/solution/BookingTicket/index.js +10 -34
  26. package/lib/core/index.d.ts +7 -0
  27. package/lib/core/index.js +20 -2
  28. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  29. package/lib/model/strategy/adapter/walletPass/evaluator.js +1 -0
  30. package/lib/model/strategy/adapter/walletPass/utils.js +1 -0
  31. package/lib/modules/Customer/index.d.ts +0 -4
  32. package/lib/modules/Customer/index.js +0 -11
  33. package/lib/modules/Customer/types.d.ts +0 -2
  34. package/lib/modules/Payment/walletpass.js +1 -0
  35. package/lib/modules/Quotation/index.d.ts +6 -0
  36. package/lib/modules/Quotation/index.js +49 -5
  37. package/lib/plugins/request.d.ts +1 -0
  38. package/lib/server/index.d.ts +8 -2
  39. package/lib/server/index.js +55 -19
  40. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  41. package/lib/server/modules/floor-plan/index.js +54 -6
  42. package/lib/server/modules/menu/index.js +31 -5
  43. package/lib/server/modules/order/index.d.ts +17 -8
  44. package/lib/server/modules/order/index.js +199 -106
  45. package/lib/server/modules/products/index.d.ts +8 -2
  46. package/lib/server/modules/products/index.js +97 -24
  47. package/lib/server/modules/resource/index.js +7 -2
  48. package/lib/server/utils/small-ticket.js +1 -1
  49. package/lib/solution/BookingByStep/index.d.ts +1 -1
  50. package/lib/solution/BookingTicket/index.d.ts +0 -2
  51. package/lib/solution/BookingTicket/index.js +2 -18
  52. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  var _excluded = ["skip", "num", "search"],
2
2
  _excluded2 = ["skip", "num"];
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
8
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
12
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
@@ -322,38 +322,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
322
322
  }
323
323
  return queryCustomerList;
324
324
  }()
325
- /**
326
- * 查询单个客户详情,不写入 customerList / pagination 状态。
327
- */
328
- )
329
- }, {
330
- key: "queryCustomerDetail",
331
- value: (function () {
332
- var _queryCustomerDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
333
- var _result$data;
334
- var result, customer;
335
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
336
- while (1) switch (_context5.prev = _context5.next) {
337
- case 0:
338
- _context5.next = 2;
339
- return this.request.get("/customer/info/".concat(id), {
340
- with_trashed: 1
341
- });
342
- case 2:
343
- result = _context5.sent;
344
- customer = (result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.customer) || (result === null || result === void 0 ? void 0 : result.data) || (result === null || result === void 0 ? void 0 : result.customer) || null;
345
- return _context5.abrupt("return", customer && _typeof(customer) === 'object' ? customer : null);
346
- case 5:
347
- case "end":
348
- return _context5.stop();
349
- }
350
- }, _callee5, this);
351
- }));
352
- function queryCustomerDetail(_x5) {
353
- return _queryCustomerDetail.apply(this, arguments);
354
- }
355
- return queryCustomerDetail;
356
- }()
357
325
  /**
358
326
  * 获取客户列表
359
327
  * @param params 查询参数
@@ -363,7 +331,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
363
331
  }, {
364
332
  key: "getCustomerList",
365
333
  value: (function () {
366
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
334
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
367
335
  var params,
368
336
  _yield$this$fetchCust2,
369
337
  customerList,
@@ -374,18 +342,18 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
374
342
  num,
375
343
  searchParams,
376
344
  response,
377
- _args6 = arguments;
378
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
379
- while (1) switch (_context6.prev = _context6.next) {
345
+ _args5 = arguments;
346
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
347
+ while (1) switch (_context5.prev = _context5.next) {
380
348
  case 0:
381
- params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
382
- _context6.prev = 1;
349
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
350
+ _context5.prev = 1;
383
351
  this.store.loading = true;
384
352
  this.store.error = null;
385
- _context6.next = 6;
353
+ _context5.next = 6;
386
354
  return this.fetchCustomerListData(params);
387
355
  case 6:
388
- _yield$this$fetchCust2 = _context6.sent;
356
+ _yield$this$fetchCust2 = _context5.sent;
389
357
  customerList = _yield$this$fetchCust2.customerList;
390
358
  total = _yield$this$fetchCust2.total;
391
359
  page = _yield$this$fetchCust2.page;
@@ -418,27 +386,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
418
386
  page: page,
419
387
  pageSize: pageSize
420
388
  };
421
- return _context6.abrupt("return", response);
389
+ return _context5.abrupt("return", response);
422
390
  case 23:
423
- _context6.prev = 23;
424
- _context6.t0 = _context6["catch"](1);
425
- _context6.next = 27;
426
- return this.handleCustomerListError(_context6.t0, 'fetch customer list');
391
+ _context5.prev = 23;
392
+ _context5.t0 = _context5["catch"](1);
393
+ _context5.next = 27;
394
+ return this.handleCustomerListError(_context5.t0, 'fetch customer list');
427
395
  case 27:
428
- throw _context6.t0;
396
+ throw _context5.t0;
429
397
  case 28:
430
- _context6.prev = 28;
398
+ _context5.prev = 28;
431
399
  this.store.loading = false;
432
400
  this.storeChange();
433
- _context6.next = 33;
401
+ _context5.next = 33;
434
402
  return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
435
403
  case 33:
436
- return _context6.finish(28);
404
+ return _context5.finish(28);
437
405
  case 34:
438
406
  case "end":
439
- return _context6.stop();
407
+ return _context5.stop();
440
408
  }
441
- }, _callee6, this, [[1, 23, 28, 34]]);
409
+ }, _callee5, this, [[1, 23, 28, 34]]);
442
410
  }));
443
411
  function getCustomerList() {
444
412
  return _getCustomerList.apply(this, arguments);
@@ -615,10 +583,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
615
583
  }, {
616
584
  key: "changeCustomerPage",
617
585
  value: (function () {
618
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(page, pageSize) {
586
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, pageSize) {
619
587
  var targetPageSize, skip, num;
620
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
621
- while (1) switch (_context7.prev = _context7.next) {
588
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
589
+ while (1) switch (_context6.prev = _context6.next) {
622
590
  case 0:
623
591
  targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
624
592
  this.setPaginationInfo(page, targetPageSize);
@@ -626,20 +594,20 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
626
594
  // skip直接使用page,num使用pageSize
627
595
  skip = page;
628
596
  num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
629
- _context7.next = 6;
597
+ _context6.next = 6;
630
598
  return this.getCustomerList(_objectSpread({
631
599
  skip: skip,
632
600
  num: num
633
601
  }, this.store.searchParams));
634
602
  case 6:
635
- return _context7.abrupt("return", _context7.sent);
603
+ return _context6.abrupt("return", _context6.sent);
636
604
  case 7:
637
605
  case "end":
638
- return _context7.stop();
606
+ return _context6.stop();
639
607
  }
640
- }, _callee7, this);
608
+ }, _callee6, this);
641
609
  }));
642
- function changeCustomerPage(_x6, _x7) {
610
+ function changeCustomerPage(_x5, _x6) {
643
611
  return _changeCustomerPage.apply(this, arguments);
644
612
  }
645
613
  return changeCustomerPage;
@@ -652,16 +620,16 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
652
620
  }, {
653
621
  key: "loadMoreCustomers",
654
622
  value: (function () {
655
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
623
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
656
624
  var nextPage, loadMoreParams, _yield$this$fetchCust3, newCustomers, total, page, pageSize, updatedCustomerList, response;
657
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
658
- while (1) switch (_context8.prev = _context8.next) {
625
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
626
+ while (1) switch (_context7.prev = _context7.next) {
659
627
  case 0:
660
628
  if (!(!this.store.hasMore || this.store.loadingMore)) {
661
- _context8.next = 2;
629
+ _context7.next = 2;
662
630
  break;
663
631
  }
664
- return _context8.abrupt("return", {
632
+ return _context7.abrupt("return", {
665
633
  list: [],
666
634
  total: this.store.total,
667
635
  page: this.store.currentPage,
@@ -670,17 +638,17 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
670
638
  case 2:
671
639
  // 计算下一页
672
640
  nextPage = this.store.currentPage + 1;
673
- _context8.prev = 3;
641
+ _context7.prev = 3;
674
642
  this.store.loadingMore = true;
675
643
  this.store.error = null;
676
644
  loadMoreParams = _objectSpread({
677
645
  skip: nextPage,
678
646
  num: this.store.pageSize
679
647
  }, this.store.searchParams); // 使用公共方法获取数据,传入存储的搜索条件
680
- _context8.next = 9;
648
+ _context7.next = 9;
681
649
  return this.fetchCustomerListData(loadMoreParams);
682
650
  case 9:
683
- _yield$this$fetchCust3 = _context8.sent;
651
+ _yield$this$fetchCust3 = _context7.sent;
684
652
  newCustomers = _yield$this$fetchCust3.customerList;
685
653
  total = _yield$this$fetchCust3.total;
686
654
  page = _yield$this$fetchCust3.page;
@@ -693,7 +661,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
693
661
  this.store.hasMore = page * pageSize < total;
694
662
 
695
663
  // 触发滚动加载特定事件
696
- _context8.next = 21;
664
+ _context7.next = 21;
697
665
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
698
666
  newCustomers: newCustomers,
699
667
  allCustomers: this.store.customerList,
@@ -715,27 +683,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
715
683
  page: page,
716
684
  pageSize: pageSize
717
685
  };
718
- return _context8.abrupt("return", response);
686
+ return _context7.abrupt("return", response);
719
687
  case 26:
720
- _context8.prev = 26;
721
- _context8.t0 = _context8["catch"](3);
722
- _context8.next = 30;
723
- return this.handleCustomerListError(_context8.t0, 'load more customers');
688
+ _context7.prev = 26;
689
+ _context7.t0 = _context7["catch"](3);
690
+ _context7.next = 30;
691
+ return this.handleCustomerListError(_context7.t0, 'load more customers');
724
692
  case 30:
725
- throw _context8.t0;
693
+ throw _context7.t0;
726
694
  case 31:
727
- _context8.prev = 31;
695
+ _context7.prev = 31;
728
696
  this.store.loadingMore = false;
729
697
  this.storeChange();
730
- _context8.next = 36;
698
+ _context7.next = 36;
731
699
  return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
732
700
  case 36:
733
- return _context8.finish(31);
701
+ return _context7.finish(31);
734
702
  case 37:
735
703
  case "end":
736
- return _context8.stop();
704
+ return _context7.stop();
737
705
  }
738
- }, _callee8, this, [[3, 26, 31, 37]]);
706
+ }, _callee7, this, [[3, 26, 31, 37]]);
739
707
  }));
740
708
  function loadMoreCustomers() {
741
709
  return _loadMoreCustomers.apply(this, arguments);
@@ -751,15 +719,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
751
719
  }, {
752
720
  key: "resetAndLoadCustomers",
753
721
  value: (function () {
754
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
722
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
755
723
  var params,
756
724
  resetParams,
757
725
  response,
758
- _args9 = arguments;
759
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
760
- while (1) switch (_context9.prev = _context9.next) {
726
+ _args8 = arguments;
727
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
728
+ while (1) switch (_context8.prev = _context8.next) {
761
729
  case 0:
762
- params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
730
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
763
731
  // 重置状态
764
732
  this.store.customerList = [];
765
733
  this.store.currentPage = 1;
@@ -771,23 +739,23 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
771
739
  skip: 1,
772
740
  num: params.num || this.store.pageSize
773
741
  }); // 调用普通的获取列表方法
774
- _context9.next = 8;
742
+ _context8.next = 8;
775
743
  return this.getCustomerList(resetParams);
776
744
  case 8:
777
- response = _context9.sent;
778
- _context9.next = 11;
745
+ response = _context8.sent;
746
+ _context8.next = 11;
779
747
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
780
748
  customers: this.store.customerList,
781
749
  total: this.store.total,
782
750
  hasMore: this.store.hasMore
783
751
  });
784
752
  case 11:
785
- return _context9.abrupt("return", response);
753
+ return _context8.abrupt("return", response);
786
754
  case 12:
787
755
  case "end":
788
- return _context9.stop();
756
+ return _context8.stop();
789
757
  }
790
- }, _callee9, this);
758
+ }, _callee8, this);
791
759
  }));
792
760
  function resetAndLoadCustomers() {
793
761
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -112,8 +112,6 @@ export interface CustomerModuleAPI {
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
113
  /** 查询客户列表但不更新列表分页状态 */
114
114
  queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
115
- /** 查询单个客户详情但不修改客户列表状态 */
116
- queryCustomerDetail: (id: string | number) => Promise<ShopCustomer | null>;
117
115
  /** 设置客户列表 */
118
116
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
119
117
  /** 设置当前选择的客户 */
@@ -620,6 +620,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
620
620
  vouchers: allList
621
621
  });
622
622
  recommended = res.recommended, transformList = res.transformList, noApplicableVoucher = res.noApplicableVoucher, recommendedAmount = res.recommendedAmount;
623
+ console.log(res, 'resres12');
623
624
  this.walletRecommendList = recommended;
624
625
 
625
626
  // 存储初始化数据到内存中,供 useWalletPass 使用
@@ -639,19 +640,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
639
640
  noApplicableVoucher: noApplicableVoucher,
640
641
  products: products || []
641
642
  });
642
- case 19:
643
- _context3.prev = 19;
643
+ case 20:
644
+ _context3.prev = 20;
644
645
  _context3.t0 = _context3["catch"](0);
645
646
  this.paymentModule.logError('[WalletPass] 初始化钱包数据失败', _context3.t0, {
646
647
  customer_id: baseParams.customer_id,
647
648
  order_expect_amount: baseParams.order_expect_amount
648
649
  });
649
650
  throw _context3.t0;
650
- case 23:
651
+ case 24:
651
652
  case "end":
652
653
  return _context3.stop();
653
654
  }
654
- }, _callee3, this, [[0, 19]]);
655
+ }, _callee3, this, [[0, 20]]);
655
656
  }));
656
657
  function initializeWalletDataAsync(_x3) {
657
658
  return _initializeWalletDataAsync.apply(this, arguments);
@@ -9,6 +9,8 @@ export declare class QuotationModule extends BaseModule implements Module {
9
9
  private request;
10
10
  private store;
11
11
  private scheduleResolver?;
12
+ private app;
13
+ private quotationListUpdatedListener?;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  loadQuotations(params?: {
@@ -16,6 +18,7 @@ export declare class QuotationModule extends BaseModule implements Module {
16
18
  customer_id?: number | string;
17
19
  }): Promise<void>;
18
20
  getQuotationList(): QuotationItem[];
21
+ setQuotationListUpdatedListener(listener?: () => void): void;
19
22
  getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
20
23
  /**
21
24
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
@@ -60,6 +63,9 @@ export declare class QuotationModule extends BaseModule implements Module {
60
63
  customer_id?: number | string;
61
64
  }): Map<string, string | null>;
62
65
  setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
66
+ private applyQuotationResponse;
67
+ private notifyQuotationListUpdated;
68
+ private getQuotationCacheKeyData;
63
69
  private isQuotationVisibleForCustomer;
64
70
  private hasValidCustomerId;
65
71
  private normalizeCustomerId;
@@ -1,6 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
4
8
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -36,12 +40,15 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
36
40
  list: []
37
41
  });
38
42
  _defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
43
+ _defineProperty(_assertThisInitialized(_this), "app", void 0);
44
+ _defineProperty(_assertThisInitialized(_this), "quotationListUpdatedListener", void 0);
39
45
  return _this;
40
46
  }
41
47
  _createClass(QuotationModule, [{
42
48
  key: "initialize",
43
49
  value: function () {
44
50
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
51
+ var _core$getPlugin, _core$getPlugin$getAp;
45
52
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
53
  while (1) switch (_context.prev = _context.next) {
47
54
  case 0:
@@ -53,10 +60,11 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
53
60
  }
54
61
  throw new Error('QuotationModule 需要 request 插件支持');
55
62
  case 4:
63
+ this.app = (_core$getPlugin = core.getPlugin('app')) === null || _core$getPlugin === void 0 || (_core$getPlugin$getAp = _core$getPlugin.getApp) === null || _core$getPlugin$getAp === void 0 ? void 0 : _core$getPlugin$getAp.call(_core$getPlugin);
56
64
  this.store = {
57
65
  list: []
58
66
  };
59
- case 5:
67
+ case 6:
60
68
  case "end":
61
69
  return _context.stop();
62
70
  }
@@ -71,8 +79,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
71
79
  key: "loadQuotations",
72
80
  value: function () {
73
81
  var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
74
- var _data;
75
- var query, res, list;
82
+ var _this2 = this;
83
+ var query, initialResultApplied, applyRemoteUpdate, res;
76
84
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
77
85
  while (1) switch (_context2.prev = _context2.next) {
78
86
  case 0:
@@ -81,19 +89,27 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
81
89
  if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
82
90
  query.channel = 'online-store';
83
91
  }
84
- _context2.next = 5;
92
+ initialResultApplied = false;
93
+ applyRemoteUpdate = function applyRemoteUpdate(response) {
94
+ _this2.applyQuotationResponse(response);
95
+ if (initialResultApplied) {
96
+ _this2.notifyQuotationListUpdated();
97
+ }
98
+ };
99
+ _context2.next = 7;
85
100
  return this.request.get('/quotation/available', query, {
86
- useCache: false,
87
- osServer: true
101
+ cache: {
102
+ type: 'indexDB',
103
+ updateCache: true,
104
+ cacheKeyData: this.getQuotationCacheKeyData(query)
105
+ },
106
+ cacheUpdateChange: applyRemoteUpdate
88
107
  });
89
- case 5:
108
+ case 7:
90
109
  res = _context2.sent;
91
- list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
92
- list.sort(function (a, b) {
93
- return b.sort - a.sort;
94
- });
95
- this.store.list = list;
96
- case 9:
110
+ this.applyQuotationResponse(res);
111
+ initialResultApplied = true;
112
+ case 10:
97
113
  case "end":
98
114
  return _context2.stop();
99
115
  }
@@ -109,10 +125,15 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
109
125
  value: function getQuotationList() {
110
126
  return this.store.list;
111
127
  }
128
+ }, {
129
+ key: "setQuotationListUpdatedListener",
130
+ value: function setQuotationListUpdatedListener(listener) {
131
+ this.quotationListUpdatedListener = listener;
132
+ }
112
133
  }, {
113
134
  key: "getQuotationCustomerScopeInfo",
114
135
  value: function getQuotationCustomerScopeInfo() {
115
- var _this2 = this;
136
+ var _this3 = this;
116
137
  var customerById = new Map();
117
138
  var quotationScopes = this.store.list.filter(function (quotation) {
118
139
  return Array.isArray(quotation.customer) && quotation.customer.length > 0;
@@ -122,7 +143,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
122
143
  var localSeen = new Set();
123
144
  var quotationCustomers = quotation.customer || [];
124
145
  quotationCustomers.forEach(function (customer) {
125
- var customerId = _this2.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
146
+ var customerId = _this3.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
126
147
  if (!customerId || localSeen.has(customerId)) return;
127
148
  localSeen.add(customerId);
128
149
  customerIds.push(customerId);
@@ -247,6 +268,41 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
247
268
  value: function setScheduleResolver(resolver) {
248
269
  this.scheduleResolver = resolver;
249
270
  }
271
+ }, {
272
+ key: "applyQuotationResponse",
273
+ value: function applyQuotationResponse(response) {
274
+ var _data;
275
+ var source = (response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
276
+ this.store.list = _toConsumableArray(source).sort(function (a, b) {
277
+ return Number(b.sort || 0) - Number(a.sort || 0);
278
+ });
279
+ }
280
+ }, {
281
+ key: "notifyQuotationListUpdated",
282
+ value: function notifyQuotationListUpdated() {
283
+ try {
284
+ var _this$quotationListUp;
285
+ (_this$quotationListUp = this.quotationListUpdatedListener) === null || _this$quotationListUp === void 0 || _this$quotationListUp.call(this);
286
+ } catch (error) {
287
+ console.warn('[QuotationModule] 报价单后台更新回调失败', error);
288
+ }
289
+ }
290
+ }, {
291
+ key: "getQuotationCacheKeyData",
292
+ value: function getQuotationCacheKeyData(query) {
293
+ var shopId = '';
294
+ try {
295
+ var _this$app, _this$app$getStorage;
296
+ var storedCore = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.storage) === null || _this$app === void 0 || (_this$app$getStorage = _this$app.getStorage) === null || _this$app$getStorage === void 0 ? void 0 : _this$app$getStorage.call(_this$app, 'core');
297
+ var coreInfo = typeof storedCore === 'string' ? JSON.parse(storedCore || '{}') : storedCore || {};
298
+ shopId = String((coreInfo === null || coreInfo === void 0 ? void 0 : coreInfo.id) || '');
299
+ } catch (_unused) {
300
+ // 缓存隔离信息读取失败时仍按请求参数缓存。
301
+ }
302
+ return _objectSpread(_objectSpread({}, query), {}, {
303
+ shop_id: shopId
304
+ });
305
+ }
250
306
  }, {
251
307
  key: "isQuotationVisibleForCustomer",
252
308
  value: function isQuotationVisibleForCustomer(quotation, customerId) {
@@ -273,17 +329,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
273
329
  key: "isQuotationActiveAt",
274
330
  value: function isQuotationActiveAt(quotation, datetime) {
275
331
  var _quotation$schedule,
276
- _this3 = this;
332
+ _this4 = this;
277
333
  if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
278
334
  var scheduleItems = [];
279
335
  quotation.schedule.forEach(function (s) {
280
- var _this3$scheduleResolv;
281
- var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
336
+ var _this4$scheduleResolv;
337
+ var full = (_this4$scheduleResolv = _this4.scheduleResolver) === null || _this4$scheduleResolv === void 0 ? void 0 : _this4$scheduleResolv.call(_this4, s.id);
282
338
  if (full) {
283
339
  scheduleItems.push(full);
284
340
  return;
285
341
  }
286
- if (_this3.scheduleResolver) {
342
+ if (_this4.scheduleResolver) {
287
343
  return;
288
344
  }
289
345
  var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
@@ -68,6 +68,7 @@ export interface RequestOptions {
68
68
  useCache?: boolean;
69
69
  customToast?: () => void;
70
70
  cache?: CacheProps;
71
+ cacheUpdateChange?: (data: any) => void;
71
72
  osServer?: boolean;
72
73
  prefix?: boolean;
73
74
  callback?: (res: any) => void;
@@ -51,6 +51,8 @@ declare class Server {
51
51
  private productQueryScheduleTimers;
52
52
  /** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
53
53
  private menuScheduleRefreshInFlight;
54
+ /** 启动阶段模块预加载任务;预渲染商品查询复用该任务,避免缓存尚未 ready 时误触发远端自愈。 */
55
+ private startupModulePreloadInFlight;
54
56
  private lastMenuScheduleRefreshAt;
55
57
  private readonly MENU_SCHEDULE_REFRESH_COOLDOWN_MS;
56
58
  private orderQuerySubscribers;
@@ -157,13 +159,17 @@ declare class Server {
157
159
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
158
160
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
159
161
  */
160
- refreshProductsInBackground(): Promise<void>;
162
+ refreshProductsInBackground(options?: {
163
+ trigger?: string;
164
+ }): Promise<void>;
161
165
  /**
162
166
  * 后台静默刷新订单数据
163
167
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
164
168
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
165
169
  */
166
- refreshOrdersInBackground(): Promise<void>;
170
+ refreshOrdersInBackground(options?: {
171
+ trigger?: string;
172
+ }): Promise<void>;
167
173
  /**
168
174
  * 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
169
175
  * 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,