@pisell/private-materials 6.12.355 → 6.12.357

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 (41) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +12 -12
  6. package/build/lowcode/view.js +12 -12
  7. package/es/components/appointmentBooking/components/Cart/Item/index.js +64 -12
  8. package/es/components/appointmentBooking/components/ConfirmInformation/index.js +7 -2
  9. package/es/components/appointmentBooking/components/Content/index.js +6 -4
  10. package/es/components/appointmentBooking/components/Voucher/index.js +11 -1
  11. package/es/components/appointmentBooking/hooks.js +33 -18
  12. package/es/components/appointmentBooking/utils.js +16 -5
  13. package/es/components/venueBooking/components/Cart/index.js +112 -18
  14. package/es/components/venueBooking/context.js +14 -3
  15. package/es/components/venueBooking/locales.js +10 -5
  16. package/es/plus/invoice/README.md +8 -2
  17. package/es/plus/invoice/ReceiptRenderer.js +1 -1
  18. package/es/plus/invoice/receipt.d.ts +2 -0
  19. package/es/plus/invoice/receipt.js +38 -8
  20. package/es/plus/invoice/receiptTranslations.js +8 -2
  21. package/es/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.js +19 -13
  22. package/es/utils/buildCartHolderParams.js +166 -0
  23. package/es/utils/holderConfig.js +6 -0
  24. package/lib/components/appointmentBooking/components/Cart/Item/index.js +63 -11
  25. package/lib/components/appointmentBooking/components/ConfirmInformation/index.js +7 -2
  26. package/lib/components/appointmentBooking/components/Content/index.js +6 -4
  27. package/lib/components/appointmentBooking/components/Voucher/index.js +11 -1
  28. package/lib/components/appointmentBooking/hooks.js +33 -18
  29. package/lib/components/appointmentBooking/utils.js +16 -5
  30. package/lib/components/venueBooking/components/Cart/index.js +111 -17
  31. package/lib/components/venueBooking/context.js +14 -3
  32. package/lib/components/venueBooking/locales.js +10 -5
  33. package/lib/plus/invoice/README.md +8 -2
  34. package/lib/plus/invoice/ReceiptRenderer.js +1 -1
  35. package/lib/plus/invoice/receipt.d.ts +2 -0
  36. package/lib/plus/invoice/receipt.js +38 -8
  37. package/lib/plus/invoice/receiptTranslations.js +8 -2
  38. package/lib/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.js +18 -12
  39. package/lib/utils/buildCartHolderParams.js +172 -0
  40. package/lib/utils/holderConfig.js +7 -0
  41. package/package.json +3 -3
@@ -126,7 +126,8 @@ var locales_default = {
126
126
  "pisell2.appointment.policy": "You have read and agreed to this policy",
127
127
  "pisell2.appointment.policy.confirm": "Confirm",
128
128
  "pisell2.appointment.booking.empty.data": "No data",
129
- "pisell2.product-select.search": "Search"
129
+ "pisell2.product-select.search": "Search",
130
+ "pisell2.venue.create.form": "Create form"
130
131
  },
131
132
  "zh-CN": {
132
133
  "pisell2.venue.step.select": "选择场地",
@@ -250,7 +251,8 @@ var locales_default = {
250
251
  "pisell2.appointment.policy": "您已仔细阅读并同意此协议",
251
252
  "pisell2.appointment.policy.confirm": "确定",
252
253
  "pisell2.appointment.booking.empty.data": "暂无数据",
253
- "pisell2.product-select.search": "搜索"
254
+ "pisell2.product-select.search": "搜索",
255
+ "pisell2.venue.create.form": "创建表单"
254
256
  },
255
257
  "zh-HK": {
256
258
  "pisell2.venue.step.select": "選擇場地",
@@ -374,7 +376,8 @@ var locales_default = {
374
376
  "pisell2.appointment.policy": "您已仔細閱讀並同意此協議",
375
377
  "pisell2.appointment.policy.confirm": "確定",
376
378
  "pisell2.appointment.booking.empty.data": "暫無數據",
377
- "pisell2.product-select.search": "搜索"
379
+ "pisell2.product-select.search": "搜索",
380
+ "pisell2.venue.create.form": "创建表单"
378
381
  },
379
382
  ja: {
380
383
  "pisell2.venue.step.select": "コートを選択",
@@ -498,7 +501,8 @@ var locales_default = {
498
501
  "pisell2.appointment.policy": "このポリシーを読み、同意しました",
499
502
  "pisell2.appointment.policy.confirm": "確認",
500
503
  "pisell2.appointment.booking.empty.data": "データなし",
501
- "pisell2.product-select.search": "検索"
504
+ "pisell2.product-select.search": "検索",
505
+ "pisell2.venue.create.form": "フォームを作成"
502
506
  },
503
507
  pt: {
504
508
  "pisell2.venue.step.select": "Escolher quadra",
@@ -622,7 +626,8 @@ var locales_default = {
622
626
  "pisell2.appointment.policy": "Você leu e concordou com esta política",
623
627
  "pisell2.appointment.policy.confirm": "Confirmar",
624
628
  "pisell2.appointment.booking.empty.data": "Sem dados",
625
- "pisell2.product-select.search": "Pesquisar"
629
+ "pisell2.product-select.search": "Pesquisar",
630
+ "pisell2.venue.create.form": "Criar formulário"
626
631
  }
627
632
  };
628
633
  //#endregion
@@ -77,8 +77,14 @@ type OrderInvoiceHandle = {
77
77
 
78
78
  OS `OrderInvoicePreview` 从模板 language 中提供 `languageOptions` 和
79
79
  `selectedLanguage`;宿主选择器调用实例 `selectLanguage(code)`,不重新准备订单或
80
- 加载低代码页面。`result.locale` 为主语言,`secondaryLocale` 仅在 `cn_en` 时为
81
- `zh_CN`。页面 UI 的 `locale` 不随此选择改变。
80
+ 加载低代码页面。`result.locale` 为主语言;`cn_en` 沿用英语在前、简体中文在后,
81
+ `ja_en` 为日语在前、英语在后,`secondaryLocale` 为对应的第二语言。
82
+ 页面 UI 的 `locale` 不随此选择改变。
83
+
84
+ POS Invoice 预览从同一份 `getInvoiceTemplateSettings()` 配置取得 modules 和
85
+ language,展示首个启用的语言模式(打印份数不重复预览),并请求该模式所需的所有
86
+ 语言快照。双语模式任一语言缺失时保留重试提示,不静默降级为单语。旧 OS 仅提供
87
+ layout 或 DEFAULT 模板未指定语言时,继续按界面语言选择。
82
88
 
83
89
  物料使用 `receipt_key` 关联来源相同的双语节点,保留仅次语言有内容的行。
84
90
  `receipt_item_kind` / `receipt_value_kind` 区分共享值和翻译文本,避免时间、编号和
@@ -26,7 +26,7 @@ function ReceiptRows({ locale, rows }) {
26
26
  return /* @__PURE__ */ React.createElement("div", {
27
27
  className: `${PREFIX}__receipt-row ${row.size === 2 ? `${PREFIX}__receipt-row--strong` : ""} ${singleValue ? `${PREFIX}__receipt-row--single` : ""} ${alignment ? `${PREFIX}__receipt-row--align-${alignment}` : ""}`,
28
28
  key: `${row.item}-${row.value}-${index}`
29
- }, row.item ? /* @__PURE__ */ React.createElement("span", null, label(String(row.item), locale)) : null, row.value ? /* @__PURE__ */ React.createElement("span", null, row.value) : null);
29
+ }, row.item ? /* @__PURE__ */ React.createElement("span", null, label(String(row.item), row.labelLocale || locale)) : null, row.value ? /* @__PURE__ */ React.createElement("span", null, row.value) : null);
30
30
  }));
31
31
  }
32
32
  function ReceiptSectionTitle({ children }) {
@@ -10,6 +10,8 @@ interface InvoiceLayoutConfig {
10
10
  module: InvoiceModuleConfig[];
11
11
  }
12
12
  interface SmallTicketItem {
13
+ /** View-only locale retained when primary and secondary rows are merged. */
14
+ labelLocale?: string;
13
15
  receipt_key?: string;
14
16
  receipt_value_kind?: 'shared' | 'text';
15
17
  receipt_item_kind?: 'shared' | 'text';
@@ -317,12 +317,8 @@ function findLocaleKey(data, candidate) {
317
317
  const lowerCandidate = candidate.toLowerCase().replace(/-/g, "_");
318
318
  return Object.keys(data).find((key) => key.toLowerCase().replace(/-/g, "_") === lowerCandidate);
319
319
  }
320
- function selectSmallTicketLocale(data, appLocale, primaryLocale) {
321
- const candidates = [
322
- ...localeCandidates(appLocale),
323
- "en",
324
- ...localeCandidates(primaryLocale || "")
325
- ];
320
+ function selectSmallTicketLocale(data, appLocale, primaryLocale, allowFallback = true) {
321
+ const candidates = [...localeCandidates(appLocale), ...allowFallback ? ["en", ...localeCandidates(primaryLocale || "")] : []];
326
322
  for (const candidate of candidates) {
327
323
  const key = findLocaleKey(data, candidate);
328
324
  if (key && hasLocalePayload(data[key])) return {
@@ -330,7 +326,7 @@ function selectSmallTicketLocale(data, appLocale, primaryLocale) {
330
326
  locale: key
331
327
  };
332
328
  }
333
- const first = Object.keys(data).find((key) => hasLocalePayload(data[key]));
329
+ const first = allowFallback ? Object.keys(data).find((key) => hasLocalePayload(data[key])) : void 0;
334
330
  return first ? {
335
331
  data: data[first],
336
332
  locale: first
@@ -362,6 +358,40 @@ function _resolveInvoiceLayoutConfig() {
362
358
  });
363
359
  return _resolveInvoiceLayoutConfig.apply(this, arguments);
364
360
  }
361
+ const INVOICE_PREVIEW_LANGUAGES = {
362
+ en: ["en"],
363
+ zh_cn: ["zh_CN"],
364
+ zh_hk: ["zh_HK"],
365
+ ja: ["ja"],
366
+ pt: ["pt"],
367
+ cn_en: ["en", "zh_CN"],
368
+ ja_en: ["ja", "en"]
369
+ };
370
+ /** Use the first enabled print mode once, regardless of its copy count. */
371
+ function resolveInvoicePreviewConfig(_x2) {
372
+ return _resolveInvoicePreviewConfig.apply(this, arguments);
373
+ }
374
+ function _resolveInvoicePreviewConfig() {
375
+ _resolveInvoicePreviewConfig = _asyncToGenerator(function* (salesModule) {
376
+ if (typeof (salesModule === null || salesModule === void 0 ? void 0 : salesModule.getInvoiceTemplateSettings) === "function") {
377
+ const settings = yield salesModule.getInvoiceTemplateSettings();
378
+ if (isRecord(settings)) {
379
+ const layout = normalizeInvoiceLayoutConfig({ module: settings.modules });
380
+ if (typeof settings.template === "string" && settings.template.trim() && settings.template.trim().toUpperCase() !== "DEFAULT" && isRecord(settings.language)) for (const [rawCode, count] of Object.entries(settings.language)) {
381
+ if (typeof count !== "number" || !Number.isFinite(count) || count <= 0) continue;
382
+ const locales = INVOICE_PREVIEW_LANGUAGES[rawCode.trim().toLowerCase().replace(/-/g, "_")];
383
+ if (Array.isArray(locales)) return {
384
+ layout,
385
+ locales: [...locales]
386
+ };
387
+ }
388
+ return { layout };
389
+ }
390
+ }
391
+ return { layout: yield resolveInvoiceLayoutConfig(salesModule) };
392
+ });
393
+ return _resolveInvoicePreviewConfig.apply(this, arguments);
394
+ }
365
395
  function text(value) {
366
396
  return value === void 0 || value === null ? "" : String(value).trim();
367
397
  }
@@ -893,4 +923,4 @@ function getModuleImage(module) {
893
923
  return text(module.image.value);
894
924
  }
895
925
  //#endregion
896
- export { buildInvoiceReceiptViewModel, formatReceiptPreviewTime, getModuleImage, getModuleText, getReceiptBookingId, getReceiptLabel, getReceiptProductTotal, isSmallTicketData, multiplyReceiptMoney, receiptMoneyValuesDiffer, resolveInvoiceLayoutConfig, resolveSmallTicketData, selectSmallTicketLocale, subtractReceiptMoney, sumReceiptMoney };
926
+ export { buildInvoiceReceiptViewModel, formatReceiptPreviewTime, getModuleImage, getModuleText, getReceiptBookingId, getReceiptLabel, getReceiptProductTotal, isSmallTicketData, multiplyReceiptMoney, receiptMoneyValuesDiffer, resolveInvoicePreviewConfig, resolveSmallTicketData, selectSmallTicketLocale, subtractReceiptMoney, sumReceiptMoney };
@@ -42,9 +42,14 @@ function receiptLabel(receipt, key) {
42
42
  return bilingualText(getReceiptLabel(receipt.locale, key), receipt.secondary && getReceiptLabel(receipt.secondary.locale, key));
43
43
  }
44
44
  function mergeTranslatedRows(primary, secondary, locale, secondaryLocale, sharedValues = false) {
45
+ const primaryRows = new Set(primary);
45
46
  return pairReceiptEntries(primary, secondary, (row) => row.receipt_key).flatMap(({ primary: row, secondary: other }) => {
46
- const item = getReceiptLabel(locale, row.item || "");
47
- const result = [_objectSpread2(_objectSpread2({}, row), {}, { item })];
47
+ const labelLocale = primaryRows.has(row) ? locale : secondaryLocale;
48
+ const item = getReceiptLabel(labelLocale, row.item || "");
49
+ const result = [_objectSpread2(_objectSpread2({}, row), {}, {
50
+ item,
51
+ labelLocale
52
+ })];
48
53
  if (!other) return result;
49
54
  let secondItem = getReceiptLabel(secondaryLocale, other.item || "");
50
55
  if (row.receipt_key === "settlement/tax-included") secondItem = secondItem.replace(/\s-?[^\s\d]*\d[\d,.]*\s(?=\()/, " ");
@@ -53,6 +58,7 @@ function mergeTranslatedRows(primary, secondary, locale, secondaryLocale, shared
53
58
  if (!secondItem && !secondValue) return result;
54
59
  result.push(_objectSpread2(_objectSpread2({}, other), {}, {
55
60
  item: secondItem,
61
+ labelLocale: secondaryLocale,
56
62
  value: secondValue,
57
63
  receipt_key: `${other.receipt_key}/secondary`
58
64
  }));
@@ -6,7 +6,7 @@ import { isVirtualSettlementTempOrder } from "../../../../../multiCurrencySettle
6
6
  import { getLocalOrderReceiptSnapshot, getOrderSmallTicketData } from "../../../../serve.js";
7
7
  import { withDisplayedReceiptFormTitles } from "../../../../utils/formTitleDisplay.js";
8
8
  import { hasInvoiceDetailSettings, hasInvoicePaymentTimeKeys, isInvoiceResourceTitleVisible, requiresInvoiceDataFiltering, requiresInvoicePaymentTimeKeys } from "../../../../../invoice/invoiceVisibility.js";
9
- import { buildInvoiceReceiptViewModel, formatReceiptPreviewTime, isSmallTicketData, resolveInvoiceLayoutConfig, resolveSmallTicketData, selectSmallTicketLocale } from "../../../../../invoice/receipt.js";
9
+ import { buildInvoiceReceiptViewModel, formatReceiptPreviewTime, isSmallTicketData, resolveInvoicePreviewConfig, resolveSmallTicketData, selectSmallTicketLocale } from "../../../../../invoice/receipt.js";
10
10
  import { useEffect, useMemo, useState } from "react";
11
11
  //#region src/plus/saleDetail/tmpl/B/components/Invoice/useInvoiceReceiptPreview.ts
12
12
  const LOADING_STATE = {
@@ -81,13 +81,12 @@ function useInvoiceReceiptPreview(context) {
81
81
  setState(_objectSpread2(_objectSpread2({}, LOADING_STATE), {}, { scope }));
82
82
  (function() {
83
83
  var _ref3 = _asyncToGenerator(function* () {
84
- var _bookingTicket$getFor;
85
84
  const { appLocale, bookingTicket, engineContext, orderId, platform, previewCreatedAt, salesDetail, salesModule, tempOrder } = scope;
86
- const layout = yield resolveInvoiceLayoutConfig(salesModule);
85
+ const { layout, locales } = yield resolveInvoicePreviewConfig(salesModule);
87
86
  if (cancelled) return null;
88
87
  const mustFilter = requiresInvoiceDataFiltering(layout);
89
88
  const needsPaymentTimeKeys = requiresInvoicePaymentTimeKeys(layout);
90
- const useSharedConfig = hasInvoiceDetailSettings(layout) || mustFilter;
89
+ const useSharedConfig = hasInvoiceDetailSettings(layout) || mustFilter || Boolean(locales);
91
90
  const isVirtualOrder = isVirtualSettlementTempOrder(tempOrder) || isVirtualSettlementTempOrder(salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.raw);
92
91
  const legacyVirtualResult = {
93
92
  receipt: null,
@@ -97,11 +96,12 @@ function useInvoiceReceiptPreview(context) {
97
96
  };
98
97
  if (isVirtualOrder && !useSharedConfig) return legacyVirtualResult;
99
98
  const requiresSource = isVirtualOrder && useSharedConfig;
99
+ const requiresFreshSnapshot = mustFilter || needsPaymentTimeKeys || requiresSource || ((locales === null || locales === void 0 ? void 0 : locales.length) || 0) > 1;
100
100
  const embeddedSnapshot = resolveSmallTicketData(salesDetail, tempOrder);
101
101
  const { snapshot, source } = yield function() {
102
102
  var _ref2 = _asyncToGenerator(function* () {
103
103
  if (platform !== "h5" && orderId !== null && orderId !== void 0) try {
104
- const freshSnapshot = yield getLocalOrderReceiptSnapshot(orderId, [appLocale], layout);
104
+ const freshSnapshot = yield getLocalOrderReceiptSnapshot(orderId, locales || [appLocale], layout);
105
105
  if (!freshSnapshot || !isSmallTicketData(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot is unavailable");
106
106
  if (mustFilter && freshSnapshot.template_visibility_applied !== true) throw new Error("Receipt snapshot does not support template filtering");
107
107
  if (needsPaymentTimeKeys && !hasInvoicePaymentTimeKeys(freshSnapshot.small_ticket_data)) throw new Error("Receipt snapshot does not identify payment history times");
@@ -111,10 +111,10 @@ function useInvoiceReceiptPreview(context) {
111
111
  source: freshSnapshot.source || null
112
112
  };
113
113
  } catch (error) {
114
- if (mustFilter || needsPaymentTimeKeys || requiresSource) throw error;
114
+ if (requiresFreshSnapshot) throw error;
115
115
  console.warn("[SaleDetail.Invoice] Failed to rebuild local receipt snapshot", error);
116
116
  }
117
- if (mustFilter || needsPaymentTimeKeys || requiresSource) throw new Error("A template-aware local receipt snapshot is required");
117
+ if (requiresFreshSnapshot) throw new Error("A template-aware local receipt snapshot is required");
118
118
  return {
119
119
  snapshot: embeddedSnapshot || (orderId !== null && orderId !== void 0 ? yield getOrderSmallTicketData(orderId) : null),
120
120
  source: null
@@ -128,17 +128,23 @@ function useInvoiceReceiptPreview(context) {
128
128
  const isVirtualSource = isVirtualSettlementTempOrder(source);
129
129
  if (isVirtualSource && !useSharedConfig) return legacyVirtualResult;
130
130
  const shopInfo = getShopInfo(engineContext);
131
- const selected = selectSmallTicketLocale(isInvoiceResourceTitleVisible(layout) ? withDisplayedReceiptFormTitles(snapshot, (bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getFor = bookingTicket.getFormTitleMap) === null || _bookingTicket$getFor === void 0 ? void 0 : _bookingTicket$getFor.call(bookingTicket)) || {}, appLocale, (salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) || []) : snapshot, appLocale, shopInfo.primary_locale);
132
- if (!selected) throw new Error("Receipt language data is unavailable");
133
- return {
134
- receipt: buildInvoiceReceiptViewModel({
135
- data: selected.data,
131
+ const buildReceipt = (locale) => {
132
+ var _bookingTicket$getFor;
133
+ const selected = selectSmallTicketLocale(snapshot, locale, shopInfo.primary_locale, !locales);
134
+ if (!selected) throw new Error(`Receipt language data is unavailable: ${locale}`);
135
+ return buildInvoiceReceiptViewModel({
136
+ data: isInvoiceResourceTitleVisible(layout) ? withDisplayedReceiptFormTitles(selected.data, (bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getFor = bookingTicket.getFormTitleMap) === null || _bookingTicket$getFor === void 0 ? void 0 : _bookingTicket$getFor.call(bookingTicket)) || {}, selected.locale, (salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) || []) : selected.data,
136
137
  layout,
137
138
  locale: selected.locale,
138
139
  previewTime: formatReceiptPreviewTime(previewCreatedAt, selected.locale),
139
140
  shopLogo: getShopLogo(shopInfo),
140
141
  taxNumberLabel: shopInfo.tax_number_title || (String(shopInfo.tax_country_code || "").toUpperCase() === "AU" ? "ABN" : void 0)
141
- }),
142
+ });
143
+ };
144
+ const receipt = buildReceipt((locales === null || locales === void 0 ? void 0 : locales[0]) || appLocale);
145
+ if (locales === null || locales === void 0 ? void 0 : locales[1]) receipt.secondary = buildReceipt(locales[1]);
146
+ return {
147
+ receipt,
142
148
  source,
143
149
  useLegacyVirtualCurrencyInvoice: false,
144
150
  useVirtualCurrencyReceipt: useSharedConfig && isVirtualSource
@@ -0,0 +1,166 @@
1
+ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
+ import { isHolderConfigEnabled, isHolderConfigRequired } from "./holderConfig.js";
3
+ import { getCustomer } from "../components/appointmentBooking/utils.js";
4
+ //#region src/utils/buildCartHolderParams.ts
5
+ const toHolderRecordId = (value) => {
6
+ if (value == null || value === "") return void 0;
7
+ const id = Number(value);
8
+ return Number.isNaN(id) ? void 0 : id;
9
+ };
10
+ /**
11
+ * 从 _origin.holder 解析 form_record_id。
12
+ * form_record 可能是 number、number[];不能假定一定是数组下标 [0]。
13
+ */
14
+ const resolveOriginHolderId = (holder) => {
15
+ const formRecord = holder === null || holder === void 0 ? void 0 : holder.form_record;
16
+ if (Array.isArray(formRecord)) for (const value of formRecord) {
17
+ const id = toHolderRecordId(value);
18
+ if (id != null) return id;
19
+ }
20
+ else {
21
+ const id = toHolderRecordId(formRecord);
22
+ if (id != null) return id;
23
+ }
24
+ return toHolderRecordId(holder === null || holder === void 0 ? void 0 : holder.form_record_id);
25
+ };
26
+ /**
27
+ * 从购物车行解析当前选中的 holder form_record_id。
28
+ *
29
+ * venueBooking:以 _origin.holder 为准(SDK 会原地更新 form_record);
30
+ * 顶层 item.holder_id 可能是上一轮 UI 注入或 SDK 回灌的滞后值,不能优先于 _origin.holder。
31
+ */
32
+ const resolveCartItemHolderId = (item) => {
33
+ var _item$_origin;
34
+ const originHolder = item === null || item === void 0 || (_item$_origin = item._origin) === null || _item$_origin === void 0 ? void 0 : _item$_origin.holder;
35
+ if (originHolder && typeof originHolder === "object") return resolveOriginHolderId(originHolder);
36
+ return toHolderRecordId(item === null || item === void 0 ? void 0 : item.holder_id);
37
+ };
38
+ const getCurrentCustomerId = (utils) => {
39
+ var _getCustomer;
40
+ return (_getCustomer = getCustomer(utils)) === null || _getCustomer === void 0 ? void 0 : _getCustomer.id;
41
+ };
42
+ const createCartHolderOption = (holder, customerId) => {
43
+ const _id = (holder === null || holder === void 0 ? void 0 : holder.formRecordId) || (holder === null || holder === void 0 ? void 0 : holder.form_record_id);
44
+ return {
45
+ key: _id,
46
+ id: _id,
47
+ label: holder === null || holder === void 0 ? void 0 : holder.main_field,
48
+ name: holder === null || holder === void 0 ? void 0 : holder.main_field,
49
+ username: holder === null || holder === void 0 ? void 0 : holder.main_field,
50
+ type: "holder",
51
+ _origin: _objectSpread2(_objectSpread2({}, holder), {}, { customer_id: customerId })
52
+ };
53
+ };
54
+ /**
55
+ * 构建 ProductCard Holder 组件使用的单条 holder 数据。
56
+ * 输出字段需要与购物车 ProductCard 消费格式保持一致。
57
+ */
58
+ const buildCartHolderOption = (holder, utils) => {
59
+ if (!holder) return {};
60
+ return createCartHolderOption(holder, getCurrentCustomerId(utils));
61
+ };
62
+ const buildCartHolderOptions = (records, utils) => {
63
+ const customerId = getCurrentCustomerId(utils);
64
+ return records.map((record) => createCartHolderOption(record, customerId));
65
+ };
66
+ const getCartHolderTitle = (records, holderId) => {
67
+ var _records$find;
68
+ if (!holderId) return "";
69
+ return (_records$find = records.find((record) => Number(record === null || record === void 0 ? void 0 : record.form_record_id) === holderId)) === null || _records$find === void 0 ? void 0 : _records$find.main_field;
70
+ };
71
+ /**
72
+ * 根据 holderMap 与购物车行数据,构建 ProductCard 所需的 holder 展示字段。
73
+ * 供 appointmentBooking、venueBooking 等购物车场景复用。
74
+ */
75
+ const buildCartHolderParams = ({ item, holderConfig = {}, formData, translation, enabled = true, utils }) => {
76
+ var _formData$form;
77
+ if (!enabled || !isHolderConfigEnabled(holderConfig)) return {
78
+ isShowChangeHolder: false,
79
+ isErrorHolder: false,
80
+ holders: []
81
+ };
82
+ const records = (formData === null || formData === void 0 ? void 0 : formData.records) || [];
83
+ const holderId = resolveCartItemHolderId(item);
84
+ return {
85
+ holder_id: holderId,
86
+ isErrorHolder: !!(!holderId && isHolderConfigRequired(holderConfig)),
87
+ isShowChangeHolder: true,
88
+ addHolderButtonText: translation(formData === null || formData === void 0 || (_formData$form = formData.form) === null || _formData$form === void 0 || (_formData$form = _formData$form.form) === null || _formData$form === void 0 || (_formData$form = _formData$form.setting) === null || _formData$form === void 0 ? void 0 : _formData$form.title),
89
+ holder_title: getCartHolderTitle(records, holderId),
90
+ holders: buildCartHolderOptions(records, utils)
91
+ };
92
+ };
93
+ /**
94
+ * 从 appointmentBooking 购物车行读取 holder_config
95
+ */
96
+ const getAppointmentCartHolderConfig = (item) => {
97
+ var _item$_productInit;
98
+ return (item === null || item === void 0 || (_item$_productInit = item._productInit) === null || _item$_productInit === void 0 ? void 0 : _item$_productInit.holder_config) || {};
99
+ };
100
+ /**
101
+ * 从 venueBooking 购物车行读取 holder_config
102
+ */
103
+ const getVenueCartHolderConfig = (item) => {
104
+ var _item$_origin2;
105
+ return (item === null || item === void 0 || (_item$_origin2 = item._origin) === null || _item$_origin2 === void 0 || (_item$_origin2 = _item$_origin2.product) === null || _item$_origin2 === void 0 ? void 0 : _item$_origin2.holder_config) || {};
106
+ };
107
+ /**
108
+ * 校验购物车中 holder_config.required 的行是否已选择 holder。
109
+ */
110
+ const validateRequiredCartHolders = ({ items = [], getHolderConfig = getVenueCartHolderConfig }) => {
111
+ const invalidItems = items.filter((item) => {
112
+ if (!isHolderConfigRequired(getHolderConfig(item))) return false;
113
+ return !resolveCartItemHolderId(item);
114
+ });
115
+ return {
116
+ hasError: invalidItems.length > 0,
117
+ invalidItems
118
+ };
119
+ };
120
+ /**
121
+ * 从 holderMap 解析 minors 表单关联的 sku 关系表单 ID(form_to_form 隐藏字段的 linkedTable)。
122
+ */
123
+ const getSkuRelationFormId = (holderMap, formId) => {
124
+ var _formData$form2, _formData$form3, _detail$setting;
125
+ if (!formId) return 0;
126
+ const formData = holderMap === null || holderMap === void 0 ? void 0 : holderMap[formId];
127
+ if ((formData === null || formData === void 0 || (_formData$form2 = formData.form) === null || _formData$form2 === void 0 || (_formData$form2 = _formData$form2.form) === null || _formData$form2 === void 0 ? void 0 : _formData$form2.form_type) !== "minors") return 0;
128
+ const detail = formData === null || formData === void 0 || (_formData$form3 = formData.form) === null || _formData$form3 === void 0 || (_formData$form3 = _formData$form3.field) === null || _formData$form3 === void 0 ? void 0 : _formData$form3.find((item) => (item === null || item === void 0 ? void 0 : item.filed_type) === "form_to_form" && (item === null || item === void 0 ? void 0 : item.status) === "hide");
129
+ return (detail === null || detail === void 0 || (_detail$setting = detail.setting) === null || _detail$setting === void 0 ? void 0 : _detail$setting.linkedTable) || 0;
130
+ };
131
+ /**
132
+ * 从 form_to_form_value 中取最新创建的 form_record_id。
133
+ */
134
+ const getSkuRelationFormRecordId = (res) => {
135
+ var _res$values;
136
+ const formToFormValue = res === null || res === void 0 || (_res$values = res.values) === null || _res$values === void 0 || (_res$values = _res$values.form_to_form_value) === null || _res$values === void 0 ? void 0 : _res$values[0];
137
+ const formDataValue = (formToFormValue === null || formToFormValue === void 0 ? void 0 : formToFormValue.form_data_value) || [];
138
+ return formDataValue[formDataValue.length - 1];
139
+ };
140
+ /**
141
+ * 处理购物车添加 holder 表单提交成功后的公共逻辑。
142
+ * - minors 关联表单:刷新 holder 列表,取 form_to_form_value 中的 record id
143
+ * - 普通表单:appendFormRecord 并直接使用 form_record_id
144
+ */
145
+ const handleCartHolderFormSuccess = ({ res, formId, skuRelationFormId, utils, module }) => {
146
+ var _res$values2, _res$values3, _res$values4;
147
+ let formRecordId = res === null || res === void 0 || (_res$values2 = res.values) === null || _res$values2 === void 0 ? void 0 : _res$values2.form_record_id;
148
+ let resolvedFormId = res === null || res === void 0 || (_res$values3 = res.values) === null || _res$values3 === void 0 ? void 0 : _res$values3.form_id;
149
+ if (formId && skuRelationFormId) {
150
+ var _module$refreshAllHol;
151
+ const customer = getCustomer(utils);
152
+ module === null || module === void 0 || (_module$refreshAllHol = module.refreshAllHolderFormRecords) === null || _module$refreshAllHol === void 0 || _module$refreshAllHol.call(module, { customer_id: customer === null || customer === void 0 ? void 0 : customer.id });
153
+ formRecordId = getSkuRelationFormRecordId(res);
154
+ resolvedFormId = formId;
155
+ } else if (formId) {
156
+ var _module$appendFormRec;
157
+ module === null || module === void 0 || (_module$appendFormRec = module.appendFormRecord) === null || _module$appendFormRec === void 0 || _module$appendFormRec.call(module, { record: res === null || res === void 0 ? void 0 : res.values });
158
+ }
159
+ return {
160
+ formRecordId,
161
+ mainField: res === null || res === void 0 || (_res$values4 = res.values) === null || _res$values4 === void 0 ? void 0 : _res$values4.main_field,
162
+ formId: resolvedFormId
163
+ };
164
+ };
165
+ //#endregion
166
+ export { buildCartHolderOption, buildCartHolderParams, getAppointmentCartHolderConfig, getSkuRelationFormId, getVenueCartHolderConfig, handleCartHolderFormSuccess, validateRequiredCartHolders };
@@ -0,0 +1,6 @@
1
+ //#region src/utils/holderConfig.ts
2
+ /** Holder selection requires an enabled configuration and a valid form ID. */
3
+ const isHolderConfigEnabled = (config) => (config === null || config === void 0 ? void 0 : config.status) === "enable" && Number.isFinite(Number(config === null || config === void 0 ? void 0 : config.resource_id)) && Number(config === null || config === void 0 ? void 0 : config.resource_id) > 0;
4
+ const isHolderConfigRequired = (config) => isHolderConfigEnabled(config) && Number(config === null || config === void 0 ? void 0 : config.required) === 1;
5
+ //#endregion
6
+ export { isHolderConfigEnabled, isHolderConfigRequired };
@@ -2,6 +2,7 @@ const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
2
2
  const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
3
  const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
4
4
  const require_index = require("../../../../shoppingCart/index.js");
5
+ const require_holderConfig = require("../../../../../utils/holderConfig.js");
5
6
  const require_utils = require("../../../utils.js");
6
7
  const require_index$1 = require("../../../../subTotal/index.js");
7
8
  const require_hooks = require("../../../hooks.js");
@@ -10,6 +11,7 @@ const require_index$2 = require("../../Deposit/index.js");
10
11
  const require_utils$1 = require("../utils.js");
11
12
  const require_index$3 = require("../ContinueButton/index.js");
12
13
  const require_index$4 = require("../../Voucher/index.js");
14
+ const require_buildCartHolderParams = require("../../../../../utils/buildCartHolderParams.js");
13
15
  let react = require("react");
14
16
  react = require_runtime.__toESM(react);
15
17
  let _pisell_utils = require("@pisell/utils");
@@ -23,9 +25,29 @@ const CartItem = ({ onNext, renderContactInfo }) => {
23
25
  const { getResourceList } = require_hooks.useAppointmentBookingResource();
24
26
  const { isFormSubject, bookingSubject, isRetailTemplate } = require_hooks.useAppointmentBookingSetting();
25
27
  const { isLogin } = require_hooks.useAppointmentBookingLogin();
28
+ const isLoggedIn = isLogin();
26
29
  const utils = require_hooks.contextUtils();
27
- const { businessUtils, translation } = utils;
30
+ const { businessUtils, translation, pisellos } = utils;
28
31
  const { taxTitle, totalTaxFee, isPriceIncludeTax, total, deposit } = summary;
32
+ const [holderMap, setHolderMap] = (0, react.useState)({});
33
+ (0, react.useEffect)(() => {
34
+ var _pisellos$effects;
35
+ const onHolderChanged = (res) => {
36
+ if ((res === null || res === void 0 ? void 0 : res.path) === "holderMap") {
37
+ var _appointmentBooking$g;
38
+ setHolderMap((appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$g = appointmentBooking.getHolderFormMap) === null || _appointmentBooking$g === void 0 ? void 0 : _appointmentBooking$g.call(appointmentBooking)) || {});
39
+ }
40
+ };
41
+ pisellos === null || pisellos === void 0 || (_pisellos$effects = pisellos.effects) === null || _pisellos$effects === void 0 || _pisellos$effects.on("appointmentBooking_holder:changed", onHolderChanged);
42
+ return () => {
43
+ var _pisellos$effects2;
44
+ pisellos === null || pisellos === void 0 || (_pisellos$effects2 = pisellos.effects) === null || _pisellos$effects2 === void 0 || _pisellos$effects2.off("appointmentBooking_holder:changed", onHolderChanged);
45
+ };
46
+ }, [appointmentBooking, pisellos]);
47
+ (0, react.useEffect)(() => {
48
+ var _appointmentBooking$g2;
49
+ setHolderMap((appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$g2 = appointmentBooking.getHolderFormMap) === null || _appointmentBooking$g2 === void 0 ? void 0 : _appointmentBooking$g2.call(appointmentBooking)) || {});
50
+ }, [appointmentBooking, isLoggedIn]);
29
51
  /**
30
52
  * @title: 当前客户
31
53
  * @description:
@@ -80,14 +102,32 @@ const CartItem = ({ onNext, renderContactInfo }) => {
80
102
  }
81
103
  if (type === "add_holder") {
82
104
  const relationShipFormId = bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.relationship_form_id;
105
+ const holderConfig = require_buildCartHolderParams.getAppointmentCartHolderConfig(e);
106
+ const formId = require_holderConfig.isHolderConfigEnabled(holderConfig) ? holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.resource_id : void 0;
107
+ const skuRelationFormId = require_buildCartHolderParams.getSkuRelationFormId(holderMap, formId);
83
108
  return require_utils.openForm({
84
- form_id: relationShipFormId || (bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.form_id),
109
+ form_id: skuRelationFormId || formId || relationShipFormId || (bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.form_id),
85
110
  title: _pisell_utils.locales.getText("pisell2.event.create.form"),
86
111
  utils,
87
112
  callback: function() {
88
113
  var _ref = require_asyncToGenerator._asyncToGenerator(function* (res) {
89
114
  if ((res === null || res === void 0 ? void 0 : res.status) === "success") {
90
115
  let result = void 0;
116
+ if (formId) {
117
+ const { formRecordId, mainField } = require_buildCartHolderParams.handleCartHolderFormSuccess({
118
+ res,
119
+ formId,
120
+ skuRelationFormId,
121
+ utils,
122
+ module: appointmentBooking
123
+ });
124
+ result = require_buildCartHolderParams.buildCartHolderOption(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, res === null || res === void 0 ? void 0 : res.values), {}, { formRecordId }), utils);
125
+ appointmentBooking.updateCart({
126
+ _id: e === null || e === void 0 ? void 0 : e._id,
127
+ account: result
128
+ });
129
+ return;
130
+ }
91
131
  if (!relationShipFormId) result = yield addAccount(res === null || res === void 0 ? void 0 : res.values, "holder");
92
132
  else result = yield require_utils$1.handleAddHolder({
93
133
  res,
@@ -112,24 +152,36 @@ const CartItem = ({ onNext, renderContactInfo }) => {
112
152
  };
113
153
  const products = (0, react.useMemo)(() => {
114
154
  if (!(carts === null || carts === void 0 ? void 0 : carts.length)) return [];
115
- carts.forEach((item) => {
116
- item.isShowChangeHolder = !appointmentBooking.isTargetCartIdNormalProduct(item === null || item === void 0 ? void 0 : item._id);
155
+ const enrichedCarts = carts.map((item) => {
156
+ const isNormalProduct = appointmentBooking.isTargetCartIdNormalProduct(item === null || item === void 0 ? void 0 : item._id);
157
+ const holderConfig = require_buildCartHolderParams.getAppointmentCartHolderConfig(item);
158
+ const holderParams = require_buildCartHolderParams.buildCartHolderParams({
159
+ item,
160
+ holderConfig,
161
+ formData: require_holderConfig.isHolderConfigEnabled(holderConfig) ? holderMap === null || holderMap === void 0 ? void 0 : holderMap[holderConfig === null || holderConfig === void 0 ? void 0 : holderConfig.resource_id] : {},
162
+ translation,
163
+ enabled: isLoggedIn && isFormSubject && !isNormalProduct,
164
+ utils
165
+ });
166
+ return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), holderParams);
117
167
  });
118
- if ((currentSelectedResources === null || currentSelectedResources === void 0 ? void 0 : currentSelectedResources.length) > 0) return carts.map((item) => {
168
+ if ((currentSelectedResources === null || currentSelectedResources === void 0 ? void 0 : currentSelectedResources.length) > 0) return enrichedCarts.map((item) => {
119
169
  const currentResourceData = currentSelectedResources.find((resource) => (resource === null || resource === void 0 ? void 0 : resource._id) === (item === null || item === void 0 ? void 0 : item._id));
120
170
  const multiResources = require_utils.getMultiResources(item, currentResourceData === null || currentResourceData === void 0 ? void 0 : currentResourceData.currentSelectedResource, currentStepParams === null || currentStepParams === void 0 ? void 0 : currentStepParams.key);
121
171
  return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
122
172
  isMultipleResource: true,
123
- multiResources,
124
- isErrorHolder: isErrorHolder || false
173
+ multiResources
125
174
  });
126
175
  });
127
- else return carts;
176
+ else return enrichedCarts;
128
177
  }, [
129
178
  carts,
130
179
  currentSelectedResources,
131
180
  currentStepParams === null || currentStepParams === void 0 ? void 0 : currentStepParams.key,
132
- isErrorHolder
181
+ isErrorHolder,
182
+ holderMap,
183
+ isFormSubject,
184
+ isLoggedIn
133
185
  ]);
134
186
  /**
135
187
  * @description: 结算列表数据
@@ -189,8 +241,8 @@ const CartItem = ({ onNext, renderContactInfo }) => {
189
241
  isShowDelete: (currentStep === null || currentStep === void 0 || (_currentStep$step2 = currentStep.step) === null || _currentStep$step2 === void 0 ? void 0 : _currentStep$step2.key) === "select-service",
190
242
  isShowAmountFooter: true,
191
243
  isShowPackageNote: false,
192
- isShowChangeHolder: isLastStep ? false : isFormSubject && isLogin,
193
- isShowHolder: isFormSubject,
244
+ isShowChangeHolder: isLastStep ? false : isFormSubject && isLoggedIn,
245
+ isShowHolder: isFormSubject && isLoggedIn,
194
246
  isShowAddHolderButton: true
195
247
  },
196
248
  collapseParams: {
@@ -3,6 +3,7 @@ const require_useEngineContext = require("../../../../hooks/useEngineContext.js"
3
3
  const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
4
4
  const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
5
5
  const require_ContactInfoContent = require("../../../../plus/contactInfoModal/ContactInfoContent.js");
6
+ const require_holderConfig = require("../../../../utils/holderConfig.js");
6
7
  const require_utils = require("../../utils.js");
7
8
  const require_useLoginUser = require("../../../../hooks/useLoginUser.js");
8
9
  const require_index = require("../../../productStockCheckModal/index.js");
@@ -25,7 +26,7 @@ const ConfirmInformation = (0, react.forwardRef)((props, ref) => {
25
26
  const utils = require_hooks.contextUtils();
26
27
  const { pubsub } = context.appHelper.utils;
27
28
  const { appointmentBooking, summary, isAgreeDepositPolicy, setLoading, carts, setTimes } = require_context.useAppointmentBookingContext();
28
- const { isRetailTemplate, bookingSetting } = require_hooks.useAppointmentBookingSetting();
29
+ const { isRetailTemplate, bookingSetting, isFormSubject } = require_hooks.useAppointmentBookingSetting();
29
30
  console.log(bookingSetting, "bookingSetting");
30
31
  const [form] = antd.Form.useForm();
31
32
  const userInfo = require_useLoginUser.default();
@@ -181,10 +182,14 @@ const ConfirmInformation = (0, react.forwardRef)((props, ref) => {
181
182
  const onCheckout = function() {
182
183
  var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (extraData) {
183
184
  try {
185
+ const _extraData = (carts === null || carts === void 0 ? void 0 : carts.some((item) => {
186
+ var _item$_productInit;
187
+ return require_holderConfig.isHolderConfigEnabled(item === null || item === void 0 || (_item$_productInit = item._productInit) === null || _item$_productInit === void 0 ? void 0 : _item$_productInit.holder_config);
188
+ })) ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, extraData), {}, { is_add_holder_info: isFormSubject }) : extraData;
184
189
  const { deposit } = summary;
185
190
  const customer = require_utils.formatAppointmentCustomerInfo(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, userInfo), extraData === null || extraData === void 0 ? void 0 : extraData.contacts_info));
186
191
  logCheckout("调用 submitOrder", require_objectSpread2._objectSpread2({ products: require_utils.formatAppointmentCartSummary(carts) }, customer));
187
- const { data } = yield appointmentBooking.submitOrder(extraData);
192
+ const { data } = yield appointmentBooking.submitOrder(_extraData);
188
193
  const { is_deposit, deposit_amount, total_amount, order_id } = data || {};
189
194
  logCheckout("submitOrder 返回", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ products: require_utils.formatAppointmentCartSummary(carts) }, customer), {}, {
190
195
  order_id: order_id || null,
@@ -29,6 +29,7 @@ const Layout = () => {
29
29
  const { currentStep, setResourceOtherParams, resourceOtherParams, setIsAgreeDepositPolicy, appointmentBooking, setLoading, policyParams, closePolicy, currentStepParams, setIsErrorHolder } = require_context.useAppointmentBookingContext();
30
30
  const { isDateSelectedFirst, isFormSubject, isRetailTemplate } = require_hooks.useAppointmentBookingSetting();
31
31
  const { isLogin } = require_hooks.useAppointmentBookingLogin();
32
+ const isLoggedIn = isLogin();
32
33
  const { getHolders } = require_hooks.useAppointmentBookingAccount();
33
34
  const { removeStep } = require_hooks.useAppointmentBookingStep();
34
35
  const { shopDiscount } = require_hooks.useShopDiscount();
@@ -49,7 +50,7 @@ const Layout = () => {
49
50
  const accountLists = yield appointmentBooking.getAccounts();
50
51
  const meAccount = accountLists === null || accountLists === void 0 ? void 0 : accountLists.find((d) => !(d === null || d === void 0 ? void 0 : d.isGuest));
51
52
  appointmentBooking.setLoginAccount(meAccount === null || meAccount === void 0 ? void 0 : meAccount.id, currentUser);
52
- } else if (!isRetailTemplate) getHolders();
53
+ } else if (!isRetailTemplate) yield getHolders();
53
54
  });
54
55
  return function handleLoginSuccess(_x) {
55
56
  return _ref.apply(this, arguments);
@@ -88,11 +89,12 @@ const Layout = () => {
88
89
  } catch (error) {}
89
90
  }, [isFormSubject, isRetailTemplate]);
90
91
  (0, react.useEffect)(() => {
91
- if (isFormSubject && isLogin && !isRetailTemplate) getHolders();
92
+ if (isFormSubject && isLoggedIn && !isRetailTemplate) getHolders();
92
93
  }, [
93
94
  isFormSubject,
94
- isLogin,
95
- isRetailTemplate
95
+ isLoggedIn,
96
+ isRetailTemplate,
97
+ appointmentBooking
96
98
  ]);
97
99
  (0, react.useEffect)(() => {
98
100
  var _currentStep$step;