@pisell/pisellos 2.1.176 → 2.1.177

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -261,10 +261,12 @@ var isInRepeatingSchedule = function isInRepeatingSchedule(targetDate, targetDat
261
261
 
262
262
  // 每日重复逻辑
263
263
  var isInDailyRepeat = function isInDailyRepeat(targetDate, startDate, endDate, repeatRule) {
264
- var daysDiff = targetDate.diff(startDate, 'day');
265
- if (daysDiff < 0) {
264
+ // dayjs#diff 会截断不足一天的负差值;必须先比较完整时刻,避免开始日前的
265
+ // 当天时段被误判为第 0 天。
266
+ if (targetDate.isBefore(startDate)) {
266
267
  return false;
267
268
  }
269
+ var daysDiff = targetDate.diff(startDate, 'day');
268
270
 
269
271
  // 检查频率
270
272
  if (daysDiff % repeatRule.frequency !== 0) {
@@ -283,6 +285,10 @@ var isInDailyRepeat = function isInDailyRepeat(targetDate, startDate, endDate, r
283
285
 
284
286
  // 每周重复逻辑
285
287
  var isInWeeklyRepeat = function isInWeeklyRepeat(targetDate, startDate, endDate, repeatRule) {
288
+ // 同上:不足一周的负差值会被截断为 0,开始时刻前不能命中重复规则。
289
+ if (targetDate.isBefore(startDate)) {
290
+ return false;
291
+ }
286
292
  var targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
287
293
 
288
294
  // 检查是否在指定的星期几内
@@ -292,9 +298,6 @@ var isInWeeklyRepeat = function isInWeeklyRepeat(targetDate, startDate, endDate,
292
298
 
293
299
  // 计算周差
294
300
  var weeksDiff = targetDate.diff(startDate, 'week');
295
- if (weeksDiff < 0) {
296
- return false;
297
- }
298
301
 
299
302
  // 检查频率
300
303
  if (weeksDiff % repeatRule.frequency !== 0) {
@@ -183,10 +183,10 @@ var isInRepeatingSchedule = (targetDate, targetDateString, targetTimeString, sch
183
183
  }
184
184
  };
185
185
  var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
186
- const daysDiff = targetDate.diff(startDate, "day");
187
- if (daysDiff < 0) {
186
+ if (targetDate.isBefore(startDate)) {
188
187
  return false;
189
188
  }
189
+ const daysDiff = targetDate.diff(startDate, "day");
190
190
  if (daysDiff % repeatRule.frequency !== 0) {
191
191
  return false;
192
192
  }
@@ -196,14 +196,14 @@ var isInDailyRepeat = (targetDate, startDate, endDate, repeatRule) => {
196
196
  return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
197
197
  };
198
198
  var isInWeeklyRepeat = (targetDate, startDate, endDate, repeatRule) => {
199
+ if (targetDate.isBefore(startDate)) {
200
+ return false;
201
+ }
199
202
  const targetDayOfWeek = targetDate.day();
200
203
  if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
201
204
  return false;
202
205
  }
203
206
  const weeksDiff = targetDate.diff(startDate, "week");
204
- if (weeksDiff < 0) {
205
- return false;
206
- }
207
207
  if (weeksDiff % repeatRule.frequency !== 0) {
208
208
  return false;
209
209
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.176",
4
+ "version": "2.1.177",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",