@pisell/pisellos 0.10.8 → 0.10.9

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 (98) hide show
  1. package/dist/core/index.js +0 -1
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  4. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  5. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  6. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  7. package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
  8. package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
  9. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
  10. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  11. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  12. package/dist/modules/Customer/index.d.ts +4 -0
  13. package/dist/modules/Customer/index.js +91 -59
  14. package/dist/modules/Customer/types.d.ts +2 -0
  15. package/dist/modules/Discount/index.d.ts +2 -0
  16. package/dist/modules/Discount/index.js +38 -5
  17. package/dist/modules/Discount/types.d.ts +11 -0
  18. package/dist/modules/Order/index.d.ts +20 -1
  19. package/dist/modules/Order/index.js +976 -730
  20. package/dist/modules/Order/types.d.ts +6 -1
  21. package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
  22. package/dist/modules/Order/utils/virtualSettlement.js +271 -0
  23. package/dist/modules/Order/utils.js +89 -48
  24. package/dist/modules/Payment/types.d.ts +2 -0
  25. package/dist/modules/Payment/utils.js +4 -1
  26. package/dist/modules/Payment/walletpass.d.ts +11 -0
  27. package/dist/modules/Payment/walletpass.js +235 -60
  28. package/dist/modules/Product/types.d.ts +23 -0
  29. package/dist/modules/ProductList/index.d.ts +15 -2
  30. package/dist/modules/ProductList/index.js +92 -13
  31. package/dist/modules/SalesSummary/index.d.ts +1 -0
  32. package/dist/modules/SalesSummary/index.js +4 -3
  33. package/dist/modules/SalesSummary/types.d.ts +1 -0
  34. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  35. package/dist/modules/SalesSummary/utils.js +21 -1
  36. package/dist/server/index.d.ts +9 -0
  37. package/dist/server/index.js +90 -58
  38. package/dist/server/modules/order/index.d.ts +1 -0
  39. package/dist/server/modules/order/index.js +252 -94
  40. package/dist/server/utils/small-ticket.js +2 -1
  41. package/dist/solution/BaseSales/index.d.ts +26 -2
  42. package/dist/solution/BaseSales/index.js +1310 -931
  43. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  44. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +78 -12
  45. package/dist/solution/BookingByStep/index.d.ts +3 -3
  46. package/dist/solution/BookingTicket/index.d.ts +5 -1
  47. package/dist/solution/BookingTicket/index.js +221 -159
  48. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  49. package/dist/solution/ScanOrder/index.js +25 -64
  50. package/lib/core/index.js +0 -1
  51. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
  53. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  54. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  55. package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
  56. package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
  57. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
  58. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  59. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  60. package/lib/modules/Customer/index.d.ts +4 -0
  61. package/lib/modules/Customer/index.js +11 -0
  62. package/lib/modules/Customer/types.d.ts +2 -0
  63. package/lib/modules/Discount/index.d.ts +2 -0
  64. package/lib/modules/Discount/index.js +37 -3
  65. package/lib/modules/Discount/types.d.ts +11 -0
  66. package/lib/modules/Order/index.d.ts +20 -1
  67. package/lib/modules/Order/index.js +393 -128
  68. package/lib/modules/Order/types.d.ts +6 -1
  69. package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
  70. package/lib/modules/Order/utils/virtualSettlement.js +300 -0
  71. package/lib/modules/Order/utils.js +65 -21
  72. package/lib/modules/Payment/types.d.ts +2 -0
  73. package/lib/modules/Payment/utils.js +5 -1
  74. package/lib/modules/Payment/walletpass.d.ts +11 -0
  75. package/lib/modules/Payment/walletpass.js +198 -17
  76. package/lib/modules/Product/types.d.ts +23 -0
  77. package/lib/modules/ProductList/index.d.ts +15 -2
  78. package/lib/modules/ProductList/index.js +85 -3
  79. package/lib/modules/SalesSummary/index.d.ts +1 -0
  80. package/lib/modules/SalesSummary/index.js +10 -2
  81. package/lib/modules/SalesSummary/types.d.ts +1 -0
  82. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  83. package/lib/modules/SalesSummary/utils.js +25 -1
  84. package/lib/server/index.d.ts +9 -0
  85. package/lib/server/index.js +54 -14
  86. package/lib/server/modules/order/index.d.ts +1 -0
  87. package/lib/server/modules/order/index.js +66 -2
  88. package/lib/server/utils/small-ticket.js +1 -1
  89. package/lib/solution/BaseSales/index.d.ts +26 -2
  90. package/lib/solution/BaseSales/index.js +261 -23
  91. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  92. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +61 -11
  93. package/lib/solution/BookingByStep/index.d.ts +3 -3
  94. package/lib/solution/BookingTicket/index.d.ts +5 -1
  95. package/lib/solution/BookingTicket/index.js +30 -2
  96. package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
  97. package/lib/solution/ScanOrder/index.js +17 -54
  98. package/package.json +1 -1
@@ -67,7 +67,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
67
67
  product_ids?: number[];
68
68
  collection?: number | string[];
69
69
  schedule_date?: string;
70
- }): Promise<any>;
70
+ }): Promise<ProductData[]>;
71
71
  /**
72
72
  * 通过 schedule 来读取商品,适用于 session 类商品
73
73
  *
@@ -87,7 +87,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
87
87
  date: string;
88
88
  product_ids?: number[];
89
89
  category_ids?: number[];
90
- }): Promise<any>;
90
+ }): Promise<ProductData[]>;
91
91
  /**
92
92
  * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
93
93
  *
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 6 | 4 | 3 | 5;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -64,6 +64,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
64
64
  scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
65
65
  private hydrateOrderCustomerFromScanDiscounts;
66
66
  private getDiscountCustomerId;
67
+ resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
68
+ /** 兼容既有优惠码扫码逻辑。 */
67
69
  private resolveCustomerByDiscountCustomerId;
68
70
  private findCustomerById;
69
71
  private normalizeCustomer;
@@ -126,7 +128,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
126
128
  loadProducts(params?: ILoadProductsParams, options?: {
127
129
  callback?: (result: any) => void;
128
130
  subscriberId?: string;
129
- }): Promise<any>;
131
+ }): Promise<ProductData[]>;
130
132
  /**
131
133
  * 获取加时商品列表。
132
134
  *
@@ -285,6 +287,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
285
287
  private buildOrderCustomerPayload;
286
288
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
287
289
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
290
+ protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
291
+ protected preferAuthoritativeProductQueryPrice(): boolean;
288
292
  /**
289
293
  * 获取客户分页信息
290
294
  * @returns 分页信息
@@ -399,7 +399,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
399
399
  }
400
400
  return null;
401
401
  }
402
- async resolveCustomerByDiscountCustomerId(customerId) {
402
+ async resolveCustomerById(customerId) {
403
403
  var _a;
404
404
  const localCustomers = this.store.customer.getCustomers();
405
405
  const localCustomer = this.findCustomerById(localCustomers, customerId);
@@ -413,7 +413,23 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
413
413
  num: 1
414
414
  });
415
415
  const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
416
- return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
416
+ if (remoteCustomer) {
417
+ return this.normalizeCustomer(remoteCustomer);
418
+ }
419
+ try {
420
+ const detailCustomer = await this.store.customer.queryCustomerDetail(customerId);
421
+ return detailCustomer ? this.normalizeCustomer(detailCustomer) : null;
422
+ } catch (error) {
423
+ console.warn(
424
+ "[BookingTicket] resolveCustomerById detail request failed",
425
+ { customerId, error }
426
+ );
427
+ return null;
428
+ }
429
+ }
430
+ /** 兼容既有优惠码扫码逻辑。 */
431
+ resolveCustomerByDiscountCustomerId(customerId) {
432
+ return this.resolveCustomerById(customerId);
417
433
  }
418
434
  findCustomerById(customers = [], customerId) {
419
435
  return customers.find((customer) => {
@@ -1020,6 +1036,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1020
1036
  waitForOrderCustomerPromotionRefresh() {
1021
1037
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1022
1038
  }
1039
+ async prepareProductPriceQueryContext(customerId) {
1040
+ await Promise.resolve();
1041
+ const normalizedCustomerId = Number(customerId || 0);
1042
+ const refreshTask = this.orderCustomerDiscountRefreshInFlight;
1043
+ const shouldWait = normalizedCustomerId > 1 && this.orderCustomerDiscountRefreshCustomerId === normalizedCustomerId && Boolean(refreshTask);
1044
+ if (shouldWait && refreshTask) {
1045
+ await refreshTask;
1046
+ }
1047
+ }
1048
+ preferAuthoritativeProductQueryPrice() {
1049
+ return true;
1050
+ }
1023
1051
  /**
1024
1052
  * 获取客户分页信息
1025
1053
  * @returns 分页信息
@@ -277,7 +277,7 @@ function transformDetailToProductAndBooking(cacheItem, ctx) {
277
277
  return { product: productInput, booking, cacheItem: preparedCacheItem };
278
278
  }
279
279
  function buildBasePayloadFromCacheItem(cacheItem, ctx) {
280
- var _a, _b, _c, _d;
280
+ var _a, _b, _c, _d, _e, _f;
281
281
  const other = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) || {};
282
282
  const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
283
283
  const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
@@ -304,6 +304,7 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
304
304
  bundle_edit: extend == null ? void 0 : extend.bundle_edit,
305
305
  discount_reason: extend == null ? void 0 : extend.discount_reason,
306
306
  discount_list: cacheItem == null ? void 0 : cacheItem.discount_list,
307
+ selected_settlement_snapshot: ((_e = cacheItem == null ? void 0 : cacheItem.metadata) == null ? void 0 : _e.selected_settlement_snapshot) ?? ((_f = extend == null ? void 0 : extend.metadata) == null ? void 0 : _f.selected_settlement_snapshot),
307
308
  _extend: extend
308
309
  };
309
310
  }
@@ -1708,60 +1708,23 @@ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
1708
1708
  schedule_datetime: scheduleDatetime,
1709
1709
  cacheId: this.cacheId
1710
1710
  });
1711
- if (Array.isArray(loaded)) {
1712
- const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1713
- loaded,
1714
- normalizedResourceId
1715
- );
1716
- const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1717
- this.enabledReservationRuleProducts = ruleProductsForResource;
1718
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1719
- if (occupancyMinutes !== void 0) {
1720
- tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1721
- }
1722
- if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1723
- pendingRequestEntryPax = 1;
1724
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1725
- if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1726
- pendingRequestPaxMin = paxBounds.min;
1727
- if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1728
- pendingRequestPaxMax = paxBounds.max;
1729
- }
1730
- } else {
1731
- this.enabledReservationRuleProducts = [];
1732
- const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1733
- this.logMethodError("loadReservationRuleProducts", error, {
1734
- resourceId: normalizedResourceId,
1735
- reservationLinkIds,
1736
- scheduleDate,
1737
- scheduleDatetime,
1738
- cacheId: this.cacheId
1739
- });
1740
- if (Array.isArray(loaded)) {
1741
- this.enabledReservationRuleProducts = loaded;
1742
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1743
- if (occupancyMinutes !== void 0) {
1744
- tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1745
- }
1746
- if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1747
- pendingRequestEntryPax = 1;
1748
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1749
- if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1750
- pendingRequestPaxMin = paxBounds.min;
1751
- if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1752
- pendingRequestPaxMax = paxBounds.max;
1753
- }
1754
- } else {
1755
- this.enabledReservationRuleProducts = [];
1756
- const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1757
- this.logMethodError("loadReservationRuleProducts", error2, {
1758
- resourceId,
1759
- reservationLinkIds,
1760
- scheduleDate,
1761
- scheduleDatetime,
1762
- cacheId: this.cacheId
1763
- });
1764
- }
1711
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1712
+ loaded,
1713
+ normalizedResourceId
1714
+ );
1715
+ const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1716
+ this.enabledReservationRuleProducts = ruleProductsForResource;
1717
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1718
+ if (occupancyMinutes !== void 0) {
1719
+ tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1720
+ }
1721
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1722
+ pendingRequestEntryPax = 1;
1723
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1724
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1725
+ pendingRequestPaxMin = paxBounds.min;
1726
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1727
+ pendingRequestPaxMax = paxBounds.max;
1765
1728
  }
1766
1729
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
1767
1730
  const occupyDetail = occupyDetails[0] ?? null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.8",
4
+ "version": "0.10.9",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",