@pisell/pisellos 2.3.124 → 2.3.126

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 (93) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
  4. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
  5. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
  6. package/dist/modules/Customer/index.js +3 -6
  7. package/dist/modules/Customer/types.d.ts +0 -2
  8. package/dist/modules/Discount/index.d.ts +2 -2
  9. package/dist/modules/Discount/index.js +151 -37
  10. package/dist/modules/Discount/types.d.ts +5 -36
  11. package/dist/modules/Order/index.d.ts +12 -7
  12. package/dist/modules/Order/index.js +307 -432
  13. package/dist/modules/Order/types.d.ts +5 -0
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
  15. package/dist/modules/Order/utils.d.ts +11 -1
  16. package/dist/modules/Order/utils.js +127 -122
  17. package/dist/modules/Payment/types.d.ts +1 -21
  18. package/dist/modules/Payment/types.js +0 -2
  19. package/dist/modules/Payment/walletpass.d.ts +1 -1
  20. package/dist/modules/Payment/walletpass.js +47 -80
  21. package/dist/modules/Rules/index.d.ts +2 -2
  22. package/dist/modules/Rules/index.js +186 -480
  23. package/dist/modules/Rules/types.d.ts +0 -4
  24. package/dist/server/modules/order/types.d.ts +0 -2
  25. package/dist/solution/BaseSales/index.d.ts +0 -1
  26. package/dist/solution/BaseSales/index.js +59 -51
  27. package/dist/solution/BaseSales/types.d.ts +2 -2
  28. package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
  29. package/dist/solution/BookingByStep/index.d.ts +1 -1
  30. package/dist/solution/BookingTicket/index.d.ts +2 -1
  31. package/dist/solution/BookingTicket/index.js +63 -60
  32. package/dist/solution/BookingTicket/types.d.ts +1 -5
  33. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  34. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
  35. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  36. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  37. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
  38. package/dist/solution/ShopDiscount/index.d.ts +0 -2
  39. package/dist/solution/ShopDiscount/index.js +42 -99
  40. package/dist/solution/ShopDiscount/utils.d.ts +2 -4
  41. package/dist/solution/ShopDiscount/utils.js +23 -43
  42. package/dist/solution/UnifiedBookingSales/index.js +2 -2
  43. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  44. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  45. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  46. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
  47. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
  48. package/lib/modules/Customer/index.js +1 -5
  49. package/lib/modules/Customer/types.d.ts +0 -2
  50. package/lib/modules/Discount/index.d.ts +2 -2
  51. package/lib/modules/Discount/index.js +129 -23
  52. package/lib/modules/Discount/types.d.ts +5 -36
  53. package/lib/modules/Order/index.d.ts +12 -7
  54. package/lib/modules/Order/index.js +107 -215
  55. package/lib/modules/Order/types.d.ts +5 -0
  56. package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
  57. package/lib/modules/Order/utils.d.ts +11 -1
  58. package/lib/modules/Order/utils.js +45 -39
  59. package/lib/modules/Payment/types.d.ts +1 -21
  60. package/lib/modules/Payment/types.js +0 -1
  61. package/lib/modules/Payment/walletpass.d.ts +1 -1
  62. package/lib/modules/Payment/walletpass.js +9 -29
  63. package/lib/modules/Rules/index.d.ts +2 -2
  64. package/lib/modules/Rules/index.js +110 -357
  65. package/lib/modules/Rules/types.d.ts +0 -4
  66. package/lib/server/modules/order/types.d.ts +0 -2
  67. package/lib/solution/BaseSales/index.d.ts +0 -1
  68. package/lib/solution/BaseSales/index.js +12 -5
  69. package/lib/solution/BaseSales/types.d.ts +2 -2
  70. package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +2 -1
  73. package/lib/solution/BookingTicket/index.js +33 -36
  74. package/lib/solution/BookingTicket/types.d.ts +1 -5
  75. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  76. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
  77. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  78. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  79. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
  80. package/lib/solution/ShopDiscount/index.d.ts +0 -2
  81. package/lib/solution/ShopDiscount/index.js +9 -55
  82. package/lib/solution/ShopDiscount/utils.d.ts +2 -4
  83. package/lib/solution/ShopDiscount/utils.js +25 -42
  84. package/lib/solution/UnifiedBookingSales/index.js +2 -2
  85. package/package.json +1 -1
  86. package/dist/modules/Discount/availability.d.ts +0 -7
  87. package/dist/modules/Discount/availability.js +0 -49
  88. package/dist/modules/Discount/entitlementPass.d.ts +0 -34
  89. package/dist/modules/Discount/entitlementPass.js +0 -147
  90. package/lib/modules/Discount/availability.d.ts +0 -7
  91. package/lib/modules/Discount/availability.js +0 -43
  92. package/lib/modules/Discount/entitlementPass.d.ts +0 -34
  93. package/lib/modules/Discount/entitlementPass.js +0 -141
@@ -182,7 +182,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
182
182
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
183
183
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshTarget", null);
184
184
  _defineProperty(_assertThisInitialized(_this), "orderCustomerPromotionRefreshInFlight", null);
185
- _defineProperty(_assertThisInitialized(_this), "customerResolveRequests", new Map());
186
185
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
187
186
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
188
187
  _defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
@@ -757,43 +756,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
757
756
  hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
758
757
  isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
759
758
  if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
760
- _context10.next = 18;
759
+ _context10.next = 12;
761
760
  break;
762
761
  }
763
- _context10.prev = 10;
764
- _context10.next = 13;
762
+ _context10.next = 12;
765
763
  return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
766
- case 13:
767
- _context10.next = 18;
768
- break;
769
- case 15:
770
- _context10.prev = 15;
771
- _context10.t0 = _context10["catch"](10);
772
- // 客户映射失败不能阻断原有 Pass 的可用性、展示或优惠处理。
773
- console.warn('[BookingTicket] scan discount customer resolve failed', {
774
- customerId: extractedCustomerId,
775
- error: _context10.t0
776
- });
777
- case 18:
764
+ case 12:
778
765
  if (!raw.isAvailable) {
779
- _context10.next = 25;
766
+ _context10.next = 19;
780
767
  break;
781
768
  }
782
- _context10.next = 21;
769
+ _context10.next = 15;
783
770
  return this.store.order.recalculateSummary({
784
771
  createIfMissing: true
785
772
  });
786
- case 21:
773
+ case 15:
787
774
  this.store.order.persistTempOrder();
788
775
  tempOrder = this.store.order.ensureTempOrder();
789
- _context10.next = 25;
776
+ _context10.next = 19;
790
777
  return this.effectsEmit('onDiscountApplied', {
791
778
  productList: tempOrder.products || [],
792
779
  discountList: this.store.order.getDiscountList(),
793
780
  selectedDiscountList: tempOrder.discount_list || [],
794
781
  tempOrder: tempOrder
795
782
  });
796
- case 25:
783
+ case 19:
797
784
  return _context10.abrupt("return", _objectSpread(_objectSpread({
798
785
  isAvailable: raw.isAvailable
799
786
  }, raw.isAccepted !== undefined ? {
@@ -803,11 +790,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
803
790
  unavailableReason: raw.unavailableReason,
804
791
  scannedDiscountList: raw.scannedDiscountList
805
792
  }));
806
- case 26:
793
+ case 20:
807
794
  case "end":
808
795
  return _context10.stop();
809
796
  }
810
- }, _callee10, this, [[10, 15]]);
797
+ }, _callee10, this);
811
798
  }));
812
799
  function scanPromotionCode(_x4, _x5) {
813
800
  return _scanPromotionCode.apply(this, arguments);
@@ -889,51 +876,54 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
889
876
  key: "resolveCustomerById",
890
877
  value: function () {
891
878
  var _resolveCustomerById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(customerId) {
892
- var _this2 = this;
893
- var rawCustomerId, numericCustomerId, normalizedCustomerId, existingRequest, request;
879
+ var _result$list;
880
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer, detailCustomer;
894
881
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
895
882
  while (1) switch (_context12.prev = _context12.next) {
896
883
  case 0:
897
- rawCustomerId = String(customerId !== null && customerId !== void 0 ? customerId : '').trim();
898
- numericCustomerId = Number(rawCustomerId);
899
- if (!(!rawCustomerId || !Number.isInteger(numericCustomerId) || numericCustomerId <= 1)) {
900
- _context12.next = 4;
884
+ localCustomers = this.store.customer.getCustomers();
885
+ localCustomer = this.findCustomerById(localCustomers, customerId);
886
+ normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
887
+ if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
888
+ _context12.next = 5;
901
889
  break;
902
890
  }
903
- return _context12.abrupt("return", null);
904
- case 4:
905
- normalizedCustomerId = String(numericCustomerId);
906
- existingRequest = this.customerResolveRequests.get(normalizedCustomerId);
907
- if (!existingRequest) {
908
- _context12.next = 8;
891
+ return _context12.abrupt("return", normalizedLocalCustomer);
892
+ case 5:
893
+ _context12.next = 7;
894
+ return this.store.customer.queryCustomerList({
895
+ ids: [customerId],
896
+ skip: 1,
897
+ num: 1
898
+ });
899
+ case 7:
900
+ result = _context12.sent;
901
+ remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
902
+ if (!remoteCustomer) {
903
+ _context12.next = 11;
909
904
  break;
910
905
  }
911
- return _context12.abrupt("return", existingRequest);
912
- case 8:
913
- request = this.request.post("/customer/resolve/".concat(encodeURIComponent(normalizedCustomerId)), {
914
- with_franchisor_data: 1,
915
- with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord']
916
- }).then(function (result) {
917
- var customer = result === null || result === void 0 ? void 0 : result.data;
918
- var resolvedCustomerId = Number(customer && _typeof(customer) === 'object' && !Array.isArray(customer) ? _this2.getRawCustomerId(customer) : NaN);
919
- if ((result === null || result === void 0 ? void 0 : result.status) !== true || (result === null || result === void 0 ? void 0 : result.code) !== 200 || !customer || _typeof(customer) !== 'object' || Array.isArray(customer) || !Number.isInteger(resolvedCustomerId) || resolvedCustomerId <= 1) {
920
- var error = new Error((result === null || result === void 0 ? void 0 : result.message) || 'Customer resolve failed');
921
- error.code = result === null || result === void 0 ? void 0 : result.code;
922
- throw error;
923
- }
924
- return _this2.normalizeCustomer(customer);
925
- }).finally(function () {
926
- if (_this2.customerResolveRequests.get(normalizedCustomerId) === request) {
927
- _this2.customerResolveRequests.delete(normalizedCustomerId);
928
- }
929
- });
930
- this.customerResolveRequests.set(normalizedCustomerId, request);
931
- return _context12.abrupt("return", request);
906
+ return _context12.abrupt("return", this.normalizeCustomer(remoteCustomer));
932
907
  case 11:
908
+ _context12.prev = 11;
909
+ _context12.next = 14;
910
+ return this.store.customer.queryCustomerDetail(customerId);
911
+ case 14:
912
+ detailCustomer = _context12.sent;
913
+ return _context12.abrupt("return", detailCustomer ? this.normalizeCustomer(detailCustomer) : null);
914
+ case 18:
915
+ _context12.prev = 18;
916
+ _context12.t0 = _context12["catch"](11);
917
+ console.warn('[BookingTicket] resolveCustomerById detail request failed', {
918
+ customerId: customerId,
919
+ error: _context12.t0
920
+ });
921
+ return _context12.abrupt("return", null);
922
+ case 22:
933
923
  case "end":
934
924
  return _context12.stop();
935
925
  }
936
- }, _callee12, this);
926
+ }, _callee12, this, [[11, 18]]);
937
927
  }));
938
928
  function resolveCustomerById(_x7) {
939
929
  return _resolveCustomerById.apply(this, arguments);
@@ -945,6 +935,17 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
945
935
  value: function resolveCustomerByDiscountCustomerId(customerId) {
946
936
  return this.resolveCustomerById(customerId);
947
937
  }
938
+ }, {
939
+ key: "findCustomerById",
940
+ value: function findCustomerById() {
941
+ var _this2 = this;
942
+ var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
943
+ var customerId = arguments.length > 1 ? arguments[1] : undefined;
944
+ return customers.find(function (customer) {
945
+ var rawId = _this2.getRawCustomerId(customer);
946
+ return rawId !== null && String(rawId) === String(customerId);
947
+ }) || null;
948
+ }
948
949
  }, {
949
950
  key: "normalizeCustomer",
950
951
  value: function normalizeCustomer(customer) {
@@ -967,6 +968,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
967
968
  var raw = customer;
968
969
  return (_ref9 = (_ref10 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref10 !== void 0 ? _ref10 : raw.customerId) !== null && _ref9 !== void 0 ? _ref9 : null;
969
970
  }
971
+ }, {
972
+ key: "hasUsableCustomerDetails",
973
+ value: function hasUsableCustomerDetails(customer) {
974
+ return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
975
+ }
970
976
 
971
977
  /**
972
978
  * 更新当前预约的 appointment_status。
@@ -2710,9 +2716,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2710
2716
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2711
2717
  return _this7.getOrderCustomerSnapshot();
2712
2718
  },
2713
- resolveCustomerById: function resolveCustomerById(customerId) {
2714
- return _this7.resolveCustomerById(customerId);
2715
- },
2716
2719
  getBusinessCode: function getBusinessCode() {
2717
2720
  var _this7$otherParams;
2718
2721
  return (_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.businessCode;
@@ -230,16 +230,12 @@ export interface GlobalScanHostBridge {
230
230
  /**
231
231
  * walk-in 扫 walletPass:直接核销优惠码(对齐 SaleDetail Voucher.handleApplyCode / cart.scanCode)。
232
232
  */
233
- applyPromotionCode?: (code: string, customerId?: number, options?: {
234
- suppressFailureNotification?: boolean;
235
- }) => Promise<{
233
+ applyPromotionCode?: (code: string, customerId?: number) => Promise<{
236
234
  isAvailable?: boolean;
237
235
  isAccepted?: boolean;
238
236
  type?: string;
239
237
  unavailableReason?: string;
240
238
  }>;
241
- /** 当前订单已有其他客户时,由宿主复用客户组件完成确认及切换。 */
242
- requestCustomerSwitch?: (customer: ICustomer) => Promise<boolean | null>;
243
239
  onNotify?: (type: 'success' | 'fail' | 'info', messageKey?: string) => void;
244
240
  refresh?: () => void;
245
241
  }
@@ -5,7 +5,6 @@ import { GlobalScanFormattedResult } from './formatGlobalScan';
5
5
  export interface GlobalScanApplyHost {
6
6
  setOrderCustomer(customer: ICustomer | null): void;
7
7
  getOrderCustomerSnapshot(): ICustomer | null;
8
- resolveCustomerById?(customerId: string | number): Promise<ICustomer | null>;
9
8
  getBusinessCode(): string | undefined;
10
9
  buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
11
10
  decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
@@ -27,7 +26,6 @@ export interface GlobalScanApplyHost {
27
26
  addProductToOrder(product: any, booking?: any): Promise<any>;
28
27
  refreshWalletAssets?(params?: {
29
28
  preserveSelection?: boolean;
30
- retainSearchResultCodes?: string[];
31
29
  }): Promise<any>;
32
30
  scanWalletAsset?(code: string): Promise<{
33
31
  type: 'walletCode' | 'normalCode';