@pisell/pisellos 0.10.40 → 0.10.41

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 (34) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Customer/index.js +4 -2
  3. package/dist/modules/Customer/types.d.ts +2 -0
  4. package/dist/modules/Payment/types.d.ts +21 -1
  5. package/dist/modules/Payment/types.js +2 -0
  6. package/dist/modules/Payment/walletpass.d.ts +1 -1
  7. package/dist/modules/Payment/walletpass.js +80 -47
  8. package/dist/solution/BaseSales/index.d.ts +1 -0
  9. package/dist/solution/BaseSales/index.js +2 -1
  10. package/dist/solution/BookingByStep/index.d.ts +2 -2
  11. package/dist/solution/BookingTicket/index.d.ts +1 -2
  12. package/dist/solution/BookingTicket/index.js +60 -63
  13. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  14. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +266 -150
  15. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +5 -3
  16. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
  17. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +8 -4
  18. package/lib/modules/Customer/index.js +4 -1
  19. package/lib/modules/Customer/types.d.ts +2 -0
  20. package/lib/modules/Payment/types.d.ts +21 -1
  21. package/lib/modules/Payment/types.js +1 -0
  22. package/lib/modules/Payment/walletpass.d.ts +1 -1
  23. package/lib/modules/Payment/walletpass.js +29 -9
  24. package/lib/solution/BaseSales/index.d.ts +1 -0
  25. package/lib/solution/BaseSales/index.js +2 -1
  26. package/lib/solution/BookingByStep/index.d.ts +2 -2
  27. package/lib/solution/BookingTicket/index.d.ts +1 -2
  28. package/lib/solution/BookingTicket/index.js +36 -33
  29. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  30. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +127 -42
  31. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +5 -3
  32. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
  33. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +7 -3
  34. package/package.json +1 -1
@@ -184,6 +184,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
184
184
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
185
185
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
186
186
  _defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
187
+ _defineProperty(_assertThisInitialized(_this), "customerResolveRequests", new Map());
187
188
  return _this;
188
189
  }
189
190
  _createClass(BookingTicketImpl, [{
@@ -755,31 +756,43 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
755
756
  hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
756
757
  isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
757
758
  if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
758
- _context10.next = 12;
759
+ _context10.next = 18;
759
760
  break;
760
761
  }
761
- _context10.next = 12;
762
+ _context10.prev = 10;
763
+ _context10.next = 13;
762
764
  return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
763
- case 12:
765
+ case 13:
766
+ _context10.next = 18;
767
+ break;
768
+ case 15:
769
+ _context10.prev = 15;
770
+ _context10.t0 = _context10["catch"](10);
771
+ // 客户映射失败不能阻断原有 Pass 的可用性、展示或优惠处理。
772
+ console.warn('[BookingTicket] scan discount customer resolve failed', {
773
+ customerId: extractedCustomerId,
774
+ error: _context10.t0
775
+ });
776
+ case 18:
764
777
  if (!raw.isAvailable) {
765
- _context10.next = 19;
778
+ _context10.next = 25;
766
779
  break;
767
780
  }
768
- _context10.next = 15;
781
+ _context10.next = 21;
769
782
  return this.store.order.recalculateSummary({
770
783
  createIfMissing: true
771
784
  });
772
- case 15:
785
+ case 21:
773
786
  this.store.order.persistTempOrder();
774
787
  tempOrder = this.store.order.ensureTempOrder();
775
- _context10.next = 19;
788
+ _context10.next = 25;
776
789
  return this.effectsEmit('onDiscountApplied', {
777
790
  productList: tempOrder.products || [],
778
791
  discountList: this.store.order.getDiscountList(),
779
792
  selectedDiscountList: tempOrder.discount_list || [],
780
793
  tempOrder: tempOrder
781
794
  });
782
- case 19:
795
+ case 25:
783
796
  return _context10.abrupt("return", _objectSpread(_objectSpread({
784
797
  isAvailable: raw.isAvailable
785
798
  }, raw.isAccepted !== undefined ? {
@@ -789,11 +802,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
789
802
  unavailableReason: raw.unavailableReason,
790
803
  scannedDiscountList: raw.scannedDiscountList
791
804
  }));
792
- case 20:
805
+ case 26:
793
806
  case "end":
794
807
  return _context10.stop();
795
808
  }
796
- }, _callee10, this);
809
+ }, _callee10, this, [[10, 15]]);
797
810
  }));
798
811
  function scanPromotionCode(_x4, _x5) {
799
812
  return _scanPromotionCode.apply(this, arguments);
@@ -875,54 +888,51 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
875
888
  key: "resolveCustomerById",
876
889
  value: function () {
877
890
  var _resolveCustomerById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(customerId) {
878
- var _result$list;
879
- var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer, detailCustomer;
891
+ var _this2 = this;
892
+ var rawCustomerId, numericCustomerId, normalizedCustomerId, existingRequest, request;
880
893
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
881
894
  while (1) switch (_context12.prev = _context12.next) {
882
895
  case 0:
883
- localCustomers = this.store.customer.getCustomers();
884
- localCustomer = this.findCustomerById(localCustomers, customerId);
885
- normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
886
- if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
887
- _context12.next = 5;
896
+ rawCustomerId = String(customerId !== null && customerId !== void 0 ? customerId : '').trim();
897
+ numericCustomerId = Number(rawCustomerId);
898
+ if (!(!rawCustomerId || !Number.isInteger(numericCustomerId) || numericCustomerId <= 1)) {
899
+ _context12.next = 4;
888
900
  break;
889
901
  }
890
- return _context12.abrupt("return", normalizedLocalCustomer);
891
- case 5:
892
- _context12.next = 7;
893
- return this.store.customer.queryCustomerList({
894
- ids: [customerId],
895
- skip: 1,
896
- num: 1
897
- });
898
- case 7:
899
- result = _context12.sent;
900
- 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;
901
- if (!remoteCustomer) {
902
- _context12.next = 11;
902
+ return _context12.abrupt("return", null);
903
+ case 4:
904
+ normalizedCustomerId = String(numericCustomerId);
905
+ existingRequest = this.customerResolveRequests.get(normalizedCustomerId);
906
+ if (!existingRequest) {
907
+ _context12.next = 8;
903
908
  break;
904
909
  }
905
- return _context12.abrupt("return", this.normalizeCustomer(remoteCustomer));
906
- case 11:
907
- _context12.prev = 11;
908
- _context12.next = 14;
909
- return this.store.customer.queryCustomerDetail(customerId);
910
- case 14:
911
- detailCustomer = _context12.sent;
912
- return _context12.abrupt("return", detailCustomer ? this.normalizeCustomer(detailCustomer) : null);
913
- case 18:
914
- _context12.prev = 18;
915
- _context12.t0 = _context12["catch"](11);
916
- console.warn('[BookingTicket] resolveCustomerById detail request failed', {
917
- customerId: customerId,
918
- error: _context12.t0
910
+ return _context12.abrupt("return", existingRequest);
911
+ case 8:
912
+ request = this.request.post("/customer/resolve/".concat(encodeURIComponent(normalizedCustomerId)), {
913
+ with_franchisor_data: 1,
914
+ with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord']
915
+ }).then(function (result) {
916
+ var customer = result === null || result === void 0 ? void 0 : result.data;
917
+ var resolvedCustomerId = Number(customer && _typeof(customer) === 'object' && !Array.isArray(customer) ? _this2.getRawCustomerId(customer) : NaN);
918
+ 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) {
919
+ var error = new Error((result === null || result === void 0 ? void 0 : result.message) || 'Customer resolve failed');
920
+ error.code = result === null || result === void 0 ? void 0 : result.code;
921
+ throw error;
922
+ }
923
+ return _this2.normalizeCustomer(customer);
924
+ }).finally(function () {
925
+ if (_this2.customerResolveRequests.get(normalizedCustomerId) === request) {
926
+ _this2.customerResolveRequests.delete(normalizedCustomerId);
927
+ }
919
928
  });
920
- return _context12.abrupt("return", null);
921
- case 22:
929
+ this.customerResolveRequests.set(normalizedCustomerId, request);
930
+ return _context12.abrupt("return", request);
931
+ case 11:
922
932
  case "end":
923
933
  return _context12.stop();
924
934
  }
925
- }, _callee12, this, [[11, 18]]);
935
+ }, _callee12, this);
926
936
  }));
927
937
  function resolveCustomerById(_x7) {
928
938
  return _resolveCustomerById.apply(this, arguments);
@@ -934,17 +944,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
934
944
  value: function resolveCustomerByDiscountCustomerId(customerId) {
935
945
  return this.resolveCustomerById(customerId);
936
946
  }
937
- }, {
938
- key: "findCustomerById",
939
- value: function findCustomerById() {
940
- var _this2 = this;
941
- var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
942
- var customerId = arguments.length > 1 ? arguments[1] : undefined;
943
- return customers.find(function (customer) {
944
- var rawId = _this2.getRawCustomerId(customer);
945
- return rawId !== null && String(rawId) === String(customerId);
946
- }) || null;
947
- }
948
947
  }, {
949
948
  key: "normalizeCustomer",
950
949
  value: function normalizeCustomer(customer) {
@@ -967,11 +966,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
967
966
  var raw = customer;
968
967
  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
968
  }
970
- }, {
971
- key: "hasUsableCustomerDetails",
972
- value: function hasUsableCustomerDetails(customer) {
973
- return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
974
- }
975
969
 
976
970
  /**
977
971
  * 更新当前预约的 appointment_status。
@@ -2695,6 +2689,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2695
2689
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2696
2690
  return _this7.getOrderCustomerSnapshot();
2697
2691
  },
2692
+ resolveCustomerById: function resolveCustomerById(customerId) {
2693
+ return _this7.resolveCustomerById(customerId);
2694
+ },
2698
2695
  getBusinessCode: function getBusinessCode() {
2699
2696
  var _this7$otherParams;
2700
2697
  return (_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.businessCode;
@@ -5,6 +5,7 @@ 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>;
8
9
  getBusinessCode(): string | undefined;
9
10
  buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
10
11
  decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
@@ -26,6 +27,7 @@ export interface GlobalScanApplyHost {
26
27
  addProductToOrder(product: any, booking?: any): Promise<any>;
27
28
  refreshWalletAssets?(params?: {
28
29
  preserveSelection?: boolean;
30
+ retainSearchResultCodes?: string[];
29
31
  }): Promise<any>;
30
32
  scanWalletAsset?(code: string): Promise<{
31
33
  type: 'walletCode' | 'normalCode';