@pisell/pisellos 2.3.130 → 2.3.132

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 (37) hide show
  1. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  2. package/dist/modules/BusinessAvailability/index.js +204 -0
  3. package/dist/modules/OpenData/types.d.ts +2 -0
  4. package/dist/modules/Order/index.d.ts +5 -2
  5. package/dist/modules/Order/index.js +315 -241
  6. package/dist/modules/Order/types.d.ts +8 -0
  7. package/dist/solution/BaseSales/index.d.ts +4 -15
  8. package/dist/solution/BaseSales/index.js +151 -89
  9. package/dist/solution/BaseSales/types.d.ts +11 -0
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.js +41 -13
  13. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  14. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  15. package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
  16. package/dist/solution/UnifiedBookingSales/index.js +154 -75
  17. package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
  18. package/dist/solution/VenueBooking/index.js +45 -44
  19. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  20. package/lib/modules/BusinessAvailability/index.js +146 -0
  21. package/lib/modules/OpenData/types.d.ts +2 -0
  22. package/lib/modules/Order/index.d.ts +5 -2
  23. package/lib/modules/Order/index.js +62 -6
  24. package/lib/modules/Order/types.d.ts +8 -0
  25. package/lib/solution/BaseSales/index.d.ts +4 -15
  26. package/lib/solution/BaseSales/index.js +64 -24
  27. package/lib/solution/BaseSales/types.d.ts +11 -0
  28. package/lib/solution/BookingByStep/index.d.ts +1 -1
  29. package/lib/solution/BookingTicket/index.d.ts +1 -1
  30. package/lib/solution/BookingTicket/index.js +37 -4
  31. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  32. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  33. package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
  34. package/lib/solution/UnifiedBookingSales/index.js +54 -0
  35. package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
  36. package/lib/solution/VenueBooking/index.js +9 -8
  37. package/package.json +1 -1
@@ -517,7 +517,15 @@ export type OrderProductMergeDecisionResult = boolean | {
517
517
  reason?: string;
518
518
  [key: string]: any;
519
519
  };
520
+ export interface OrderCartIntentCommitContext {
521
+ action: 'add_product' | 'update_product' | 'increase_quantity' | 'scan_promotion';
522
+ tempOrder: OrderTempOrder | null;
523
+ }
520
524
  export interface OrderHooksConfig {
525
+ /** Optional customer-order guard; called synchronously before the first cart write. */
526
+ beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
527
+ /** Captures tenant/business runtime identity for asynchronous cart intents. */
528
+ getCartIntentScope?: () => unknown;
521
529
  onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
522
530
  }
523
531
  /**
@@ -1,6 +1,6 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
3
+ import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesSubmitSalesOrderParams, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
5
  import { type PickupTimingBookingInput } from '../../modules/Order/pickupTiming';
6
6
  import type { PickupTimingAvailability, PickupTimingSelection, PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
@@ -339,13 +339,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
339
339
  productList?: Record<string, any>[];
340
340
  discountList?: Discount[];
341
341
  }): Promise<void>;
342
- submitScanOrder<T = any>(params?: {
343
- payments?: OrderPaymentSource[];
344
- paymentStatus?: BaseSalesPaymentStatus;
345
- smallTicketDataFlag?: number;
346
- confirmPendingVoucherPayments?: boolean;
347
- enhancePayload?: SubmitPayloadEnhancer;
348
- }): Promise<T>;
342
+ submitScanOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
343
+ private buildVirtualSettlementOrderData;
349
344
  private buildVirtualSettlementSubmitData;
350
345
  /**
351
346
  * 提交当前 Sales 订单。
@@ -353,13 +348,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
353
348
  * PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
354
349
  * payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
355
350
  */
356
- submitSalesOrder<T = any>(params?: {
357
- payments?: OrderPaymentSource[];
358
- paymentStatus?: BaseSalesPaymentStatus;
359
- smallTicketDataFlag?: number;
360
- confirmPendingVoucherPayments?: boolean;
361
- enhancePayload?: SubmitPayloadEnhancer;
362
- }): Promise<T>;
351
+ submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
363
352
  saveSalesOrderDraft<T = any>(params?: {
364
353
  platform?: string;
365
354
  businessCode?: string;
@@ -1,3 +1,6 @@
1
+ var _excluded = ["payment_status"];
2
+ 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; }
3
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
6
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
@@ -3996,92 +3999,91 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3996
3999
  }
3997
4000
  return submitScanOrder;
3998
4001
  }()
4002
+ }, {
4003
+ key: "buildVirtualSettlementOrderData",
4004
+ value: function buildVirtualSettlementOrderData() {
4005
+ var _tempOrder$metadata$c, _tempOrder$metadata2;
4006
+ if (!this.store.order) return null;
4007
+ var tempOrder = this.store.order.getTempOrder();
4008
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) return null;
4009
+ var snapshot = getTempOrderSettlementSnapshot(tempOrder);
4010
+ var currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
4011
+ if (!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0) {
4012
+ throw new Error('Virtual currency settlement configuration is invalid.');
4013
+ }
4014
+ return {
4015
+ snapshot: snapshot,
4016
+ currencyProductId: currencyProductId,
4017
+ currencyCode: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || ''),
4018
+ currencySymbol: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || ''),
4019
+ currencyFormat: String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first')
4020
+ };
4021
+ }
3999
4022
  }, {
4000
4023
  key: "buildVirtualSettlementSubmitData",
4001
4024
  value: function () {
4002
4025
  var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
4003
- var _tempOrder$metadata$c, _tempOrder$metadata2;
4004
- var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
4026
+ var settlement, tempOrder, currencyProductId, summary, amount, customerId, asset, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
4005
4027
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4006
4028
  while (1) switch (_context34.prev = _context34.next) {
4007
4029
  case 0:
4008
- if (this.store.order) {
4009
- _context34.next = 2;
4030
+ settlement = this.buildVirtualSettlementOrderData();
4031
+ if (!(!settlement || !this.store.order)) {
4032
+ _context34.next = 3;
4010
4033
  break;
4011
4034
  }
4012
4035
  return _context34.abrupt("return", null);
4013
- case 2:
4036
+ case 3:
4014
4037
  tempOrder = this.store.order.getTempOrder();
4015
- if (this.isActiveVirtualSettlementOrder(tempOrder)) {
4016
- _context34.next = 5;
4017
- break;
4018
- }
4019
- return _context34.abrupt("return", null);
4020
- case 5:
4021
- snapshot = getTempOrderSettlementSnapshot(tempOrder);
4022
- currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
4023
- if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
4024
- _context34.next = 9;
4025
- break;
4026
- }
4027
- throw new Error('Virtual currency settlement configuration is invalid.');
4028
- case 9:
4029
- _context34.next = 11;
4038
+ currencyProductId = settlement.currencyProductId;
4039
+ _context34.next = 7;
4030
4040
  return this.store.order.recalculateSummary({
4031
4041
  createIfMissing: true
4032
4042
  });
4033
- case 11:
4043
+ case 7:
4034
4044
  summary = _context34.sent;
4035
4045
  amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
4036
4046
  customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
4037
4047
  if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
4038
- _context34.next = 17;
4048
+ _context34.next = 13;
4039
4049
  break;
4040
4050
  }
4041
- _context34.next = 17;
4051
+ _context34.next = 13;
4042
4052
  return this.store.order.loadDiscountConfig({
4043
4053
  customerId: customerId,
4044
4054
  action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
4045
4055
  orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
4046
4056
  apply: false
4047
4057
  });
4048
- case 17:
4058
+ case 13:
4049
4059
  asset = this.store.order.getVirtualCurrencyList().find(function (item) {
4050
4060
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
4051
4061
  });
4052
- currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
4053
- currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
4054
- currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
4055
4062
  if (!amount.lte(0)) {
4056
- _context34.next = 23;
4063
+ _context34.next = 16;
4057
4064
  break;
4058
4065
  }
4059
- return _context34.abrupt("return", {
4060
- payments: [],
4061
- snapshot: snapshot,
4062
- currencyProductId: currencyProductId,
4063
- currencyCode: currencyCode,
4064
- currencySymbol: currencySymbol,
4065
- currencyFormat: currencyFormat
4066
- });
4067
- case 23:
4066
+ return _context34.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
4067
+ payments: []
4068
+ }));
4069
+ case 16:
4068
4070
  if (asset) {
4069
- _context34.next = 25;
4071
+ _context34.next = 18;
4070
4072
  break;
4071
4073
  }
4072
4074
  throw new Error('No matching virtual currency card is available.');
4073
- case 25:
4075
+ case 18:
4074
4076
  balance = new Decimal(asset.balance || 0);
4075
4077
  if (!balance.lt(amount)) {
4076
- _context34.next = 28;
4078
+ _context34.next = 21;
4077
4079
  break;
4078
4080
  }
4079
4081
  throw new Error('Insufficient virtual currency balance.');
4080
- case 28:
4082
+ case 21:
4081
4083
  amountText = amount.toFixed(2);
4082
4084
  paymentNumber = "LOCAL_".concat(createUuidV4());
4083
4085
  if (!this.store.order.isOnlineStorePlatform()) {
4084
- _context34.next = 34;
4086
+ _context34.next = 27;
4085
4087
  break;
4086
4088
  }
4087
4089
  payment = {
@@ -4098,22 +4100,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4098
4100
  },
4099
4101
  wallet_pass_use_value: amountText
4100
4102
  };
4101
- _context34.next = 41;
4103
+ _context34.next = 34;
4102
4104
  break;
4103
- case 34:
4104
- _context34.next = 36;
4105
+ case 27:
4106
+ _context34.next = 29;
4105
4107
  return this.getPaymentMethodsAsync();
4106
- case 36:
4108
+ case 29:
4107
4109
  paymentMethods = _context34.sent;
4108
4110
  paymentMethod = paymentMethods.find(function (method) {
4109
4111
  return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
4110
4112
  });
4111
4113
  if (paymentMethod) {
4112
- _context34.next = 40;
4114
+ _context34.next = 33;
4113
4115
  break;
4114
4116
  }
4115
4117
  throw new Error('PRODUCTVOUCHER payment method is unavailable.');
4116
- case 40:
4118
+ case 33:
4117
4119
  payment = {
4118
4120
  payment_number: paymentNumber,
4119
4121
  amount: amountText,
@@ -4132,16 +4134,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4132
4134
  wallet_pass_use_value: amountText,
4133
4135
  metadata: {}
4134
4136
  };
4135
- case 41:
4136
- return _context34.abrupt("return", {
4137
- payments: [payment],
4138
- snapshot: snapshot,
4139
- currencyProductId: currencyProductId,
4140
- currencyCode: currencyCode,
4141
- currencySymbol: currencySymbol,
4142
- currencyFormat: currencyFormat
4143
- });
4144
- case 42:
4137
+ case 34:
4138
+ return _context34.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
4139
+ payments: [payment]
4140
+ }));
4141
+ case 35:
4145
4142
  case "end":
4146
4143
  return _context34.stop();
4147
4144
  }
@@ -4163,7 +4160,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4163
4160
  value: (function () {
4164
4161
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4165
4162
  var _params$smallTicketDa, _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
4166
- var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, _enhancePayload, submitParams;
4163
+ var isDeferredPayment, virtualPaymentSettlement, virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, configuredEnhancePayload, _enhancePayload, submitParams;
4167
4164
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4168
4165
  while (1) switch (_context35.prev = _context35.next) {
4169
4166
  case 0:
@@ -4182,14 +4179,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4182
4179
  freeze: true
4183
4180
  });
4184
4181
  case 5:
4185
- _context35.next = 7;
4182
+ isDeferredPayment = (params === null || params === void 0 ? void 0 : params.paymentExecution) === 'deferred';
4183
+ if (!isDeferredPayment) {
4184
+ _context35.next = 10;
4185
+ break;
4186
+ }
4187
+ _context35.t0 = null;
4188
+ _context35.next = 13;
4189
+ break;
4190
+ case 10:
4191
+ _context35.next = 12;
4186
4192
  return this.buildVirtualSettlementSubmitData();
4187
- case 7:
4188
- virtualSettlement = _context35.sent;
4189
- // this.store.order.persistTempOrder();
4190
- inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
4193
+ case 12:
4194
+ _context35.t0 = _context35.sent;
4195
+ case 13:
4196
+ virtualPaymentSettlement = _context35.t0;
4197
+ virtualSettlement = isDeferredPayment ? this.buildVirtualSettlementOrderData() : virtualPaymentSettlement; // this.store.order.persistTempOrder();
4198
+ inferredPaymentStatus = isDeferredPayment ? undefined : this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
4191
4199
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
4192
- _enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
4200
+ virtualSettlementEnhancePayload = virtualSettlement ? function (payload, ctx) {
4201
+ var _callerPayload$metada, _currencySettlementCo;
4202
+ var callerPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
4203
+ var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
4204
+ return _objectSpread(_objectSpread({}, callerPayload), {}, {
4205
+ metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
4206
+ currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
4207
+ settlement_type: 'virtual_currency',
4208
+ settlement_ids: [virtualSettlement.currencyProductId],
4209
+ currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
4210
+ })
4211
+ }),
4212
+ currency_code: virtualSettlement.currencyCode,
4213
+ currency_symbol: virtualSettlement.currencySymbol,
4214
+ currency_format: virtualSettlement.currencyFormat
4215
+ });
4216
+ } : params === null || params === void 0 ? void 0 : params.enhancePayload;
4217
+ configuredEnhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(virtualSettlementEnhancePayload); // Apply this last so neither a stale draft status nor a caller enhancer can
4218
+ // turn deferred submission into payment. The live wallet selection is untouched.
4219
+ _enhancePayload = isDeferredPayment ? function (payload, ctx) {
4220
+ var enhancedPayload = configuredEnhancePayload ? configuredEnhancePayload(payload, ctx) : payload;
4221
+ var _paymentStatus = enhancedPayload.payment_status,
4222
+ orderPayload = _objectWithoutProperties(enhancedPayload, _excluded);
4223
+ return _objectSpread(_objectSpread({}, orderPayload), {}, {
4224
+ payments: []
4225
+ });
4226
+ } : configuredEnhancePayload;
4193
4227
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
4194
4228
  cacheId: this.cacheId,
4195
4229
  platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
@@ -4197,29 +4231,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4197
4231
  channel: this.getSubmitOrderSalesChannel(),
4198
4232
  type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type,
4199
4233
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
4200
- }, virtualSettlement ? {
4201
- payments: virtualSettlement.payments
4234
+ }, isDeferredPayment ? {
4235
+ payments: []
4236
+ } : virtualPaymentSettlement ? {
4237
+ payments: virtualPaymentSettlement.payments
4202
4238
  } : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
4203
4239
  payments: params.payments
4204
4240
  } : {}), inferredPaymentStatus !== undefined ? {
4205
4241
  paymentStatus: inferredPaymentStatus
4206
4242
  } : {}), smallTicketDataFlag !== undefined ? {
4207
4243
  smallTicketDataFlag: smallTicketDataFlag
4208
- } : {}), virtualSettlement ? {
4244
+ } : {}), isDeferredPayment || virtualSettlement ? {
4209
4245
  confirmPendingVoucherPayments: false
4210
4246
  } : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
4211
4247
  confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
4212
4248
  } : {}), virtualSettlement ? {
4213
4249
  enhancePayload: function enhancePayload(payload, ctx) {
4214
- var _callerPayload$metada, _currencySettlementCo;
4250
+ var _callerPayload$metada2, _currencySettlementCo2;
4215
4251
  var callerPayload = _enhancePayload ? _enhancePayload(payload, ctx) : payload;
4216
- var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
4252
+ var currencySettlementConfig = ((_callerPayload$metada2 = callerPayload.metadata) === null || _callerPayload$metada2 === void 0 ? void 0 : _callerPayload$metada2.currency_settlement_config) || {};
4217
4253
  return _objectSpread(_objectSpread({}, callerPayload), {}, {
4218
4254
  metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
4219
4255
  currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
4220
4256
  settlement_type: 'virtual_currency',
4221
4257
  settlement_ids: [virtualSettlement.currencyProductId],
4222
- currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
4258
+ currency_display_snapshot: cloneDeep((_currencySettlementCo2 = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo2 !== void 0 ? _currencySettlementCo2 : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
4223
4259
  })
4224
4260
  }),
4225
4261
  currency_code: virtualSettlement.currencyCode,
@@ -4231,7 +4267,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4231
4267
  enhancePayload: _enhancePayload
4232
4268
  } : {});
4233
4269
  return _context35.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
4234
- case 13:
4270
+ case 22:
4235
4271
  case "end":
4236
4272
  return _context35.stop();
4237
4273
  }
@@ -6575,20 +6611,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6575
6611
  }
6576
6612
  throw new Error('order 模块未初始化');
6577
6613
  case 3:
6578
- _context63.next = 5;
6579
- return this.store.order.addProductToOrder(product, booking, options);
6580
- case 5:
6581
- products = _context63.sent;
6582
- return _context63.abrupt("return", products);
6614
+ if (!(options === undefined)) {
6615
+ _context63.next = 9;
6616
+ break;
6617
+ }
6618
+ _context63.next = 6;
6619
+ return this.store.order.addProductToOrder(product, booking);
6620
+ case 6:
6621
+ _context63.t0 = _context63.sent;
6622
+ _context63.next = 12;
6623
+ break;
6583
6624
  case 9:
6584
- _context63.prev = 9;
6585
- _context63.t0 = _context63["catch"](0);
6586
- throw _context63.t0;
6625
+ _context63.next = 11;
6626
+ return this.store.order.addProductToOrder(product, booking, options);
6627
+ case 11:
6628
+ _context63.t0 = _context63.sent;
6587
6629
  case 12:
6630
+ products = _context63.t0;
6631
+ return _context63.abrupt("return", products);
6632
+ case 16:
6633
+ _context63.prev = 16;
6634
+ _context63.t1 = _context63["catch"](0);
6635
+ throw _context63.t1;
6636
+ case 19:
6588
6637
  case "end":
6589
6638
  return _context63.stop();
6590
6639
  }
6591
- }, _callee63, this, [[0, 9]]);
6640
+ }, _callee63, this, [[0, 16]]);
6592
6641
  }));
6593
6642
  function addProductToOrder(_x52, _x53, _x54) {
6594
6643
  return _addProductToOrder.apply(this, arguments);
@@ -6779,19 +6828,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6779
6828
  }
6780
6829
  throw new Error('order 模块未初始化');
6781
6830
  case 3:
6782
- _context68.next = 5;
6831
+ if (!(options === undefined)) {
6832
+ _context68.next = 9;
6833
+ break;
6834
+ }
6835
+ _context68.next = 6;
6836
+ return this.store.order.removeProductsFromOrder(identities);
6837
+ case 6:
6838
+ _context68.t0 = _context68.sent;
6839
+ _context68.next = 12;
6840
+ break;
6841
+ case 9:
6842
+ _context68.next = 11;
6783
6843
  return this.store.order.removeProductsFromOrder(identities, options);
6784
- case 5:
6785
- return _context68.abrupt("return", _context68.sent);
6786
- case 8:
6787
- _context68.prev = 8;
6788
- _context68.t0 = _context68["catch"](0);
6789
- throw _context68.t0;
6790
6844
  case 11:
6845
+ _context68.t0 = _context68.sent;
6846
+ case 12:
6847
+ return _context68.abrupt("return", _context68.t0);
6848
+ case 15:
6849
+ _context68.prev = 15;
6850
+ _context68.t1 = _context68["catch"](0);
6851
+ throw _context68.t1;
6852
+ case 18:
6791
6853
  case "end":
6792
6854
  return _context68.stop();
6793
6855
  }
6794
- }, _callee68, this, [[0, 8]]);
6856
+ }, _callee68, this, [[0, 15]]);
6795
6857
  }));
6796
6858
  function removeProductsFromOrder(_x60, _x61) {
6797
6859
  return _removeProductsFromOrder.apply(this, arguments);
@@ -4,6 +4,8 @@ import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderCon
4
4
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
5
5
  import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
6
6
  import type { PaymentMethod } from '../../modules/Payment/types';
7
+ import type { OrderPaymentSource } from '../../modules/Order/types';
8
+ import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
7
9
  /**
8
10
  * BaseSales 流程 hook 后缀。
9
11
  * 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
@@ -27,6 +29,15 @@ export interface BaseSalesCashPaymentOptions {
27
29
  /** 指定现金支付方式;省略时使用默认 CASHMANUAL。 */
28
30
  paymentMethodId?: number | string;
29
31
  }
32
+ export interface BaseSalesSubmitSalesOrderParams {
33
+ payments?: OrderPaymentSource[];
34
+ paymentStatus?: BaseSalesPaymentStatus;
35
+ smallTicketDataFlag?: number;
36
+ confirmPendingVoucherPayments?: boolean;
37
+ enhancePayload?: SubmitPayloadEnhancer;
38
+ /** Create the order without executing payment; payment status comes from the server. */
39
+ paymentExecution?: 'deferred';
40
+ }
30
41
  export interface BaseSalesCashPaymentConfig {
31
42
  available: boolean;
32
43
  paymentMethod?: PaymentMethod;
@@ -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 | 2 | 1 | 5 | 4 | 3 | 6;
329
+ weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -346,7 +346,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
346
346
  * 获取当前的客户搜索条件
347
347
  * @returns 当前搜索条件
348
348
  */
349
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
349
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
350
350
  /**
351
351
  * 获取客户列表状态(包含滚动加载相关状态)
352
352
  * @returns 客户状态
@@ -2664,7 +2664,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2664
2664
  value: (function () {
2665
2665
  var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(code, bridge) {
2666
2666
  var _this7 = this;
2667
- var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2667
+ var trimmed, _bridge$onNotify, _bridge$refresh, beforeScanCommit, beforeScanDialog, guardCallback, guardedBridge, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2668
2668
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2669
2669
  while (1) switch (_context32.prev = _context32.next) {
2670
2670
  case 0:
@@ -2680,20 +2680,45 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2680
2680
  });
2681
2681
  case 4:
2682
2682
  _context32.prev = 4;
2683
+ // Capture before lookup/UI awaits, so a result cannot land in a new cart.
2684
+ // Unscoped POS Order modules return a no-op guard.
2685
+ beforeScanCommit = this.store.order.createCartIntentCommitGuard('add_product');
2686
+ beforeScanDialog = this.store.order.createCartIntentCommitGuard('add_product');
2687
+ guardCallback = function guardCallback(callback) {
2688
+ return callback ? function () {
2689
+ beforeScanCommit();
2690
+ return callback.apply(void 0, arguments);
2691
+ } : undefined;
2692
+ };
2693
+ guardedBridge = bridge ? _objectSpread(_objectSpread({}, bridge), {}, {
2694
+ confirmDetail: guardCallback(bridge.confirmDetail),
2695
+ confirmBookingEdit: guardCallback(bridge.confirmBookingEdit),
2696
+ applyPromotionCode: guardCallback(bridge.applyPromotionCode),
2697
+ openOrder: guardCallback(bridge.openOrder),
2698
+ requestCustomerSwitch: guardCallback(bridge.requestCustomerSwitch),
2699
+ openProductDetail: bridge.openProductDetail ? function (payload) {
2700
+ beforeScanDialog();
2701
+ return bridge.openProductDetail(payload);
2702
+ } : undefined,
2703
+ openBookingEdit: bridge.openBookingEdit ? function (payload) {
2704
+ beforeScanDialog();
2705
+ return bridge.openBookingEdit(payload);
2706
+ } : undefined
2707
+ }) : undefined;
2683
2708
  localSearch = function localSearch(v) {
2684
2709
  return _this7.store.products.findProductsByCodeOrBarcode(v);
2685
2710
  };
2686
2711
  scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
2687
- _context32.next = 9;
2712
+ _context32.next = 13;
2688
2713
  return scanCallback({
2689
2714
  type: 'nativeScanner',
2690
2715
  value: trimmed
2691
2716
  });
2692
- case 9:
2717
+ case 13:
2693
2718
  raw = _context32.sent;
2694
2719
  formatted = formatGlobalScanResult(raw, trimmed);
2695
2720
  if (formatted) {
2696
- _context32.next = 14;
2721
+ _context32.next = 18;
2697
2722
  break;
2698
2723
  }
2699
2724
  bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -2701,11 +2726,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2701
2726
  status: 'failed',
2702
2727
  reason: 'not_found'
2703
2728
  });
2704
- case 14:
2705
- _context32.next = 16;
2729
+ case 18:
2730
+ _context32.next = 20;
2706
2731
  return applyGlobalScan({
2707
2732
  setOrderCustomer: function setOrderCustomer(customer) {
2708
- return _this7.setOrderCustomer(customer);
2733
+ beforeScanCommit();
2734
+ _this7.setOrderCustomer(customer);
2709
2735
  },
2710
2736
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2711
2737
  return _this7.getOrderCustomerSnapshot();
@@ -2730,21 +2756,23 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2730
2756
  return _this7.transformDetailToProductAndBooking(input);
2731
2757
  },
2732
2758
  addProductToOrder: function addProductToOrder(product, booking) {
2759
+ beforeScanCommit();
2733
2760
  return _this7.addProductToOrder(product, booking);
2734
2761
  },
2735
2762
  refreshWalletAssets: function refreshWalletAssets(params) {
2736
2763
  return _this7.refreshWalletAssets(params);
2737
2764
  },
2738
2765
  scanWalletAsset: function scanWalletAsset(scanCode) {
2766
+ beforeScanCommit();
2739
2767
  return _this7.scanWalletAsset(scanCode);
2740
2768
  }
2741
- }, formatted, bridge);
2742
- case 16:
2769
+ }, formatted, guardedBridge);
2770
+ case 20:
2743
2771
  _result7 = _context32.sent;
2744
2772
  bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
2745
2773
  return _context32.abrupt("return", _result7);
2746
- case 21:
2747
- _context32.prev = 21;
2774
+ case 25:
2775
+ _context32.prev = 25;
2748
2776
  _context32.t0 = _context32["catch"](4);
2749
2777
  console.error('[BookingTicket] handleGlobalScanCode failed', _context32.t0);
2750
2778
  bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -2752,11 +2780,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2752
2780
  status: 'failed',
2753
2781
  reason: 'not_found'
2754
2782
  });
2755
- case 26:
2783
+ case 30:
2756
2784
  case "end":
2757
2785
  return _context32.stop();
2758
2786
  }
2759
- }, _callee32, this, [[4, 21]]);
2787
+ }, _callee32, this, [[4, 25]]);
2760
2788
  }));
2761
2789
  function handleGlobalScanCode(_x21, _x22) {
2762
2790
  return _handleGlobalScanCode.apply(this, arguments);
@@ -0,0 +1,27 @@
1
+ import { type BusinessAvailability } from '../../modules/BusinessAvailability';
2
+ import type { ScheduleModule } from '../../modules/Schedule';
3
+ interface BusinessAvailabilityHost {
4
+ loadOpenData: () => Promise<Record<string, unknown> | null>;
5
+ getSchedule: () => ScheduleModule | undefined;
6
+ getTimezone: () => string;
7
+ getScope: () => string;
8
+ now?: () => Date;
9
+ }
10
+ /** Read successful configuration once per business runtime; evaluate the clock on demand. */
11
+ export declare class BusinessAvailabilityController {
12
+ private readonly host;
13
+ private runtime?;
14
+ constructor(host: BusinessAvailabilityHost);
15
+ invalidate(): void;
16
+ private now;
17
+ private getRuntime;
18
+ private assertCurrent;
19
+ private loadConfig;
20
+ private loadSchedules;
21
+ private error;
22
+ /** Synchronous final cart-commit check; deliberately never starts a load. */
23
+ getCachedAvailability(): BusinessAvailability;
24
+ getAvailability(): Promise<BusinessAvailability>;
25
+ assertAvailable(): void;
26
+ }
27
+ export {};