feat:充值流程
This commit is contained in:
1 parent
a50a4a6a60
commit
28afa35b35
18 files changed
+521
-2
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 日期范围类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DateRangeTypeEnum {
|
||||
|
||||
YESTERDAY("0", "昨天"),
|
||||
TODAY("1", "今日"),
|
||||
THIS_WEEK("2", "本周"),
|
||||
THIS_MONTH("3", "本月"),
|
||||
CURRENT_SEASON("4", "本季度"),
|
||||
HALF_YEAR("5", "近半年"),
|
||||
THIS_YEAR("6", "本年"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static DateRangeTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.enums.DateRangeTypeEnum;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
|
||||
/**
|
||||
* 时间范围工具类
|
||||
*/
|
||||
@UtilityClass
|
||||
public class DateRangeTool {
|
||||
|
||||
static public LocalDate[] transitionDateTypeToDateList(DateRangeTypeEnum dateType) {
|
||||
LocalDateTime[] localDateTimes = transitionDateTypeToDateTimeList(dateType);
|
||||
return new LocalDate[]{localDateTimes[0].toLocalDate(), localDateTimes[1].toLocalDate(),};
|
||||
}
|
||||
|
||||
static public LocalDateTime[] transitionDateTypeToDateTimeList(DateRangeTypeEnum dateType) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
switch (dateType) {
|
||||
case YESTERDAY:
|
||||
return new LocalDateTime[]{
|
||||
LocalDateTime.now().minusDays(1).withHour(0).withMinute(0).withSecond(0),
|
||||
LocalDateTime.now().minusDays(1).withHour(23).withMinute(59).withSecond(59)
|
||||
};
|
||||
case TODAY:
|
||||
return new LocalDateTime[]{
|
||||
LocalDateTime.now().withHour(0).withMinute(0).withSecond(0),
|
||||
LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)
|
||||
};
|
||||
case THIS_WEEK:
|
||||
LocalDateTime weekStart = now.minusDays(7).withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime weekEnd = now.withHour(23).withMinute(59).withSecond(59);
|
||||
return new LocalDateTime[]{weekStart, weekEnd};
|
||||
case THIS_MONTH:
|
||||
LocalDateTime monthStart = now.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime monthEnd = now.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
|
||||
return new LocalDateTime[]{monthStart, monthEnd};
|
||||
case CURRENT_SEASON:
|
||||
LocalDateTime quarterStart = now.with(now.getMonth().firstMonthOfQuarter()).with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime quarterEnd = quarterStart.plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
|
||||
return new LocalDateTime[]{quarterStart, quarterEnd};
|
||||
case HALF_YEAR:
|
||||
LocalDateTime halfYearStart = now.with(now.getMonth().firstMonthOfQuarter()).with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime halfYearEnd = halfYearStart.plusMonths(6).with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
|
||||
return new LocalDateTime[]{halfYearStart, halfYearEnd};
|
||||
case THIS_YEAR:
|
||||
LocalDateTime yearStart = now.with(TemporalAdjusters.firstDayOfYear()).withHour(0).withMinute(0).withSecond(0);
|
||||
LocalDateTime yearEnd = now.with(TemporalAdjusters.lastDayOfYear()).withHour(23).withMinute(59).withSecond(59);
|
||||
return new LocalDateTime[]{yearStart, yearEnd};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user