@pisell/pisellos 2.3.195 → 2.3.197

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 (59) hide show
  1. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  2. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  3. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  4. package/dist/modules/BookingContext/utils/index.js +1 -0
  5. package/dist/modules/BookingContext/utils/productExtend.d.ts +6 -0
  6. package/dist/modules/BookingContext/utils/productExtend.js +21 -0
  7. package/dist/modules/Order/index.d.ts +3 -0
  8. package/dist/modules/Order/index.js +127 -46
  9. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  10. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  11. package/dist/modules/Product/index.d.ts +1 -1
  12. package/dist/modules/ResourcePlanner/planner.js +24 -0
  13. package/dist/modules/ResourcePlanner/types.d.ts +7 -0
  14. package/dist/server/index.js +207 -193
  15. package/dist/server/modules/order/index.js +2 -1
  16. package/dist/shared/receipt/small-ticket.d.ts +3 -0
  17. package/dist/shared/receipt/small-ticket.js +26 -3
  18. package/dist/solution/BookingByStep/index.d.ts +2 -2
  19. package/dist/solution/BookingTicket/index.d.ts +2 -14
  20. package/dist/solution/BookingTicket/index.js +8 -4
  21. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  22. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  23. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  24. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  25. package/dist/solution/OrderInvoicePreview/index.js +13 -8
  26. package/dist/solution/UnifiedBookingSales/index.d.ts +16 -2
  27. package/dist/solution/UnifiedBookingSales/index.js +1670 -1377
  28. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
  29. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
  30. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  31. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  32. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  33. package/lib/modules/BookingContext/utils/index.js +11 -0
  34. package/lib/modules/BookingContext/utils/productExtend.d.ts +6 -0
  35. package/lib/modules/BookingContext/utils/productExtend.js +23 -0
  36. package/lib/modules/Order/index.d.ts +3 -0
  37. package/lib/modules/Order/index.js +85 -16
  38. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  39. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  40. package/lib/modules/Product/index.d.ts +1 -1
  41. package/lib/modules/ResourcePlanner/planner.js +23 -0
  42. package/lib/modules/ResourcePlanner/types.d.ts +7 -0
  43. package/lib/server/index.js +21 -5
  44. package/lib/server/modules/order/index.js +2 -1
  45. package/lib/shared/receipt/small-ticket.d.ts +3 -0
  46. package/lib/shared/receipt/small-ticket.js +24 -1
  47. package/lib/solution/BookingByStep/index.d.ts +2 -2
  48. package/lib/solution/BookingTicket/index.d.ts +2 -14
  49. package/lib/solution/BookingTicket/index.js +4 -2
  50. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  51. package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
  52. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  53. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  54. package/lib/solution/OrderInvoicePreview/index.js +6 -1
  55. package/lib/solution/UnifiedBookingSales/index.d.ts +16 -2
  56. package/lib/solution/UnifiedBookingSales/index.js +176 -36
  57. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
  58. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
  59. package/package.json +1 -1
@@ -1731,6 +1731,7 @@ class Server {
1731
1731
  customer_id,
1732
1732
  ids,
1733
1733
  extension_type,
1734
+ application_code,
1734
1735
  strategy_context
1735
1736
  } = data;
1736
1737
  const {
@@ -1765,6 +1766,7 @@ class Server {
1765
1766
  schedule_datetime,
1766
1767
  customer_id,
1767
1768
  extension_type,
1769
+ application_code,
1768
1770
  strategy_context
1769
1771
  }
1770
1772
  });
@@ -1780,6 +1782,7 @@ class Server {
1780
1782
  schedule_datetime,
1781
1783
  customer_id,
1782
1784
  extension_type,
1785
+ application_code,
1783
1786
  strategy_context
1784
1787
  });
1785
1788
  if (subscriberId && typeof callback === 'function') {
@@ -1881,6 +1884,7 @@ class Server {
1881
1884
  schedule_date,
1882
1885
  schedule_datetime: scheduleDatetime,
1883
1886
  product_id: productId,
1887
+ application_code: data?.application_code ?? this.extractQueryParam(url || '', 'application_code') ?? undefined,
1884
1888
  ...(data && typeof data === 'object' ? {
1885
1889
  customer_id: data.customer_id,
1886
1890
  strategy_context: data.strategy_context
@@ -3515,8 +3519,13 @@ class Server {
3515
3519
  }
3516
3520
  getSmallTicketShopInfo() {
3517
3521
  const shopInfo = this.getAppData('shop_info') || {};
3522
+ // WebPOS getData does not expose core/default_domain; read the business
3523
+ // shop model directly when the expanded shop_info has not loaded it yet.
3524
+ const shopCore = this.app?.models?.getStore?.().getDataByModel?.('core', 'core') || this.app?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || {};
3518
3525
  return {
3519
3526
  ...shopInfo,
3527
+ default_domain: shopInfo.default_domain || shopCore.default_domain,
3528
+ private_domain_protocol: shopInfo.private_domain_protocol || shopCore.private_domain_protocol,
3520
3529
  currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
3521
3530
  currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
3522
3531
  tax_title: shopInfo.tax_title || this.getAppData('tax_title'),
@@ -4369,7 +4378,11 @@ class Server {
4369
4378
  });
4370
4379
  return;
4371
4380
  }
4372
- const localOrder = await this.order.getLocalOrderByLookup(lookup);
4381
+ let localOrder = await this.order.getLocalOrderByLookup(lookup);
4382
+ const orderId = data?.order_id ?? data?.orderId;
4383
+ if (!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup)) {
4384
+ localOrder = await this.order.getLocalOrderByLookup(orderId);
4385
+ }
4373
4386
  if (!localOrder) {
4374
4387
  this.logWarning(`${title}: 本地订单不存在,跳过核销状态更新`, {
4375
4388
  lookup,
@@ -6074,8 +6087,11 @@ class Server {
6074
6087
  customer_id,
6075
6088
  extension_type,
6076
6089
  product_id,
6090
+ application_code,
6077
6091
  strategy_context
6078
6092
  } = context;
6093
+ // 仅 Kiosk 查询额外按商品销售渠道过滤。
6094
+ const isVisibleProduct = product => (product?.status || 'published') === 'published' && (application_code !== 'kiosk' || Array.isArray(product?.channel_application) && product.channel_application.includes('kiosk'));
6079
6095
  const queryIds = Array.isArray(ids) ? ids.map(id => Number(id)).filter(id => Number.isFinite(id)) : [];
6080
6096
  this.logInfo('computeProductQueryResult 开始', {
6081
6097
  menuListIdsCount: menu_list_ids?.length ?? 0,
@@ -6123,7 +6139,7 @@ class Server {
6123
6139
  count: productsWithPrice.length,
6124
6140
  ids: uniqueIds
6125
6141
  });
6126
- const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(p => (p?.status || 'published') === 'published');
6142
+ const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(isVisibleProduct);
6127
6143
  const extensionFilteredProducts = this.filterProductsByExtensionTypes(filteredProducts, extension_type);
6128
6144
  (0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
6129
6145
  mode: 'ids',
@@ -6153,7 +6169,7 @@ class Server {
6153
6169
  count: allProductsWithPrice.length,
6154
6170
  productId: pid
6155
6171
  });
6156
- const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(p => (p?.status || 'published') === 'published'), extension_type);
6172
+ const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(isVisibleProduct), extension_type);
6157
6173
  const item = published.find(p => Number(p.id) === pid) ?? null;
6158
6174
  (0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
6159
6175
  mode: 'single',
@@ -6182,7 +6198,7 @@ class Server {
6182
6198
  });
6183
6199
  const tStatus = performance.now();
6184
6200
  const beforeStatusCount = filteredProducts.length;
6185
- filteredProducts = filteredProducts.filter(p => (p?.status || 'published') === 'published');
6201
+ filteredProducts = filteredProducts.filter(isVisibleProduct);
6186
6202
  (0, _product.perfMark)('computeQuery.filterByStatus(extensionType)', performance.now() - tStatus, {
6187
6203
  before: beforeStatusCount,
6188
6204
  after: filteredProducts.length
@@ -6265,7 +6281,7 @@ class Server {
6265
6281
  });
6266
6282
  const tStatus = performance.now();
6267
6283
  const beforeStatusCount = filteredProducts.length;
6268
- filteredProducts = filteredProducts.filter(p => (p?.status || "published") === 'published');
6284
+ filteredProducts = filteredProducts.filter(isVisibleProduct);
6269
6285
  (0, _product.perfMark)('computeQuery.filterByStatus', performance.now() - tStatus, {
6270
6286
  before: beforeStatusCount,
6271
6287
  after: filteredProducts.length
@@ -8,6 +8,7 @@ var _lodashEs = require("lodash-es");
8
8
  var _localEftposState = require("../../../modules/Order/localEftposState");
9
9
  var _dayjs = _interopRequireDefault(require("dayjs"));
10
10
  var _BaseModule = require("../../../modules/BaseModule");
11
+ var _unpaidAmountGap = require("../../../modules/Order/unpaidAmountGap");
11
12
  var _orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
12
13
  var _types = require("./types");
13
14
  var _paymentUtils = require("../../../modules/Order/payment-utils");
@@ -251,7 +252,7 @@ class OrderModule extends _BaseModule.BaseModule {
251
252
  this.logInfo('订单子项身份已规范化', context);
252
253
  }
253
254
  }
254
- return result.order;
255
+ return (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(result.order);
255
256
  }
256
257
 
257
258
  /**
@@ -15,6 +15,9 @@ export interface SmallTicketShopInfo {
15
15
  currency_code?: string;
16
16
  primary_locale?: string;
17
17
  timezone?: string;
18
+ /** Customer-facing shop domain, supplied by the host shop context. */
19
+ default_domain?: string;
20
+ private_domain_protocol?: string;
18
21
  [key: string]: any;
19
22
  }
20
23
  export interface BuildSmallTicketDataParams {
@@ -7,6 +7,7 @@ exports.buildSmallTicketData = buildSmallTicketData;
7
7
  exports.hasSmallTicketData = hasSmallTicketData;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _decimal = _interopRequireDefault(require("decimal.js"));
10
+ var _unpaidAmountGap = require("../../modules/Order/unpaidAmountGap");
10
11
  var _holderRelations = require("../../modules/Order/holderRelations");
11
12
  var _pickupTiming = require("../../modules/Order/pickupTiming");
12
13
  var _templateVisibility = require("./templateVisibility");
@@ -300,7 +301,8 @@ const LABELS = {
300
301
  }
301
302
  };
302
303
  function buildSmallTicketData(params) {
303
- const order = params.includeReceiptKeys ? copyReceiptSource(params.order || {}) : params.order || {};
304
+ const normalizedOrder = (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(params.order || {});
305
+ const order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
304
306
  const shopInfo = params.shopInfo || {};
305
307
  const locales = resolveLocales(shopInfo, params.locales);
306
308
  const productMap = params.productMap || {};
@@ -393,10 +395,14 @@ function buildBaseData(params) {
393
395
  financials
394
396
  } = params;
395
397
  const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
398
+ const rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
396
399
  return {
397
400
  shop_name: stringify(shopInfo.name || order.shop_name),
398
401
  note: stringify(order.note),
399
402
  shop_order_number: stringify(order.shop_order_number),
403
+ ...(rewardClaim ? {
404
+ reward_claim: rewardClaim
405
+ } : {}),
400
406
  order_number: orderNumber,
401
407
  shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
402
408
  shop_phone: stringify(shopInfo.phone || order.shop_phone),
@@ -415,6 +421,23 @@ function buildBaseData(params) {
415
421
  } : {})
416
422
  };
417
423
  }
424
+ function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
425
+ const domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
426
+ const orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
427
+ if (!domain || !orderNumber) return undefined;
428
+ try {
429
+ const protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
430
+ const base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : `${protocol}://${domain}`);
431
+ if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
432
+ return undefined;
433
+ }
434
+ const url = new URL('/claim-purchase-rewards', base);
435
+ url.searchParams.set('shop_order_number', orderNumber);
436
+ return url.toString();
437
+ } catch {
438
+ return undefined;
439
+ }
440
+ }
418
441
  function buildProducts(order, locale, productMap) {
419
442
  const products = Array.isArray(order.products) ? order.products : [];
420
443
  const allergyByProductUid = buildProductAllergyMap(order, locale);
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
366
366
  * 获取当前的客户搜索条件
367
367
  * @returns 当前搜索条件
368
368
  */
369
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
369
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
370
370
  /**
371
371
  * 获取客户列表状态(包含滚动加载相关状态)
372
372
  * @returns 客户状态
@@ -485,19 +485,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
485
485
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
486
486
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
487
487
  */
488
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
489
- action: "reloadCatalog";
490
- } | {
491
- action: "add";
492
- cacheItem: any;
493
- } | {
494
- action: "requiresDetail";
495
- payload: AddProductRequiresDetailPayload;
496
- } | {
497
- action: "requiresBookingEdit";
498
- cacheItem: any;
499
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
500
- };
488
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
501
489
  /** 规格弹窗 callback 后的第二段决策。 */
502
490
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
503
491
  /**
@@ -1623,7 +1623,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1623
1623
  presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
1624
1624
  ...(extra || {}),
1625
1625
  orderSessionId: this.getOrderSessionId() ?? undefined,
1626
- isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId)
1626
+ isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
1627
+ platform: String(this.otherParams?.platform || '').trim().toLowerCase()
1627
1628
  };
1628
1629
  }
1629
1630
 
@@ -1717,7 +1718,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1717
1718
  ...(extra || {}),
1718
1719
  channel: this.getSubmitOrderSalesChannel(),
1719
1720
  orderSessionId: this.getOrderSessionId() ?? undefined,
1720
- isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId)
1721
+ isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
1722
+ platform: String(this.otherParams?.platform || '').trim().toLowerCase()
1721
1723
  };
1722
1724
  }
1723
1725
 
@@ -41,6 +41,8 @@ export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecide
41
41
  * @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
42
42
  */
43
43
  export interface AddProductRequiresDetailPayload {
44
+ /** Same prepared decision cache supplied to the Host; never a separate Flow preflight. */
45
+ preparedCacheItem?: any;
44
46
  item: ProductData | Record<string, any>;
45
47
  /** UI 需展示的子弹窗开关。 */
46
48
  showConfig: {
@@ -15,6 +15,7 @@ exports.prepareBookingCacheItem = prepareBookingCacheItem;
15
15
  exports.transformDetailToProductAndBooking = transformDetailToProductAndBooking;
16
16
  var _dayjs = _interopRequireDefault(require("dayjs"));
17
17
  var _BookingContext = require("../../../modules/BookingContext");
18
+ var _resolveUniqueCartDetail = require("./resolveUniqueCartDetail");
18
19
  var _transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
19
20
  var _weighingProductSku = require("./weighingProductSku");
20
21
  var _platform = require("../../../utils/platform");
@@ -43,6 +44,7 @@ function needsSpecDetailModal(item) {
43
44
  * 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
44
45
  */
45
46
  function needsBookingEdit(cacheItem, ctx) {
47
+ if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) return (0, _BookingContext.calendarBookingNeedsInput)(cacheItem);
46
48
  if (isNormalBookingProduct(cacheItem)) return false;
47
49
  if ((0, _platform.isSelfServicePlatform)(ctx?.channel)) return true;
48
50
  const isAutoAllocationOn = ctx?.isAutoAllocationOn || (() => true);
@@ -61,13 +63,26 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
61
63
  */
62
64
  function decideAddProduct(item, ctx) {
63
65
  const derivedCtx = withDerivedBookingCtx(ctx);
64
- if (needsSpecDetailModal(item)) {
66
+ const calendarRange = (0, _BookingContext.getCalendarBookingRange)(item, derivedCtx);
67
+ const uniqueValue = calendarRange ? (0, _resolveUniqueCartDetail.resolveUniqueCartDetailValue)(item) : null;
68
+ const selectedItem = uniqueValue ? {
69
+ ...item,
70
+ cartDetailValue: uniqueValue,
71
+ isOpenDetailModal: false
72
+ } : item;
73
+ if (needsSpecDetailModal(selectedItem)) {
74
+ const preparedCacheItem = calendarRange ? prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx) : undefined;
65
75
  return {
66
76
  action: 'requiresDetail',
67
- payload: buildRequiresDetailPayload(item, derivedCtx)
77
+ payload: {
78
+ ...buildRequiresDetailPayload(item, derivedCtx),
79
+ ...(preparedCacheItem ? {
80
+ preparedCacheItem
81
+ } : {})
82
+ }
68
83
  };
69
84
  }
70
- const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx);
85
+ const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
71
86
  if (needsBookingEdit(cacheItem, derivedCtx)) {
72
87
  return {
73
88
  action: 'requiresBookingEdit',
@@ -147,6 +162,21 @@ function isMultiDayLike(cacheItem) {
147
162
  * `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
148
163
  */
149
164
  function prepareBookingCacheItem(cacheItem, ctx) {
165
+ if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) {
166
+ if (cacheItem._data?.calendarBookingPreparationKey === (0, _BookingContext.calendarBookingPreparationKey)(cacheItem, ctx)) return cacheItem;
167
+ return (0, _BookingContext.getProductExtend)({
168
+ cacheItem,
169
+ ctx: ctx,
170
+ isDisabledTime: true
171
+ });
172
+ }
173
+ if (ctx?.bookingTimeRangeFromCalendar && (cacheItem.duration?.type === 'days' || cacheItem.duration_type === 'days' || cacheItem._extend?.sub_type === 'days')) {
174
+ ctx = {
175
+ ...ctx,
176
+ bookingTimeRangeFromCalendar: undefined,
177
+ resourceIdFromCalendar: undefined
178
+ };
179
+ }
150
180
  if (ctx?.rememberedTime === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
151
181
  return cacheItem;
152
182
  }
@@ -0,0 +1,8 @@
1
+ type RecordValue = Record<string, any>;
2
+ /**
3
+ * Resolve a whole SKU only when the original configuration proves one legal
4
+ * result. A default, a stock-filtered remainder, or missing detail is not proof
5
+ * of uniqueness. The input product and its existing selections stay untouched.
6
+ */
7
+ export declare function resolveUniqueCartDetailValue(product: RecordValue): RecordValue | null;
8
+ export {};
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveUniqueCartDetailValue = resolveUniqueCartDetailValue;
7
+ const flag = value => value === true || value === 1 || value === '1';
8
+ const cleared = value => value === false || value === 0 || value === '0';
9
+ const enabled = item => item && !flag(item.disabled) && !cleared(item.is_enabled) && item.deleted_at == null;
10
+ const sellable = item => enabled(item) && (!flag(item.is_track) || flag(item.over_sold) || Number(item.stock_quantity) > 0);
11
+ const bound = (value, fallback = 0) => {
12
+ if (value == null || value === '') return fallback;
13
+ if (typeof value !== 'number' && typeof value !== 'string') return null;
14
+ const number = Number(value);
15
+ return Number.isInteger(number) && number >= 0 ? number : null;
16
+ };
17
+ const validId = value => (typeof value === 'number' || typeof value === 'string') && Number.isSafeInteger(Number(value)) && Number(value) > 0;
18
+
19
+ /** A choice is unique only if its complete allowed quantity interval is one value. */
20
+ function fixedQuantity(minimums, maximums) {
21
+ const min = Math.max(1, ...minimums);
22
+ const max = Math.min(...maximums.filter(value => value > 0), Infinity);
23
+ return min === max ? min : null;
24
+ }
25
+ function configuredGroups(product, key, countKey) {
26
+ const groups = product[key];
27
+ if (groups == null && product[countKey] == null) return null;
28
+ const count = bound(product[countKey]);
29
+ if (count == null || groups != null && !Array.isArray(groups)) return null;
30
+ if (count > 0 && (!Array.isArray(groups) || groups.length !== count)) return null;
31
+ return groups || [];
32
+ }
33
+
34
+ /**
35
+ * Resolve a whole SKU only when the original configuration proves one legal
36
+ * result. A default, a stock-filtered remainder, or missing detail is not proof
37
+ * of uniqueness. The input product and its existing selections stay untouched.
38
+ */
39
+ function resolveUniqueCartDetailValue(product) {
40
+ if (!product || !validId(product.id ?? product.product_id) || flag(product.open_sold_weight)) return null;
41
+ const productId = product.id ?? product.product_id;
42
+ const existing = product.cartDetailValue;
43
+ const hasConfiguredSku = flag(product.is_variant) || Number(product.variant_count) > 0 || Number(product.option_group_count) > 0 || Number(product.bundle_group_count) > 0 || product.option_group?.length > 0 || product.bundle_group?.length > 0 || product.bundle_groups?.length > 0 || product.variant_group?.length > 0;
44
+ if (existing && !hasConfiguredSku && !(existing.option?.length || existing.bundle?.length)) {
45
+ return {
46
+ ...existing,
47
+ product_id: productId,
48
+ quantity: 1
49
+ };
50
+ }
51
+ const knowsVariantShape = cleared(product.is_variant) || product.variant_count === 0 || product.variant_count === '0' || Array.isArray(product.variant) || Array.isArray(product.variant_group);
52
+ if (!knowsVariantShape) return null;
53
+ const optionGroups = configuredGroups(product, 'option_group', 'option_group_count');
54
+ const bundleKey = product.bundle_group != null ? 'bundle_group' : 'bundle_groups';
55
+ const bundleGroups = configuredGroups(product, bundleKey, 'bundle_group_count');
56
+ if (!optionGroups || !bundleGroups) return null;
57
+ const value = {
58
+ ...(product.cartDetailValue || {}),
59
+ product_id: productId,
60
+ product_variant_id: 0,
61
+ option: [],
62
+ bundle: [],
63
+ quantity: 1
64
+ };
65
+ const hasVariant = flag(product.is_variant) || Number(product.variant_count) > 0 || Array.isArray(product.variant_group) && product.variant_group.length > 0 || Array.isArray(product.variant) && product.variant.length > 0;
66
+ if (hasVariant) {
67
+ if (!Array.isArray(product.variant) || product.variant.length !== 1 || Number(product.variant_count) > 0 && Number(product.variant_count) !== 1) return null;
68
+ const [variant] = product.variant;
69
+ if (!validId(variant?.id) || !sellable(variant)) return null;
70
+ value.product_variant_id = variant.id;
71
+ if (variant.price == null || variant.price === '' || !Number.isFinite(Number(variant.price)) || Number(variant.price) < 0) return null;
72
+ value.price = variant.price;
73
+ value.production_code = variant.production_code ?? variant.code ?? '';
74
+ }
75
+ for (const group of optionGroups) {
76
+ // Do not silently remove configured alternatives that are disabled or out of stock.
77
+ if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.option_item) || group.option_item.length !== 1) return null;
78
+ const [item] = group.option_item;
79
+ if (!validId(item?.id) || !sellable(item)) return null;
80
+ const multiple = flag(group.is_multiple);
81
+ const groupMin = bound(group.min_quantity);
82
+ const groupMax = bound(group.max_quantity);
83
+ const itemMin = bound(item.min_quantity);
84
+ const itemMax = bound(item.max_quantity, 1);
85
+ if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null)) return null;
86
+ const advanced = multiple && flag(group.metadata?.advanced_settings_enabled);
87
+ const minTypes = advanced ? bound(group.metadata?.option_types_config?.min) : 0;
88
+ const maxTypes = advanced ? bound(group.metadata?.option_types_config?.max) : 0;
89
+ if (minTypes == null || maxTypes == null || minTypes > 1 || maxTypes > 0 && maxTypes < minTypes) return null;
90
+ const required = multiple ? groupMin > 0 || minTypes > 0 : flag(group.required);
91
+ if (!required) return null;
92
+ const quantity = fixedQuantity([itemMin, ...(multiple ? [groupMin] : [])], [itemMax, ...(multiple ? [groupMax] : [])]);
93
+ if (!quantity) return null;
94
+ const price = item.price ?? item.add_price ?? 0;
95
+ value.option.push({
96
+ ...item,
97
+ id: item.id,
98
+ product_option_item_id: item.id,
99
+ option_group_item_id: item.id,
100
+ option_group_id: group.id,
101
+ product_id: productId,
102
+ quantity,
103
+ num: quantity,
104
+ price,
105
+ original_price: price
106
+ });
107
+ }
108
+ for (const group of bundleGroups) {
109
+ if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.bundle_item) || group.bundle_item.length !== 1) return null;
110
+ const [item] = group.bundle_item;
111
+ if (!validId(item?.id) || !validId(item?.bundle_product_id) || !sellable(item) || item.option_group?.length || item.variant_group?.length || item.variant?.length || item.bundle_group?.length || item.bundle_groups?.length || flag(item.is_variant) || flag(item.open_sold_weight) || Number(item.variant_count) > 0 || Number(item.option_group_count) > 0 || Number(item.bundle_group_count) > 0) return null;
112
+ const groupMin = bound(group.min_quantity);
113
+ const groupMax = bound(group.max_quantity);
114
+ const itemMin = bound(item.min_quantity);
115
+ const itemMax = bound(item.max_quantity);
116
+ if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null) || groupMin <= 0) return null;
117
+ const quantity = fixedQuantity([groupMin, itemMin], [groupMax, itemMax]);
118
+ if (!quantity) return null;
119
+ value.bundle.push({
120
+ ...item,
121
+ id: item.id,
122
+ group_id: group.id,
123
+ bundle_group_id: group.id,
124
+ _bundle_product_id: item.bundle_product_id,
125
+ quantity,
126
+ num: quantity,
127
+ option: []
128
+ });
129
+ }
130
+ const key = [productId, value.product_variant_id, ...value.option.map(item => `o${item.option_group_id}:${item.id}:${item.quantity}`), ...value.bundle.map(item => `b${item.group_id}:${item.id}:${item.quantity}`), ...(value.session ? [`s${value.session.key ?? value.session.id ?? ''}`] : [])].join('_');
131
+ return {
132
+ ...value,
133
+ key,
134
+ rowKey: key
135
+ };
136
+ }
@@ -130,9 +130,12 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
130
130
  const task = (async () => {
131
131
  const [snapshot, context, template] = await Promise.all([this.loadSource(input), this.loadContext(input), (0, _loadCustomerInvoiceLayout.loadCustomerInvoiceTemplate)(this.request, input)]);
132
132
  const source = (0, _loadPaymentMethods.withPaymentMethodNames)(snapshot, context.methods);
133
- const getData = this.core.getPlugin('app')?.getData?.();
133
+ const appPlugin = this.core.getPlugin('app');
134
+ const getData = appPlugin?.getData?.();
134
135
  if (getData?.('shop_id') != null && String(getData('shop_id')) !== String(input.shopId)) throw new Error('Invoice shop changed');
135
136
  const coreData = getData?.('core');
137
+ const hostApp = appPlugin?.getApp?.();
138
+ const shopCore = hostApp?.models?.getStore?.().getDataByModel?.('core', 'core') || hostApp?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || coreData?.core || coreData || {};
136
139
  const shop = {
137
140
  ...(coreData?.core?.shop || coreData?.shop || {}),
138
141
  ...(getData?.('shop_info') || {}),
@@ -142,6 +145,8 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
142
145
  tax_country_code: getData('tax_country_code')
143
146
  } : {})
144
147
  };
148
+ shop.default_domain || (shop.default_domain = shopCore.default_domain);
149
+ shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
145
150
  if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
146
151
  const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
147
152
  const remembered = this.languageSelection?.code;
@@ -5,8 +5,8 @@ import type { AddProductDecideContext } from '../BookingTicket/utils/addProductD
5
5
  import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
6
6
  import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
7
7
  import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
8
- import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
9
- import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
8
+ import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityRequirementSelection, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
9
+ import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRange, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
10
10
  import type { BusinessAvailability } from '../../modules/BusinessAvailability';
11
11
  import { BookingTicket } from '../BookingTicket';
12
12
  import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
@@ -122,6 +122,18 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
122
122
  * 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
123
123
  */
124
124
  prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
125
+ /** Reuse an approved calendar cache; only the final commit may mutate the order. */
126
+ prepareDirectAddCalendarBooking(cacheItem: any, options?: {
127
+ bookingCount?: number;
128
+ availabilityCommitGuard?: () => void;
129
+ }): Promise<{
130
+ cacheItem: any;
131
+ contextId: string;
132
+ candidate: ContextualProductTimeRange;
133
+ requirementSelections: AvailabilityRequirementSelection[];
134
+ partySize: number;
135
+ bookingCount: number;
136
+ } | null>;
125
137
  private resolveAvailabilityPrepareDefaults;
126
138
  private buildAvailabilityPrepareKey;
127
139
  private clearAvailabilityRemoteResourceState;
@@ -309,6 +321,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
309
321
  stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
310
322
  /** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
311
323
  supportsVenueTicketExtras(): boolean;
324
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
325
+ supportsVenueExtraHolders(): boolean;
312
326
  /**
313
327
  * Adds one retail line without replacing the cart's existing retail selection.
314
328
  * This is intentionally separate from stageRetailProducts(), whose contract is