@pisell/pisellos 0.0.551 → 0.0.553

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 (32) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Holder/index.d.ts +7 -1
  3. package/dist/modules/Holder/index.js +153 -14
  4. package/dist/modules/Holder/types.d.ts +9 -1
  5. package/dist/modules/Holder/utils.d.ts +7 -3
  6. package/dist/modules/Holder/utils.js +16 -2
  7. package/dist/modules/Order/index.js +5 -1
  8. package/dist/modules/Order/utils.d.ts +2 -1
  9. package/dist/modules/Order/utils.js +21 -17
  10. package/dist/solution/BookingByStep/index.d.ts +8 -2
  11. package/dist/solution/BookingByStep/index.js +251 -212
  12. package/dist/solution/ScanOrder/index.d.ts +1 -1
  13. package/dist/solution/ScanOrder/index.js +72 -29
  14. package/dist/solution/ScanOrder/types.d.ts +6 -1
  15. package/dist/solution/VenueBooking/index.d.ts +5 -2
  16. package/dist/solution/VenueBooking/index.js +684 -656
  17. package/lib/modules/Holder/index.d.ts +7 -1
  18. package/lib/modules/Holder/index.js +75 -3
  19. package/lib/modules/Holder/types.d.ts +9 -1
  20. package/lib/modules/Holder/utils.d.ts +7 -3
  21. package/lib/modules/Holder/utils.js +18 -4
  22. package/lib/modules/Order/index.js +4 -1
  23. package/lib/modules/Order/utils.d.ts +2 -1
  24. package/lib/modules/Order/utils.js +11 -7
  25. package/lib/solution/BookingByStep/index.d.ts +8 -2
  26. package/lib/solution/BookingByStep/index.js +22 -10
  27. package/lib/solution/ScanOrder/index.d.ts +1 -1
  28. package/lib/solution/ScanOrder/index.js +40 -8
  29. package/lib/solution/ScanOrder/types.d.ts +6 -1
  30. package/lib/solution/VenueBooking/index.d.ts +5 -2
  31. package/lib/solution/VenueBooking/index.js +37 -16
  32. package/package.json +1 -1
@@ -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.553",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",