@pisell/pisellos 0.0.551 → 0.0.552

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.
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, HolderModuleAPI, HolderFormMap } from './types';
3
+ import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, IRefreshAllFormRecordsParams, HolderModuleAPI, HolderFormMap } from './types';
4
4
  export * from './types';
5
5
  export * from './utils';
6
6
  export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
@@ -15,6 +15,7 @@ export declare class HolderModule extends BaseModule implements Module, HolderMo
15
15
  private error;
16
16
  /** 已加载过表单数据的 form_id 缓存标记 */
17
17
  private loadedFormIds;
18
+ private window;
18
19
  constructor(name?: string, version?: string);
19
20
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
20
21
  /** 统一提交 formMap,仅此处触发 store changed */
@@ -38,5 +39,10 @@ export declare class HolderModule extends BaseModule implements Module, HolderMo
38
39
  appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
39
40
  removeFormRecord(formId: number | string, formRecordId: number): void;
40
41
  clearFormData(formId?: number | string): void;
42
+ /**
43
+ * 登录后按当前 holderMap 批量刷新所有表单的 records。
44
+ * 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
45
+ */
46
+ refreshAllFormRecords(params?: IRefreshAllFormRecordsParams): Promise<HolderFormMap>;
41
47
  storeChange(path?: string): void;
42
48
  }
@@ -136,18 +136,22 @@ var HolderModule = class extends import_BaseModule.BaseModule {
136
136
  }
137
137
  }
138
138
  async fetchRecords(params) {
139
- var _a;
139
+ var _a, _b, _c;
140
140
  const url = params.url || "/form/data/v1";
141
141
  const { form_id, shop_id, num, skip, customer_id, ...rest } = params.query || {};
142
142
  const formId = (0, import_utils.normalizeFormId)(form_id);
143
143
  const useCache = params.useCache !== false;
144
+ const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
145
+ const customerId = customer_id ?? customer.id;
146
+ if (!customerId)
147
+ return [];
144
148
  this.isLoading = true;
145
149
  this.error = null;
146
150
  try {
147
151
  const res = await this.request.get(
148
152
  url,
149
153
  {
150
- customer_id,
154
+ customer_id: customerId,
151
155
  form_id,
152
156
  shop_id,
153
157
  num: num || 100,
@@ -157,7 +161,7 @@ var HolderModule = class extends import_BaseModule.BaseModule {
157
161
  },
158
162
  { useCache }
159
163
  );
160
- const records = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [];
164
+ const records = ((_c = res == null ? void 0 : res.data) == null ? void 0 : _c.list) || [];
161
165
  const nextFormMap = { ...this.store.holderMap };
162
166
  this.patchFormMap(nextFormMap, formId, { records });
163
167
  this.commitFormMap(nextFormMap);
@@ -306,6 +310,74 @@ var HolderModule = class extends import_BaseModule.BaseModule {
306
310
  this.commitFormMap({});
307
311
  }
308
312
  }
313
+ /**
314
+ * 登录后按当前 holderMap 批量刷新所有表单的 records。
315
+ * 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
316
+ */
317
+ async refreshAllFormRecords(params = {}) {
318
+ const { customer_id, recordsUrl, num, skip } = params;
319
+ const useCache = params.useCache ?? false;
320
+ if (!customer_id) {
321
+ return this.getHolderFormMap();
322
+ }
323
+ const entries = Object.entries(this.store.holderMap);
324
+ if (!entries.length) {
325
+ return this.getHolderFormMap();
326
+ }
327
+ const url = recordsUrl || "/form/data/v1";
328
+ this.isLoading = true;
329
+ this.error = null;
330
+ try {
331
+ const results = await Promise.all(
332
+ entries.map(async ([mapKey, item]) => {
333
+ var _a;
334
+ const meta = (0, import_utils.resolveFormMetaFromHolderItem)(mapKey, item);
335
+ if (!meta)
336
+ return null;
337
+ try {
338
+ const res = await this.request.get(
339
+ url,
340
+ {
341
+ customer_id,
342
+ form_id: meta.form_id,
343
+ shop_id: meta.shop_id,
344
+ num: num || 100,
345
+ skip: skip || 1,
346
+ front_end_cache_id: useCache && this.cacheId
347
+ },
348
+ { useCache }
349
+ );
350
+ return {
351
+ formId: meta.form_id,
352
+ records: ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || []
353
+ };
354
+ } catch (error) {
355
+ console.error(
356
+ `[HolderModule] refreshAllFormRecords failed for form ${meta.form_id}`,
357
+ error
358
+ );
359
+ return null;
360
+ }
361
+ })
362
+ );
363
+ const nextFormMap = { ...this.store.holderMap };
364
+ results.forEach((result) => {
365
+ if (!result)
366
+ return;
367
+ this.patchFormMap(nextFormMap, result.formId, {
368
+ records: result.records
369
+ });
370
+ this.loadedFormIds.add(result.formId);
371
+ });
372
+ this.commitFormMap(nextFormMap);
373
+ return (0, import_lodash_es.cloneDeep)(nextFormMap);
374
+ } catch (error) {
375
+ this.error = error instanceof Error ? error.message : String(error);
376
+ throw error;
377
+ } finally {
378
+ this.isLoading = false;
379
+ }
380
+ }
309
381
  storeChange(path) {
310
382
  if (path !== "holderMap" && path !== void 0) {
311
383
  return;
@@ -68,7 +68,7 @@ export interface IFetchFormRecordsParams {
68
68
  export interface IAddFormRecordParams {
69
69
  url?: string;
70
70
  body: {
71
- form_id: number | string;
71
+ form_id: number;
72
72
  shop_id: number | string;
73
73
  customer_id?: number;
74
74
  [key: string]: any;
@@ -100,6 +100,13 @@ export interface IEnsureFormByProductParams {
100
100
  shop_id?: number | string;
101
101
  useCache?: boolean;
102
102
  }
103
+ export interface IRefreshAllFormRecordsParams {
104
+ customer_id?: number;
105
+ useCache?: boolean;
106
+ recordsUrl?: string;
107
+ num?: number;
108
+ skip?: number;
109
+ }
103
110
  export interface HolderModuleAPI {
104
111
  getHolderFormMap: () => HolderFormMap;
105
112
  getHolderFormData: (formId: number | string) => IFormItemData | undefined;
@@ -112,4 +119,5 @@ export interface HolderModuleAPI {
112
119
  appendFormRecord: (params: IAppendFormRecordParams) => IFormRecord;
113
120
  removeFormRecord: (formId: number | string, formRecordId: number) => void;
114
121
  clearFormData: (formId?: number | string) => void;
122
+ refreshAllFormRecords: (params?: IRefreshAllFormRecordsParams) => Promise<HolderFormMap>;
115
123
  }
@@ -1,9 +1,13 @@
1
1
  import { ProductData } from '../Product/types';
2
- import { IHolderConfig } from './types';
2
+ import { IFormItemData, IHolderConfig } from './types';
3
3
  export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
4
- export declare function getFormIdFromHolderConfig(config: IHolderConfig): string;
5
- export declare function normalizeFormId(formId: number | string): string;
4
+ export declare function getFormIdFromHolderConfig(config: IHolderConfig): number;
5
+ export declare function normalizeFormId(formId: number | string): number;
6
6
  export declare function createEmptyFormItemData(): {
7
7
  records: any[];
8
8
  form: Record<string, any>;
9
9
  };
10
+ export declare function resolveFormMetaFromHolderItem(mapKey: string, item: IFormItemData): {
11
+ form_id: string | number;
12
+ shop_id: number | string;
13
+ } | null;
@@ -22,7 +22,8 @@ __export(utils_exports, {
22
22
  createEmptyFormItemData: () => createEmptyFormItemData,
23
23
  getFormIdFromHolderConfig: () => getFormIdFromHolderConfig,
24
24
  getProductHolderConfig: () => getProductHolderConfig,
25
- normalizeFormId: () => normalizeFormId
25
+ normalizeFormId: () => normalizeFormId,
26
+ resolveFormMetaFromHolderItem: () => resolveFormMetaFromHolderItem
26
27
  });
27
28
  module.exports = __toCommonJS(utils_exports);
28
29
  function getProductHolderConfig(product) {
@@ -37,10 +38,10 @@ function getProductHolderConfig(product) {
37
38
  return config;
38
39
  }
39
40
  function getFormIdFromHolderConfig(config) {
40
- return String(config == null ? void 0 : config.resource_id);
41
+ return Number(config == null ? void 0 : config.resource_id);
41
42
  }
42
43
  function normalizeFormId(formId) {
43
- return String(formId);
44
+ return Number(formId);
44
45
  }
45
46
  function createEmptyFormItemData() {
46
47
  return {
@@ -48,10 +49,23 @@ function createEmptyFormItemData() {
48
49
  form: {}
49
50
  };
50
51
  }
52
+ function resolveFormMetaFromHolderItem(mapKey, item) {
53
+ const formInfo = item.form || {};
54
+ const nestedForm = formInfo.form || {};
55
+ const form_id = normalizeFormId(
56
+ nestedForm.id ?? formInfo.form_id ?? formInfo.id ?? mapKey
57
+ );
58
+ const shop_id = nestedForm.shop_id ?? formInfo.shop_id;
59
+ if (shop_id === void 0 || shop_id === null || shop_id === "") {
60
+ return null;
61
+ }
62
+ return { form_id, shop_id };
63
+ }
51
64
  // Annotate the CommonJS export names for ESM import in node:
52
65
  0 && (module.exports = {
53
66
  createEmptyFormItemData,
54
67
  getFormIdFromHolderConfig,
55
68
  getProductHolderConfig,
56
- normalizeFormId
69
+ normalizeFormId,
70
+ resolveFormMetaFromHolderItem
57
71
  });
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -608,6 +608,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
608
608
  let is_deposit = 0;
609
609
  if (params.cartItems.length > 0) {
610
610
  params.cartItems.forEach((item) => {
611
+ var _a2;
611
612
  if (!item._origin.duration) {
612
613
  const { duration, durationType } = (0, import_utils.generateDuration)(item);
613
614
  item._origin.duration = duration;
@@ -615,7 +616,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
615
616
  }
616
617
  const discountList = (0, import_utils.getAllDiscountList)(item);
617
618
  item._origin.product.discount_list = discountList;
618
- (0, import_utils.ensureCartItemOriginHolder)(item);
619
+ if ((_a2 = params == null ? void 0 : params.extraData) == null ? void 0 : _a2.is_add_holder_info) {
620
+ (0, import_utils.ensureCartItemOriginHolder)(item, this.window);
621
+ }
619
622
  if ((0, import_utils2.isNormalProduct)(item._origin)) {
620
623
  order.relation_products.push(item._origin.product);
621
624
  const relationForms = item._origin.relation_forms || [];
@@ -2,6 +2,7 @@ import Decimal from 'decimal.js';
2
2
  import { CartItem } from "../Cart";
3
3
  import type { ScanOrderSubmitPayload, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
4
4
  import type { RulesParamsHooks } from '../Rules/types';
5
+ import type { WindowPlugin } from '../../plugins';
5
6
  /**
6
7
  * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
7
8
  *
@@ -94,7 +95,7 @@ export interface CartOrderHolder {
94
95
  /**
95
96
  * 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
96
97
  */
97
- export declare function ensureCartItemOriginHolder(cartItem: CartItem): void;
98
+ export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
98
99
  export declare const getAllDiscountList: (cartItem: CartItem) => any;
99
100
  export declare function createUuidV4(): string;
100
101
  export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
@@ -198,13 +198,17 @@ var mergeRelationForms = (relationForms) => {
198
198
  }, {})
199
199
  ).filter((item) => item.form_record_ids.length > 0);
200
200
  };
201
- function resolveCartItemHolderCustomerId(cartItem) {
202
- var _a, _b, _c;
203
- const origin = cartItem._origin;
204
- const account = (_a = origin == null ? void 0 : origin.metadata) == null ? void 0 : _a.account;
205
- return ((_b = origin == null ? void 0 : origin.holder) == null ? void 0 : _b.customer_id) ?? ((_c = account == null ? void 0 : account._origin) == null ? void 0 : _c.customer_id) ?? (account == null ? void 0 : account.customer_id);
201
+ function getCustomerIdFromStorage(window) {
202
+ var _a;
203
+ try {
204
+ const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
205
+ const customerId = Number(customer == null ? void 0 : customer.id);
206
+ return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
207
+ } catch {
208
+ return void 0;
209
+ }
206
210
  }
207
- function ensureCartItemOriginHolder(cartItem) {
211
+ function ensureCartItemOriginHolder(cartItem, window) {
208
212
  var _a;
209
213
  if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
210
214
  return;
@@ -217,7 +221,7 @@ function ensureCartItemOriginHolder(cartItem) {
217
221
  return;
218
222
  }
219
223
  cartItem._origin.holder = {
220
- customer_id: resolveCartItemHolderCustomerId(cartItem),
224
+ customer_id: getCustomerIdFromStorage(window),
221
225
  form_id: holderConfig.resource_id,
222
226
  form_record: [formRecordId]
223
227
  };
@@ -131,6 +131,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
131
131
  * 获取 holder 表单 map
132
132
  */
133
133
  getHolderFormMap(): import("../../modules").HolderFormMap;
134
+ /**
135
+ * 登录后或外部触发时,按当前 holderMap 批量刷新所有表单的 records
136
+ */
137
+ refreshAllHolderFormRecords(params?: {
138
+ customer_id?: number;
139
+ }): Promise<import("../../modules").HolderFormMap>;
134
140
  /**
135
141
  * 添加表单记录
136
142
  */
@@ -320,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
320
326
  date: string;
321
327
  status: string;
322
328
  week: string;
323
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
324
330
  }[]>;
325
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
326
332
  private getScheduleDataByIds;
@@ -367,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
367
373
  };
368
374
  setOtherData(key: string, value: any): void;
369
375
  getOtherData(key: string): any;
370
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
371
377
  /**
372
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
373
379
  *
@@ -386,6 +386,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
386
386
  getHolderFormMap() {
387
387
  return this.store.holder.getHolderFormMap();
388
388
  }
389
+ /**
390
+ * 登录后或外部触发时,按当前 holderMap 批量刷新所有表单的 records
391
+ */
392
+ async refreshAllHolderFormRecords(params) {
393
+ return this.store.holder.refreshAllFormRecords({
394
+ customer_id: params == null ? void 0 : params.customer_id,
395
+ useCache: false
396
+ });
397
+ }
389
398
  /**
390
399
  * 添加表单记录
391
400
  */
@@ -499,6 +508,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
499
508
  date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
500
509
  }
501
510
  this.updateQuotationPriceAndCart(date);
511
+ try {
512
+ const customerId = Number(accountInfo.id);
513
+ await this.refreshAllHolderFormRecords({
514
+ customer_id: customerId
515
+ });
516
+ } catch (error) {
517
+ console.error("[BookingByStep] 登录后刷新 holder 表单失败", error);
518
+ }
502
519
  }
503
520
  } else {
504
521
  throw new Error(`没有找到${accountId}账户`);
@@ -612,7 +629,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
612
629
  date,
613
630
  account
614
631
  }) {
615
- var _a, _b;
616
632
  const {
617
633
  bundle,
618
634
  options,
@@ -645,15 +661,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
645
661
  }
646
662
  }
647
663
  try {
648
- const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
649
- if (customer == null ? void 0 : customer.id) {
650
- this.store.holder.ensureFormByProduct({
651
- product: productData,
652
- customer_id: Number(customer.id),
653
- shop_id: (productData == null ? void 0 : productData.shop_id) || "",
654
- useCache: true
655
- });
656
- }
664
+ this.store.holder.ensureFormByProduct({
665
+ product: productData,
666
+ shop_id: (productData == null ? void 0 : productData.shop_id) || "",
667
+ useCache: true
668
+ });
657
669
  } catch (error) {
658
670
  console.error("[BookingByStep] 加载 holder 表单失败", error);
659
671
  }
@@ -34,6 +34,7 @@ export interface ScanOrderOrderProductIdentity {
34
34
  /** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
35
35
  product_option_item?: any[];
36
36
  product_bundle?: any[];
37
+ shop_id?: number | string;
37
38
  }
38
39
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
39
40
  order_detail_id: number | null;
@@ -7,7 +7,7 @@ import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
7
  import type { ProductData } from '../../modules/Product/types';
8
8
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
9
9
  import type { StrategyConfig } from '../../model/strategy/type';
10
- import type { IAppendFormRecordParams } from '../../modules/Holder/types';
10
+ import type { IAppendFormRecordParams, IRefreshAllFormRecordsParams } from '../../modules/Holder/types';
11
11
  export * from './types';
12
12
  interface VenueBookingItemRuleRuntimeConfig {
13
13
  strategyConfigs?: StrategyConfig[];
@@ -54,7 +54,6 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
54
54
  private normalizeCustomerId;
55
55
  private resolveCustomerIdFromLoginPayload;
56
56
  private resolveHolderCustomerId;
57
- private ensureProductHolderForm;
58
57
  /**
59
58
  * 按商品 holder_config 预加载表单数据到 holderMap。
60
59
  * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
@@ -206,6 +205,10 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
206
205
  * 获取 holder 表单 map
207
206
  */
208
207
  getHolderFormMap(): import("../../modules/Holder").HolderFormMap;
208
+ /**
209
+ * UI 层触发:按当前 holderMap 批量刷新所有表单的 records
210
+ */
211
+ refreshAllHolderFormRecords(params?: Pick<IRefreshAllFormRecordsParams, 'customer_id' | 'useCache' | 'recordsUrl' | 'num' | 'skip'>): Promise<import("../../modules/Holder").HolderFormMap>;
209
212
  /**
210
213
  * 添加表单记录
211
214
  */
@@ -262,21 +262,17 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
262
262
  return Number(customer.id);
263
263
  return void 0;
264
264
  }
265
- async ensureProductHolderForm(product) {
266
- if (!product)
267
- return;
268
- await this.preloadHolderForms([product]);
269
- }
270
265
  /**
271
266
  * 按商品 holder_config 预加载表单数据到 holderMap。
272
267
  * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
273
268
  */
274
269
  async preloadHolderForms(products) {
270
+ var _a, _b, _c, _d;
275
271
  if (!this.store.holder || !products.length)
276
272
  return;
277
273
  const seenFormIds = /* @__PURE__ */ new Set();
278
- for (const product of products) {
279
- const holderConfig = (0, import_utils4.getProductHolderConfig)(product);
274
+ for (const item of products) {
275
+ const holderConfig = (0, import_utils4.getProductHolderConfig)((_a = item == null ? void 0 : item._origin) == null ? void 0 : _a.product);
280
276
  if (!holderConfig)
281
277
  continue;
282
278
  const formId = (0, import_utils4.getFormIdFromHolderConfig)(holderConfig);
@@ -285,9 +281,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
285
281
  seenFormIds.add(formId);
286
282
  try {
287
283
  await this.store.holder.ensureFormByProduct({
288
- product,
284
+ product: ((_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) || {},
289
285
  customer_id: this.resolveHolderCustomerId(),
290
- shop_id: product.shop_id,
286
+ shop_id: (_d = (_c = item == null ? void 0 : item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.shop_id,
291
287
  useCache: true
292
288
  });
293
289
  } catch (error) {
@@ -341,6 +337,12 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
341
337
  this.customerLoginRefreshIdInFlight = params.customerId;
342
338
  const refreshTask = (async () => {
343
339
  var _a;
340
+ if (this.store.holder) {
341
+ await this.store.holder.refreshAllFormRecords({
342
+ customer_id: params.customerId,
343
+ useCache: false
344
+ });
345
+ }
344
346
  if (this.store.quotation) {
345
347
  await this.store.quotation.loadQuotations({
346
348
  channel: (_a = this.otherParams) == null ? void 0 : _a.channel
@@ -615,7 +617,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
615
617
  return this.loadAllProductsInFlight;
616
618
  }
617
619
  async _doLoadAllProducts() {
618
- var _a, _b, _c;
620
+ var _a, _b, _c, _d, _e;
619
621
  this.logMethodStart("loadAllProducts");
620
622
  try {
621
623
  if (!this.store.venueProducts)
@@ -644,7 +646,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
644
646
  }
645
647
  this.store.addonProducts.addProduct(addonList);
646
648
  this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
647
- await this.preloadHolderForms(venueList);
649
+ if (this.store.order) {
650
+ const products = ((_e = (_d = this.store.order) == null ? void 0 : _d.getOrderProducts) == null ? void 0 : _e.call(_d)) || [];
651
+ await this.preloadHolderForms(products);
652
+ }
648
653
  this.productsLoaded = true;
649
654
  this.logMethodSuccess("loadAllProducts", {
650
655
  total: list.length,
@@ -1037,6 +1042,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1037
1042
  * 同一场地下不同商品互不干扰,各自单独 reconcile。
1038
1043
  */
1039
1044
  async reconcileOrderForResourceProduct(resourceId, productId, slots) {
1045
+ var _a, _b;
1040
1046
  const mappings = this.resourceProductMap.get(resourceId);
1041
1047
  if (!mappings || !mappings.length || !this.store.order)
1042
1048
  return;
@@ -1050,10 +1056,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1050
1056
  );
1051
1057
  tempOrder.bookings = (tempOrder.bookings || []).filter(
1052
1058
  (b) => {
1053
- var _a, _b, _c, _d;
1054
- if (!((_a = b.metadata) == null ? void 0 : _a.venue_booking))
1059
+ var _a2, _b2, _c, _d;
1060
+ if (!((_a2 = b.metadata) == null ? void 0 : _a2.venue_booking))
1055
1061
  return true;
1056
- if (String((_b = b.metadata) == null ? void 0 : _b.resource_id) !== String(resourceId))
1062
+ if (String((_b2 = b.metadata) == null ? void 0 : _b2.resource_id) !== String(resourceId))
1057
1063
  return true;
1058
1064
  const bookingProductId = ((_c = b.metadata) == null ? void 0 : _c.product_id) ?? ((_d = b == null ? void 0 : b.product) == null ? void 0 : _d.product_id);
1059
1065
  if (bookingProductId == null)
@@ -1074,7 +1080,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1074
1080
  const childRawResources = this.getCombinedChildRawResources(rawResource);
1075
1081
  const venueProduct = this.getVenueProducts().find((p) => p.id === mapping.productId);
1076
1082
  tempOrder.bookings = tempOrder.bookings || [];
1077
- await this.ensureProductHolderForm(venueProduct);
1078
1083
  for (let i = 0; i < merged.length; i++) {
1079
1084
  const group = merged[i];
1080
1085
  const identityKey = (0, import_slotMerge.buildVenueIdentityKey)(resourceId, i);
@@ -1148,7 +1153,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1148
1153
  custom_deposit_data: customDepositData,
1149
1154
  metadata: {},
1150
1155
  holder_config: venueProduct == null ? void 0 : venueProduct.holder_config,
1151
- bookingUuid
1156
+ bookingUuid,
1157
+ shop_id: (venueProduct == null ? void 0 : venueProduct.shop_id) || 0
1152
1158
  },
1153
1159
  sub_type: "minutes",
1154
1160
  duration,
@@ -1179,6 +1185,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1179
1185
  });
1180
1186
  tempOrder.bookings.push(booking);
1181
1187
  }
1188
+ const products = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderProducts) == null ? void 0 : _b.call(_a)) || [];
1189
+ await this.preloadHolderForms(products);
1182
1190
  this.store.order.applyDiscount();
1183
1191
  await this.store.order.recalculateSummary({ createIfMissing: true });
1184
1192
  this.store.order.persistTempOrder();
@@ -1996,6 +2004,19 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1996
2004
  throw new Error("[VenueBooking] holder 模块未初始化");
1997
2005
  return this.store.holder.getHolderFormMap();
1998
2006
  }
2007
+ /**
2008
+ * UI 层触发:按当前 holderMap 批量刷新所有表单的 records
2009
+ */
2010
+ async refreshAllHolderFormRecords(params) {
2011
+ if (!this.store.holder)
2012
+ throw new Error("[VenueBooking] holder 模块未初始化");
2013
+ const customer_id = (params == null ? void 0 : params.customer_id) ?? this.resolveHolderCustomerId();
2014
+ return this.store.holder.refreshAllFormRecords({
2015
+ ...params,
2016
+ customer_id,
2017
+ useCache: (params == null ? void 0 : params.useCache) ?? false
2018
+ });
2019
+ }
1999
2020
  /**
2000
2021
  * 添加表单记录
2001
2022
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.551",
4
+ "version": "0.0.552",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",