@pisell/pisellos 2.1.160 → 2.1.161

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 (51) hide show
  1. package/dist/modules/Order/index.d.ts +0 -1
  2. package/dist/modules/Order/index.js +1 -18
  3. package/dist/modules/Order/types.d.ts +0 -2
  4. package/dist/modules/Order/utils.d.ts +0 -10
  5. package/dist/modules/Order/utils.js +3 -35
  6. package/dist/modules/Product/types.d.ts +0 -7
  7. package/dist/modules/index.d.ts +0 -1
  8. package/dist/modules/index.js +1 -2
  9. package/dist/plugins/window.d.ts +0 -1
  10. package/dist/solution/BookingByStep/index.d.ts +0 -15
  11. package/dist/solution/BookingByStep/index.js +204 -276
  12. package/dist/solution/BookingByStep/types.d.ts +1 -2
  13. package/dist/solution/BookingByStep/types.js +1 -3
  14. package/dist/solution/ScanOrder/index.js +1 -1
  15. package/dist/solution/ScanOrder/types.d.ts +0 -1
  16. package/dist/solution/VenueBooking/index.d.ts +0 -19
  17. package/dist/solution/VenueBooking/index.js +733 -963
  18. package/dist/solution/VenueBooking/types.d.ts +0 -2
  19. package/dist/types/index.d.ts +0 -1
  20. package/lib/modules/Order/index.d.ts +0 -1
  21. package/lib/modules/Order/index.js +0 -14
  22. package/lib/modules/Order/types.d.ts +0 -2
  23. package/lib/modules/Order/utils.d.ts +0 -10
  24. package/lib/modules/Order/utils.js +5 -36
  25. package/lib/modules/Product/types.d.ts +0 -7
  26. package/lib/modules/index.d.ts +0 -1
  27. package/lib/modules/index.js +1 -3
  28. package/lib/plugins/window.d.ts +0 -1
  29. package/lib/solution/BookingByStep/index.d.ts +0 -15
  30. package/lib/solution/BookingByStep/index.js +0 -39
  31. package/lib/solution/BookingByStep/types.d.ts +1 -2
  32. package/lib/solution/BookingByStep/types.js +0 -5
  33. package/lib/solution/ScanOrder/index.js +1 -1
  34. package/lib/solution/ScanOrder/types.d.ts +0 -1
  35. package/lib/solution/VenueBooking/index.d.ts +0 -19
  36. package/lib/solution/VenueBooking/index.js +16 -134
  37. package/lib/solution/VenueBooking/types.d.ts +0 -2
  38. package/lib/types/index.d.ts +0 -1
  39. package/package.json +2 -2
  40. package/dist/modules/Holder/index.d.ts +0 -48
  41. package/dist/modules/Holder/index.js +0 -640
  42. package/dist/modules/Holder/types.d.ts +0 -123
  43. package/dist/modules/Holder/types.js +0 -1
  44. package/dist/modules/Holder/utils.d.ts +0 -13
  45. package/dist/modules/Holder/utils.js +0 -34
  46. package/lib/modules/Holder/index.d.ts +0 -48
  47. package/lib/modules/Holder/index.js +0 -402
  48. package/lib/modules/Holder/types.d.ts +0 -123
  49. package/lib/modules/Holder/types.js +0 -17
  50. package/lib/modules/Holder/utils.d.ts +0 -13
  51. package/lib/modules/Holder/utils.js +0 -71
@@ -54,8 +54,6 @@ var import_utils3 = require("../../modules/Order/utils");
54
54
  var import_Order = require("../../modules/Order");
55
55
  var import_types4 = require("../RegisterAndLogin/types");
56
56
  var import_decimal = __toESM(require("decimal.js"));
57
- var import_Holder = require("../../modules/Holder");
58
- var import_utils4 = require("../../modules/Holder/utils");
59
57
  __reExport(VenueBooking_exports, require("./types"), module.exports);
60
58
  var OPEN_DATA_SECTION_CODES = [
61
59
  "basic",
@@ -255,42 +253,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
255
253
  }
256
254
  return null;
257
255
  }
258
- resolveHolderCustomerId() {
259
- var _a, _b;
260
- const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
261
- if (customer == null ? void 0 : customer.id)
262
- return Number(customer.id);
263
- return void 0;
264
- }
265
- /**
266
- * 按商品 holder_config 预加载表单数据到 holderMap。
267
- * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
268
- */
269
- async preloadHolderForms(products) {
270
- var _a, _b, _c, _d;
271
- if (!this.store.holder || !products.length)
272
- return;
273
- const seenFormIds = /* @__PURE__ */ new Set();
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);
276
- if (!holderConfig)
277
- continue;
278
- const formId = (0, import_utils4.getFormIdFromHolderConfig)(holderConfig);
279
- if (seenFormIds.has(formId))
280
- continue;
281
- seenFormIds.add(formId);
282
- try {
283
- await this.store.holder.ensureFormByProduct({
284
- product: ((_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) || {},
285
- customer_id: this.resolveHolderCustomerId(),
286
- shop_id: (_d = (_c = item == null ? void 0 : item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.shop_id,
287
- useCache: true
288
- });
289
- } catch (error) {
290
- console.error("[VenueBooking] 预加载 holder 表单失败", { formId, error });
291
- }
292
- }
293
- }
294
256
  clearLoginEffectListeners() {
295
257
  for (const dispose of this.loginEffectDisposers) {
296
258
  dispose();
@@ -337,12 +299,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
337
299
  this.customerLoginRefreshIdInFlight = params.customerId;
338
300
  const refreshTask = (async () => {
339
301
  var _a;
340
- if (this.store.holder) {
341
- await this.store.holder.refreshAllFormRecords({
342
- customer_id: params.customerId,
343
- useCache: false
344
- });
345
- }
346
302
  if (this.store.quotation) {
347
303
  await this.store.quotation.loadQuotations({
348
304
  channel: (_a = this.otherParams) == null ? void 0 : _a.channel
@@ -370,7 +326,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
370
326
  }
371
327
  }
372
328
  async initialize(core, options = {}) {
373
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
329
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
374
330
  this.logMethodStart("initialize");
375
331
  this.core = core;
376
332
  this.initializeOptions = options || {};
@@ -495,42 +451,20 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
495
451
  cacheId: (_g = this.otherParams) == null ? void 0 : _g.cacheId
496
452
  }
497
453
  });
498
- let holderCacheState;
499
- if ((_h = this.otherParams) == null ? void 0 : _h.cacheId) {
500
- const sessionData = this.window.sessionStorage.getItem(this.name);
501
- if (sessionData) {
502
- try {
503
- const data = JSON.parse(sessionData);
504
- holderCacheState = (_i = data[this.otherParams.cacheId]) == null ? void 0 : _i[`${this.name}_holder`];
505
- } catch {
506
- }
507
- }
508
- }
509
- const holderModule = new import_Holder.HolderModule(`${this.name}_holder`);
510
- this.store.holder = holderModule;
511
- this.core.registerModule(holderModule, {
512
- initialState: holderCacheState,
513
- otherParams: {
514
- ...this.otherParams,
515
- fatherModule: this.name,
516
- openCache: !!((_j = this.otherParams) == null ? void 0 : _j.cacheId),
517
- cacheId: (_k = this.otherParams) == null ? void 0 : _k.cacheId
518
- }
519
- });
520
454
  if (this.store.scanOrderLogger) {
521
455
  this.store.scanOrderLogger.setContext(this.getLoggerContext());
522
456
  }
523
457
  this.registerCustomerLoginListeners();
524
458
  console.log("[VenueBooking] 初始化开始");
525
459
  try {
526
- await ((_l = this.store.order) == null ? void 0 : _l.recalculateSummary({ createIfMissing: false }));
527
- (_m = this.store.order) == null ? void 0 : _m.persistTempOrder();
460
+ await ((_h = this.store.order) == null ? void 0 : _h.recalculateSummary({ createIfMissing: false }));
461
+ (_i = this.store.order) == null ? void 0 : _i.persistTempOrder();
528
462
  await this.loadRuntimeConfigs();
529
463
  if (this.store.schedule) {
530
464
  await this.store.schedule.loadAllSchedule();
531
465
  this.injectScheduleResolverToQuotation();
532
- (_o = this.store.quotation) == null ? void 0 : _o.loadQuotations({
533
- channel: (_n = this.otherParams) == null ? void 0 : _n.channel
466
+ (_k = this.store.quotation) == null ? void 0 : _k.loadQuotations({
467
+ channel: (_j = this.otherParams) == null ? void 0 : _j.channel
534
468
  });
535
469
  }
536
470
  await this.refreshItemRuleQuantityLimits();
@@ -617,7 +551,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
617
551
  return this.loadAllProductsInFlight;
618
552
  }
619
553
  async _doLoadAllProducts() {
620
- var _a, _b, _c, _d, _e;
554
+ var _a, _b, _c;
621
555
  this.logMethodStart("loadAllProducts");
622
556
  try {
623
557
  if (!this.store.venueProducts)
@@ -646,10 +580,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
646
580
  }
647
581
  this.store.addonProducts.addProduct(addonList);
648
582
  this.resourceProductMap = (0, import_resource.buildResourceProductMap)(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
- }
653
583
  this.productsLoaded = true;
654
584
  this.logMethodSuccess("loadAllProducts", {
655
585
  total: list.length,
@@ -1042,7 +972,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1042
972
  * 同一场地下不同商品互不干扰,各自单独 reconcile。
1043
973
  */
1044
974
  async reconcileOrderForResourceProduct(resourceId, productId, slots) {
1045
- var _a, _b;
1046
975
  const mappings = this.resourceProductMap.get(resourceId);
1047
976
  if (!mappings || !mappings.length || !this.store.order)
1048
977
  return;
@@ -1056,10 +985,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1056
985
  );
1057
986
  tempOrder.bookings = (tempOrder.bookings || []).filter(
1058
987
  (b) => {
1059
- var _a2, _b2, _c, _d;
1060
- if (!((_a2 = b.metadata) == null ? void 0 : _a2.venue_booking))
988
+ var _a, _b, _c, _d;
989
+ if (!((_a = b.metadata) == null ? void 0 : _a.venue_booking))
1061
990
  return true;
1062
- if (String((_b2 = b.metadata) == null ? void 0 : _b2.resource_id) !== String(resourceId))
991
+ if (String((_b = b.metadata) == null ? void 0 : _b.resource_id) !== String(resourceId))
1063
992
  return true;
1064
993
  const bookingProductId = ((_c = b.metadata) == null ? void 0 : _c.product_id) ?? ((_d = b == null ? void 0 : b.product) == null ? void 0 : _d.product_id);
1065
994
  if (bookingProductId == null)
@@ -1151,10 +1080,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1151
1080
  product_option_item: [],
1152
1081
  discount_list: [],
1153
1082
  custom_deposit_data: customDepositData,
1154
- metadata: {},
1155
- holder_config: venueProduct == null ? void 0 : venueProduct.holder_config,
1156
- bookingUuid,
1157
- shop_id: (venueProduct == null ? void 0 : venueProduct.shop_id) || 0
1083
+ metadata: {}
1158
1084
  },
1159
1085
  sub_type: "minutes",
1160
1086
  duration,
@@ -1185,8 +1111,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1185
1111
  });
1186
1112
  tempOrder.bookings.push(booking);
1187
1113
  }
1188
- const products = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderProducts) == null ? void 0 : _b.call(_a)) || [];
1189
- await this.preloadHolderForms(products);
1190
1114
  this.store.order.applyDiscount();
1191
1115
  await this.store.order.recalculateSummary({ createIfMissing: true });
1192
1116
  this.store.order.persistTempOrder();
@@ -1973,57 +1897,15 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1973
1897
  }
1974
1898
  }
1975
1899
  setBookingHolder(bookingUid, holder) {
1976
- var _a, _b, _c, _d;
1977
- if (!this.store.order)
1978
- return;
1979
- const tempOrder = this.store.order.ensureTempOrder();
1980
- const booking = (_a = tempOrder.bookings) == null ? void 0 : _a.find(
1981
- (b) => {
1982
- var _a2;
1983
- return ((_a2 = b.metadata) == null ? void 0 : _a2.unique_identification_number) === bookingUid;
1984
- }
1985
- );
1900
+ var _a;
1901
+ const order = this.getTempOrder();
1902
+ const booking = (_a = order == null ? void 0 : order.bookings) == null ? void 0 : _a.find((b) => {
1903
+ var _a2;
1904
+ return ((_a2 = b.metadata) == null ? void 0 : _a2.unique_identification_number) === bookingUid;
1905
+ });
1986
1906
  if (booking) {
1987
1907
  booking.holder = holder;
1988
1908
  }
1989
- for (const product of tempOrder.products) {
1990
- const productBookingUid = ((_b = product.metadata) == null ? void 0 : _b.booking_uid) ?? ((_d = (_c = product._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.bookingUuid);
1991
- if (String(productBookingUid) !== String(bookingUid))
1992
- continue;
1993
- const origin = product._origin && typeof product._origin === "object" ? product._origin : {};
1994
- origin.holder = holder;
1995
- product._origin = origin;
1996
- }
1997
- this.store.order.notifyTempOrderChanged();
1998
- }
1999
- /**
2000
- * 获取 holder 表单 map
2001
- */
2002
- getHolderFormMap() {
2003
- if (!this.store.holder)
2004
- throw new Error("[VenueBooking] holder 模块未初始化");
2005
- return this.store.holder.getHolderFormMap();
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
- }
2020
- /**
2021
- * 添加表单记录
2022
- */
2023
- appendFormRecord(params) {
2024
- if (!this.store.holder)
2025
- throw new Error("[VenueBooking] holder 模块未初始化");
2026
- return this.store.holder.appendFormRecord(params);
2027
1909
  }
2028
1910
  // ─── OpenData 可用性 ───
2029
1911
  async checkOpenDataAvailability() {
@@ -1,6 +1,5 @@
1
1
  import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, DateModule, ScheduleModule, QuotationModule, OpenDataModule } from '../../modules';
2
2
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
- import { HolderModule } from '../../modules/Holder';
4
3
  export type { ScanOrderOrderProductIdentity, ScanOrderOrderProduct, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder, ScanOrderSubmitPayload, } from '../ScanOrder/types';
5
4
  export declare enum VenueBookingHooks {
6
5
  onInited = "venueBooking:onInited",
@@ -146,7 +145,6 @@ export interface VenueBookingState {
146
145
  passed: boolean | null;
147
146
  failures: QuantityCheckResult[];
148
147
  };
149
- holder?: HolderModule;
150
148
  }
151
149
  export interface VenueBookingLoggerRuntimeConfig {
152
150
  provider?: ScanOrderLoggerProviderType;
@@ -6,7 +6,6 @@ export interface Plugin {
6
6
  version: string;
7
7
  initialize: () => Promise<void> | void;
8
8
  destroy?: () => Promise<void> | void;
9
- getLocalStorage?: (key: string) => string | null;
10
9
  }
11
10
  export interface PluginOptions {
12
11
  dependencies?: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.160",
4
+ "version": "2.1.161",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
19
19
  "changeset": "changeset",
20
20
  "version": "changeset version",
21
- "release": "changeset publish && npm run sync && git push",
21
+ "release": "changeset publish --registry=https://registry.npmjs.com/ && npm run sync && git push",
22
22
  "example": "npx parcel-bundler examples/index.html",
23
23
  "docs": "typedoc --out docs src/index.ts",
24
24
  "sync": "node sync.js",
@@ -1,48 +0,0 @@
1
- import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { BaseModule } from '../BaseModule';
3
- import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, IRefreshAllFormRecordsParams, HolderModuleAPI, HolderFormMap } from './types';
4
- export * from './types';
5
- export * from './utils';
6
- export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
7
- protected defaultName: string;
8
- protected defaultVersion: string;
9
- private store;
10
- private request;
11
- private cacheId;
12
- private openCache;
13
- private fatherModule;
14
- private isLoading;
15
- private error;
16
- /** 已加载过表单数据的 form_id 缓存标记 */
17
- private loadedFormIds;
18
- private window;
19
- constructor(name?: string, version?: string);
20
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
21
- /** 统一提交 formMap,仅此处触发 store changed */
22
- private commitFormMap;
23
- /** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
24
- private notifyFormMapChanged;
25
- getHolderFormMap(): HolderFormMap;
26
- getHolderFormData(formId: number | string): IFormItemData | undefined;
27
- setFormData(formId: number | string, data: Partial<IFormItemData>): void;
28
- private ensureFormItem;
29
- private hasFormData;
30
- private patchFormMap;
31
- fetchFormInfo(params: IFetchFormInfoParams): Promise<IFormInfo | IFormInfo[]>;
32
- fetchRecords(params: IFetchFormRecordsParams): Promise<any>;
33
- ensureFormData(params: IEnsureFormDataParams): Promise<IFormItemData>;
34
- ensureFormByProduct(params: IEnsureFormByProductParams): Promise<IFormItemData | null>;
35
- addFormRecord(params: IAddFormRecordParams): Promise<any>;
36
- /**
37
- * UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
38
- */
39
- appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
40
- removeFormRecord(formId: number | string, formRecordId: number): void;
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>;
47
- storeChange(path?: string): void;
48
- }