| | |
| | | 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.model.*; |
| | | import com.dsh.account.model.query.appUserQuery.QueryAppUser; |
| | | import com.dsh.account.model.vo.QueryAppUserVO; |
| | | import com.dsh.account.service.IVipPaymentService; |
| | | import com.dsh.account.service.TAppUserService; |
| | | 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.service.TCourseInfoRecordService; |
| | | 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.util.ArrayList; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Autowired |
| | | private TCourseInfoRecordService courseInfoRecordService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | /** |
| | | * 获取所有用户 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryAppUserList") |
| | | public List<TAppUser> queryAppUserList(@RequestBody AppUserByNameAndPhoneDTO dto){ |
| | | return appUserService.queryAPPUserByNameAndPhone(dto); |
| | | } |
| | | /** |
| | | * 根据用户姓名和电话模糊查询 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryAPPUserByNameAndPhone") |
| | | public List<TAppUser> queryAPPUserByNameAndPhone(@RequestBody AppUserByNameAndPhoneDTO dto){ |
| | | return appUserService.queryAPPUserByNameAndPhone(dto); |
| | | } |
| | | /** |
| | | * 根据用户id获取用户信息 |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryAppUser1") |
| | | public TAppUser queryAppUser1(@RequestBody Integer appUserId){ |
| | | TAppUser appUser = appUserService.getById(appUserId); |
| | | return appUser; |
| | | } |
| | | /** |
| | | * 冻结/解冻 1=解冻 2=冻结 |
| | | */ |
| | | @RequestMapping("/base/appUser/changeState") |
| | | public Object changeState(@RequestBody AdvertisementChangeStateDTO dto){ |
| | | return appUserService.changeState(dto); |
| | | } |
| | | /** |
| | | * 后台添加 |
| | | */ |
| | | @RequestMapping("/base/appUser/addAppUser1") |
| | | public Object addAppUser1(@RequestBody TAppUser query){ |
| | | // 修改 |
| | | if (query.getId()!=null){ |
| | | TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", query.getPhone()).ne("id",query.getId())); |
| | | if (null != phone){ |
| | | return 5001; |
| | | } |
| | | } |
| | | query.setIsVip(0); |
| | | query.setPassword("111111"); |
| | | query.setInsertTime(new Date()); |
| | | return appUserService.saveOrUpdate(query); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息列表数据 |
| | | */ |
| | | @RequestMapping("/base/appUser/listAll") |
| | | public List<QueryAppUserVO> listAll(@RequestBody QueryAppUser query){ |
| | | |
| | | return appUserService.listAll(query); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户手机号获取用户id |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/getAppUserByPhone/{phone}") |
| | | public TAppUser getAppUserByPhone(@PathVariable("phone") String phone){ |
| | | TAppUser appUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", phone)); |
| | | return appUser; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/getSMSCode") |
| | |
| | | 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(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/appUser/queryByNamePhone") |
| | | List<TAppUser> queryByNamePhone(@RequestBody QueryByNamePhone queryByNamePhone){ |
| | | public List<TAppUser> queryByNamePhone(@RequestBody QueryByNamePhone queryByNamePhone){ |
| | | try { |
| | | LambdaQueryWrapper<TAppUser> tAppUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if(ToolUtil.isNotEmpty(queryByNamePhone.getName())){ |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/base/appUser/queryById") |
| | | public TAppUser queryById(@RequestBody Integer appUserId){ |
| | | try { |
| | | return appUserService.getById(appUserId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new TAppUser(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据名称模糊搜索用户 |
| | | * @param name |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/appUser/queryAppUserListByName") |
| | | public List<TAppUser> queryAppUserListByName(@RequestBody String name){ |
| | | return appUserService.list(new QueryWrapper<TAppUser>().eq("state", 1).like("name", name)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/appUser/addCourseInfoRecord") |
| | | public Boolean addCourseInfoRecord(@RequestBody TCourseInfoRecord tCourseInfoRecord){ |
| | | boolean save = courseInfoRecordService.save(tCourseInfoRecord); |
| | | return save; |
| | | } |
| | | |
| | | @PostMapping("/appUser/getSelects") |
| | | public List<SelectDto> getSelects(@RequestBody List<Integer> studentIds){ |
| | | List<SelectDto> selectDtos = appUserService.getSelects(studentIds); |
| | | 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); |
| | | } |
| | | } |