@pisell/pisellos 2.1.1 → 2.1.3

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 (31) hide show
  1. package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
  2. package/dist/modules/Cart/utils/changePrice.js +1 -1
  3. package/dist/modules/Discount/index.d.ts +2 -1
  4. package/dist/modules/Discount/index.js +67 -4
  5. package/dist/modules/Discount/types.d.ts +25 -0
  6. package/dist/modules/ProductList/index.d.ts +1 -2
  7. package/dist/modules/ProductList/index.js +26 -40
  8. package/dist/modules/ProductList/types.d.ts +0 -1
  9. package/dist/solution/BookingByStep/index.js +51 -35
  10. package/dist/solution/BookingByStep/types.d.ts +3 -2
  11. package/dist/solution/BookingByStep/utils/timeslots.js +161 -69
  12. package/dist/solution/BuyTickets/index.d.ts +2 -2
  13. package/dist/solution/BuyTickets/index.js +1 -1
  14. package/dist/solution/ShopDiscount/index.d.ts +1 -1
  15. package/dist/solution/ShopDiscount/index.js +6 -6
  16. package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
  17. package/lib/modules/Cart/utils/changePrice.js +1 -1
  18. package/lib/modules/Discount/index.d.ts +2 -1
  19. package/lib/modules/Discount/index.js +45 -3
  20. package/lib/modules/Discount/types.d.ts +25 -0
  21. package/lib/modules/ProductList/index.d.ts +1 -2
  22. package/lib/modules/ProductList/index.js +8 -24
  23. package/lib/modules/ProductList/types.d.ts +0 -1
  24. package/lib/solution/BookingByStep/index.js +40 -28
  25. package/lib/solution/BookingByStep/types.d.ts +3 -2
  26. package/lib/solution/BookingByStep/utils/timeslots.js +103 -49
  27. package/lib/solution/BuyTickets/index.d.ts +2 -2
  28. package/lib/solution/BuyTickets/index.js +1 -1
  29. package/lib/solution/ShopDiscount/index.d.ts +1 -1
  30. package/lib/solution/ShopDiscount/index.js +2 -2
  31. package/package.json +1 -1
@@ -390,7 +390,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
390
390
  }
391
391
  // 获取商品/服务的可用日期
392
392
  async getAvailableDate(params = {}) {
393
- var _a, _b, _c;
393
+ var _a, _b, _c, _d;
394
394
  let { products, startDate, endDate, type, useCache = true } = params;
395
395
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
396
396
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -407,14 +407,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
407
407
  if (this.store.currentProduct) {
408
408
  tempProducts = [
409
409
  {
410
- ...this.store.currentProduct.getData(),
411
- _schedule: this.store.currentProduct.getOtherParams()["schedule"]
410
+ ...this.store.currentProduct,
411
+ _schedule: (_a = this.store.currentProductMeta) == null ? void 0 : _a["schedule"]
412
412
  }
413
413
  ];
414
414
  }
415
415
  let dateRange = this.store.date.getDateRange();
416
- const tempStartDate = startDate || ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date);
417
- const tempEndDate = endDate || ((_b = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _b.date) || ((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date);
416
+ const tempStartDate = startDate || ((_b = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _b.date);
417
+ const tempEndDate = endDate || ((_c = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _c.date) || ((_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date);
418
418
  if (!tempProducts.length) {
419
419
  return [];
420
420
  }
@@ -694,7 +694,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
694
694
  }
695
695
  if (!allOriginResources.length) {
696
696
  const dateList = this.store.date.getDateList();
697
- dateList.forEach((n) => {
697
+ dateList == null ? void 0 : dateList.forEach((n) => {
698
698
  if (n.resource)
699
699
  allOriginResources.push(...n.resource);
700
700
  });
@@ -1596,15 +1596,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1596
1596
  }
1597
1597
  // 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
1598
1598
  async openProductDetail(productId) {
1599
- const targetProduct = await this.store.products.getProduct(productId);
1600
- if (targetProduct) {
1601
- const targetProductData = targetProduct.getData();
1602
- this.store.currentProduct = targetProduct;
1599
+ const targetProductData = await this.store.products.getProduct(productId);
1600
+ if (targetProductData) {
1601
+ this.store.currentProduct = targetProductData;
1602
+ this.store.currentProductMeta = {};
1603
1603
  if (targetProductData["schedule.ids"]) {
1604
1604
  const newScheduleArr = this.getScheduleDataByIds(
1605
1605
  targetProductData["schedule.ids"]
1606
1606
  );
1607
- targetProduct.setOtherParams("schedule", newScheduleArr);
1607
+ if (!this.store.currentProductMeta)
1608
+ this.store.currentProductMeta = {};
1609
+ this.store.currentProductMeta.schedule = newScheduleArr;
1608
1610
  } else if (targetProductData.duration) {
1609
1611
  const dateRange = this.store.date.getDateRange();
1610
1612
  if (!(dateRange == null ? void 0 : dateRange.length))
@@ -1618,8 +1620,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1618
1620
  }
1619
1621
  }
1620
1622
  closeProductDetail() {
1621
- var _a;
1622
- (_a = this.store.currentProduct) == null ? void 0 : _a.setOtherParams("schedule", []);
1623
+ if (this.store.currentProductMeta) {
1624
+ this.store.currentProductMeta.schedule = [];
1625
+ }
1623
1626
  this.store.currentProduct = void 0;
1624
1627
  }
1625
1628
  getTimeslotBySchedule({
@@ -1628,9 +1631,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1628
1631
  resources,
1629
1632
  product
1630
1633
  }) {
1631
- var _a, _b, _c, _d, _e, _f;
1634
+ var _a, _b, _c, _d, _e;
1632
1635
  const targetProduct = this.store.currentProduct;
1633
- const targetProductData = product || (targetProduct == null ? void 0 : targetProduct.getData());
1636
+ const targetProductData = product || targetProduct;
1634
1637
  let targetSchedules = [];
1635
1638
  if (scheduleIds == null ? void 0 : scheduleIds.length) {
1636
1639
  targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
@@ -1650,7 +1653,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1650
1653
  );
1651
1654
  const productResources = (0, import_resources.getResourcesByProduct)(
1652
1655
  resourcesMap,
1653
- resources || ((_c = (_b = (_a = this.store.currentProduct) == null ? void 0 : _a.getData()) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
1656
+ resources || ((_b = (_a = this.store.currentProduct) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
1654
1657
  selectedResources,
1655
1658
  1
1656
1659
  );
@@ -1671,9 +1674,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1671
1674
  return -1;
1672
1675
  return 0;
1673
1676
  });
1674
- const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
1677
+ const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1675
1678
  (n) => n.status === 1
1676
- )) == null ? void 0 : _f.id;
1679
+ )) == null ? void 0 : _e.id;
1677
1680
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1678
1681
  const resourcesUseableMap = {};
1679
1682
  let count = 0;
@@ -1747,9 +1750,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1747
1750
  return this.otherData[key];
1748
1751
  }
1749
1752
  async getProductTypeById(id) {
1750
- const product = await this.store.products.getProduct(id);
1751
- if (product) {
1752
- return product.getProductType();
1753
+ var _a;
1754
+ const productData = await this.store.products.getProduct(id);
1755
+ if (productData) {
1756
+ if (productData.duration) {
1757
+ return "duration";
1758
+ }
1759
+ if ((_a = productData["schedule.ids"]) == null ? void 0 : _a.length) {
1760
+ return "session";
1761
+ }
1762
+ return "normal";
1753
1763
  }
1754
1764
  return "normal";
1755
1765
  }
@@ -1910,7 +1920,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1910
1920
  return results;
1911
1921
  }
1912
1922
  async getAvailableDateForSessionOptimize(params = {}) {
1913
- var _a, _b, _c, _d, _e, _f;
1923
+ var _a, _b, _c, _d;
1914
1924
  let { startDate, endDate } = params;
1915
1925
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
1916
1926
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -1926,7 +1936,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1926
1936
  tempEndDate = endDate || "";
1927
1937
  }
1928
1938
  endDate = tempEndDate;
1929
- const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
1939
+ const cache = (_a = this.store.currentProductMeta) == null ? void 0 : _a["timeSlotBySchedule"];
1930
1940
  if (cache) {
1931
1941
  if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
1932
1942
  this.store.date.setDateList(cache.dateList);
@@ -1937,8 +1947,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1937
1947
  }
1938
1948
  }
1939
1949
  let tempProducts;
1940
- tempProducts = (_b = this.store.currentProduct) == null ? void 0 : _b.getData();
1941
- const schedule = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["schedule"];
1950
+ tempProducts = this.store.currentProduct;
1951
+ const schedule = (_b = this.store.currentProductMeta) == null ? void 0 : _b["schedule"];
1942
1952
  const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
1943
1953
  schedule,
1944
1954
  startDate || "",
@@ -1955,7 +1965,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1955
1965
  let dates = [];
1956
1966
  let currentDate = (0, import_dayjs.default)(startDate);
1957
1967
  let firstAvailableDate = "";
1958
- const openResources = ((_e = (_d = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.filter(
1968
+ const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
1959
1969
  (m) => m.status === 1
1960
1970
  )) || [];
1961
1971
  const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
@@ -2056,12 +2066,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2056
2066
  }
2057
2067
  dates = (0, import_utils3.handleAvailableDateByResource)(res.data, dates);
2058
2068
  this.store.date.setDateList(dates);
2059
- (_f = this.store.currentProduct) == null ? void 0 : _f.setOtherParams("timeSlotBySchedule", {
2069
+ if (!this.store.currentProductMeta)
2070
+ this.store.currentProductMeta = {};
2071
+ this.store.currentProductMeta.timeSlotBySchedule = {
2060
2072
  dateList: dates,
2061
2073
  firstAvailableDate,
2062
2074
  startDate,
2063
2075
  endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
2064
- });
2076
+ };
2065
2077
  return {
2066
2078
  dateList: dates,
2067
2079
  firstAvailableDate
@@ -1,4 +1,4 @@
1
- import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
1
+ import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
2
2
  export interface BookingByStepState {
3
3
  cart: CartModule;
4
4
  summary: SummaryModule;
@@ -11,7 +11,8 @@ export interface BookingByStepState {
11
11
  accountList: AccountListModule;
12
12
  order: OrderModule;
13
13
  payment: PaymentModule;
14
- currentProduct?: Product;
14
+ currentProduct?: ProductData;
15
+ currentProductMeta?: Record<string, any>;
15
16
  schedule: ScheduleModule;
16
17
  }
17
18
  export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
@@ -79,78 +79,132 @@ function findFastestAvailableResource({
79
79
  currentCapacity = 1,
80
80
  countMap = {}
81
81
  }) {
82
- var _a, _b;
82
+ var _a, _b, _c;
83
83
  const currentTime = (0, import_dayjs.default)();
84
84
  let fastestTime = null;
85
85
  let fastestResources = [];
86
+ console.log("[TimeslotUtils] 查找最快可用资源:", {
87
+ currentTime: currentTime.format("YYYY-MM-DD HH:mm:ss"),
88
+ resourceCount: resources.length,
89
+ currentCapacity,
90
+ countMap
91
+ });
86
92
  for (const resource of resources) {
87
93
  const todayTimes = resource.times.filter((time) => {
88
- return (0, import_dayjs.default)(time.start_at).isSame(currentTime, "day");
94
+ const isToday = (0, import_dayjs.default)(time.start_at).isSame(currentTime, "day");
95
+ const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
96
+ return isToday && isStillWorking;
89
97
  });
90
- if (todayTimes.length === 0)
98
+ if (todayTimes.length === 0) {
99
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
91
100
  continue;
92
- todayTimes.sort((a, b) => {
93
- return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at));
94
- });
101
+ }
95
102
  for (const time of todayTimes) {
96
- const startTime = (0, import_dayjs.default)(time.start_at);
97
- if (startTime.isBefore(currentTime))
98
- continue;
99
- if (resource.resourceType === "single") {
100
- const hasBooking = (_a = time.event_list) == null ? void 0 : _a.some((event) => {
101
- return (0, import_dayjs.default)(event.start_at).isSame(startTime);
103
+ const workStartTime = (0, import_dayjs.default)(time.start_at);
104
+ const workEndTime = (0, import_dayjs.default)(time.end_at);
105
+ let nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
106
+ console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
107
+ workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
108
+ checkStartTime: nextAvailableTime.format("HH:mm:ss"),
109
+ eventCount: ((_a = time.event_list) == null ? void 0 : _a.length) || 0
110
+ });
111
+ const relevantEvents = ((_b = time.event_list) == null ? void 0 : _b.filter((event) => {
112
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
113
+ return eventEnd.isAfter(nextAvailableTime);
114
+ })) || [];
115
+ relevantEvents.sort(
116
+ (a, b) => (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at))
117
+ );
118
+ let finalAvailableTime = nextAvailableTime;
119
+ for (const event of relevantEvents) {
120
+ const eventStart = (0, import_dayjs.default)(event.start_at);
121
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
122
+ console.log(`[TimeslotUtils] 检查事件冲突:`, {
123
+ resourceId: resource.id,
124
+ eventTime: `${eventStart.format("HH:mm")}-${eventEnd.format("HH:mm")}`,
125
+ checkTime: finalAvailableTime.format("HH:mm:ss"),
126
+ pax: event.pax || 1
102
127
  });
103
- if (!hasBooking) {
104
- if (!fastestTime || startTime.isSame(fastestTime)) {
105
- fastestTime = startTime;
106
- fastestResources.push(resource);
107
- } else if (startTime.isBefore(fastestTime)) {
108
- fastestTime = startTime;
109
- fastestResources = [resource];
128
+ if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
129
+ if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
130
+ finalAvailableTime = eventEnd;
131
+ console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
110
132
  }
111
- break;
112
- }
113
- } else {
114
- const totalCapacity = resource.capacity || 0;
115
- const usedCapacity = ((_b = time.event_list) == null ? void 0 : _b.reduce((sum, event) => {
116
- return (0, import_dayjs.default)(event.start_at).isSame(startTime) ? sum + (event.pax || 0) : sum;
117
- }, 0)) || 0;
118
- const remainingCapacity = totalCapacity - usedCapacity;
119
- if (remainingCapacity >= (countMap[resource.id] || 0) + currentCapacity) {
120
- if (!fastestTime || startTime.isSame(fastestTime)) {
121
- fastestTime = startTime;
122
- fastestResources.push(resource);
123
- } else if (startTime.isBefore(fastestTime)) {
124
- fastestTime = startTime;
125
- fastestResources = [resource];
133
+ } else {
134
+ const totalCapacity = resource.capacity || 0;
135
+ const currentUsedCapacity = countMap[resource.id] || 0;
136
+ const eventUsedCapacity = event.pax || 1;
137
+ if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(30, "minute"))) {
138
+ const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
139
+ if (totalRequiredCapacity > totalCapacity) {
140
+ finalAvailableTime = eventEnd;
141
+ console.log(`[TimeslotUtils] 容量不足,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
142
+ }
126
143
  }
127
- break;
128
144
  }
129
145
  }
146
+ if (finalAvailableTime.isAfter(workEndTime)) {
147
+ console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
148
+ continue;
149
+ }
150
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 最快可用时间: ${finalAvailableTime.format("HH:mm:ss")}`);
151
+ if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
152
+ fastestTime = finalAvailableTime;
153
+ fastestResources = [resource];
154
+ console.log(`[TimeslotUtils] 更新最快时间: ${fastestTime.format("HH:mm:ss")}, 资源: ${resource.main_field}`);
155
+ } else if (finalAvailableTime.isSame(fastestTime)) {
156
+ fastestResources.push(resource);
157
+ console.log(`[TimeslotUtils] 添加相同时间资源: ${resource.main_field}`);
158
+ }
159
+ break;
130
160
  }
131
161
  }
132
- if (!fastestTime || fastestResources.length === 0)
162
+ if (!fastestTime || fastestResources.length === 0) {
163
+ console.log("[TimeslotUtils] 未找到可用资源");
133
164
  return null;
134
- if (fastestResources.length === 1)
165
+ }
166
+ console.log(`[TimeslotUtils] 找到 ${fastestResources.length} 个最快可用资源,时间: ${fastestTime.format("HH:mm:ss")}`);
167
+ if (fastestResources.length === 1) {
168
+ console.log(`[TimeslotUtils] 返回唯一最快资源: ${fastestResources[0].main_field}`);
135
169
  return fastestResources[0];
170
+ }
171
+ let selectedResource = fastestResources[0];
136
172
  let maxIdleTime = 0;
137
- let selectedResource = null;
173
+ console.log(`[TimeslotUtils] 比较 ${fastestResources.length} 个资源的空闲时间:`);
138
174
  for (const resource of fastestResources) {
139
- const idleTime = calculateResourceAvailableTime({
140
- resource,
141
- timeSlots: {
142
- start_time: fastestTime.format("HH:mm"),
143
- end_time: fastestTime.format("HH:mm"),
144
- start_at: fastestTime,
145
- end_at: fastestTime
146
- },
147
- currentCapacity: (countMap[resource.id] || 0) + currentCapacity
175
+ const workingTime = resource.times.find((time) => {
176
+ const isToday = (0, import_dayjs.default)(time.start_at).isSame(fastestTime, "day");
177
+ const isStillWorking = (0, import_dayjs.default)(time.end_at).isAfter(fastestTime);
178
+ return isToday && isStillWorking;
179
+ });
180
+ if (!workingTime)
181
+ continue;
182
+ const workEndTime = (0, import_dayjs.default)(workingTime.end_at);
183
+ let totalIdleTime = workEndTime.diff(fastestTime, "minute");
184
+ const relevantEvents = ((_c = workingTime.event_list) == null ? void 0 : _c.filter((event) => {
185
+ const eventStart = (0, import_dayjs.default)(event.start_at);
186
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
187
+ return eventEnd.isAfter(fastestTime) && eventStart.isAfter(fastestTime);
188
+ })) || [];
189
+ for (const event of relevantEvents) {
190
+ const eventStart = (0, import_dayjs.default)(event.start_at);
191
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
192
+ const eventDuration = eventEnd.diff(eventStart, "minute");
193
+ totalIdleTime -= eventDuration;
194
+ }
195
+ console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}):`, {
196
+ 工作结束时间: workEndTime.format("HH:mm"),
197
+ 总工作时长: workEndTime.diff(fastestTime, "minute") + "分钟",
198
+ 预约占用时长: workEndTime.diff(fastestTime, "minute") - totalIdleTime + "分钟",
199
+ 实际空闲时长: totalIdleTime + "分钟"
148
200
  });
149
- if (idleTime > maxIdleTime) {
150
- maxIdleTime = idleTime;
201
+ if (totalIdleTime > maxIdleTime) {
202
+ maxIdleTime = totalIdleTime;
151
203
  selectedResource = resource;
204
+ console.log(`[TimeslotUtils] 更新最佳选择: ${resource.main_field} (空闲${totalIdleTime}分钟)`);
152
205
  }
153
206
  }
207
+ console.log(`[TimeslotUtils] 最终选择资源: ${selectedResource.main_field} (最长空闲${maxIdleTime}分钟)`);
154
208
  return selectedResource;
155
209
  }
156
210
  function filterConditionTimeSlots(times, startTime, endTime) {
@@ -1,5 +1,5 @@
1
1
  import { Module, PisellCore } from '../../types';
2
- import { Product, ProductData } from '../../modules/';
2
+ import { ProductData } from '../../modules/';
3
3
  import { BaseModule } from '../../modules/BaseModule';
4
4
  export * from './types';
5
5
  export declare class BuyTicketsImpl extends BaseModule implements Module {
@@ -16,7 +16,7 @@ export declare class BuyTicketsImpl extends BaseModule implements Module {
16
16
  loadProductsByCategory(categoryId: number): Promise<void>;
17
17
  destroy(): Promise<void>;
18
18
  getProducts(): Promise<ProductData[]>;
19
- getProduct(id: number): Promise<Product>;
19
+ getProduct(id: number): Promise<ProductData>;
20
20
  listSubmit(data: Record<string, any>): Promise<{
21
21
  status: boolean;
22
22
  data: any;
@@ -98,7 +98,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
98
98
  return mainProduct;
99
99
  if (otherProduct)
100
100
  return otherProduct;
101
- return Promise.reject("Not fund product for id: " + id);
101
+ throw new Error(`Product not found: ${id}`);
102
102
  }
103
103
  // 商品列表页提交
104
104
  async listSubmit(data) {
@@ -34,7 +34,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
34
34
  discountList: Discount[];
35
35
  };
36
36
  setProductList(productList: Record<string, any>[]): void;
37
- scanCode(code: string): Promise<{
37
+ scanCode(code: string, customerId?: number): Promise<{
38
38
  isAvailable: boolean;
39
39
  productList: Record<string, any>[];
40
40
  discountList: Discount[];
@@ -198,10 +198,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
198
198
  this.store.productList = productList;
199
199
  }
200
200
  // 扫码输入code
201
- async scanCode(code) {
201
+ async scanCode(code, customerId) {
202
202
  var _a, _b;
203
203
  try {
204
- const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code)) || [];
204
+ const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
205
205
  const rulesModule = this.store.rules;
206
206
  if (!rulesModule) {
207
207
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.1",
4
+ "version": "2.1.3",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",