@pisell/pisellos 0.10.39 → 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 (40) hide show
  1. package/dist/modules/BookingContext/index.js +4 -4
  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 +64 -43
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  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/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  19. package/dist/solution/UnifiedBookingSales/index.js +10 -10
  20. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  21. package/lib/modules/BookingContext/index.js +3 -3
  22. package/lib/modules/Customer/index.js +4 -1
  23. package/lib/modules/Customer/types.d.ts +2 -0
  24. package/lib/modules/Payment/types.d.ts +21 -1
  25. package/lib/modules/Payment/types.js +1 -0
  26. package/lib/modules/Payment/walletpass.d.ts +1 -1
  27. package/lib/modules/Payment/walletpass.js +29 -9
  28. package/lib/solution/BaseSales/index.d.ts +1 -0
  29. package/lib/solution/BaseSales/index.js +18 -3
  30. package/lib/solution/BookingByStep/index.d.ts +1 -1
  31. package/lib/solution/BookingTicket/index.d.ts +1 -2
  32. package/lib/solution/BookingTicket/index.js +36 -33
  33. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  34. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +127 -42
  35. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +5 -3
  36. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
  37. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +7 -3
  38. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  39. package/lib/solution/UnifiedBookingSales/index.js +4 -4
  40. package/package.json +1 -1
@@ -4760,7 +4760,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4760
4760
  return this.publishWalletAssetsState(clearedState);
4761
4761
  case 20:
4762
4762
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
4763
- preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
4763
+ preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged,
4764
+ retainSearchResultCodes: params === null || params === void 0 ? void 0 : params.retainSearchResultCodes
4764
4765
  });
4765
4766
  _context43.next = 23;
4766
4767
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
@@ -5083,8 +5084,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5083
5084
  key: "confirmWalletPayment",
5084
5085
  value: (function () {
5085
5086
  var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
5086
- var _this$store$order$get3, _this$store$order14, _this$store$order$get4, _this$store$order$get5, _this$store$order15;
5087
- var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5087
+ var _this$store$order$get3, _this$store$order14, _this$store$order$get5, _this$store$order$get6, _this$store$order16;
5088
+ var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get4, _this$store$order15, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5088
5089
  return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5089
5090
  while (1) switch (_context50.prev = _context50.next) {
5090
5091
  case 0:
@@ -5096,83 +5097,103 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5096
5097
  case 2:
5097
5098
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5098
5099
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5100
+ amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
5099
5101
  if (!pendingWalletAmount.lte(0)) {
5100
- _context50.next = 6;
5102
+ _context50.next = 14;
5101
5103
  break;
5102
5104
  }
5103
- throw new Error('当前订单没有待确认的 Wallet 支付');
5104
- case 6:
5105
- amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
5105
+ this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
5106
+ amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
5107
+ });
5108
+ _context50.next = 9;
5109
+ return this.submitSalesOrder({
5110
+ smallTicketDataFlag: 1
5111
+ });
5112
+ case 9:
5113
+ _submitResult = _context50.sent;
5114
+ if (!isRejectedSalesSubmitResult(_submitResult)) {
5115
+ _context50.next = 12;
5116
+ break;
5117
+ }
5118
+ throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5119
+ case 12:
5120
+ _latestAmountSnapshot = (_this$store$order$get4 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order15);
5121
+ return _context50.abrupt("return", {
5122
+ submitResult: _submitResult,
5123
+ payments: this.store.order.getOrderPayments(),
5124
+ isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
5125
+ });
5126
+ case 14:
5106
5127
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5107
5128
  if (!effectiveAmountDue.gt(0.01)) {
5108
- _context50.next = 10;
5129
+ _context50.next = 17;
5109
5130
  break;
5110
5131
  }
5111
5132
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
5112
- case 10:
5113
- beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
5114
- _context50.prev = 11;
5115
- _context50.next = 14;
5133
+ case 17:
5134
+ beforePaymentStatus = (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.payment_status;
5135
+ _context50.prev = 18;
5136
+ _context50.next = 21;
5116
5137
  return this.submitSalesOrder({
5117
5138
  smallTicketDataFlag: 1,
5118
5139
  confirmPendingVoucherPayments: true
5119
5140
  });
5120
- case 14:
5141
+ case 21:
5121
5142
  submitResult = _context50.sent;
5122
5143
  if (!isRejectedSalesSubmitResult(submitResult)) {
5123
- _context50.next = 17;
5144
+ _context50.next = 24;
5124
5145
  break;
5125
5146
  }
5126
5147
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
5127
- case 17:
5128
- _context50.next = 27;
5148
+ case 24:
5149
+ _context50.next = 34;
5129
5150
  break;
5130
- case 19:
5131
- _context50.prev = 19;
5132
- _context50.t0 = _context50["catch"](11);
5151
+ case 26:
5152
+ _context50.prev = 26;
5153
+ _context50.t0 = _context50["catch"](18);
5133
5154
  this.store.order.setOrderPayments(beforePayments);
5134
5155
  restoredTempOrder = this.store.order.getTempOrder();
5135
5156
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5136
5157
  restoredTempOrder.payment_status = beforePaymentStatus;
5137
5158
  this.store.order.persistTempOrder();
5138
5159
  }
5139
- _context50.next = 26;
5160
+ _context50.next = 33;
5140
5161
  return this.store.order.recalculateSummary({
5141
5162
  createIfMissing: true
5142
5163
  });
5143
- case 26:
5164
+ case 33:
5144
5165
  throw _context50.t0;
5145
- case 27:
5166
+ case 34:
5146
5167
  if (!this.store.payment) {
5147
- _context50.next = 38;
5168
+ _context50.next = 45;
5148
5169
  break;
5149
5170
  }
5150
- _context50.prev = 28;
5171
+ _context50.prev = 35;
5151
5172
  committed = this.getCommittedWalletAssets();
5152
5173
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5153
- _context50.next = 33;
5174
+ _context50.next = 40;
5154
5175
  return this.publishWalletAssetsState(walletState);
5155
- case 33:
5156
- _context50.next = 38;
5176
+ case 40:
5177
+ _context50.next = 45;
5157
5178
  break;
5158
- case 35:
5159
- _context50.prev = 35;
5160
- _context50.t1 = _context50["catch"](28);
5179
+ case 42:
5180
+ _context50.prev = 42;
5181
+ _context50.t1 = _context50["catch"](35);
5161
5182
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
5162
5183
  error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1)
5163
5184
  });
5164
- case 38:
5165
- latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order15);
5185
+ case 45:
5186
+ latestAmountSnapshot = (_this$store$order$get6 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16);
5166
5187
  return _context50.abrupt("return", {
5167
5188
  submitResult: submitResult,
5168
5189
  payments: this.store.order.getOrderPayments(),
5169
5190
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
5170
5191
  });
5171
- case 40:
5192
+ case 47:
5172
5193
  case "end":
5173
5194
  return _context50.stop();
5174
5195
  }
5175
- }, _callee50, this, [[11, 19], [28, 35]]);
5196
+ }, _callee50, this, [[18, 26], [35, 42]]);
5176
5197
  }));
5177
5198
  function confirmWalletPayment() {
5178
5199
  return _confirmWalletPayment.apply(this, arguments);
@@ -5188,7 +5209,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5188
5209
  key: "payCash",
5189
5210
  value: (function () {
5190
5211
  var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5191
- var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
5212
+ var _this$store$order$get7, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
5192
5213
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5193
5214
  return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5194
5215
  while (1) switch (_context51.prev = _context51.next) {
@@ -5232,7 +5253,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5232
5253
  throw new Error('现金支付金额超过当前待支付金额');
5233
5254
  case 17:
5234
5255
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5235
- beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
5256
+ beforePaymentStatus = (_this$store$order$get7 = this.store.order.getTempOrder()) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.payment_status;
5236
5257
  uniquePaymentNumber = createUuidV4();
5237
5258
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5238
5259
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
@@ -5343,7 +5364,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5343
5364
  key: "commitPaymentMethodPayment",
5344
5365
  value: (function () {
5345
5366
  var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5346
- var _this$store$order$get7, _this$store$order16, _this$store$order$get8, _params$metadata, _params$originAmount;
5367
+ var _this$store$order$get8, _this$store$order17, _this$store$order$get9, _params$metadata, _params$originAmount;
5347
5368
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5348
5369
  return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5349
5370
  while (1) switch (_context52.prev = _context52.next) {
@@ -5387,7 +5408,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5387
5408
  }
5388
5409
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
5389
5410
  case 15:
5390
- amountSnapshot = (_this$store$order$get7 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16);
5411
+ amountSnapshot = (_this$store$order$get8 = (_this$store$order17 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order17);
5391
5412
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5392
5413
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5393
5414
  if (!amountDue.lte(0)) {
@@ -5403,7 +5424,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5403
5424
  throw new Error('支付金额超过当前待支付金额');
5404
5425
  case 22:
5405
5426
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5406
- beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
5427
+ beforePaymentStatus = (_this$store$order$get9 = this.store.order.getTempOrder()) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.payment_status;
5407
5428
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5408
5429
  metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
5409
5430
  unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
@@ -6188,16 +6209,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6188
6209
  }, {
6189
6210
  key: "getUnfulfilledPromotions",
6190
6211
  value: function getUnfulfilledPromotions() {
6191
- var _this$store$order17;
6192
- return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getUnfulfilledPromotions()) || [];
6212
+ var _this$store$order18;
6213
+ return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getUnfulfilledPromotions()) || [];
6193
6214
  }
6194
6215
 
6195
6216
  /** 最近一次促销计算输出的赠品操作 diff。 */
6196
6217
  }, {
6197
6218
  key: "getLastGiftActions",
6198
6219
  value: function getLastGiftActions() {
6199
- var _this$store$order18;
6200
- return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getLastGiftActions()) || null;
6220
+ var _this$store$order19;
6221
+ return ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 ? void 0 : _this$store$order19.getLastGiftActions()) || null;
6201
6222
  }
6202
6223
 
6203
6224
  // 获取商品列表
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -33,6 +33,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
33
33
  protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
34
34
  protected loadOpenDataInFlightTarget: string | null;
35
35
  protected openDataTarget: string | null;
36
+ private readonly customerResolveRequests;
36
37
  /**
37
38
  * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
38
39
  * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
@@ -78,10 +79,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
78
79
  resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
79
80
  /** 兼容既有优惠码扫码逻辑。 */
80
81
  private resolveCustomerByDiscountCustomerId;
81
- private findCustomerById;
82
82
  private normalizeCustomer;
83
83
  private getRawCustomerId;
84
- private hasUsableCustomerDetails;
85
84
  /**
86
85
  * 更新当前预约的 appointment_status。
87
86
  *
@@ -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';