diff --git a/bweb/src/main/java/com/hfkj/config/AuthConfig.java b/bweb/src/main/java/com/hfkj/config/AuthConfig.java index 0f20dd3..d32876b 100644 --- a/bweb/src/main/java/com/hfkj/config/AuthConfig.java +++ b/bweb/src/main/java/com/hfkj/config/AuthConfig.java @@ -90,6 +90,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/secUser/*") .excludePathPatterns("/cornucopia/*") .excludePathPatterns("/partner/*") + .excludePathPatterns("/userCount/*") ; } diff --git a/bweb/src/main/java/com/hfkj/controller/BsUserCountController.java b/bweb/src/main/java/com/hfkj/controller/BsUserCountController.java new file mode 100644 index 0000000..95d4019 --- /dev/null +++ b/bweb/src/main/java/com/hfkj/controller/BsUserCountController.java @@ -0,0 +1,272 @@ +package com.hfkj.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsUser; +import com.hfkj.entity.BsUserParentRel; +import com.hfkj.model.ResponseData; +import com.hfkj.service.user.BsUserCountService; +import com.hfkj.service.user.BsUserGradeService; +import com.hfkj.service.user.BsUserParentRelService; +import com.hfkj.service.user.BsUserService; +import com.hfkj.sysenum.user.UserGradeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @className: CmsController + * @author: HuRui + * @date: 2024/9/24 + **/ +@Controller +@RequestMapping(value = "/userCount") +@Api(value = "用户统计") +public class BsUserCountController { + private static Logger log = LoggerFactory.getLogger(BsUserCountController.class); + @Resource + private BsUserCountService userCountService; + + @RequestMapping(value="/countUserNumber",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "统计用户数量") + public ResponseData countUserNumber() { + try { + // 今日时间 + Map todayTime = DateUtil.getTodayTimeObj(); + // 昨日时间 + Map yesterdayTime = DateUtil.getYesterdayTimeObj(); + // 本月时间 + Map thisMonthTime = DateUtil.getThisMonthTimeObj(); + // 上月时间 + Map lastMonthTime = DateUtil.getLastMonthTimeObj(); + + Map map = new HashMap<>(); + + // 平台注册用户数 + Map platformRegister = new HashMap<>(); + Calendar timeS = new GregorianCalendar(); + timeS.set(Calendar.YEAR, 2024); + timeS.set(Calendar.MONTH, 1); + timeS.set(Calendar.DAY_OF_MONTH, 0); + timeS.set(Calendar.HOUR_OF_DAY, 23); + timeS.set(Calendar.MINUTE, 59); + timeS.set(Calendar.SECOND, 59); + // 今日 + platformRegister.put("today", userCountService.countPlatformRegister(timeS.getTime(), todayTime.get("timeE"))); + // 昨日 + platformRegister.put("yesterday", userCountService.countPlatformRegister(timeS.getTime(), yesterdayTime.get("timeE"))); + // 本月 + platformRegister.put("thisMonth", userCountService.countPlatformRegister(timeS.getTime(), thisMonthTime.get("timeE"))); + // 上月 + platformRegister.put("lastMonth", userCountService.countPlatformRegister(timeS.getTime(), lastMonthTime.get("timeE"))); + map.put("platformRegister", platformRegister); + + + // 新增用户数 + Map addNumber = new HashMap<>(); + // 今日 + addNumber.put("today", userCountService.countAdd(todayTime.get("timeS"), todayTime.get("timeE"))); + // 昨日 + addNumber.put("yesterday", userCountService.countAdd(yesterdayTime.get("timeS"), yesterdayTime.get("timeE"))); + // 本月 + addNumber.put("thisMonth", userCountService.countAdd(thisMonthTime.get("timeS"), thisMonthTime.get("timeE"))); + // 上月 + addNumber.put("lastMonth", userCountService.countAdd(lastMonthTime.get("timeS"), lastMonthTime.get("timeE"))); + map.put("addNumber", addNumber); + + + // 登录用户数 + Map loginNumber = new HashMap<>(); + // 今日 + loginNumber.put("today", userCountService.countLogin(todayTime.get("timeS"), todayTime.get("timeE"))); + // 昨日 + loginNumber.put("yesterday", userCountService.countLogin(yesterdayTime.get("timeS"), yesterdayTime.get("timeE"))); + // 本月 + loginNumber.put("thisMonth", userCountService.countLogin(thisMonthTime.get("timeS"), thisMonthTime.get("timeE"))); + // 上月 + loginNumber.put("lastMonth", userCountService.countLogin(lastMonthTime.get("timeS"), lastMonthTime.get("timeE"))); + map.put("loginNumber", loginNumber); + + + // 下单用户数 + Map placeOrder = new HashMap<>(); + // 今日 + placeOrder.put("today", userCountService.countPlaceOrder(todayTime.get("timeS"), todayTime.get("timeE"))); + // 昨日 + placeOrder.put("yesterday", userCountService.countPlaceOrder(yesterdayTime.get("timeS"), yesterdayTime.get("timeE"))); + // 本月 + placeOrder.put("thisMonth", userCountService.countPlaceOrder(thisMonthTime.get("timeS"), thisMonthTime.get("timeE"))); + // 上月 + placeOrder.put("lastMonth", userCountService.countPlaceOrder(lastMonthTime.get("timeS"), lastMonthTime.get("timeE"))); + map.put("placeOrder", placeOrder); + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/queryUserNumber",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询用户数量") + public ResponseData queryUserNumber(@RequestParam(value = "timeS" , required = true) Long timeS, + @RequestParam(value = "timeE" , required = true) Long timeE) { + try { + + Map map = new HashMap<>(); + + Calendar defaultTimeS = new GregorianCalendar(); + defaultTimeS.set(Calendar.YEAR, 2024); + defaultTimeS.set(Calendar.MONTH, 1); + defaultTimeS.set(Calendar.DAY_OF_MONTH, 0); + defaultTimeS.set(Calendar.HOUR_OF_DAY, 23); + defaultTimeS.set(Calendar.MINUTE, 59); + defaultTimeS.set(Calendar.SECOND, 59); + + // 平台注册用户数 + map.put("platformRegister", userCountService.countPlatformRegister(defaultTimeS.getTime(), new Date(timeE))); + + // 新增用户数 + map.put("addNumber", userCountService.countAdd(new Date(timeS), new Date(timeE))); + + // 登录用户数 + map.put("loginNumber", userCountService.countLogin(new Date(timeS), new Date(timeE))); + + // 下单用户数 + map.put("placeOrder", userCountService.countPlaceOrder(new Date(timeS), new Date(timeE))); + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/countUserGrade",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "统计用户等级") + public ResponseData countUserGrade() { + try { + // 固定初始化开始时间 + Calendar timeS = new GregorianCalendar(); + timeS.set(Calendar.YEAR, 2024); + timeS.set(Calendar.MONTH, 1); + timeS.set(Calendar.DAY_OF_MONTH, 0); + timeS.set(Calendar.HOUR_OF_DAY, 23); + timeS.set(Calendar.MINUTE, 59); + timeS.set(Calendar.SECOND, 59); + + // 今日 + Map todayTime = DateUtil.getTodayTimeObj(); + List> todayData = userCountService.countUserGrade(timeS.getTime(), todayTime.get("timeE")); + + // 昨日时间 + Map yesterdayTime = DateUtil.getYesterdayTimeObj(); + List> yesterdayData = userCountService.countUserGrade(timeS.getTime(), yesterdayTime.get("timeE")); + + // 本月时间 + Map thisMonthTime = DateUtil.getThisMonthTimeObj(); + List> thisMonthData = userCountService.countUserGrade(timeS.getTime(), thisMonthTime.get("timeE")); + + // 上月时间 + Map lastMonthTime = DateUtil.getLastMonthTimeObj(); + List> lastMonthData = userCountService.countUserGrade(timeS.getTime(), lastMonthTime.get("timeE")); + + List list = new ArrayList<>(); + + // 等级 + Map grade1 = new LinkedHashMap<>(); + grade1.put("gradeCode", UserGradeEnum.grade1.getCode()); + grade1.put("gradeName", UserGradeEnum.grade1.getName()); + // 今日 + List> todayGrade1 = todayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade1.getCode())).collect(Collectors.toList()); + grade1.put("today", todayGrade1.isEmpty()?0:todayGrade1.get(0).get("count")); + // 昨日 + List> yesterdayGrade1 = yesterdayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade1.getCode())).collect(Collectors.toList()); + grade1.put("yesterday", yesterdayGrade1.isEmpty()?0:yesterdayGrade1.get(0).get("count")); + // 本月 + List> thisMonthGrade1 = thisMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade1.getCode())).collect(Collectors.toList()); + grade1.put("thisMonth", thisMonthGrade1.isEmpty()?0:thisMonthGrade1.get(0).get("count")); + // 上月 + List> lastMonthGrade1 = lastMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade1.getCode())).collect(Collectors.toList()); + grade1.put("lastMonth", lastMonthGrade1.isEmpty()?0:lastMonthGrade1.get(0).get("count")); + list.add(grade1); + + + Map grade2 = new LinkedHashMap<>(); + grade2.put("gradeCode", UserGradeEnum.grade2.getCode()); + grade2.put("gradeName", UserGradeEnum.grade2.getName()); + // 今日 + List> todayGrade2 = todayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade2.getCode())).collect(Collectors.toList()); + grade2.put("today", todayGrade2.isEmpty()?0:todayGrade2.get(0).get("count")); + // 昨日 + List> yesterdayGrade2 = yesterdayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade2.getCode())).collect(Collectors.toList()); + grade2.put("yesterday", yesterdayGrade2.isEmpty()?0:yesterdayGrade2.get(0).get("count")); + // 本月 + List> thisMonthGrade2 = thisMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade2.getCode())).collect(Collectors.toList()); + grade2.put("thisMonth", thisMonthGrade2.isEmpty()?0:thisMonthGrade2.get(0).get("count")); + // 上月 + List> lastMonthGrade2 = lastMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade2.getCode())).collect(Collectors.toList()); + grade2.put("lastMonth", lastMonthGrade2.isEmpty()?0:lastMonthGrade2.get(0).get("count")); + list.add(grade2); + + + Map grade3 = new LinkedHashMap<>(); + grade3.put("gradeCode", UserGradeEnum.grade3.getCode()); + grade3.put("gradeName", UserGradeEnum.grade3.getName()); + // 今日 + List> todayGrade3 = todayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade3.getCode())).collect(Collectors.toList()); + grade3.put("today", todayGrade3.isEmpty()?0:todayGrade3.get(0).get("count")); + // 昨日 + List> yesterdayGrade3 = yesterdayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade3.getCode())).collect(Collectors.toList()); + grade3.put("yesterday", yesterdayGrade3.isEmpty()?0:yesterdayGrade3.get(0).get("count")); + // 本月 + List> thisMonthGrade3 = thisMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade3.getCode())).collect(Collectors.toList()); + grade3.put("thisMonth", thisMonthGrade3.isEmpty()?0:thisMonthGrade3.get(0).get("count")); + // 上月 + List> lastMonthGrade3 = lastMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade3.getCode())).collect(Collectors.toList()); + grade3.put("lastMonth", lastMonthGrade3.isEmpty()?0:lastMonthGrade3.get(0).get("count")); + list.add(grade3); + + + Map grade4 = new LinkedHashMap<>(); + grade4.put("gradeCode", UserGradeEnum.grade4.getCode()); + grade4.put("gradeName", UserGradeEnum.grade4.getName()); + // 今日 + List> todayGrade4 = todayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade4.getCode())).collect(Collectors.toList()); + grade4.put("today", todayGrade4.isEmpty()?0:todayGrade4.get(0).get("count")); + // 昨日 + List> yesterdayGrade4 = yesterdayData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade4.getCode())).collect(Collectors.toList()); + grade4.put("yesterday", yesterdayGrade4.isEmpty()?0:yesterdayGrade4.get(0).get("count")); + // 本月 + List> thisMonthGrade4 = thisMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade4.getCode())).collect(Collectors.toList()); + grade4.put("thisMonth", thisMonthGrade4.isEmpty()?0:thisMonthGrade4.get(0).get("count")); + // 上月 + List> lastMonthGrade4 = lastMonthData.stream().filter(o -> Integer.valueOf(o.get("grade").toString()).equals(UserGradeEnum.grade4.getCode())).collect(Collectors.toList()); + grade4.put("lastMonth", lastMonthGrade4.isEmpty()?0:lastMonthGrade4.get(0).get("count")); + list.add(grade4); + + return ResponseMsgUtil.success(list); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/schedule/src/main/java/com/hfkj/schedule/UserGradeSchedule.java b/schedule/src/main/java/com/hfkj/schedule/UserGradeSchedule.java index 37fb154..88c4b1d 100644 --- a/schedule/src/main/java/com/hfkj/schedule/UserGradeSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/UserGradeSchedule.java @@ -2,18 +2,25 @@ package com.hfkj.schedule; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.ListUtil; +import com.hfkj.dao.BsUserGradeCountMapper; import com.hfkj.entity.BsUser; +import com.hfkj.entity.BsUserGradeCount; import com.hfkj.model.UserSessionObject; +import com.hfkj.service.user.BsUserCountService; import com.hfkj.service.user.BsUserGradeService; import com.hfkj.service.user.BsUserService; import com.hfkj.service.user.impl.BsUserServiceImpl; +import com.hfkj.sysenum.user.UserGradeEnum; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadPoolExecutor; @@ -31,6 +38,10 @@ public class UserGradeSchedule { @Resource private BsUserGradeService userGradeService; @Resource + private BsUserCountService userCountService; + @Resource + private BsUserGradeCountMapper userGradeCountMapper; + @Resource private UserCenter userCenter; @Scheduled(cron = "0 0 5 * * ?") // 每日凌晨05:00:00 执行一次 @@ -108,6 +119,27 @@ public class UserGradeSchedule { } + @Scheduled(cron = "0 30 5 * * ?") // 每日凌晨05:00:00 执行一次 + public void count() { + try { + // 昨日时间 + Map todayTime = DateUtil.getTodayTimeObj(); + + BsUserGradeCount userGradeCount = new BsUserGradeCount(); + userGradeCount.setStartTime(todayTime.get("timeS")); + userGradeCount.setEndTime(todayTime.get("timeE")); + userGradeCount.setCreateTime(new Date()); + + // userGradeCount.setGrade1(userCountService.countUserGrade(UserGradeEnum.grade1, todayTime.get("timeS"), todayTime.get("timeE"))); + // userGradeCount.setGrade2(userCountService.countUserGrade(UserGradeEnum.grade2, todayTime.get("timeS"), todayTime.get("timeE"))); + // userGradeCount.setGrade3(userCountService.countUserGrade(UserGradeEnum.grade3, todayTime.get("timeS"), todayTime.get("timeE"))); + // userGradeCount.setGrade4(userCountService.countUserGrade(UserGradeEnum.grade4, todayTime.get("timeS"), todayTime.get("timeE"))); + userGradeCountMapper.insert(userGradeCount); + + } catch (Exception e) { + System.out.println("统计失败!!!"); + } + } } diff --git a/service/src/main/java/com/hfkj/common/utils/DateUtil.java b/service/src/main/java/com/hfkj/common/utils/DateUtil.java index 89cd92d..63ea876 100644 --- a/service/src/main/java/com/hfkj/common/utils/DateUtil.java +++ b/service/src/main/java/com/hfkj/common/utils/DateUtil.java @@ -9,8 +9,7 @@ import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.time.*; -import java.util.Calendar; -import java.util.Date; +import java.util.*; public class DateUtil { @@ -35,6 +34,102 @@ public class DateUtil { private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + /** + * 获取今天时间对象 + * @return + */ + public static Map getTodayTimeObj() { + Map map = new HashMap<>(); + // 开始 + Calendar timeS = Calendar.getInstance(); + timeS.set(Calendar.HOUR_OF_DAY, 00); + timeS.set(Calendar.MINUTE, 00); + timeS.set(Calendar.SECOND, 00); + map.put("timeS", timeS.getTime()); + // 结束 + Calendar timeE = Calendar.getInstance(); + timeE.set(Calendar.HOUR_OF_DAY, 23); + timeE.set(Calendar.MINUTE, 59); + timeE.set(Calendar.SECOND, 59); + map.put("timeE", timeE.getTime()); + return map; + } + + /** + * 获取昨日时间对象 + * @return + */ + public static Map getYesterdayTimeObj() { + Map map = new HashMap<>(); + // 开始 + Calendar timeS = Calendar.getInstance(); + timeS.add(Calendar.DAY_OF_MONTH, -1); + timeS.set(Calendar.HOUR_OF_DAY, 00); + timeS.set(Calendar.MINUTE, 00); + timeS.set(Calendar.SECOND, 00); + map.put("timeS", timeS.getTime()); + // 结束 + Calendar timeE = Calendar.getInstance(); + timeE.add(Calendar.DAY_OF_MONTH, -1); + timeE.set(Calendar.HOUR_OF_DAY, 23); + timeE.set(Calendar.MINUTE, 59); + timeE.set(Calendar.SECOND, 59); + map.put("timeE", timeE.getTime()); + return map; + } + + /** + * 获取本月时间对象 + * @return + */ + public static Map getThisMonthTimeObj() { + Map map = new HashMap<>(); + // 开始 + Calendar timeS = Calendar.getInstance(); + timeS.set(Calendar.DATE, 1); + timeS.set(Calendar.HOUR_OF_DAY, 00); + timeS.set(Calendar.MINUTE, 00); + timeS.set(Calendar.SECOND, 00); + map.put("timeS", timeS.getTime()); + // 结束 + Calendar timeE = Calendar.getInstance(); + timeE.set(Calendar.DATE, 1); + timeE.add(Calendar.MONTH, 1); + timeE.add(Calendar.DATE, -1); + timeE.set(Calendar.HOUR_OF_DAY, 23); + timeE.set(Calendar.MINUTE, 59); + timeE.set(Calendar.SECOND, 59); + map.put("timeE", timeE.getTime()); + return map; + } + + /** + * 获取上月时间对象 + * @return + */ + public static Map getLastMonthTimeObj() { + Map map = new HashMap<>(); + // 开始 + Calendar timeS = Calendar.getInstance(); + timeS.set(Calendar.MONTH, timeS.get(Calendar.MONTH)-1); + timeS.set(Calendar.DATE, 1); + timeS.set(Calendar.HOUR_OF_DAY, 00); + timeS.set(Calendar.MINUTE, 00); + timeS.set(Calendar.SECOND, 00); + map.put("timeS", timeS.getTime()); + // 结束 + Calendar timeE = Calendar.getInstance(); + timeE.set(Calendar.DATE, 1); + timeE.add(Calendar.DATE, -1); + timeE.set(Calendar.HOUR_OF_DAY, 23); + timeE.set(Calendar.MINUTE, 59); + timeE.set(Calendar.SECOND, 59); + map.put("timeE", timeE.getTime()); + return map; + } + + + public static Integer getThisYear(){ Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR); @@ -100,24 +195,6 @@ public class DateUtil { return strtodate; } - /** - * @throws - * @Title: getDateBegin - * @Description: TODO(获取指定日期开始) - * @author: 杜江 - * @param: [date] - * @return: java.util.Date - */ - public static Date getDateBegin(Date date) { - LocalDate nowDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - //设置零点 - LocalDateTime beginTime = LocalDateTime.of(nowDate, LocalTime.MIN); - //将时间进行格式化 - ZoneId zoneId = ZoneId.systemDefault(); - ZonedDateTime zdt = beginTime.atZone(zoneId); - return Date.from(zdt.toInstant()); - } - /** * date转换成UNIX时间戳,毫秒 * @@ -156,21 +233,6 @@ public class DateUtil { return cal.getTime(); } - /** - * @throws - * @Title: addSeconds - * @Description: TODO(指定日期 , 指定秒后的时间) - * @author: 杜江 - * @param: [date, seconds] - * @return: java.util.Date - */ - public static Date addSeconds(Date date, int seconds) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.SECOND, seconds); - return calendar.getTime(); - } - /** * 获取某月最后一天日期 * @return Date @@ -679,67 +741,7 @@ public class DateUtil { } - /** - * 字符串日期转换成中文格式日期 - * - * @param date 字符串日期 yyyy-MM-dd - * @return yyyy年MM月dd日 - * @throws Exception - */ - public static String dateToCnDate(Date date) { - try { - String dateString = date2String(date, Y_M_D); - String result = ""; - String[] cnDate = new String[]{"〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"}; - String ten = "十"; - String[] dateStr = dateString.split("-"); - for (int i = 0; i < dateStr.length; i++) { - for (int j = 0; j < dateStr[i].length(); j++) { - String charStr = dateStr[i]; - String str = String.valueOf(charStr.charAt(j)); - if (charStr.length() == 2) { - if (charStr.equals("10")) { - result += ten; - break; - } else { - if (j == 0) { - if (charStr.charAt(j) == '1') - result += ten; - else if (charStr.charAt(j) == '0') - result += ""; - else - result += cnDate[Integer.parseInt(str)] + ten; - } - if (j == 1) { - if (charStr.charAt(j) == '0') - result += ""; - else - result += cnDate[Integer.parseInt(str)]; - } - } - } else { - result += cnDate[Integer.parseInt(str)]; - } - } - if (i == 0) { - result += "年"; - continue; - } - if (i == 1) { - result += "月"; - continue; - } - if (i == 2) { - result += "日"; - continue; - } - } - return result; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } + /** diff --git a/service/src/main/java/com/hfkj/dao/BsOrderMapperExt.java b/service/src/main/java/com/hfkj/dao/BsOrderMapperExt.java index 08c462e..61b1f81 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderMapperExt.java @@ -1,7 +1,18 @@ package com.hfkj.dao; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + /** * mapper扩展类 */ public interface BsOrderMapperExt { -} \ No newline at end of file + + @Select("") + Long countPlaceOrder(@Param("timeS") String timeS, @Param("timeE")String timeE); +} diff --git a/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapper.java b/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapper.java new file mode 100644 index 0000000..0635d42 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapper.java @@ -0,0 +1,108 @@ +package com.hfkj.dao; + +import com.hfkj.entity.BsUserGradeCount; +import com.hfkj.entity.BsUserGradeCountExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface BsUserGradeCountMapper extends BsUserGradeCountMapperExt { + @SelectProvider(type=BsUserGradeCountSqlProvider.class, method="countByExample") + long countByExample(BsUserGradeCountExample example); + + @DeleteProvider(type=BsUserGradeCountSqlProvider.class, method="deleteByExample") + int deleteByExample(BsUserGradeCountExample example); + + @Delete({ + "delete from bs_user_grade_count", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into bs_user_grade_count (start_time, end_time, ", + "grade1, grade2, grade3, ", + "grade4, create_time)", + "values (#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, ", + "#{grade1,jdbcType=BIGINT}, #{grade2,jdbcType=BIGINT}, #{grade3,jdbcType=BIGINT}, ", + "#{grade4,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(BsUserGradeCount record); + + @InsertProvider(type=BsUserGradeCountSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(BsUserGradeCount record); + + @SelectProvider(type=BsUserGradeCountSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="grade1", property="grade1", jdbcType=JdbcType.BIGINT), + @Result(column="grade2", property="grade2", jdbcType=JdbcType.BIGINT), + @Result(column="grade3", property="grade3", jdbcType=JdbcType.BIGINT), + @Result(column="grade4", property="grade4", jdbcType=JdbcType.BIGINT), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP) + }) + List selectByExample(BsUserGradeCountExample example); + + @Select({ + "select", + "id, start_time, end_time, grade1, grade2, grade3, grade4, create_time", + "from bs_user_grade_count", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="grade1", property="grade1", jdbcType=JdbcType.BIGINT), + @Result(column="grade2", property="grade2", jdbcType=JdbcType.BIGINT), + @Result(column="grade3", property="grade3", jdbcType=JdbcType.BIGINT), + @Result(column="grade4", property="grade4", jdbcType=JdbcType.BIGINT), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP) + }) + BsUserGradeCount selectByPrimaryKey(Long id); + + @UpdateProvider(type=BsUserGradeCountSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") BsUserGradeCount record, @Param("example") BsUserGradeCountExample example); + + @UpdateProvider(type=BsUserGradeCountSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") BsUserGradeCount record, @Param("example") BsUserGradeCountExample example); + + @UpdateProvider(type=BsUserGradeCountSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(BsUserGradeCount record); + + @Update({ + "update bs_user_grade_count", + "set start_time = #{startTime,jdbcType=TIMESTAMP},", + "end_time = #{endTime,jdbcType=TIMESTAMP},", + "grade1 = #{grade1,jdbcType=BIGINT},", + "grade2 = #{grade2,jdbcType=BIGINT},", + "grade3 = #{grade3,jdbcType=BIGINT},", + "grade4 = #{grade4,jdbcType=BIGINT},", + "create_time = #{createTime,jdbcType=TIMESTAMP}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(BsUserGradeCount record); +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapperExt.java b/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapperExt.java new file mode 100644 index 0000000..667288f --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserGradeCountMapperExt.java @@ -0,0 +1,29 @@ +package com.hfkj.dao; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +/** + * mapper扩展类 + */ +public interface BsUserGradeCountMapperExt { + + @Select("") + List> collect(@Param("timeS") String timeS, @Param("timeE") String timeE); +} diff --git a/service/src/main/java/com/hfkj/dao/BsUserGradeCountSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsUserGradeCountSqlProvider.java new file mode 100644 index 0000000..7f4919d --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserGradeCountSqlProvider.java @@ -0,0 +1,276 @@ +package com.hfkj.dao; + +import com.hfkj.entity.BsUserGradeCount; +import com.hfkj.entity.BsUserGradeCountExample.Criteria; +import com.hfkj.entity.BsUserGradeCountExample.Criterion; +import com.hfkj.entity.BsUserGradeCountExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class BsUserGradeCountSqlProvider { + + public String countByExample(BsUserGradeCountExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("bs_user_grade_count"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(BsUserGradeCountExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("bs_user_grade_count"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(BsUserGradeCount record) { + SQL sql = new SQL(); + sql.INSERT_INTO("bs_user_grade_count"); + + if (record.getStartTime() != null) { + sql.VALUES("start_time", "#{startTime,jdbcType=TIMESTAMP}"); + } + + if (record.getEndTime() != null) { + sql.VALUES("end_time", "#{endTime,jdbcType=TIMESTAMP}"); + } + + if (record.getGrade1() != null) { + sql.VALUES("grade1", "#{grade1,jdbcType=BIGINT}"); + } + + if (record.getGrade2() != null) { + sql.VALUES("grade2", "#{grade2,jdbcType=BIGINT}"); + } + + if (record.getGrade3() != null) { + sql.VALUES("grade3", "#{grade3,jdbcType=BIGINT}"); + } + + if (record.getGrade4() != null) { + sql.VALUES("grade4", "#{grade4,jdbcType=BIGINT}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + return sql.toString(); + } + + public String selectByExample(BsUserGradeCountExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("start_time"); + sql.SELECT("end_time"); + sql.SELECT("grade1"); + sql.SELECT("grade2"); + sql.SELECT("grade3"); + sql.SELECT("grade4"); + sql.SELECT("create_time"); + sql.FROM("bs_user_grade_count"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + BsUserGradeCount record = (BsUserGradeCount) parameter.get("record"); + BsUserGradeCountExample example = (BsUserGradeCountExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("bs_user_grade_count"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getStartTime() != null) { + sql.SET("start_time = #{record.startTime,jdbcType=TIMESTAMP}"); + } + + if (record.getEndTime() != null) { + sql.SET("end_time = #{record.endTime,jdbcType=TIMESTAMP}"); + } + + if (record.getGrade1() != null) { + sql.SET("grade1 = #{record.grade1,jdbcType=BIGINT}"); + } + + if (record.getGrade2() != null) { + sql.SET("grade2 = #{record.grade2,jdbcType=BIGINT}"); + } + + if (record.getGrade3() != null) { + sql.SET("grade3 = #{record.grade3,jdbcType=BIGINT}"); + } + + if (record.getGrade4() != null) { + sql.SET("grade4 = #{record.grade4,jdbcType=BIGINT}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("bs_user_grade_count"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("start_time = #{record.startTime,jdbcType=TIMESTAMP}"); + sql.SET("end_time = #{record.endTime,jdbcType=TIMESTAMP}"); + sql.SET("grade1 = #{record.grade1,jdbcType=BIGINT}"); + sql.SET("grade2 = #{record.grade2,jdbcType=BIGINT}"); + sql.SET("grade3 = #{record.grade3,jdbcType=BIGINT}"); + sql.SET("grade4 = #{record.grade4,jdbcType=BIGINT}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + + BsUserGradeCountExample example = (BsUserGradeCountExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(BsUserGradeCount record) { + SQL sql = new SQL(); + sql.UPDATE("bs_user_grade_count"); + + if (record.getStartTime() != null) { + sql.SET("start_time = #{startTime,jdbcType=TIMESTAMP}"); + } + + if (record.getEndTime() != null) { + sql.SET("end_time = #{endTime,jdbcType=TIMESTAMP}"); + } + + if (record.getGrade1() != null) { + sql.SET("grade1 = #{grade1,jdbcType=BIGINT}"); + } + + if (record.getGrade2() != null) { + sql.SET("grade2 = #{grade2,jdbcType=BIGINT}"); + } + + if (record.getGrade3() != null) { + sql.SET("grade3 = #{grade3,jdbcType=BIGINT}"); + } + + if (record.getGrade4() != null) { + sql.SET("grade4 = #{grade4,jdbcType=BIGINT}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, BsUserGradeCountExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/BsUserMapperExt.java b/service/src/main/java/com/hfkj/dao/BsUserMapperExt.java index 4078eb8..1e5277e 100644 --- a/service/src/main/java/com/hfkj/dao/BsUserMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsUserMapperExt.java @@ -4,4 +4,4 @@ package com.hfkj.dao; * mapper扩展类 */ public interface BsUserMapperExt { -} \ No newline at end of file +} diff --git a/service/src/main/java/com/hfkj/entity/BsUserGradeCount.java b/service/src/main/java/com/hfkj/entity/BsUserGradeCount.java new file mode 100644 index 0000000..54e7e4b --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/BsUserGradeCount.java @@ -0,0 +1,174 @@ +package com.hfkj.entity; + +import java.io.Serializable; +import java.util.Date; + +/** + * bs_user_grade_count + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class BsUserGradeCount implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 统计周期 + */ + private Date startTime; + + /** + * 统计周期 + */ + private Date endTime; + + /** + * 见习会员数量 + */ + private Long grade1; + + /** + * 正式会员数量 + */ + private Long grade2; + + /** + * 团长数量 + */ + private Long grade3; + + /** + * 渠道数量 + */ + private Long grade4; + + private Date createTime; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Long getGrade1() { + return grade1; + } + + public void setGrade1(Long grade1) { + this.grade1 = grade1; + } + + public Long getGrade2() { + return grade2; + } + + public void setGrade2(Long grade2) { + this.grade2 = grade2; + } + + public Long getGrade3() { + return grade3; + } + + public void setGrade3(Long grade3) { + this.grade3 = grade3; + } + + public Long getGrade4() { + return grade4; + } + + public void setGrade4(Long grade4) { + this.grade4 = grade4; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + BsUserGradeCount other = (BsUserGradeCount) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime())) + && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime())) + && (this.getGrade1() == null ? other.getGrade1() == null : this.getGrade1().equals(other.getGrade1())) + && (this.getGrade2() == null ? other.getGrade2() == null : this.getGrade2().equals(other.getGrade2())) + && (this.getGrade3() == null ? other.getGrade3() == null : this.getGrade3().equals(other.getGrade3())) + && (this.getGrade4() == null ? other.getGrade4() == null : this.getGrade4().equals(other.getGrade4())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode()); + result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode()); + result = prime * result + ((getGrade1() == null) ? 0 : getGrade1().hashCode()); + result = prime * result + ((getGrade2() == null) ? 0 : getGrade2().hashCode()); + result = prime * result + ((getGrade3() == null) ? 0 : getGrade3().hashCode()); + result = prime * result + ((getGrade4() == null) ? 0 : getGrade4().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", startTime=").append(startTime); + sb.append(", endTime=").append(endTime); + sb.append(", grade1=").append(grade1); + sb.append(", grade2=").append(grade2); + sb.append(", grade3=").append(grade3); + sb.append(", grade4=").append(grade4); + sb.append(", createTime=").append(createTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/BsUserGradeCountExample.java b/service/src/main/java/com/hfkj/entity/BsUserGradeCountExample.java new file mode 100644 index 0000000..9411bed --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/BsUserGradeCountExample.java @@ -0,0 +1,703 @@ +package com.hfkj.entity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class BsUserGradeCountExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public BsUserGradeCountExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andStartTimeIsNull() { + addCriterion("start_time is null"); + return (Criteria) this; + } + + public Criteria andStartTimeIsNotNull() { + addCriterion("start_time is not null"); + return (Criteria) this; + } + + public Criteria andStartTimeEqualTo(Date value) { + addCriterion("start_time =", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeNotEqualTo(Date value) { + addCriterion("start_time <>", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeGreaterThan(Date value) { + addCriterion("start_time >", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeGreaterThanOrEqualTo(Date value) { + addCriterion("start_time >=", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeLessThan(Date value) { + addCriterion("start_time <", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeLessThanOrEqualTo(Date value) { + addCriterion("start_time <=", value, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeIn(List values) { + addCriterion("start_time in", values, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeNotIn(List values) { + addCriterion("start_time not in", values, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeBetween(Date value1, Date value2) { + addCriterion("start_time between", value1, value2, "startTime"); + return (Criteria) this; + } + + public Criteria andStartTimeNotBetween(Date value1, Date value2) { + addCriterion("start_time not between", value1, value2, "startTime"); + return (Criteria) this; + } + + public Criteria andEndTimeIsNull() { + addCriterion("end_time is null"); + return (Criteria) this; + } + + public Criteria andEndTimeIsNotNull() { + addCriterion("end_time is not null"); + return (Criteria) this; + } + + public Criteria andEndTimeEqualTo(Date value) { + addCriterion("end_time =", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotEqualTo(Date value) { + addCriterion("end_time <>", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeGreaterThan(Date value) { + addCriterion("end_time >", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeGreaterThanOrEqualTo(Date value) { + addCriterion("end_time >=", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeLessThan(Date value) { + addCriterion("end_time <", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeLessThanOrEqualTo(Date value) { + addCriterion("end_time <=", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeIn(List values) { + addCriterion("end_time in", values, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotIn(List values) { + addCriterion("end_time not in", values, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeBetween(Date value1, Date value2) { + addCriterion("end_time between", value1, value2, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotBetween(Date value1, Date value2) { + addCriterion("end_time not between", value1, value2, "endTime"); + return (Criteria) this; + } + + public Criteria andGrade1IsNull() { + addCriterion("grade1 is null"); + return (Criteria) this; + } + + public Criteria andGrade1IsNotNull() { + addCriterion("grade1 is not null"); + return (Criteria) this; + } + + public Criteria andGrade1EqualTo(Long value) { + addCriterion("grade1 =", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1NotEqualTo(Long value) { + addCriterion("grade1 <>", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1GreaterThan(Long value) { + addCriterion("grade1 >", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1GreaterThanOrEqualTo(Long value) { + addCriterion("grade1 >=", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1LessThan(Long value) { + addCriterion("grade1 <", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1LessThanOrEqualTo(Long value) { + addCriterion("grade1 <=", value, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1In(List values) { + addCriterion("grade1 in", values, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1NotIn(List values) { + addCriterion("grade1 not in", values, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1Between(Long value1, Long value2) { + addCriterion("grade1 between", value1, value2, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade1NotBetween(Long value1, Long value2) { + addCriterion("grade1 not between", value1, value2, "grade1"); + return (Criteria) this; + } + + public Criteria andGrade2IsNull() { + addCriterion("grade2 is null"); + return (Criteria) this; + } + + public Criteria andGrade2IsNotNull() { + addCriterion("grade2 is not null"); + return (Criteria) this; + } + + public Criteria andGrade2EqualTo(Long value) { + addCriterion("grade2 =", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2NotEqualTo(Long value) { + addCriterion("grade2 <>", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2GreaterThan(Long value) { + addCriterion("grade2 >", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2GreaterThanOrEqualTo(Long value) { + addCriterion("grade2 >=", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2LessThan(Long value) { + addCriterion("grade2 <", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2LessThanOrEqualTo(Long value) { + addCriterion("grade2 <=", value, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2In(List values) { + addCriterion("grade2 in", values, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2NotIn(List values) { + addCriterion("grade2 not in", values, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2Between(Long value1, Long value2) { + addCriterion("grade2 between", value1, value2, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade2NotBetween(Long value1, Long value2) { + addCriterion("grade2 not between", value1, value2, "grade2"); + return (Criteria) this; + } + + public Criteria andGrade3IsNull() { + addCriterion("grade3 is null"); + return (Criteria) this; + } + + public Criteria andGrade3IsNotNull() { + addCriterion("grade3 is not null"); + return (Criteria) this; + } + + public Criteria andGrade3EqualTo(Long value) { + addCriterion("grade3 =", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3NotEqualTo(Long value) { + addCriterion("grade3 <>", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3GreaterThan(Long value) { + addCriterion("grade3 >", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3GreaterThanOrEqualTo(Long value) { + addCriterion("grade3 >=", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3LessThan(Long value) { + addCriterion("grade3 <", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3LessThanOrEqualTo(Long value) { + addCriterion("grade3 <=", value, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3In(List values) { + addCriterion("grade3 in", values, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3NotIn(List values) { + addCriterion("grade3 not in", values, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3Between(Long value1, Long value2) { + addCriterion("grade3 between", value1, value2, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade3NotBetween(Long value1, Long value2) { + addCriterion("grade3 not between", value1, value2, "grade3"); + return (Criteria) this; + } + + public Criteria andGrade4IsNull() { + addCriterion("grade4 is null"); + return (Criteria) this; + } + + public Criteria andGrade4IsNotNull() { + addCriterion("grade4 is not null"); + return (Criteria) this; + } + + public Criteria andGrade4EqualTo(Long value) { + addCriterion("grade4 =", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4NotEqualTo(Long value) { + addCriterion("grade4 <>", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4GreaterThan(Long value) { + addCriterion("grade4 >", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4GreaterThanOrEqualTo(Long value) { + addCriterion("grade4 >=", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4LessThan(Long value) { + addCriterion("grade4 <", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4LessThanOrEqualTo(Long value) { + addCriterion("grade4 <=", value, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4In(List values) { + addCriterion("grade4 in", values, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4NotIn(List values) { + addCriterion("grade4 not in", values, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4Between(Long value1, Long value2) { + addCriterion("grade4 between", value1, value2, "grade4"); + return (Criteria) this; + } + + public Criteria andGrade4NotBetween(Long value1, Long value2) { + addCriterion("grade4 not between", value1, value2, "grade4"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/service/user/BsUserCountService.java b/service/src/main/java/com/hfkj/service/user/BsUserCountService.java new file mode 100644 index 0000000..c36b310 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/user/BsUserCountService.java @@ -0,0 +1,55 @@ +package com.hfkj.service.user; + +import com.hfkj.sysenum.user.UserGradeEnum; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @className: BsUserService + * @author: HuRui + * @date: 2024/10/20 + **/ +public interface BsUserCountService { + + /** + * 平台总注册用户数 + * @param timeS + * @param timeE + */ + Long countPlatformRegister(Date timeS, Date timeE); + + /** + * 新增用户数 + * @param timeS + * @param timeE + * @return + */ + Long countAdd(Date timeS, Date timeE); + + /** + * 登录用户数 + * @param timeS + * @param timeE + * @return + */ + Long countLogin(Date timeS, Date timeE); + + /** + * 下单用户数 + * @param timeS + * @param timeE + * @return + */ + Long countPlaceOrder(Date timeS, Date timeE) throws Exception; + + /** + * 统计等级用户 + * @param timeS + * @param timeE + * @return + */ + List> countUserGrade(Date timeS, Date timeE) throws Exception; + +} diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserCountServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserCountServiceImpl.java new file mode 100644 index 0000000..0f6b350 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserCountServiceImpl.java @@ -0,0 +1,66 @@ +package com.hfkj.service.user.impl; + +import com.hfkj.common.utils.DateUtil; +import com.hfkj.dao.BsOrderMapper; +import com.hfkj.dao.BsUserGradeCountMapper; +import com.hfkj.dao.BsUserLoginLogMapper; +import com.hfkj.dao.BsUserMapper; +import com.hfkj.entity.BsUserExample; +import com.hfkj.entity.BsUserGradeCount; +import com.hfkj.entity.BsUserLoginLogExample; +import com.hfkj.service.user.BsUserCountService; +import com.hfkj.sysenum.user.UserGradeEnum; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @className: BsUserCountServiceImpl + * @author: HuRui + * @date: 2024/10/20 + **/ +@Service("userCountService") +public class BsUserCountServiceImpl implements BsUserCountService { + @Resource + private BsUserMapper userMapper; + @Resource + private BsUserLoginLogMapper userLoginLogMapper; + @Resource + private BsUserGradeCountMapper userGradeCountMapper; + @Resource + private BsOrderMapper orderMapper; + + @Override + public Long countPlatformRegister(Date timeS, Date timeE) { + BsUserExample example = new BsUserExample(); + example.createCriteria().andCreateTimeGreaterThanOrEqualTo(timeS).andCreateTimeLessThanOrEqualTo(timeE); + return userMapper.countByExample(example); + } + + @Override + public Long countAdd(Date timeS, Date timeE) { + BsUserExample example = new BsUserExample(); + example.createCriteria().andCreateTimeGreaterThanOrEqualTo(timeS).andCreateTimeLessThanOrEqualTo(timeE); + return userMapper.countByExample(example); + } + + @Override + public Long countLogin(Date timeS, Date timeE) { + BsUserLoginLogExample example = new BsUserLoginLogExample(); + example.createCriteria().andCreateTimeGreaterThanOrEqualTo(timeS).andCreateTimeLessThanOrEqualTo(timeE); + return userLoginLogMapper.countByExample(example); + } + + @Override + public Long countPlaceOrder(Date timeS, Date timeE) throws Exception { + return orderMapper.countPlaceOrder(DateUtil.date2String(timeS, DateUtil.Y_M_D_HMS), DateUtil.date2String(timeE, DateUtil.Y_M_D_HMS)); + } + + @Override + public List> countUserGrade(Date timeS, Date timeE) throws Exception { + return userGradeCountMapper.collect(DateUtil.date2String(timeS, DateUtil.Y_M_D_HMS), DateUtil.date2String(timeE, DateUtil.Y_M_D_HMS)); + } +} diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 0a708f5..3085fba 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -186,8 +186,8 @@ public class BsUserServiceImpl implements BsUserService { if (user == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); } - if (!user.getStatus().equals(UserStatusEnum.status1.getCode())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态不正确,无法封禁"); + if (!user.getStatus().equals(UserStatusEnum.status2.getCode())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态不正确,无法恢复"); } user.setStatus(UserStatusEnum.status1.getCode()); updateInfo(user);