@pisell/pisellos 0.0.556 → 0.0.558

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 (68) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +3 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  4. package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
  5. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  6. package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
  7. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  8. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  9. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  10. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  11. package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  12. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  13. package/dist/model/strategy/adapter/index.d.ts +4 -0
  14. package/dist/model/strategy/adapter/index.js +5 -1
  15. package/dist/modules/Order/index.d.ts +1 -1
  16. package/dist/modules/Product/index.d.ts +1 -1
  17. package/dist/modules/ProductList/index.d.ts +2 -1
  18. package/dist/modules/ProductList/index.js +21 -11
  19. package/dist/solution/BookingByStep/index.d.ts +2 -2
  20. package/dist/solution/ScanOrder/index.d.ts +2 -1
  21. package/dist/solution/ScanOrder/index.js +137 -117
  22. package/dist/solution/ScanOrder/utils.d.ts +5 -0
  23. package/dist/solution/ScanOrder/utils.js +55 -23
  24. package/dist/solution/VenueBooking/index.d.ts +22 -3
  25. package/dist/solution/VenueBooking/index.js +259 -166
  26. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  27. package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
  28. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  29. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
  30. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +69 -0
  31. package/dist/solution/VenueBooking/utils/smartPricing.js +233 -0
  32. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  33. package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
  34. package/lib/index.d.ts +1 -0
  35. package/lib/index.js +3 -0
  36. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
  37. package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
  38. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
  39. package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
  40. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  41. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  42. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  43. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  44. package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
  45. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  46. package/lib/model/strategy/adapter/index.d.ts +4 -0
  47. package/lib/model/strategy/adapter/index.js +13 -2
  48. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  49. package/lib/modules/Order/index.d.ts +1 -1
  50. package/lib/modules/Product/index.d.ts +1 -1
  51. package/lib/modules/ProductList/index.d.ts +2 -1
  52. package/lib/modules/ProductList/index.js +45 -40
  53. package/lib/solution/BookingByStep/index.d.ts +2 -2
  54. package/lib/solution/ScanOrder/index.d.ts +2 -1
  55. package/lib/solution/ScanOrder/index.js +29 -18
  56. package/lib/solution/ScanOrder/utils.d.ts +5 -0
  57. package/lib/solution/ScanOrder/utils.js +23 -0
  58. package/lib/solution/VenueBooking/index.d.ts +22 -3
  59. package/lib/solution/VenueBooking/index.js +151 -63
  60. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  61. package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
  62. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  63. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
  64. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +69 -0
  65. package/lib/solution/VenueBooking/utils/smartPricing.js +180 -0
  66. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  67. package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
  68. package/package.json +1 -1
@@ -629,23 +629,55 @@ export function collectLinkProductIdsFromReservationRules(rules) {
629
629
  }
630
630
 
631
631
  /**
632
- * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
632
+ * 找到第一个归属指定桌台的预约规则商品。
633
+ * 归属判断基于商品资源中的 default_resource / optional_resource。
633
634
  */
634
- export function pickFirstDurationMinutesFromProducts(products) {
635
+ export function findReservationRuleProductByResourceId(products, resourceId) {
636
+ var numericResourceId = Number(resourceId);
637
+ if (!Number.isFinite(numericResourceId) || numericResourceId <= 0) return undefined;
635
638
  var _iterator7 = _createForOfIteratorHelper(products),
636
639
  _step7;
637
640
  try {
638
641
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
639
- var _product$duration;
642
+ var _product$product_reso;
640
643
  var product = _step7.value;
644
+ var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
645
+ if (!Array.isArray(resources)) continue;
646
+ var hasMatchedResource = resources.some(function (resource) {
647
+ var defaultResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.default_resource) ? resource.default_resource : [];
648
+ var optionalResources = Array.isArray(resource === null || resource === void 0 ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
649
+ return [].concat(_toConsumableArray(defaultResources), _toConsumableArray(optionalResources)).some(function (id) {
650
+ return Number(id) === numericResourceId;
651
+ });
652
+ });
653
+ if (hasMatchedResource) return product;
654
+ }
655
+ } catch (err) {
656
+ _iterator7.e(err);
657
+ } finally {
658
+ _iterator7.f();
659
+ }
660
+ return undefined;
661
+ }
662
+
663
+ /**
664
+ * 返回列表中第一个带有效 duration.value(分钟)的商品时长。
665
+ */
666
+ export function pickFirstDurationMinutesFromProducts(products) {
667
+ var _iterator8 = _createForOfIteratorHelper(products),
668
+ _step8;
669
+ try {
670
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
671
+ var _product$duration;
672
+ var product = _step8.value;
641
673
  var value = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.value;
642
674
  var n = Number(value);
643
675
  if (Number.isFinite(n) && n > 0) return Math.floor(n);
644
676
  }
645
677
  } catch (err) {
646
- _iterator7.e(err);
678
+ _iterator8.e(err);
647
679
  } finally {
648
- _iterator7.f();
680
+ _iterator8.f();
649
681
  }
650
682
  return undefined;
651
683
  }
@@ -675,11 +707,11 @@ export function computeResourceIsFull(params) {
675
707
  if (!Number.isFinite(totalCapacity) || totalCapacity <= 0) return false;
676
708
  var now = dayjs();
677
709
  var occupied = 0;
678
- var _iterator8 = _createForOfIteratorHelper(capacityList || []),
679
- _step8;
710
+ var _iterator9 = _createForOfIteratorHelper(capacityList || []),
711
+ _step9;
680
712
  try {
681
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
682
- var slot = _step8.value;
713
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
714
+ var slot = _step9.value;
683
715
  var start = dayjs(slot === null || slot === void 0 ? void 0 : slot.start_at);
684
716
  var end = dayjs(slot === null || slot === void 0 ? void 0 : slot.end_at);
685
717
  if (!start.isValid() || !end.isValid()) continue;
@@ -689,9 +721,9 @@ export function computeResourceIsFull(params) {
689
721
  }
690
722
  }
691
723
  } catch (err) {
692
- _iterator8.e(err);
724
+ _iterator9.e(err);
693
725
  } finally {
694
- _iterator8.f();
726
+ _iterator9.f();
695
727
  }
696
728
  return occupied >= totalCapacity;
697
729
  }
@@ -701,11 +733,11 @@ export function computeResourceIsFull(params) {
701
733
  * 仅返回有限数字字段;若均无法解析则返回 `undefined`。
702
734
  */
703
735
  export function pickFirstCustomCapacityPaxBounds(products) {
704
- var _iterator9 = _createForOfIteratorHelper(products),
705
- _step9;
736
+ var _iterator10 = _createForOfIteratorHelper(products),
737
+ _step10;
706
738
  try {
707
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
708
- var p = _step9.value;
739
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
740
+ var p = _step10.value;
709
741
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
710
742
  if (!cap || cap.type !== 'custom') continue;
711
743
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -724,9 +756,9 @@ export function pickFirstCustomCapacityPaxBounds(products) {
724
756
  if (out.min !== undefined || out.max !== undefined) return out;
725
757
  }
726
758
  } catch (err) {
727
- _iterator9.e(err);
759
+ _iterator10.e(err);
728
760
  } finally {
729
- _iterator9.f();
761
+ _iterator10.f();
730
762
  }
731
763
  return undefined;
732
764
  }
@@ -736,11 +768,11 @@ export function pickFirstCustomCapacityPaxBounds(products) {
736
768
  * 无匹配时返回 `undefined`,调用方应回退为 `0`。
737
769
  */
738
770
  export function pickFirstCustomCapacityDimensionId(products) {
739
- var _iterator10 = _createForOfIteratorHelper(products),
740
- _step10;
771
+ var _iterator11 = _createForOfIteratorHelper(products),
772
+ _step11;
741
773
  try {
742
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
743
- var p = _step10.value;
774
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
775
+ var p = _step11.value;
744
776
  var cap = p === null || p === void 0 ? void 0 : p.capacity;
745
777
  if (!cap || cap.type !== 'custom') continue;
746
778
  if (!Array.isArray(cap.custom) || cap.custom.length === 0) continue;
@@ -756,9 +788,9 @@ export function pickFirstCustomCapacityDimensionId(products) {
756
788
  }
757
789
  }
758
790
  } catch (err) {
759
- _iterator10.e(err);
791
+ _iterator11.e(err);
760
792
  } finally {
761
- _iterator10.f();
793
+ _iterator11.f();
762
794
  }
763
795
  return undefined;
764
796
  }
@@ -3,6 +3,7 @@ import { BaseModule } from '../../modules/BaseModule';
3
3
  import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
4
  import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
5
  import type { UpdateProductInOrderParams } from '../../modules/Order/types';
6
+ import type { ScheduleItem } from '../../modules/Schedule/types';
6
7
  import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
8
  import type { ProductData } from '../../modules/Product/types';
8
9
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -41,6 +42,10 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
42
  private productsLoaded;
42
43
  private loadOpenDataConfigInFlight;
43
44
  private static readonly OPEN_DATA_CACHE_TTL;
45
+ /** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
46
+ private slotPriceMapCache;
47
+ /** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
48
+ private smartPricingProductCatalog;
44
49
  private getLoggerContext;
45
50
  private safeStringify;
46
51
  private pickErrorMessage;
@@ -75,6 +80,21 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
75
80
  passed: boolean | null;
76
81
  failures: QuantityCheckResult[];
77
82
  };
83
+ /** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
84
+ private clearSlotPriceMapCache;
85
+ /** 读取当前登录 customerId */
86
+ private resolveCustomerIdForSmartPricing;
87
+ /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
88
+ private getScheduleListForSmartPricing;
89
+ /** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
90
+ private buildSmartPricingContext;
91
+ /** venue + addon 全量商品,供智能定价评估 */
92
+ private getAllProductsForSmartPricing;
93
+ private getSlotPriceMapCacheKey;
94
+ /**
95
+ * 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
96
+ */
97
+ private buildSlotPriceMapForDate;
78
98
  loadAllProducts(): Promise<{
79
99
  venueProducts: ProductData[];
80
100
  addonProducts: ProductData[];
@@ -147,8 +167,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
147
167
  setSlotConfig(config: Partial<VenueBookingSlotConfig>): void;
148
168
  getSlotConfig(): VenueBookingSlotConfig;
149
169
  loadSchedules(): Promise<void>;
150
- private injectScheduleResolverToQuotation;
151
- getScheduleListByIds(ids: number[]): import("../../server").ScheduleItem[];
170
+ getScheduleListByIds(ids: number[]): ScheduleItem[];
152
171
  getTempOrder(): import("./types").ScanOrderTempOrder | null;
153
172
  updateTempOrderNote(note: string): string;
154
173
  updateTempOrderContactsInfo(contactsInfo: any[]): any[];
@@ -156,7 +175,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
156
175
  onCustomerLogin(params: {
157
176
  customerId: number;
158
177
  }): Promise<void>;
159
- private recalculateOrderPricesFromQuotation;
178
+ private recalculateOrderPricesFromSmartPricing;
160
179
  scanCode(code: string, customerId?: number): Promise<{
161
180
  isAvailable: boolean;
162
181
  discountList: import("../../modules/Discount").Discount[];