@pisell/pisellos 2.3.196 → 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 (33) hide show
  1. package/dist/modules/Order/index.d.ts +3 -0
  2. package/dist/modules/Order/index.js +127 -46
  3. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  4. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  5. package/dist/modules/Product/index.d.ts +1 -1
  6. package/dist/server/index.js +180 -176
  7. package/dist/server/modules/order/index.js +2 -1
  8. package/dist/shared/receipt/small-ticket.d.ts +3 -0
  9. package/dist/shared/receipt/small-ticket.js +26 -3
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +1 -13
  12. package/dist/solution/OrderInvoicePreview/index.js +13 -8
  13. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
  14. package/dist/solution/UnifiedBookingSales/index.js +66 -57
  15. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
  16. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
  17. package/lib/modules/Order/index.d.ts +3 -0
  18. package/lib/modules/Order/index.js +85 -16
  19. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  20. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  21. package/lib/modules/Product/index.d.ts +1 -1
  22. package/lib/server/index.js +16 -4
  23. package/lib/server/modules/order/index.js +2 -1
  24. package/lib/shared/receipt/small-ticket.d.ts +3 -0
  25. package/lib/shared/receipt/small-ticket.js +24 -1
  26. package/lib/solution/BookingByStep/index.d.ts +1 -1
  27. package/lib/solution/BookingTicket/index.d.ts +1 -13
  28. package/lib/solution/OrderInvoicePreview/index.js +6 -1
  29. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
  30. package/lib/solution/UnifiedBookingSales/index.js +37 -33
  31. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
  32. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
  33. package/package.json +1 -1
@@ -34,6 +34,7 @@ import { cloneDeep, isEqual } from 'lodash-es';
34
34
  import { isLocalFinalizedPayment, LOCAL_EFTPOS_FINALIZED, LOCAL_EFTPOS_REFRESH_REQUIRED, requiresLocalPaymentRefresh } from "../../../modules/Order/localEftposState";
35
35
  import dayjs from 'dayjs';
36
36
  import { BaseModule } from "../../../modules/BaseModule";
37
+ import { normalizeUnpaidOrderAmountGap } from "../../../modules/Order/unpaidAmountGap";
37
38
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
38
39
  import { OrderHooks } from "./types";
39
40
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "../../../modules/Order/payment-utils";
@@ -375,7 +376,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
375
376
  this.logInfo('订单子项身份已规范化', context);
376
377
  }
377
378
  }
378
- return result.order;
379
+ return normalizeUnpaidOrderAmountGap(result.order);
379
380
  }
380
381
 
381
382
  /**
@@ -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 {
@@ -20,6 +20,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
21
21
  import dayjs from 'dayjs';
22
22
  import Decimal from 'decimal.js';
23
+ import { normalizeUnpaidOrderAmountGap } from "../../modules/Order/unpaidAmountGap";
23
24
  import { getProductHolderRelations, hasProductBooking } from "../../modules/Order/holderRelations";
24
25
  import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
25
26
  import { resolveInvoiceDataVisibility } from "./templateVisibility";
@@ -318,7 +319,8 @@ var LABELS = {
318
319
  }
319
320
  };
320
321
  export function buildSmallTicketData(params) {
321
- var order = params.includeReceiptKeys ? copyReceiptSource(params.order || {}) : params.order || {};
322
+ var normalizedOrder = normalizeUnpaidOrderAmountGap(params.order || {});
323
+ var order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
322
324
  var shopInfo = params.shopInfo || {};
323
325
  var locales = resolveLocales(shopInfo, params.locales);
324
326
  var productMap = params.productMap || {};
@@ -409,10 +411,14 @@ function buildBaseData(params) {
409
411
  currencySymbol = params.currencySymbol,
410
412
  financials = params.financials;
411
413
  var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
412
- return _objectSpread({
414
+ var rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
415
+ return _objectSpread(_objectSpread({
413
416
  shop_name: stringify(shopInfo.name || order.shop_name),
414
417
  note: stringify(order.note),
415
- shop_order_number: stringify(order.shop_order_number),
418
+ shop_order_number: stringify(order.shop_order_number)
419
+ }, rewardClaim ? {
420
+ reward_claim: rewardClaim
421
+ } : {}), {}, {
416
422
  order_number: orderNumber,
417
423
  shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
418
424
  shop_phone: stringify(shopInfo.phone || order.shop_phone),
@@ -430,6 +436,23 @@ function buildBaseData(params) {
430
436
  updated_at: formatDateTime(order.updated_at, locale)
431
437
  } : {});
432
438
  }
439
+ function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
440
+ var domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
441
+ var orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
442
+ if (!domain || !orderNumber) return undefined;
443
+ try {
444
+ var protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
445
+ var base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : "".concat(protocol, "://").concat(domain));
446
+ if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
447
+ return undefined;
448
+ }
449
+ var url = new URL('/claim-purchase-rewards', base);
450
+ url.searchParams.set('shop_order_number', orderNumber);
451
+ return url.toString();
452
+ } catch (_unused) {
453
+ return undefined;
454
+ }
455
+ }
433
456
  function buildProducts(order, locale, productMap) {
434
457
  var products = Array.isArray(order.products) ? order.products : [];
435
458
  var allergyByProductUid = buildProductAllergyMap(order, locale);
@@ -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<"duration" | "normal" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -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
  /**
@@ -187,8 +187,8 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
187
187
  error: null
188
188
  });
189
189
  var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
190
- var _this3$core$getPlugin, _this3$core$getPlugin2, _coreData$core, _this3$languageSelect;
191
- var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, getData, coreData, shop, languageOptions, remembered, selected, locale, result;
190
+ var _appPlugin$getData, _appPlugin$getApp, _hostApp$models, _hostApp$models$getSt, _hostApp$models$getSt2, _hostApp$models$getSt3, _hostApp$data, _hostApp$data$getStor, _hostApp$data$getStor2, _hostApp$data$getStor3, _coreData$core, _this3$languageSelect;
191
+ var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, appPlugin, getData, coreData, hostApp, shopCore, shop, languageOptions, remembered, selected, locale, result;
192
192
  return _regeneratorRuntime().wrap(function _callee$(_context) {
193
193
  while (1) switch (_context.prev = _context.next) {
194
194
  case 0:
@@ -201,23 +201,28 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
201
201
  context = _yield$Promise$all2[1];
202
202
  template = _yield$Promise$all2[2];
203
203
  source = withPaymentMethodNames(snapshot, context.methods);
204
- getData = (_this3$core$getPlugin = _this3.core.getPlugin('app')) === null || _this3$core$getPlugin === void 0 || (_this3$core$getPlugin2 = _this3$core$getPlugin.getData) === null || _this3$core$getPlugin2 === void 0 ? void 0 : _this3$core$getPlugin2.call(_this3$core$getPlugin);
204
+ appPlugin = _this3.core.getPlugin('app');
205
+ getData = appPlugin === null || appPlugin === void 0 || (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
205
206
  if (!((getData === null || getData === void 0 ? void 0 : getData('shop_id')) != null && String(getData('shop_id')) !== String(input.shopId))) {
206
- _context.next = 11;
207
+ _context.next = 12;
207
208
  break;
208
209
  }
209
210
  throw new Error('Invoice shop changed');
210
- case 11:
211
+ case 12:
211
212
  coreData = getData === null || getData === void 0 ? void 0 : getData('core');
213
+ hostApp = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
214
+ shopCore = (hostApp === null || hostApp === void 0 || (_hostApp$models = hostApp.models) === null || _hostApp$models === void 0 || (_hostApp$models$getSt = _hostApp$models.getStore) === null || _hostApp$models$getSt === void 0 || (_hostApp$models$getSt2 = (_hostApp$models$getSt3 = _hostApp$models$getSt.call(_hostApp$models)).getDataByModel) === null || _hostApp$models$getSt2 === void 0 ? void 0 : _hostApp$models$getSt2.call(_hostApp$models$getSt3, 'core', 'core')) || (hostApp === null || hostApp === void 0 || (_hostApp$data = hostApp.data) === null || _hostApp$data === void 0 || (_hostApp$data = _hostApp$data.store) === null || _hostApp$data === void 0 || (_hostApp$data$getStor = _hostApp$data.getStore) === null || _hostApp$data$getStor === void 0 || (_hostApp$data$getStor2 = (_hostApp$data$getStor3 = _hostApp$data$getStor.call(_hostApp$data)).getDataByModel) === null || _hostApp$data$getStor2 === void 0 ? void 0 : _hostApp$data$getStor2.call(_hostApp$data$getStor3, 'core', 'core')) || (coreData === null || coreData === void 0 ? void 0 : coreData.core) || coreData || {};
212
215
  shop = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (coreData === null || coreData === void 0 || (_coreData$core = coreData.core) === null || _coreData$core === void 0 ? void 0 : _coreData$core.shop) || (coreData === null || coreData === void 0 ? void 0 : coreData.shop) || {}), (getData === null || getData === void 0 ? void 0 : getData('shop_info')) || {}), input.shop), context.shop), getData !== null && getData !== void 0 && getData('tax_country_code') ? {
213
216
  tax_country_code: getData('tax_country_code')
214
217
  } : {});
218
+ shop.default_domain || (shop.default_domain = shopCore.default_domain);
219
+ shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
215
220
  if (!(generation !== _this3.generation || _this3.disposed)) {
216
- _context.next = 15;
221
+ _context.next = 20;
217
222
  break;
218
223
  }
219
224
  throw new Error('Invoice request superseded');
220
- case 15:
225
+ case 20:
221
226
  languageOptions = resolveCustomerInvoiceLanguages(template.language, input.locale);
222
227
  remembered = (_this3$languageSelect = _this3.languageSelection) === null || _this3$languageSelect === void 0 ? void 0 : _this3$languageSelect.code;
223
228
  selected = languageOptions.find(function (option) {
@@ -254,7 +259,7 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
254
259
  error: null
255
260
  });
256
261
  return _context.abrupt("return", result);
257
- case 22:
262
+ case 27:
258
263
  case "end":
259
264
  return _context.stop();
260
265
  }
@@ -321,6 +321,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
321
321
  stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
322
322
  /** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
323
323
  supportsVenueTicketExtras(): boolean;
324
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
325
+ supportsVenueExtraHolders(): boolean;
324
326
  /**
325
327
  * Adds one retail line without replacing the cart's existing retail selection.
326
328
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -4395,7 +4395,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4395
4395
  assertCurrent: assertCurrent,
4396
4396
  load: function () {
4397
4397
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
4398
- var promise, pricingMenus, menus, onlyIds, onlyCollections, productIds, collections, products, pool;
4398
+ var promise, menuCache, pricingMenus, menus, onlyIds, onlyCollections, productIds, collections, emptySelection, products, pool;
4399
4399
  return _regeneratorRuntime().wrap(function _callee39$(_context40) {
4400
4400
  while (1) switch (_context40.prev = _context40.next) {
4401
4401
  case 0:
@@ -4419,12 +4419,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4419
4419
  if (((_this15$venueCatalogM = _this15.venueCatalogMenus) === null || _this15$venueCatalogM === void 0 ? void 0 : _this15$venueCatalogM.promise) === promise) _this15.venueCatalogMenus = undefined;
4420
4420
  });
4421
4421
  }
4422
- _context40.next = 3;
4423
- return _this15.venueCatalogMenus.promise;
4424
- case 3:
4422
+ menuCache = _this15.venueCatalogMenus;
4423
+ _context40.next = 4;
4424
+ return menuCache.promise;
4425
+ case 4:
4425
4426
  pricingMenus = _context40.sent;
4426
- menus = validateVenueMenus(pricingMenus, menuIds);
4427
4427
  assertCurrent();
4428
+ _context40.prev = 6;
4429
+ menus = validateVenueMenus(pricingMenus, menuIds);
4430
+ _context40.next = 14;
4431
+ break;
4432
+ case 10:
4433
+ _context40.prev = 10;
4434
+ _context40.t0 = _context40["catch"](6);
4435
+ // A malformed selected menu must be fetched again on explicit retry.
4436
+ if (_this15.venueCatalogMenus === menuCache) _this15.venueCatalogMenus = undefined;
4437
+ throw _context40.t0;
4438
+ case 14:
4428
4439
  // A menu query with a date may exclude future members. Read the raw ID union
4429
4440
  // without menu/time/customer pricing filters, then filter collection/all menus locally.
4430
4441
  onlyIds = menus.every(function (menu) {
@@ -4443,15 +4454,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4443
4454
  return String(product.product_collection_id);
4444
4455
  });
4445
4456
  }))) : undefined;
4446
- if (!(onlyIds && !(productIds !== null && productIds !== void 0 && productIds.length))) {
4447
- _context40.next = 14;
4457
+ emptySelection = (productIds === null || productIds === void 0 ? void 0 : productIds.length) === 0 || (collections === null || collections === void 0 ? void 0 : collections.length) === 0;
4458
+ if (!emptySelection) {
4459
+ _context40.next = 23;
4448
4460
  break;
4449
4461
  }
4450
- _context40.t0 = [];
4451
- _context40.next = 17;
4462
+ _context40.t1 = [];
4463
+ _context40.next = 26;
4452
4464
  break;
4453
- case 14:
4454
- _context40.next = 16;
4465
+ case 23:
4466
+ _context40.next = 25;
4455
4467
  return _this15.store.products.loadVenueCatalogPool({
4456
4468
  product_ids: productIds,
4457
4469
  collection: collections,
@@ -4459,16 +4471,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4459
4471
  extension_type: params.extension_type,
4460
4472
  cacheId: _this15.cacheId
4461
4473
  });
4462
- case 16:
4463
- _context40.t0 = _context40.sent;
4464
- case 17:
4465
- products = _context40.t0;
4474
+ case 25:
4475
+ _context40.t1 = _context40.sent;
4476
+ case 26:
4477
+ products = _context40.t1;
4466
4478
  assertCurrent();
4467
4479
  pool = {
4468
4480
  menus: menus,
4469
4481
  pricingMenus: cloneDeep(pricingMenus),
4470
4482
  products: products.filter(function (product) {
4471
- return menus.some(function (menu) {
4483
+ return !('deleted_at' in product && product.deleted_at) && (!product.status || product.status === 'published') && menus.some(function (menu) {
4472
4484
  return productMatchesVenueMenu(product, menu);
4473
4485
  });
4474
4486
  })
@@ -4479,11 +4491,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4479
4491
  _this15.store.products.rememberRawProductQueryResult(cloneDeep(pool.products));
4480
4492
  _this15.store.products.addProduct(cloneDeep(pool.products));
4481
4493
  return _context40.abrupt("return", pool);
4482
- case 24:
4494
+ case 33:
4483
4495
  case "end":
4484
4496
  return _context40.stop();
4485
4497
  }
4486
- }, _callee39);
4498
+ }, _callee39, null, [[6, 10]]);
4487
4499
  }));
4488
4500
  function load() {
4489
4501
  return _load.apply(this, arguments);
@@ -5304,12 +5316,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5304
5316
  quotedSourceProductPrice: quoteSourcePrice
5305
5317
  } : {}));
5306
5318
  if (orderProduct && _typeof(orderProduct) === 'object') {
5319
+ var _sourceProduct$metada3, _sourceProduct$_exten4;
5307
5320
  var venueMetadata = Object.fromEntries(['venue_booking_role', 'venue_booking_parent_uid', 'venue_booking_service_datetime', 'venue_booking_scope_key'].filter(function (key) {
5308
5321
  var _sourceProduct$metada2;
5309
5322
  return ((_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2[key]) !== undefined;
5310
5323
  }).map(function (key) {
5311
5324
  return [key, sourceProduct.metadata[key]];
5312
5325
  }));
5326
+ var isVenueExtra = ownershipKey === 'unified_booking_sales_retail' && ['tickets_extra', 'party_extra'].includes(venueMetadata.venue_booking_role);
5327
+ if (isVenueExtra && ((_sourceProduct$metada3 = sourceProduct.metadata) === null || _sourceProduct$metada3 === void 0 ? void 0 : _sourceProduct$metada3.venue_extra_holder_variant_id) !== undefined) {
5328
+ var _sourceProduct$holder;
5329
+ // null explicitly clears a previous SKU override. The adapter pairs the marker
5330
+ // with its resolved policy, independent of the product's original settings.
5331
+ venueMetadata.venue_extra_holder_variant_id = sourceProduct.metadata.venue_extra_holder_variant_id;
5332
+ var holderConfig = (_sourceProduct$holder = sourceProduct.holder_config) !== null && _sourceProduct$holder !== void 0 ? _sourceProduct$holder : sourceProduct.metadata.holder_config;
5333
+ if (holderConfig) venueMetadata.holder_config = cloneDeep(holderConfig);
5334
+ }
5313
5335
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
5314
5336
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
5315
5337
  orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), venueMetadata), {}, _defineProperty({}, ownershipKey, true), hasDurationQuote || quoteMethod === 'fixed_price' ? {
@@ -5320,6 +5342,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5320
5342
  } : {}), quotationShelfId !== undefined ? {
5321
5343
  quotation_shelf_id: quotationShelfId
5322
5344
  } : {});
5345
+ // Extras use retail order-detail relations even when the catalog product
5346
+ // also has a bookable duration. Order binds the patch to the final line UID.
5347
+ if (isVenueExtra && Array.isArray((_sourceProduct$_exten4 = sourceProduct._extend) === null || _sourceProduct$_exten4 === void 0 ? void 0 : _sourceProduct$_exten4.holder_relations)) {
5348
+ orderProduct._extend = _objectSpread(_objectSpread({}, orderProduct._extend), {}, {
5349
+ holder_relations: cloneDeep(sourceProduct._extend.holder_relations)
5350
+ });
5351
+ }
5323
5352
  }
5324
5353
  return orderProduct;
5325
5354
  }
@@ -5465,6 +5494,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5465
5494
  return true;
5466
5495
  }
5467
5496
 
5497
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
5498
+ }, {
5499
+ key: "supportsVenueExtraHolders",
5500
+ value: function supportsVenueExtraHolders() {
5501
+ return true;
5502
+ }
5503
+
5468
5504
  /**
5469
5505
  * Adds one retail line without replacing the cart's existing retail selection.
5470
5506
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -5532,7 +5568,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5532
5568
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
5533
5569
  case 16:
5534
5570
  if (!(((_metadata2 = orderProduct.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.venue_booking_role) === 'tickets_extra')) {
5535
- _context52.next = 31;
5571
+ _context52.next = 29;
5536
5572
  break;
5537
5573
  }
5538
5574
  _order = this.getTempOrder();
@@ -5554,27 +5590,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5554
5590
  }
5555
5591
  };
5556
5592
  guard();
5557
- // Retail extras are order-owned, with their own UID and no Holder/booking.
5593
+ // Retail extras are order-owned, with their own UID and no booking.
5558
5594
  delete orderProduct.unique_identification_number;
5559
5595
  delete meta.unique_identification_number;
5560
5596
  delete meta.venue_booking_parent_uid;
5561
- orderProduct.holder_config = {
5562
- status: 'disable',
5563
- required: 0
5564
- };
5565
- meta.holder_config = {
5566
- status: 'disable',
5567
- required: 0
5568
- };
5569
5597
  return _context52.abrupt("return", this.addProductToOrder(orderProduct, undefined, {
5570
5598
  disableMerge: true,
5571
5599
  availabilityCommitGuard: guard,
5572
5600
  availabilityCommitTargetGuard: isCurrentOrder,
5573
5601
  salesNotes: params.salesNotes
5574
5602
  }));
5575
- case 31:
5603
+ case 29:
5576
5604
  if (!(((_metadata3 = orderProduct.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.venue_booking_role) === 'party_extra')) {
5577
- _context52.next = 47;
5605
+ _context52.next = 43;
5578
5606
  break;
5579
5607
  }
5580
5608
  _order2 = this.getTempOrder();
@@ -5584,9 +5612,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5584
5612
  // Its parent UID owns the extra; the parent's appointment time does not price it.
5585
5613
  _purchaseDatetime = String(_meta.venue_booking_service_datetime || '');
5586
5614
  normalizedPurchaseDatetime = _purchaseDatetime.length === 16 ? "".concat(_purchaseDatetime, ":00") : _purchaseDatetime;
5587
- _identity = [_order2 === null || _order2 === void 0 ? void 0 : _order2.order_id, _order2 === null || _order2 === void 0 ? void 0 : _order2.external_sale_number];
5615
+ _identity = [_order2 === null || _order2 === void 0 ? void 0 : _order2.order_id, _order2 === null || _order2 === void 0 ? void 0 : _order2.external_sale_number, _order2 === null || _order2 === void 0 ? void 0 : _order2.customer_id];
5588
5616
  _isCurrentOrder = function _isCurrentOrder() {
5589
- return _this17.getTempOrder() === _order2 && (_order2 === null || _order2 === void 0 ? void 0 : _order2.order_id) === _identity[0] && (_order2 === null || _order2 === void 0 ? void 0 : _order2.external_sale_number) === _identity[1];
5617
+ return _this17.getTempOrder() === _order2 && (_order2 === null || _order2 === void 0 ? void 0 : _order2.order_id) === _identity[0] && (_order2 === null || _order2 === void 0 ? void 0 : _order2.external_sale_number) === _identity[1] && (_order2 === null || _order2 === void 0 ? void 0 : _order2.customer_id) === _identity[2];
5590
5618
  };
5591
5619
  _guard = function _guard() {
5592
5620
  var _params$availabilityC2, _parent$metadata, _parent$metadata2;
@@ -5599,27 +5627,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5599
5627
  _guard();
5600
5628
  delete orderProduct.unique_identification_number;
5601
5629
  delete orderProduct.metadata.unique_identification_number;
5602
- orderProduct.holder_config = {
5603
- status: 'disable',
5604
- required: 0
5605
- };
5606
- orderProduct.metadata.holder_config = {
5607
- status: 'disable',
5608
- required: 0
5609
- };
5610
5630
  return _context52.abrupt("return", this.addProductToOrder(orderProduct, undefined, {
5611
5631
  disableMerge: true,
5612
5632
  availabilityCommitGuard: _guard,
5613
5633
  availabilityCommitTargetGuard: _isCurrentOrder,
5614
5634
  salesNotes: params.salesNotes
5615
5635
  }));
5616
- case 47:
5636
+ case 43:
5617
5637
  return _context52.abrupt("return", this.addProductToOrder(orderProduct, undefined, _objectSpread(_objectSpread({}, params.availabilityCommitGuard ? {
5618
5638
  availabilityCommitGuard: params.availabilityCommitGuard
5619
5639
  } : {}), params.salesNotes ? {
5620
5640
  salesNotes: params.salesNotes
5621
5641
  } : {})));
5622
- case 48:
5642
+ case 44:
5623
5643
  case "end":
5624
5644
  return _context52.stop();
5625
5645
  }
@@ -8095,19 +8115,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8095
8115
  break;
8096
8116
  }
8097
8117
  relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
8098
- var _line$metadata3;
8099
8118
  var line = _this29.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
8100
8119
  if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
8101
- if (((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_extra') {
8102
- line.holder_config = {
8103
- status: 'disable',
8104
- required: 0
8105
- };
8106
- line.metadata.holder_config = {
8107
- status: 'disable',
8108
- required: 0
8109
- };
8110
- }
8111
8120
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
8112
8121
  var sourceUid = getProductLineUid(source);
8113
8122
  if (sourceUid) {
@@ -8198,8 +8207,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8198
8207
  products = _context70.sent;
8199
8208
  case 176:
8200
8209
  addedLines = products.filter(function (line) {
8201
- var _line$product_id, _line$metadata4;
8202
- return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
8210
+ var _line$product_id, _line$metadata3;
8211
+ return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
8203
8212
  });
8204
8213
  productLineUids = addedLines.map(function (line) {
8205
8214
  return getProductLineUid(line);
@@ -8213,8 +8222,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8213
8222
  }).filter(Boolean);
8214
8223
  if (bookingUids.length === 0) {
8215
8224
  bookingUids = addedLines.map(function (line) {
8216
- var _ref72, _line$booking_uid, _line$metadata5;
8217
- return String((_ref72 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5.booking_uid) !== null && _ref72 !== void 0 ? _ref72 : '');
8225
+ var _ref72, _line$booking_uid, _line$metadata4;
8226
+ return String((_ref72 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid) !== null && _ref72 !== void 0 ? _ref72 : '');
8218
8227
  }).filter(Boolean);
8219
8228
  }
8220
8229
  productLineUid = productLineUids[productLineUids.length - 1] || '';
@@ -310,6 +310,7 @@ export interface UnifiedBookingSalesApi {
310
310
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
311
311
  queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
312
312
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
313
+ supportsVenueExtraHolders: () => boolean;
313
314
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
314
315
  prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
315
316
  getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
@@ -24,18 +24,24 @@ export function readVenueCatalogList(response, description) {
24
24
  throw venueCatalogError('VENUE_CATALOG_LOAD_FAILED', (response === null || response === void 0 ? void 0 : response.message) || "".concat(description, " could not be loaded."));
25
25
  }
26
26
  var total = (_ref = (_response$data$total = response.data.total) !== null && _response$data$total !== void 0 ? _response$data$total : response.data.total_count) !== null && _ref !== void 0 ? _ref : response.data.total_num;
27
- if (total != null && Number.isFinite(Number(total)) && Number(total) > list.length) {
27
+ if (total == null ? list.length >= 999 : !Number.isSafeInteger(Number(total)) || Number(total) < 0 || Number(total) > list.length) {
28
28
  throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " is incomplete. A complete catalog response is required."));
29
29
  }
30
+ if (list.some(function (row) {
31
+ return !Number.isSafeInteger(Number(row === null || row === void 0 ? void 0 : row.form_record_id)) || Number(row.form_record_id) <= 0;
32
+ })) {
33
+ throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " contains a record without a valid menu ID."));
34
+ }
30
35
  return list;
31
36
  }
32
37
  export function validateVenueMenus(records, ids) {
33
- return ids.map(function (id) {
38
+ return ids.flatMap(function (id) {
34
39
  var menu = records.find(function (row) {
35
40
  return Number(row.form_record_id) === id;
36
41
  });
37
- var config = menu === null || menu === void 0 ? void 0 : menu.partyroom_package;
38
- if (!menu || !['product_all', 'products', 'product_collection'].includes(config === null || config === void 0 ? void 0 : config.type) || !Array.isArray(menu.schedule) || menu.schedule.some(function (value) {
42
+ if (!menu || menu.deleted_at || menu.status && menu.status !== 'valid') return [];
43
+ var config = menu.partyroom_package;
44
+ if (!['product_all', 'products', 'product_collection'].includes(config === null || config === void 0 ? void 0 : config.type) || !Array.isArray(menu.schedule) || menu.schedule.some(function (value) {
39
45
  return !Number.isSafeInteger(Number(value)) || Number(value) <= 0;
40
46
  }) || config.type !== 'product_all' && (!Array.isArray(config.products) || config.products.some(function (row) {
41
47
  var value = Number(row === null || row === void 0 ? void 0 : row[config.type === 'products' ? 'product_id' : 'product_collection_id']);
@@ -43,7 +49,7 @@ export function validateVenueMenus(records, ids) {
43
49
  }))) {
44
50
  throw venueCatalogError('VENUE_MENU_INCOMPLETE', 'The configured menu is incomplete. Reload the booking page.');
45
51
  }
46
- return cloneDeep(menu);
52
+ return [cloneDeep(menu)];
47
53
  });
48
54
  }
49
55
 
@@ -243,6 +243,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
243
243
  private calculatePaymentTotal;
244
244
  private calculateOrderPaidPaymentTotal;
245
245
  private getDepositAmount;
246
+ private isDepositSelectionDisabled;
247
+ /** Cap only the active target; product rules, manual intent and saved snapshots stay raw. */
248
+ private applyEffectiveDepositSummary;
246
249
  private normalizeDepositAmount;
247
250
  private normalizeDepositFlag;
248
251
  private getHistoricalDepositSnapshot;