@pisell/pisellos 2.3.232 → 2.3.234

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 (51) hide show
  1. package/dist/modules/Customer/types.d.ts +4 -0
  2. package/dist/modules/Order/index.d.ts +10 -0
  3. package/dist/modules/Order/index.js +1392 -1157
  4. package/dist/modules/Order/types.d.ts +3 -0
  5. package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
  6. package/dist/modules/Order/utils/bookingUuid.js +24 -0
  7. package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
  8. package/dist/modules/Order/utils/virtualSettlement.js +13 -0
  9. package/dist/modules/Order/utils.d.ts +1 -0
  10. package/dist/modules/Order/utils.js +12 -6
  11. package/dist/shared/payment/loadPaymentMethods.d.ts +5 -1
  12. package/dist/shared/payment/loadPaymentMethods.js +36 -2
  13. package/dist/solution/BaseSales/index.d.ts +4 -0
  14. package/dist/solution/BaseSales/index.js +571 -435
  15. package/dist/solution/BookingTicket/index.d.ts +3 -1
  16. package/dist/solution/BookingTicket/index.js +49 -43
  17. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
  18. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
  19. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +69 -13
  20. package/dist/solution/Checkout/index.js +104 -69
  21. package/dist/solution/Checkout/types.d.ts +1 -0
  22. package/dist/solution/ScanOrder/index.js +10 -2
  23. package/dist/solution/VenueBooking/index.js +522 -490
  24. package/dist/utils/platform.d.ts +3 -0
  25. package/dist/utils/platform.js +8 -0
  26. package/lib/modules/Customer/types.d.ts +4 -0
  27. package/lib/modules/Order/index.d.ts +10 -0
  28. package/lib/modules/Order/index.js +155 -20
  29. package/lib/modules/Order/types.d.ts +3 -0
  30. package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
  31. package/lib/modules/Order/utils/bookingUuid.js +25 -0
  32. package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
  33. package/lib/modules/Order/utils/virtualSettlement.js +9 -1
  34. package/lib/modules/Order/utils.d.ts +1 -0
  35. package/lib/modules/Order/utils.js +14 -5
  36. package/lib/shared/payment/loadPaymentMethods.d.ts +5 -1
  37. package/lib/shared/payment/loadPaymentMethods.js +14 -0
  38. package/lib/solution/BaseSales/index.d.ts +4 -0
  39. package/lib/solution/BaseSales/index.js +78 -16
  40. package/lib/solution/BookingTicket/index.d.ts +3 -1
  41. package/lib/solution/BookingTicket/index.js +4 -1
  42. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
  43. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
  44. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +44 -5
  45. package/lib/solution/Checkout/index.js +21 -0
  46. package/lib/solution/Checkout/types.d.ts +1 -0
  47. package/lib/solution/ScanOrder/index.js +6 -0
  48. package/lib/solution/VenueBooking/index.js +6 -1
  49. package/lib/utils/platform.d.ts +3 -0
  50. package/lib/utils/platform.js +10 -0
  51. package/package.json +1 -1
@@ -223,6 +223,9 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
223
223
  }
224
224
  }
225
225
  const mergedItem = mergedUid ? (0, _orderCollectionIdentity.setOrderCollectionUid)(kind, incomingItem, mergedUid) : (0, _lodashEs.cloneDeep)(incomingItem);
226
+ if (kind === 'booking' && !mergedItem.uuid && currentItem.uuid !== undefined) {
227
+ mergedItem.uuid = currentItem.uuid;
228
+ }
226
229
  const persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
227
230
  if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
228
231
  mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
@@ -749,6 +752,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
749
752
  if (!effects || typeof effects.on !== 'function') return;
750
753
  this.paymentMethodsChangedUnsubscribe = effects.on(PAYMENT_METHODS_CHANGED_EVENT, async payload => {
751
754
  if (!Array.isArray(payload?.newMethods)) return;
755
+ const channel = this.getTerminalVirtualCurrencyChannel();
756
+ if (channel) {
757
+ this.store.order?.syncTerminalVirtualCurrencyPaymentMethods(channel, payload.newMethods);
758
+ }
752
759
  await this.getPaymentMethodsAsync();
753
760
  });
754
761
  }
@@ -1639,6 +1646,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1639
1646
  isMultiCurrencySettlementEnabled() {
1640
1647
  return this.otherParams?.enableMultiCurrencySettlement === true;
1641
1648
  }
1649
+ getTerminalVirtualCurrencyChannel() {
1650
+ if (!this.isMultiCurrencySettlementEnabled()) return undefined;
1651
+ return (0, _platform.resolveTerminalVirtualCurrencyChannel)(this.otherParams?.platform, this.otherParams?.businessCode ?? this.otherParams?.business_code);
1652
+ }
1642
1653
  isActiveVirtualSettlementOrder(tempOrder) {
1643
1654
  return this.isMultiCurrencySettlementEnabled() && (0, _virtualSettlement.isVirtualSettlementOrder)(tempOrder);
1644
1655
  }
@@ -2834,8 +2845,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2834
2845
  currencyFormat: String(tempOrder?.currency_format || 'symbol_first')
2835
2846
  };
2836
2847
  }
2837
- async buildVirtualSettlementSubmitData() {
2838
- const settlement = this.buildVirtualSettlementOrderData();
2848
+ async buildVirtualSettlementSubmitData(settlement, terminalPaymentMethod) {
2839
2849
  if (!settlement || !this.store.order) return null;
2840
2850
  const tempOrder = this.store.order.getTempOrder();
2841
2851
  const {
@@ -2846,6 +2856,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2846
2856
  });
2847
2857
  const amount = new _decimal.default(summary?.total_amount || 0).toDecimalPlaces(2);
2848
2858
  const customerId = Number(tempOrder?.customer_id || 0);
2859
+ if (terminalPaymentMethod && amount.gt(0) && !(customerId > 1)) {
2860
+ throw new _virtualSettlement.VirtualCurrencyCustomerRequiredError();
2861
+ }
2849
2862
  if (amount.gt(0) && customerId > 0 && customerId !== 1) {
2850
2863
  await this.store.order.loadDiscountConfig({
2851
2864
  customerId,
@@ -2862,22 +2875,23 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2862
2875
  };
2863
2876
  }
2864
2877
  if (!asset) {
2865
- throw new Error('No matching virtual currency card is available.');
2878
+ throw new _virtualSettlement.VirtualCurrencyAssetNotFoundError(currencyProductId);
2866
2879
  }
2867
2880
  const balance = new _decimal.default(asset.balance || 0);
2868
2881
  if (balance.lt(amount)) {
2869
- throw new Error('Insufficient virtual currency balance.');
2882
+ throw new _virtualSettlement.VirtualCurrencyBalanceError(balance.toFixed(2), amount.toFixed(2));
2870
2883
  }
2871
2884
  const amountText = amount.toFixed(2);
2872
2885
  const paymentNumber = `LOCAL_${(0, _utils.createUuidV4)()}`;
2886
+ const metadata = {
2887
+ unique_payment_number: (0, _utils.createUuidV4)()
2888
+ };
2873
2889
  let payment;
2874
- if (this.store.order.isOnlineStorePlatform()) {
2890
+ if (!terminalPaymentMethod && this.store.order.isOnlineStorePlatform()) {
2875
2891
  payment = {
2876
2892
  payment_number: paymentNumber,
2877
2893
  amount: amount.toNumber(),
2878
- metadata: {
2879
- unique_payment_number: (0, _utils.createUuidV4)()
2880
- },
2894
+ metadata,
2881
2895
  tag: asset.tag,
2882
2896
  voucher_id: asset.id,
2883
2897
  wallet_pass_usage_unit: {
@@ -2887,8 +2901,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2887
2901
  wallet_pass_use_value: amountText
2888
2902
  };
2889
2903
  } else {
2890
- const paymentMethods = await this.getPaymentMethodsAsync();
2891
- const paymentMethod = paymentMethods.find(method => String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER');
2904
+ const paymentMethod = terminalPaymentMethod ?? (await this.getPaymentMethodsAsync()).find(method => String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER');
2892
2905
  if (!paymentMethod) {
2893
2906
  throw new Error('PRODUCTVOUCHER payment method is unavailable.');
2894
2907
  }
@@ -2908,7 +2921,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2908
2921
  points: 1
2909
2922
  },
2910
2923
  wallet_pass_use_value: amountText,
2911
- metadata: {}
2924
+ metadata
2912
2925
  };
2913
2926
  }
2914
2927
  return {
@@ -2932,8 +2945,23 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2932
2945
  freeze: true
2933
2946
  });
2934
2947
  const isDeferredPayment = params?.paymentExecution === 'deferred';
2935
- const virtualPaymentSettlement = isDeferredPayment ? null : await this.buildVirtualSettlementSubmitData();
2936
- const virtualSettlement = isDeferredPayment ? this.buildVirtualSettlementOrderData() : virtualPaymentSettlement;
2948
+ const checkoutOrder = this.store.order.getTempOrder();
2949
+ const virtualOrderData = this.buildVirtualSettlementOrderData();
2950
+ const checkoutCustomerId = checkoutOrder?.customer_id;
2951
+ const checkoutSettlementKey = (0, _virtualSettlement.getTempOrderSettlementKey)(checkoutOrder);
2952
+ const virtualPaymentChannel = virtualOrderData ? this.getTerminalVirtualCurrencyChannel() : undefined;
2953
+ const terminalPaymentMethod = virtualPaymentChannel ? this.store.order.getTerminalVirtualCurrencyPaymentMethod(virtualPaymentChannel, virtualPaymentChannel === 'pos' ? this.getPaymentMethods() : undefined) : undefined;
2954
+ const readCheckoutLines = () => checkoutOrder?.products.map(product => [String(product.product_id), String(product.product_variant_id ?? 0), Number(product.num ?? 1)]);
2955
+ const checkoutLines = terminalPaymentMethod && !isDeferredPayment ? readCheckoutLines() : undefined;
2956
+ const assertCheckoutCartUnchanged = () => {
2957
+ if (terminalPaymentMethod && (this.store.order?.getTempOrder() !== checkoutOrder || checkoutOrder?.customer_id !== checkoutCustomerId || (0, _virtualSettlement.getTempOrderSettlementKey)(checkoutOrder) !== checkoutSettlementKey || checkoutLines && !(0, _lodashEs.isEqual)(readCheckoutLines(), checkoutLines))) {
2958
+ throw (0, _inventory.salesGuardError)('The cart changed. Please try again.');
2959
+ }
2960
+ };
2961
+ const virtualPaymentSettlement = isDeferredPayment ? null : await this.buildVirtualSettlementSubmitData(virtualOrderData, terminalPaymentMethod);
2962
+ assertCheckoutCartUnchanged();
2963
+ const submitsTerminalVirtualPayment = Boolean(terminalPaymentMethod && virtualPaymentSettlement?.payments.length);
2964
+ const virtualSettlement = isDeferredPayment ? virtualOrderData : virtualPaymentSettlement;
2937
2965
  // this.store.order.persistTempOrder();
2938
2966
  const inferredPaymentStatus = isDeferredPayment ? undefined : this.getSubmitPaymentStatus(params?.paymentStatus);
2939
2967
  const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
@@ -2972,9 +3000,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2972
3000
  } : configuredEnhancePayload;
2973
3001
  const submitParams = {
2974
3002
  cacheId: this.cacheId,
2975
- platform: this.otherParams?.platform,
3003
+ platform: virtualPaymentChannel === 'kiosk' ? 'kiosk' : this.otherParams?.platform,
2976
3004
  businessCode: this.otherParams?.businessCode || this.otherParams?.business_code,
2977
- channel: this.getSubmitOrderSalesChannel(),
3005
+ channel: virtualPaymentChannel === 'kiosk' ? 'kiosk' : this.getSubmitOrderSalesChannel(),
2978
3006
  type: this.otherParams?.type,
2979
3007
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
2980
3008
  ...(isDeferredPayment ? {
@@ -2998,9 +3026,27 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2998
3026
  ...(virtualSettlement ? {
2999
3027
  enhancePayload: (payload, ctx) => {
3000
3028
  const callerPayload = enhancePayload ? enhancePayload(payload, ctx) : payload;
3029
+ if (terminalPaymentMethod && virtualPaymentSettlement) {
3030
+ assertCheckoutCartUnchanged();
3031
+ if (virtualPaymentChannel === 'kiosk') {
3032
+ const currentMethod = this.store.order?.getTerminalVirtualCurrencyPaymentMethod('kiosk');
3033
+ if (this.getTerminalVirtualCurrencyChannel() !== 'kiosk' || currentMethod?.id !== terminalPaymentMethod.id) {
3034
+ throw (0, _inventory.salesGuardError)('The payment method changed. Please try again.');
3035
+ }
3036
+ }
3037
+ const summary = callerPayload.summary ?? payload.summary;
3038
+ const orderAmount = _decimal.default.max(0, summary?.total_amount ?? 0).toDecimalPlaces(2);
3039
+ const payment = callerPayload.payments?.find(item => item.code === terminalPaymentMethod.code);
3040
+ if (!orderAmount.eq(payment?.amount ?? 0)) {
3041
+ throw (0, _inventory.salesGuardError)('The cart changed. Please try again.');
3042
+ }
3043
+ }
3001
3044
  const currencySettlementConfig = callerPayload.metadata?.currency_settlement_config || {};
3002
3045
  return {
3003
3046
  ...callerPayload,
3047
+ ...(submitsTerminalVirtualPayment ? {
3048
+ payment_status: 'paid'
3049
+ } : {}),
3004
3050
  metadata: {
3005
3051
  ...(callerPayload.metadata || {}),
3006
3052
  currency_settlement_config: {
@@ -3019,7 +3065,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
3019
3065
  enhancePayload
3020
3066
  } : {})
3021
3067
  };
3022
- return this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
3068
+ return !submitsTerminalVirtualPayment && this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
3023
3069
  }
3024
3070
  pendingLocalEftposFinalizations = new Map();
3025
3071
  async finalizeLocalEftposPayment(params) {
@@ -3919,6 +3965,22 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
3919
3965
  getPaymentMethods() {
3920
3966
  return [...this.paymentMethodsCache];
3921
3967
  }
3968
+ async checkTerminalVirtualCurrencyPaymentMethod(channel) {
3969
+ if (!this.store.order) return false;
3970
+ try {
3971
+ await this.store.order.refreshTerminalVirtualCurrencyPaymentMethod(channel);
3972
+ return true;
3973
+ } catch {
3974
+ return false;
3975
+ }
3976
+ }
3977
+ hasPosVirtualCurrencyPaymentMethod() {
3978
+ return this.checkTerminalVirtualCurrencyPaymentMethod('pos');
3979
+ }
3980
+ async hasTerminalVirtualCurrencyPaymentMethod() {
3981
+ const channel = this.getTerminalVirtualCurrencyChannel();
3982
+ return channel ? this.checkTerminalVirtualCurrencyPaymentMethod(channel) : false;
3983
+ }
3922
3984
  findCashPaymentMethod(paymentMethods, paymentMethodId) {
3923
3985
  return paymentMethods.find(method => {
3924
3986
  if (method?.enabled === false || method?.enable === false) return false;
@@ -85,7 +85,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
85
85
  * 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
86
86
  */
87
87
  loadSalesDetail(orderIdOrParams: number | string | LoadSalesDetailParams): Promise<ISalesDetail>;
88
- scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
88
+ scanPromotionCode(code: string, customerId?: number, options?: {
89
+ productVouchersOnly?: boolean;
90
+ }): Promise<BaseSalesScanCodeResult>;
89
91
  private hydrateOrderCustomerFromScanDiscounts;
90
92
  private getDiscountCustomerId;
91
93
  resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
@@ -474,7 +474,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
474
474
  }
475
475
  return sales;
476
476
  }
477
- async scanPromotionCode(code, customerId) {
477
+ async scanPromotionCode(code, customerId, options) {
478
+ if (options?.productVouchersOnly && (customerId === 0 || customerId === 1)) {
479
+ return super.scanPromotionCode(code, customerId, options);
480
+ }
478
481
  if (!this.store.order) throw new Error('order 模块未初始化');
479
482
  const raw = await this.store.order.scanCode(code, customerId);
480
483
  const scannedList = raw.scannedDiscountList || [];
@@ -24,6 +24,7 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
24
24
  products: import("../../../modules/Order/types").OrderSubmitProduct[];
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
+ product_tax_fee?: string | undefined;
27
28
  small_ticket_data_flag?: number | undefined;
28
29
  status: string;
29
30
  metadata: Record<string, any>;
@@ -4,5 +4,5 @@ import type { GlobalScanFormattedResult } from './formatGlobalScan';
4
4
  export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
5
5
  loadCustomerDiscounts(): Promise<Record<string, any>[]>;
6
6
  }
7
- /** Resolve the scanned account, then collect all of that customer's vouchers. */
7
+ /** Collect vouchers by member account or by scan code for a walk-in. */
8
8
  export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
@@ -4,25 +4,64 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.applyProductVoucherCollectionScan = applyProductVoucherCollectionScan;
7
+ var _cartView = require("../cartView");
7
8
  var _applyGlobalScan = require("./applyGlobalScan");
8
- /** Resolve the scanned account, then collect all of that customer's vouchers. */
9
+ /** Collect vouchers by member account or by scan code for a walk-in. */
9
10
  async function applyProductVoucherCollectionScan(host, formatted, bridge) {
10
11
  const assertCurrent = () => {
11
12
  if (bridge.isCurrent?.() === false) {
12
13
  throw new DOMException('Scan session ended', 'AbortError');
13
14
  }
14
15
  };
16
+ assertCurrent();
15
17
  const isPass = formatted.searchType === 'walletPass';
16
- // Order numbers and wristbands resolve through batch-search. Their returned
17
- // passes identify the customer; they are not the collection's voucher list.
18
+ const customerId = formatted.customerId ?? formatted.data?.id ?? formatted.data?.customer_id;
19
+ if (isPass && customerId != null && customerId !== '' && (0, _cartView.isWalkInCustomer)({
20
+ id: customerId
21
+ })) {
22
+ if (formatted.isWalletPassUnavailableAtStore) {
23
+ return {
24
+ status: 'failed',
25
+ reason: 'invalid_data'
26
+ };
27
+ }
28
+ if (!bridge.applyPromotionCode) return {
29
+ status: 'failed',
30
+ reason: 'no_bridge'
31
+ };
32
+ const promotion = await bridge.applyPromotionCode(formatted.scanCode, Number(customerId), {
33
+ productVouchersOnly: true,
34
+ suppressFailureNotification: true
35
+ });
36
+ assertCurrent();
37
+ if (!Array.isArray(promotion.scannedDiscountList)) {
38
+ return {
39
+ status: 'failed',
40
+ reason: 'entry_resolution_failed'
41
+ };
42
+ }
43
+ const redemption = {
44
+ source: 'scan',
45
+ vouchers: promotion.scannedDiscountList
46
+ };
47
+ return promotion.isAccepted ?? promotion.isAvailable ? {
48
+ status: 'success',
49
+ kind: 'promotion',
50
+ redemption
51
+ } : {
52
+ status: 'failed',
53
+ reason: 'not_found',
54
+ redemption
55
+ };
56
+ }
57
+
18
58
  // Resolve source-shop IDs before reusing the wallet customer-binding flow.
19
59
  const customerScan = isPass ? {
20
60
  ...formatted,
21
61
  searchType: 'wallet',
22
- customerId: formatted.customerId ?? formatted.data?.id ?? formatted.data?.customer_id,
62
+ customerId,
23
63
  isCrossShopWallet: true
24
64
  } : formatted;
25
- assertCurrent();
26
65
  const result = await (0, _applyGlobalScan.applyGlobalScan)({
27
66
  ...host,
28
67
  setOrderCustomer: customer => {
@@ -10,6 +10,8 @@ exports.CheckoutImpl = void 0;
10
10
  var _BaseModule = require("../../modules/BaseModule");
11
11
  var _decimal = _interopRequireDefault(require("decimal.js"));
12
12
  var _Order = require("../../modules/Order");
13
+ var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
14
+ var _orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
13
15
  var _Payment = require("../../modules/Payment");
14
16
  var _types = require("./types");
15
17
  Object.keys(_types).forEach(function (key) {
@@ -458,6 +460,7 @@ class CheckoutImpl extends _BaseModule.BaseModule {
458
460
  params.orderData.tax_fee = params.totalInfo?.total?.tax;
459
461
 
460
462
  // 保存原始订单数据和小计数据到状态中
463
+ params.orderData.bookings?.forEach(_bookingUuid.assignBookingUuid);
461
464
  this.store.localOrderData = params.orderData;
462
465
  this.store.cartSummary = params.cartSummary;
463
466
 
@@ -590,6 +593,24 @@ class CheckoutImpl extends _BaseModule.BaseModule {
590
593
  // 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
591
594
  const allOrders = await this.payment.getOrderListAsync();
592
595
  const existingOrder = allOrders.find(o => String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId));
596
+
597
+ // POS 再次保存会重建预约行;按已有行标识复用上次保存的 UUID。
598
+ const previousBookings = existingOrder?.order_info?.original_order_data?.bookings;
599
+ const previousUuids = new Map();
600
+ if (Array.isArray(previousBookings)) {
601
+ for (const booking of previousBookings) {
602
+ const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
603
+ if (uid && booking.uuid !== undefined) previousUuids.set(uid, booking.uuid);
604
+ }
605
+ }
606
+ for (const booking of params.orderData.bookings || []) {
607
+ const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
608
+ if (uid && previousUuids.has(uid)) {
609
+ booking.uuid ?? (booking.uuid = previousUuids.get(uid));
610
+ previousUuids.delete(uid);
611
+ }
612
+ (0, _bookingUuid.assignBookingUuid)(booking);
613
+ }
593
614
  if (existingOrder) {
594
615
  // 🔧 新增: 如果传入了 existPayment,需要更新支付项列表
595
616
  if (params.existPayment && params.existPayment.length > 0) {
@@ -149,6 +149,7 @@ export interface LocalOrderData {
149
149
  * 本地预订项
150
150
  */
151
151
  export interface LocalBookingItem {
152
+ uuid?: string | null;
152
153
  /** ID */
153
154
  id: number;
154
155
  /** 数量 */
@@ -881,12 +881,18 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
881
881
  let bookings = payload.bookings || [];
882
882
  let scheduleDate = payload.schedule_date;
883
883
  if (!tempOrder.order_id && bookings.length === 0) {
884
+ const extend = tempOrder._extend ?? (tempOrder._extend = {});
885
+ if (!extend.scanOrderBookingUuid) {
886
+ extend.scanOrderBookingUuid = (0, _utils2.createUuidV4)();
887
+ this.store.order?.persistTempOrder?.();
888
+ }
884
889
  const bookingStart = this.getShopTime(now);
885
890
  const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
886
891
  // Add elapsed minutes before formatting both ends so DST changes are respected.
887
892
  const bookingEnd = this.getShopTime(new Date(now.getTime() + bookingDuration * 60_000));
888
893
  scheduleDate = bookingStart.dateTime;
889
894
  bookings = [(0, _utils2.normalizeSubmitBooking)({
895
+ uuid: extend.scanOrderBookingUuid,
890
896
  relation_id: 0,
891
897
  form_id: 0,
892
898
  start_time: bookingStart.time,
@@ -38,6 +38,7 @@ var _smartPricing = require("./utils/smartPricing");
38
38
  var _slotMerge = require("./utils/slotMerge");
39
39
  var _utils3 = require("../../modules/Order/utils");
40
40
  var _Order = require("../../modules/Order");
41
+ var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
41
42
  var _types4 = require("../RegisterAndLogin/types");
42
43
  var _decimal = _interopRequireDefault(require("decimal.js"));
43
44
  var _Holder = require("../../modules/Holder");
@@ -1197,6 +1198,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1197
1198
  if (!mapping) return;
1198
1199
  const tempOrder = this.store.order.ensureTempOrder();
1199
1200
  const matchesCurrent = (meta, pid) => !!meta?.venue_booking && String(meta?.resource_id) === String(resourceId) && Number(pid) === Number(productId);
1201
+ const previousBookings = (tempOrder.bookings || []).filter(row => row.uuid && matchesCurrent(row.metadata, row.metadata?.product_id ?? row.product?.product_id));
1200
1202
  tempOrder.products = tempOrder.products.filter(p => !matchesCurrent(p.metadata, p.product_id));
1201
1203
  tempOrder.bookings = (tempOrder.bookings || []).filter(b => {
1202
1204
  if (!b.metadata?.venue_booking) return true;
@@ -1332,7 +1334,10 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1332
1334
  productUid,
1333
1335
  childResources: childRawResources
1334
1336
  });
1335
- tempOrder.bookings.push(booking);
1337
+ // A resized or split interval can reuse its original UUID once.
1338
+ const original = previousBookings.findIndex(row => `${row.start_date} ${String(row.start_time).slice(0, 5)}` < group.endTime && `${row.end_date} ${String(row.end_time).slice(0, 5)}` > group.startTime);
1339
+ if (original >= 0) booking.uuid = previousBookings.splice(original, 1)[0].uuid;
1340
+ tempOrder.bookings.push((0, _bookingUuid.ensureBookingUuid)(booking));
1336
1341
  }
1337
1342
 
1338
1343
  // 获取表单信息
@@ -2,6 +2,9 @@
2
2
  * Normalize the runtime platform passed through solution/module otherParams.
3
3
  */
4
4
  export declare function normalizeRuntimePlatform(platform: unknown): string;
5
+ export declare function isPosTerminalPlatform(platform: unknown): boolean;
6
+ export type TerminalVirtualCurrencyChannel = 'pos' | 'kiosk';
7
+ export declare function resolveTerminalVirtualCurrencyChannel(platform: unknown, businessCode: unknown): TerminalVirtualCurrencyChannel | undefined;
5
8
  /**
6
9
  * PC and H5 are authenticated-customer clients rather than staff terminals.
7
10
  */
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isCustomerUserPlatform = isCustomerUserPlatform;
7
+ exports.isPosTerminalPlatform = isPosTerminalPlatform;
7
8
  exports.isSelfServicePlatform = isSelfServicePlatform;
8
9
  exports.normalizeRuntimePlatform = normalizeRuntimePlatform;
10
+ exports.resolveTerminalVirtualCurrencyChannel = resolveTerminalVirtualCurrencyChannel;
9
11
  const CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
10
12
  const SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
11
13
 
@@ -15,6 +17,14 @@ const SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
15
17
  function normalizeRuntimePlatform(platform) {
16
18
  return String(platform ?? '').trim().toLowerCase();
17
19
  }
20
+ function isPosTerminalPlatform(platform) {
21
+ const normalized = normalizeRuntimePlatform(platform);
22
+ return normalized === 'pos' || normalized === 'webpos';
23
+ }
24
+ function resolveTerminalVirtualCurrencyChannel(platform, businessCode) {
25
+ if (isPosTerminalPlatform(platform)) return 'pos';
26
+ if (normalizeRuntimePlatform(platform) === 'kiosk' && businessCode === 'retail') return 'kiosk';
27
+ }
18
28
 
19
29
  /**
20
30
  * PC and H5 are authenticated-customer clients rather than staff terminals.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.232",
4
+ "version": "2.3.234",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",