| | |
| | | package com.dsh.account.controller; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.account.dto.SelectDto; |
| | | import com.dsh.account.dto.UserInfoQueryDTO; |
| | | import com.dsh.account.entity.Coach; |
| | | import com.dsh.account.entity.TAppUser; |
| | | import com.dsh.account.entity.TCourseInfoRecord; |
| | |
| | | import com.dsh.account.service.IVipPaymentService; |
| | | import com.dsh.account.service.TAppUserService; |
| | | import com.dsh.account.service.TCourseInfoRecordService; |
| | | import com.dsh.account.util.PayMoneyUtil; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.TokenUtil; |
| | | import com.dsh.account.util.ToolUtil; |
| | | import com.dsh.account.util.*; |
| | | import com.dsh.account.vo.GroupCityInfoVO; |
| | | import com.dsh.account.vo.UserInfoQueryVO; |
| | | import com.dsh.account.vo.entity.DayData; |
| | | import com.dsh.account.vo.entity.MonthData; |
| | | import com.dsh.account.vo.entity.WeekData; |
| | | import com.dsh.account.vo.entity.YearData; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private TCourseInfoRecordService courseInfoRecordService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | /** |
| | | * 获取所有用户 |
| | |
| | | public ResultUtil<String> loginWeChat(LoginWeChatVo loginWeChatVo){ |
| | | try { |
| | | return appUserService.loginWechat(loginWeChatVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/bind") |
| | | @ApiOperation(value = "微信登录--绑定手机号", tags = {"APP-登录注册"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<String> bind(String phone,String openId,String code){ |
| | | try { |
| | | String value = redisUtil.getValue(phone); |
| | | if(!code.equals(value)){ |
| | | return ResultUtil.error("验证码无效", ""); |
| | | } |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getOpenid, openId)); |
| | | TAppUser tAppUser = list.get(0); |
| | | tAppUser.setPhone(phone); |
| | | appUserService.updateById(tAppUser); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | System.out.println("=======selectDtos======>"+selectDtos); |
| | | return selectDtos; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/appUser/userInfo") |
| | | public UserInfoQueryVO userInfo(@RequestBody UserInfoQueryDTO dto){ |
| | | |
| | | UserInfoQueryVO userInfoQueryVO = new UserInfoQueryVO(); |
| | | |
| | | LambdaQueryWrapper<TAppUser> wrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | if(StringUtils.hasLength(dto.getCityCode())){ |
| | | wrapper.eq(TAppUser::getCityCode,dto.getCityCode()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getOperatorId())){ |
| | | wrapper.eq(TAppUser::getInsertType,2); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getOperatorId()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getStoreId())){ |
| | | wrapper.eq(TAppUser::getInsertType,3); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getStoreId()); |
| | | } |
| | | |
| | | // 查询会员总数,年度会员总数 |
| | | int userCount = appUserService.count(wrapper); |
| | | int userVipCount = appUserService.count(wrapper.eq(TAppUser::getIsVip,1)); |
| | | |
| | | userInfoQueryVO.setUserCount(userCount); |
| | | userInfoQueryVO.setUserVipCount(userVipCount); |
| | | |
| | | if(Objects.nonNull(dto.getIsVip())){ |
| | | wrapper.eq(TAppUser::getIsVip,dto.getIsVip()); |
| | | } |
| | | |
| | | // 年度数据 |
| | | List<YearData> yearData = appUserService.getYearUserCount(dto); |
| | | userInfoQueryVO.setYearData(yearData); |
| | | // 月度数据 |
| | | List<MonthData> monthData = appUserService.getMonthUserCount(dto); |
| | | userInfoQueryVO.setMonthData(monthData); |
| | | |
| | | // 获取最近四周 |
| | | LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); |
| | | LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); |
| | | // 周度数据 |
| | | dto.setStartTime(minNow.minusDays(6).toString()); |
| | | dto.setEndTime(maxNow.toString()); |
| | | WeekData week4 = appUserService.getWeekUserCount4(dto); |
| | | dto.setStartTime(minNow.minusDays(13).toString()); |
| | | dto.setEndTime(maxNow.minusDays(6).toString()); |
| | | WeekData week3 = appUserService.getWeekUserCount3(dto); |
| | | dto.setStartTime(minNow.minusDays(20).toString()); |
| | | dto.setEndTime(maxNow.minusDays(13).toString()); |
| | | WeekData week2 = appUserService.getWeekUserCount2(dto); |
| | | dto.setStartTime(minNow.minusDays(27).toString()); |
| | | dto.setEndTime(maxNow.minusDays(20).toString()); |
| | | WeekData week1 = appUserService.getWeekUserCount1(dto); |
| | | |
| | | List<WeekData> weekDataList = new ArrayList<>(); |
| | | weekDataList.add(week1); |
| | | weekDataList.add(week2); |
| | | weekDataList.add(week3); |
| | | weekDataList.add(week4); |
| | | userInfoQueryVO.setWeekData(weekDataList); |
| | | |
| | | // 日度数据 |
| | | dto.setStartTime(minNow.minusDays(6).toString()); |
| | | dto.setEndTime(maxNow.toString()); |
| | | List<DayData> dayData = appUserService.getDayUserCount(dto); |
| | | userInfoQueryVO.setDayData(dayData); |
| | | return userInfoQueryVO; |
| | | } |
| | | |
| | | @PostMapping("/appUser/ageInfo") |
| | | public Map<String,Long> ageInfo(@RequestBody UserInfoQueryDTO dto){ |
| | | |
| | | Map<String,Long> map = new HashMap<>(); |
| | | |
| | | LambdaQueryWrapper<TAppUser> wrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | if(StringUtils.hasLength(dto.getCityCode())){ |
| | | wrapper.eq(TAppUser::getCityCode,dto.getCityCode()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getOperatorId())){ |
| | | wrapper.eq(TAppUser::getInsertType,2); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getOperatorId()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getStoreId())){ |
| | | wrapper.eq(TAppUser::getInsertType,3); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getStoreId()); |
| | | } |
| | | |
| | | List<TAppUser> list = appUserService.list(wrapper); |
| | | // 查询会员 |
| | | list.forEach(tAppUser->tAppUser.setAge(DateUtil.ageOfNow(tAppUser.getBirthday()))); |
| | | |
| | | map.put("age1", list.stream().filter(e -> e.getAge() > 0 && e.getAge() <= 12).count()); |
| | | map.put("age2",list.stream().filter(e -> e.getAge() >= 13 && e.getAge() <= 18).count()); |
| | | map.put("age3",list.stream().filter(e -> e.getAge() >= 19 && e.getAge() <= 25).count()); |
| | | map.put("age4",list.stream().filter(e -> e.getAge() >= 26 && e.getAge() <= 35).count()); |
| | | map.put("age5",list.stream().filter(e -> e.getAge() >= 36 && e.getAge() <= 50).count()); |
| | | map.put("age6",list.stream().filter(e -> e.getAge() >= 51).count()); |
| | | return map; |
| | | } |
| | | |
| | | @PostMapping("/appUser/sexInfo") |
| | | public Map<String,Integer> sexInfo(@RequestBody UserInfoQueryDTO dto){ |
| | | |
| | | Map<String,Integer> map = new HashMap<>(2); |
| | | LambdaQueryWrapper<TAppUser> wrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | if(StringUtils.hasLength(dto.getCityCode())){ |
| | | wrapper.eq(TAppUser::getCityCode,dto.getCityCode()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getOperatorId())){ |
| | | wrapper.eq(TAppUser::getInsertType,2); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getOperatorId()); |
| | | } |
| | | |
| | | if(Objects.nonNull(dto.getStoreId())){ |
| | | wrapper.eq(TAppUser::getInsertType,3); |
| | | wrapper.eq(TAppUser::getAddUserId,dto.getStoreId()); |
| | | } |
| | | |
| | | // 查询会员 |
| | | int boyCount = appUserService.count(wrapper.eq(TAppUser::getGender,1)); |
| | | int girlCount = appUserService.count(wrapper.eq(TAppUser::getGender,2)); |
| | | map.put("boyCount",boyCount); |
| | | map.put("girlCount",girlCount); |
| | | return map; |
| | | } |
| | | |
| | | @PostMapping("/appUser/groupCityInfo") |
| | | public List<GroupCityInfoVO> groupCityInfo(@RequestBody UserInfoQueryDTO dto){ |
| | | // 查询地区会员 |
| | | return appUserService.groupCityInfo(dto); |
| | | } |
| | | } |