@pisell/pisellos 2.3.228 → 2.3.230

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 (39) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Customer/types.d.ts +4 -0
  3. package/dist/modules/Order/index.d.ts +1 -1
  4. package/dist/modules/Order/index.js +123 -79
  5. package/dist/modules/Order/types.d.ts +2 -0
  6. package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
  7. package/dist/modules/Order/utils/bookingUuid.js +24 -0
  8. package/dist/modules/Order/utils.js +2 -0
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Summary/utils.d.ts +1 -1
  11. package/dist/solution/BaseSales/index.js +3 -0
  12. package/dist/solution/BookingByStep/index.d.ts +3 -3
  13. package/dist/solution/BookingTicket/index.d.ts +1 -0
  14. package/dist/solution/BookingTicket/index.js +49 -18
  15. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +6 -6
  16. package/dist/solution/Checkout/index.js +104 -69
  17. package/dist/solution/Checkout/types.d.ts +1 -0
  18. package/dist/solution/ScanOrder/index.js +10 -2
  19. package/dist/solution/VenueBooking/index.js +522 -490
  20. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  21. package/lib/modules/Customer/types.d.ts +4 -0
  22. package/lib/modules/Order/index.d.ts +1 -1
  23. package/lib/modules/Order/index.js +44 -6
  24. package/lib/modules/Order/types.d.ts +2 -0
  25. package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
  26. package/lib/modules/Order/utils/bookingUuid.js +25 -0
  27. package/lib/modules/Order/utils.js +5 -1
  28. package/lib/modules/Product/index.d.ts +1 -1
  29. package/lib/modules/Summary/utils.d.ts +1 -1
  30. package/lib/solution/BaseSales/index.js +3 -0
  31. package/lib/solution/BookingByStep/index.d.ts +3 -3
  32. package/lib/solution/BookingTicket/index.d.ts +1 -0
  33. package/lib/solution/BookingTicket/index.js +27 -6
  34. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +6 -6
  35. package/lib/solution/Checkout/index.js +21 -0
  36. package/lib/solution/Checkout/types.d.ts +1 -0
  37. package/lib/solution/ScanOrder/index.js +6 -0
  38. package/lib/solution/VenueBooking/index.js +6 -1
  39. package/package.json +1 -1
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -44,6 +44,10 @@ export interface ShopGetCustomerListParams {
44
44
  num?: number;
45
45
  /** 搜索关键词 */
46
46
  search?: string;
47
+ /** Full national phone number, without the international calling code. */
48
+ phone?: string;
49
+ /** Exact email lookup, independent from the generic search keyword. */
50
+ email?: string;
47
51
  /** 关联查询参数 */
48
52
  with?: CustomerWith[];
49
53
  /** wallet搜索标识 */
@@ -644,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
644
644
  generateIdempotencyToken(): string;
645
645
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
646
646
  createOrder(params: CommitOrderParams['query']): {
647
- type: "appointment_booking" | "virtual";
647
+ type: "virtual" | "appointment_booking";
648
648
  platform: string;
649
649
  sales_channel: string;
650
650
  order_sales_channel: string;
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "isFulfillmentTimingBooking", {
11
11
  }
12
12
  });
13
13
  var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
14
+ var _bookingUuid = require("./utils/bookingUuid");
14
15
  var _localEftposState = require("./localEftposState");
15
16
  var _BaseModule = require("../BaseModule");
16
17
  var _types = require("./types");
@@ -2585,7 +2586,7 @@ class OrderModule extends _BaseModule.BaseModule {
2585
2586
  booking_uid: bookingUid
2586
2587
  },
2587
2588
  booking: {
2588
- ...params.booking,
2589
+ ...(0, _bookingUuid.ensureBookingUuid)(params.booking),
2589
2590
  is_all: (0, _utils.normalizeBookingIsAll)(params.booking),
2590
2591
  product_uid: productUid,
2591
2592
  sub_type: (0, _utils.normalizeBookingSubType)(params.booking),
@@ -3200,7 +3201,7 @@ class OrderModule extends _BaseModule.BaseModule {
3200
3201
  const tempOrder = this.ensureTempOrder();
3201
3202
  const bookings = tempOrder.bookings || [];
3202
3203
  const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
3203
- const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
3204
+ const nextBooking = (0, _bookingUuid.ensureBookingUuid)((0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]));
3204
3205
  // Keep the first row's identity and position; repair duplicate marked rows only.
3205
3206
  tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
3206
3207
  this.notifyTempOrderChanged();
@@ -3852,6 +3853,16 @@ class OrderModule extends _BaseModule.BaseModule {
3852
3853
  * if (pending) await pending;
3853
3854
  */
3854
3855
  appendProductLineToTempOrder(tempOrder, product, booking, options) {
3856
+ const incomingBookingUuid = booking?.uuid;
3857
+ if (booking && incomingBookingUuid && tempOrder.bookings?.some(item => item.uuid === incomingBookingUuid)) {
3858
+ // Appending a copy creates a different booking; editing uses the update path below.
3859
+ booking = {
3860
+ ...booking,
3861
+ uuid: (0, _utils.createUuidV4)(),
3862
+ id: undefined,
3863
+ schedule_event_id: undefined
3864
+ };
3865
+ }
3855
3866
  const linked = booking ? this.createLinkedProductAndBooking({
3856
3867
  product,
3857
3868
  booking
@@ -4016,6 +4027,12 @@ class OrderModule extends _BaseModule.BaseModule {
4016
4027
  singleLine.num = 1;
4017
4028
  delete singleLine.product_quantity;
4018
4029
  const singleBooking = (0, _lodashEs.cloneDeep)(booking);
4030
+ if (index > 0) {
4031
+ // Both single-add and batch-add quantity splits create separate appointments.
4032
+ delete singleBooking.uuid;
4033
+ delete singleBooking.schedule_event_id;
4034
+ delete singleBooking.id;
4035
+ }
4019
4036
  const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
4020
4037
  const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
4021
4038
  const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
@@ -4266,7 +4283,8 @@ class OrderModule extends _BaseModule.BaseModule {
4266
4283
  const target = live.products[targetIndex];
4267
4284
  const scopeKey = String(target?.metadata?.venue_booking_scope_key || '');
4268
4285
  const targetBookingUid = String(target?.booking_uid || target?.metadata?.booking_uid || '');
4269
- if (!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number(params.product.num ?? 1) !== 1 || target.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_scope_key !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(params.booking.metadata?.unique_identification_number || '') !== targetBookingUid || (live.bookings || []).filter(booking => this.getBookingUniqueIdentificationNumber(booking) === targetBookingUid).length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
4286
+ const targetBookings = (live.bookings || []).filter(row => this.getBookingUniqueIdentificationNumber(row) === targetBookingUid);
4287
+ if (!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number(params.product.num ?? 1) !== 1 || target.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_scope_key !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(params.booking.metadata?.unique_identification_number || '') !== targetBookingUid || targetBookings.length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
4270
4288
  throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
4271
4289
  }
4272
4290
  const children = live.products.filter(line => line.metadata?.venue_booking_role === 'party_extra' && String(line.metadata?.venue_booking_parent_uid || '') === uid);
@@ -4326,7 +4344,9 @@ class OrderModule extends _BaseModule.BaseModule {
4326
4344
  venue_booking_service_datetime: serviceDatetime
4327
4345
  };
4328
4346
  replacement.unique_identification_number = uid;
4329
- await this.appendProductLineToTempOrder(draft, replacement, (0, _lodashEs.cloneDeep)(params.booking), {
4347
+ const replacementBooking = (0, _lodashEs.cloneDeep)(params.booking);
4348
+ replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
4349
+ await this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
4330
4350
  insertAtIndex: targetIndex,
4331
4351
  disableMerge: true,
4332
4352
  beforeCommit
@@ -4734,12 +4754,22 @@ class OrderModule extends _BaseModule.BaseModule {
4734
4754
  ...(normalizedProduct.metadata || {}),
4735
4755
  unique_identification_number: productUid
4736
4756
  };
4757
+ const originalBookingUid = targetProduct.booking_uid || targetProduct.metadata?.booking_uid || preservedBookingUid;
4758
+ const bookings = tempOrder.bookings || [];
4759
+ const eventId = booking.schedule_event_id;
4760
+ const originalBooking = bookings.find(row => Number(eventId) > 0 && String(row.schedule_event_id) === String(eventId)) ?? bookings.find(row => originalBookingUid && row.metadata?.unique_identification_number === originalBookingUid);
4761
+ const {
4762
+ uuid: incomingUuid = originalBooking?.uuid
4763
+ } = booking;
4737
4764
  const linked = this.createLinkedProductAndBooking({
4738
4765
  product: {
4739
4766
  ...normalizedProduct,
4740
4767
  unique_identification_number: productUid
4741
4768
  },
4742
- booking
4769
+ booking: {
4770
+ ...booking,
4771
+ uuid: originalBooking?.uuid || incomingUuid
4772
+ }
4743
4773
  });
4744
4774
  this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
4745
4775
  normalizedProduct = {
@@ -5001,9 +5031,13 @@ class OrderModule extends _BaseModule.BaseModule {
5001
5031
  throw new Error('[Order] 目标 booking 不存在,无法更新');
5002
5032
  }
5003
5033
  const targetBooking = tempOrder.bookings[bookingIndex] || {};
5034
+ const {
5035
+ uuid: incomingUuid = targetBooking.uuid
5036
+ } = updates;
5004
5037
  const nextBooking = {
5005
5038
  ...targetBooking,
5006
5039
  ...updates,
5040
+ uuid: targetBooking.uuid || incomingUuid,
5007
5041
  metadata: {
5008
5042
  ...(targetBooking.metadata || {}),
5009
5043
  ...(updates.metadata || {}),
@@ -5013,6 +5047,7 @@ class OrderModule extends _BaseModule.BaseModule {
5013
5047
  unique_identification_number: bookingUid
5014
5048
  }
5015
5049
  };
5050
+ (0, _bookingUuid.assignBookingUuid)(nextBooking);
5016
5051
  this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
5017
5052
  nextBooking.is_all = (0, _utils.normalizeBookingIsAll)(nextBooking);
5018
5053
  nextBooking.sub_type = (0, _utils.normalizeBookingSubType)(nextBooking);
@@ -5713,6 +5748,7 @@ class OrderModule extends _BaseModule.BaseModule {
5713
5748
  * @returns 后端返回的订单数据(包含订单ID等)
5714
5749
  */
5715
5750
  async createOrderByCheckout(params) {
5751
+ params.bookings?.forEach(_bookingUuid.assignBookingUuid);
5716
5752
  // 过滤掉由在线店铺下单的 payment 支付数据
5717
5753
  const onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
5718
5754
  params.payments = params.payments?.filter(p => !onlineStorePaymentCodeList.includes(p.code));
@@ -5800,6 +5836,7 @@ class OrderModule extends _BaseModule.BaseModule {
5800
5836
  url,
5801
5837
  query
5802
5838
  } = params;
5839
+ query.bookings?.forEach(_bookingUuid.assignBookingUuid);
5803
5840
  const fetchUrl = url || '/order/sales/checkout';
5804
5841
  const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
5805
5842
  const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
@@ -6154,8 +6191,9 @@ class OrderModule extends _BaseModule.BaseModule {
6154
6191
  })) : [];
6155
6192
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(b => {
6156
6193
  const booking = this.normalizeHydratedBookingHolder(b || {});
6194
+ const submitted = (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0;
6157
6195
  return {
6158
- ...booking,
6196
+ ...(submitted ? (0, _bookingUuid.ensureBookingUuid)(booking) : booking),
6159
6197
  is_all: (0, _utils.normalizeBookingIsAll)(booking),
6160
6198
  sub_type: (0, _utils.normalizeBookingSubType)(booking)
6161
6199
  };
@@ -617,6 +617,8 @@ export interface CommitOrderParams {
617
617
  };
618
618
  }
619
619
  export interface OrderSubmitBooking {
620
+ /** Stable booking identity, created once and shared with external allocations. */
621
+ uuid?: string | null;
620
622
  relation_id?: string;
621
623
  form_id?: string;
622
624
  collect_pax?: number;
@@ -0,0 +1,4 @@
1
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
2
+ export declare function ensureBookingUuid<T extends Record<string, any>>(booking: T): T;
3
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
4
+ export declare function assignBookingUuid(booking: Record<string, any> | null | undefined): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assignBookingUuid = assignBookingUuid;
7
+ exports.ensureBookingUuid = ensureBookingUuid;
8
+ var _orderCollectionIdentity = require("./orderCollectionIdentity");
9
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
10
+ function ensureBookingUuid(booking) {
11
+ if (booking.uuid) return booking;
12
+ // Only an explicit null confirms that an existing booking needs a UUID when saved.
13
+ if (booking.uuid !== null && Number(booking.schedule_event_id || booking.id) > 0) return booking;
14
+ return {
15
+ ...booking,
16
+ uuid: (0, _orderCollectionIdentity.createUuidV4)()
17
+ };
18
+ }
19
+
20
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
21
+ function assignBookingUuid(booking) {
22
+ if (!booking) return;
23
+ const resolved = ensureBookingUuid(booking);
24
+ if (resolved !== booking) booking.uuid = resolved.uuid;
25
+ }
@@ -140,6 +140,7 @@ var _manualProductDiscount = require("./utils/manualProductDiscount");
140
140
  var _utils = require("../Holder/utils");
141
141
  var _utils2 = require("../../solution/ScanOrder/utils");
142
142
  var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
143
+ var _bookingUuid = require("./utils/bookingUuid");
143
144
  var _salesNotes = require("./salesNotes");
144
145
  var _pickupTiming = require("./pickupTiming");
145
146
  var _holderRelations = require("./holderRelations");
@@ -1664,7 +1665,10 @@ function buildSubmitPayload(params) {
1664
1665
  delivery_type: tempOrder.delivery_type || 'shop_service',
1665
1666
  schedule_date: scheduleDate,
1666
1667
  // created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
1667
- bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
1668
+ bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => {
1669
+ (0, _bookingUuid.assignBookingUuid)(booking);
1670
+ return normalizeSubmitBooking(booking);
1671
+ }),
1668
1672
  payments: tempOrder.payments || [],
1669
1673
  relation_forms: tempOrder.relation_forms || [],
1670
1674
  // contacts: tempOrder.contacts || [],
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "normal" | "session" | "duration";
53
53
  }
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -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];
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 1 | 2 | 6 | 4 | 5 | 3;
345
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -361,7 +361,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
361
361
  count: number;
362
362
  left: number;
363
363
  summaryCount: number;
364
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
364
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
365
365
  }[];
366
366
  /**
367
367
  * 找到多个资源的公共可用时间段
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
392
+ getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -295,6 +295,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
295
295
  private getCustomerContactOrderKey;
296
296
  replaceTempOrder(...args: Parameters<BaseSalesImpl['replaceTempOrder']>): Promise<import("../../modules/Order/types").OrderTempOrder>;
297
297
  private applyDefaultOrderCustomerContactInfo;
298
+ private withAccountNameFallback;
298
299
  private prefillOrderCustomerContactInfo;
299
300
  protected waitForOrderCustomerContactInfo(): Promise<void>;
300
301
  validateContactInfo(): Promise<void>;
@@ -1168,21 +1168,41 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1168
1168
  tempOrder: this.getTempOrder()
1169
1169
  });
1170
1170
  }
1171
+ withAccountNameFallback(contact, customer) {
1172
+ let next = contact;
1173
+ // Saved booking contacts take precedence. Only missing name fields fall back
1174
+ // to the account profile; phone/email keep their existing contact-info source.
1175
+ for (const field of ['first_name', 'last_name']) {
1176
+ if (typeof contact?.[field] === 'string' && contact[field].trim()) continue;
1177
+ const name = customer[field];
1178
+ if (typeof name !== 'string' || !name.trim()) continue;
1179
+ if (next === contact) next = {
1180
+ ...contact
1181
+ };
1182
+ next[field] = name.trim();
1183
+ }
1184
+ return next;
1185
+ }
1171
1186
  prefillOrderCustomerContactInfo(customer, customerChanged) {
1172
1187
  const order = this.getTempOrder();
1173
1188
  const customerId = Number(order?.customer_id);
1174
- if (!order || !Number.isInteger(customerId) || customerId <= 1 || order.contacts_info != null || order._extend?.contactInfoEdited) return;
1189
+ if (!order || !Number.isInteger(customerId) || customerId <= 1 || order._extend?.contactInfoEdited) return;
1175
1190
  // A restored new cart may already have its customer ID. Existing sales keep their snapshot,
1176
1191
  // even when it is empty; only an explicit customer switch replaces it.
1177
1192
  if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
1178
- const contact = (0, _contactInfo.extractCustomerContactInfo)(customer);
1193
+ const contact = order.contacts_info ?? (0, _contactInfo.extractCustomerContactInfo)(customer);
1179
1194
  if (contact) {
1180
1195
  this.orderCustomerContactRequest = null;
1181
- void this.applyDefaultOrderCustomerContactInfo(contact);
1196
+ const next = this.withAccountNameFallback(contact, customer);
1197
+ if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
1182
1198
  return;
1183
1199
  }
1184
1200
  // A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
1185
- if (customer.contacts_info !== undefined) return;
1201
+ if (customer.contacts_info !== undefined) {
1202
+ const next = this.withAccountNameFallback(null, customer);
1203
+ if (next) void this.applyDefaultOrderCustomerContactInfo(next);
1204
+ return;
1205
+ }
1186
1206
  const userPlatform = (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
1187
1207
  const getAuthenticatedCustomerId = () => Number(this.core?.getPlugin?.('user')?.get?.()?.id);
1188
1208
  if (userPlatform && getAuthenticatedCustomerId() !== customerId) return;
@@ -1208,12 +1228,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1208
1228
  }
1209
1229
  // POS and physical Kiosk share the /shop request plugin and current-shop customer resolver.
1210
1230
  const resolved = await this.resolveCustomerById(customerId);
1211
- return Number(resolved?.id) === customerId ? (0, _contactInfo.extractCustomerContactInfo)(resolved) : null;
1231
+ return resolved && Number(resolved.id) === customerId ? this.withAccountNameFallback((0, _contactInfo.extractCustomerContactInfo)(resolved), resolved) : null;
1212
1232
  };
1213
1233
  pending.promise = loadContact().then(async value => {
1214
1234
  const current = this.getTempOrder();
1215
1235
  if (this.orderCustomerContactRequest !== pending || this.getCustomerContactOrderKey() !== orderKey || Number(current?.customer_id) !== customerId || scope !== this.getCustomerContactScope() || current?._extend?.contactInfoEdited || current?.contacts_info != null || userPlatform && getAuthenticatedCustomerId() !== customerId) return;
1216
- if (value) await this.applyDefaultOrderCustomerContactInfo(value);
1236
+ const next = this.withAccountNameFallback(value, customer);
1237
+ if (next) await this.applyDefaultOrderCustomerContactInfo(next);
1217
1238
  }).catch(() => {
1218
1239
  // A failed default does not prevent manual entry; a subsequent sync can retry.
1219
1240
  if (this.orderCustomerContactRequest === pending) this.orderCustomerContactRequest = null;
@@ -26,12 +26,16 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
27
  small_ticket_data_flag?: number | undefined;
28
28
  metadata: Record<string, any>;
29
+ type: string;
29
30
  note: string;
31
+ holder: Record<string, any> | null;
32
+ relation_forms: any[];
33
+ holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
30
34
  order_id: number | null;
35
+ external_sale_number: string;
31
36
  order_number: string | null;
32
37
  shop_order_number: string | null;
33
38
  shop_full_order_number: string | null;
34
- type: string;
35
39
  business_code?: string | undefined;
36
40
  sales_channel: string;
37
41
  order_sales_channel: string;
@@ -58,14 +62,10 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
58
62
  schedule_date: string;
59
63
  bookings: any[];
60
64
  payments: any[];
65
+ refunds?: any[] | undefined;
61
66
  surcharges: any[];
62
- relation_forms: any[];
63
67
  contacts: any[];
64
68
  contacts_info: Record<string, any> | null;
65
- holder: Record<string, any> | null;
66
- external_sale_number: string;
67
- holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
68
- refunds?: any[] | undefined;
69
69
  order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
70
70
  };
71
71
  export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
@@ -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
  /** 数量 */
@@ -877,10 +877,16 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
877
877
  const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
878
878
  let bookings = payload.bookings || [];
879
879
  if (!tempOrder.order_id && bookings.length === 0) {
880
+ const extend = tempOrder._extend ?? (tempOrder._extend = {});
881
+ if (!extend.scanOrderBookingUuid) {
882
+ extend.scanOrderBookingUuid = (0, _utils2.createUuidV4)();
883
+ this.store.order?.persistTempOrder?.();
884
+ }
880
885
  const bookingStart = (0, _dayjs.default)(now);
881
886
  const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
882
887
  const bookingEnd = bookingStart.add(bookingDuration, 'minute');
883
888
  bookings = [(0, _utils2.normalizeSubmitBooking)({
889
+ uuid: extend.scanOrderBookingUuid,
884
890
  relation_id: 0,
885
891
  form_id: 0,
886
892
  start_time: bookingStart.format('HH:mm'),
@@ -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
  // 获取表单信息
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.228",
4
+ "version": "2.3.230",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",