@pisell/pisellos 0.0.492 → 0.0.494

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 (35) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  3. package/dist/modules/Order/index.d.ts +5 -0
  4. package/dist/modules/Order/index.js +70 -5
  5. package/dist/modules/Order/utils.js +12 -2
  6. package/dist/modules/Quotation/index.d.ts +8 -0
  7. package/dist/modules/Quotation/index.js +46 -13
  8. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  9. package/dist/solution/BookingByStep/index.js +44 -42
  10. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  11. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  12. package/dist/solution/ScanOrder/utils.js +22 -3
  13. package/dist/solution/VenueBooking/index.d.ts +8 -9
  14. package/dist/solution/VenueBooking/index.js +612 -565
  15. package/dist/solution/VenueBooking/types.d.ts +7 -0
  16. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
  17. package/dist/solution/VenueBooking/utils/slotMerge.js +92 -15
  18. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  19. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  20. package/lib/modules/Order/index.d.ts +5 -0
  21. package/lib/modules/Order/index.js +37 -1
  22. package/lib/modules/Order/utils.js +13 -0
  23. package/lib/modules/Quotation/index.d.ts +8 -0
  24. package/lib/modules/Quotation/index.js +27 -6
  25. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  26. package/lib/solution/BookingByStep/index.js +4 -2
  27. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  28. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  29. package/lib/solution/ScanOrder/utils.js +20 -3
  30. package/lib/solution/VenueBooking/index.d.ts +8 -9
  31. package/lib/solution/VenueBooking/index.js +79 -69
  32. package/lib/solution/VenueBooking/types.d.ts +7 -0
  33. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +13 -2
  34. package/lib/solution/VenueBooking/utils/slotMerge.js +67 -13
  35. package/package.json +1 -1
@@ -91,8 +91,14 @@ export function findFastestAvailableResource(_ref2) {
91
91
  _ref2$currentCapacity = _ref2.currentCapacity,
92
92
  currentCapacity = _ref2$currentCapacity === void 0 ? 1 : _ref2$currentCapacity,
93
93
  _ref2$countMap = _ref2.countMap,
94
- countMap = _ref2$countMap === void 0 ? {} : _ref2$countMap;
94
+ countMap = _ref2$countMap === void 0 ? {} : _ref2$countMap,
95
+ targetDate = _ref2.targetDate,
96
+ _ref2$durationMinutes = _ref2.durationMinutes,
97
+ durationMinutes = _ref2$durationMinutes === void 0 ? 30 : _ref2$durationMinutes;
95
98
  var currentTime = dayjs();
99
+ var resolvedDuration = durationMinutes > 0 ? durationMinutes : 30;
100
+ var targetDay = targetDate ? dayjs(targetDate) : currentTime;
101
+ var isTargetDayToday = targetDay.isSame(currentTime, 'day');
96
102
  var fastestTime = null;
97
103
  var fastestResources = [];
98
104
  console.log('[TimeslotUtils] 查找最快可用资源:', {
@@ -108,17 +114,18 @@ export function findFastestAvailableResource(_ref2) {
108
114
  try {
109
115
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
110
116
  var _resource = _step2.value;
111
- // 获取资源当天且还在工作时间内的时间段
112
- var todayTimes = _resource.times.filter(function (time) {
113
- var isToday = dayjs(time.start_at).isSame(currentTime, 'day');
114
- var isStillWorking = dayjs(time.end_at).isAfter(currentTime);
115
- return isToday && isStillWorking;
117
+ // 获取资源在目标日期且还在工作时间内的时间段
118
+ var targetDayTimes = _resource.times.filter(function (time) {
119
+ var isSameTargetDay = dayjs(time.start_at).isSame(targetDay, 'day');
120
+ if (!isSameTargetDay) return false;
121
+ if (!isTargetDayToday) return true;
122
+ return dayjs(time.end_at).isAfter(currentTime);
116
123
  });
117
- if (todayTimes.length === 0) {
124
+ if (targetDayTimes.length === 0) {
118
125
  console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, ") \u4ECA\u65E5\u65E0\u53EF\u7528\u65F6\u95F4\u6BB5"));
119
126
  continue;
120
127
  }
121
- var _iterator4 = _createForOfIteratorHelper(todayTimes),
128
+ var _iterator4 = _createForOfIteratorHelper(targetDayTimes),
122
129
  _step4;
123
130
  try {
124
131
  var _loop = function _loop() {
@@ -128,7 +135,7 @@ export function findFastestAvailableResource(_ref2) {
128
135
  var workEndTime = dayjs(time.end_at);
129
136
 
130
137
  // 确定检查的起始时间(当前时间 vs 工作开始时间)
131
- var nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
138
+ var nextAvailableTime = isTargetDayToday && currentTime.isAfter(workStartTime) ? currentTime : workStartTime;
132
139
  console.log("[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, "):"), {
133
140
  workTime: "".concat(workStartTime.format('HH:mm'), "-").concat(workEndTime.format('HH:mm')),
134
141
  checkStartTime: nextAvailableTime.format('HH:mm:ss'),
@@ -165,7 +172,7 @@ export function findFastestAvailableResource(_ref2) {
165
172
  // 检查资源类型和容量
166
173
  if (_resource.resourceType === 'single' || (_resource.capacity || 1) === 1) {
167
174
  // 单人预约资源:检查时间冲突
168
- if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
175
+ if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(resolvedDuration, 'minute'))) {
169
176
  // 有冲突,使用事件结束时间
170
177
  finalAvailableTime = _eventEnd;
171
178
  console.log("[TimeslotUtils] \u53D1\u73B0\u65F6\u95F4\u51B2\u7A81\uFF0C\u8C03\u6574\u5230: ".concat(finalAvailableTime.format('HH:mm:ss')));
@@ -177,7 +184,7 @@ export function findFastestAvailableResource(_ref2) {
177
184
  var eventUsedCapacity = _event.pax || 1;
178
185
 
179
186
  // 如果在事件时间范围内,检查容量是否足够
180
- if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
187
+ if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(resolvedDuration, 'minute'))) {
181
188
  var totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
182
189
  if (totalRequiredCapacity > totalCapacity) {
183
190
  // 容量不足,使用事件结束时间
@@ -194,7 +201,7 @@ export function findFastestAvailableResource(_ref2) {
194
201
  } finally {
195
202
  _iterator5.f();
196
203
  }
197
- if (finalAvailableTime.isAfter(workEndTime)) {
204
+ if (finalAvailableTime.add(resolvedDuration, 'minute').isAfter(workEndTime)) {
198
205
  console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, " \u53EF\u7528\u65F6\u95F4\u8D85\u51FA\u5DE5\u4F5C\u65F6\u95F4\uFF0C\u8DF3\u8FC7"));
199
206
  return 0; // continue
200
207
  }
@@ -358,6 +358,25 @@ export function normalizeOrderProduct(product) {
358
358
  if (product.identity_key && !metadata.unique_identification_number) {
359
359
  metadata.unique_identification_number = product.identity_key;
360
360
  }
361
+ var resolvedOriginalPrice = product.original_price || '0.00';
362
+ var resolvedSellingPrice = product.selling_price || '0.00';
363
+ if (metadata.main_product_original_price === undefined) {
364
+ metadata.main_product_original_price = resolvedOriginalPrice;
365
+ }
366
+ if (metadata.main_product_selling_price === undefined) {
367
+ metadata.main_product_selling_price = resolvedSellingPrice;
368
+ }
369
+ if (metadata.source_product_price === undefined) {
370
+ var _product$_origin$orig, _product$_origin;
371
+ metadata.source_product_price = (_product$_origin$orig = (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.original_price) !== null && _product$_origin$orig !== void 0 ? _product$_origin$orig : resolvedOriginalPrice;
372
+ }
373
+ var normalizedBundle = (product.product_bundle || []).map(function (item) {
374
+ var _ref, _item$bundle_selling_, _ref2, _ref3, _item$custom_price;
375
+ return _objectSpread(_objectSpread({}, item), {}, {
376
+ bundle_selling_price: (_ref = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref !== void 0 ? _ref : '0.00',
377
+ custom_price: (_ref2 = (_ref3 = (_item$custom_price = item.custom_price) !== null && _item$custom_price !== void 0 ? _item$custom_price : item.bundle_selling_price) !== null && _ref3 !== void 0 ? _ref3 : item.price) !== null && _ref2 !== void 0 ? _ref2 : '0.00'
378
+ });
379
+ });
361
380
  return {
362
381
  order_detail_id: product.order_detail_id || null,
363
382
  product_id: product.product_id,
@@ -365,13 +384,13 @@ export function normalizeOrderProduct(product) {
365
384
  product_variant_id: product.product_variant_id,
366
385
  identity_key: product.identity_key,
367
386
  product_option_item: product.product_option_item || [],
368
- selling_price: product.selling_price || '0.00',
369
- original_price: product.original_price || '0.00',
387
+ selling_price: resolvedSellingPrice,
388
+ original_price: resolvedOriginalPrice,
370
389
  payment_price: product.payment_price || '0.00',
371
390
  tax_fee: product.tax_fee || '0.00',
372
391
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
373
392
  discount_list: product.discount_list || [],
374
- product_bundle: product.product_bundle || [],
393
+ product_bundle: normalizedBundle,
375
394
  metadata: metadata,
376
395
  _origin: product._origin
377
396
  };
@@ -60,14 +60,12 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
60
60
  passed: boolean | null;
61
61
  failures: QuantityCheckResult[];
62
62
  };
63
- loadVenueProducts(params: {
64
- productIds: number[];
65
- }): Promise<ProductData[]>;
66
- loadAddonProducts(params: {
67
- categoryIds?: number[];
68
- productIds?: number[];
69
- collectionIds?: number[];
70
- }): Promise<ProductData[]>;
63
+ loadAllProducts(): Promise<{
64
+ venueProducts: ProductData[];
65
+ addonProducts: ProductData[];
66
+ }>;
67
+ loadVenueProducts(): Promise<ProductData[]>;
68
+ loadAddonProducts(): Promise<ProductData[]>;
71
69
  getVenueProducts(): ProductData[];
72
70
  getAddonProductsList(): ProductData[];
73
71
  loadQuotations(params?: {
@@ -107,6 +105,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
107
105
  setSlotConfig(config: Partial<VenueBookingSlotConfig>): void;
108
106
  getSlotConfig(): VenueBookingSlotConfig;
109
107
  loadSchedules(): Promise<void>;
108
+ private injectScheduleResolverToQuotation;
110
109
  getScheduleListByIds(ids: number[]): import("../../server").ScheduleItem[];
111
110
  getTempOrder(): import("./types").ScanOrderTempOrder | null;
112
111
  updateTempOrderNote(note: string): string;
@@ -140,7 +139,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
140
139
  updates: Partial<ScanOrderOrderProduct>;
141
140
  }): Promise<ScanOrderOrderProduct[]>;
142
141
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
143
- getProductList(): Promise<any>;
142
+ getProductList(): Promise<ProductData[]>;
144
143
  private loadOpenDataConfig;
145
144
  private loadRuntimeConfigs;
146
145
  private fetchItemRuleConfigsByModelIds;