| | |
| | | package com.dsh.account.controller; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.nacos.common.utils.Md5Utils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.account.dto.BindDto; |
| | | import com.dsh.account.dto.IntroduceUserQuery; |
| | | 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.dto.UpdateInfoDto; |
| | | import com.dsh.account.entity.*; |
| | | 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.service.TCourseInfoRecordService; |
| | | import com.dsh.account.service.*; |
| | | 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.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 io.swagger.models.auth.In; |
| | | 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; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private TCourseInfoRecordService courseInfoRecordService; |
| | | |
| | | @Autowired |
| | | private TAppGiftService appGiftService; |
| | | /** |
| | | * 根据介绍有礼id查询当前活动参与次数 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/getActivityPeoples") |
| | | public Integer getActivityPeoples(@RequestBody Integer activityId){ |
| | | int activityId1 = appGiftService.list(new QueryWrapper<TAppGift>().eq("activityId", activityId)) |
| | | .size(); |
| | | return activityId1; |
| | | } |
| | | /** |
| | | * 介绍有礼 -- 参与用户列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryIntroduceAll") |
| | | public List<IntroduceUser> queryIntroduceAll(@RequestBody IntroduceUserQuery query){ |
| | | return appGiftService.queryIntroduceAll(query); |
| | | } |
| | | /** |
| | | * 获取所有用户 |
| | | */ |
| | |
| | | public List<TAppUser> queryAppUserList(@RequestBody AppUserByNameAndPhoneDTO dto){ |
| | | return appUserService.queryAPPUserByNameAndPhone(dto); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户姓名和电话模糊查询 |
| | | */ |
| | |
| | | if (null != phone){ |
| | | return 5001; |
| | | } |
| | | }else { |
| | | TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", query.getPhone())); |
| | | if (null != phone){ |
| | | return 5001; |
| | | } |
| | | } |
| | | query.setIsVip(0); |
| | | query.setPassword("111111"); |
| | | query.setInsertTime(new Date()); |
| | | return appUserService.saveOrUpdate(query); |
| | | } |
| | |
| | | /** |
| | | * 获取用户信息列表数据 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/base/appUser/listAll") |
| | | public List<QueryAppUserVO> listAll(@RequestBody QueryAppUser query){ |
| | | List<QueryAppUserVO> queryAppUserVOS = appUserService.listAll(query); |
| | | ArrayList<QueryAppUserVO> res = new ArrayList<>(); |
| | | |
| | | return appUserService.listAll(query); |
| | | if (query.getUserIds()!=null && query.getUserIds().size()!=0){ |
| | | List<QueryAppUserVO> queryAppUserVOS1 = appUserService.listAll1(query); |
| | | queryAppUserVOS.addAll(queryAppUserVOS1); |
| | | } |
| | | List<QueryAppUserVO> collect = queryAppUserVOS.stream().distinct().collect(Collectors.toList()); |
| | | for (QueryAppUserVO vo : collect) { |
| | | // 会员到期时间小于当前时间或者会员到期时间为null 则会员过期 |
| | | if (vo.getVipEndTime()!=null && vo.getVipEndTime().after(new Date())){ |
| | | vo.setIsVip(1); |
| | | }else{ |
| | | vo.setIsVip(0); |
| | | } |
| | | if (query.getIsVip() != null && (!query.getIsVip().equals("")) ){ |
| | | if (vo.getIsVip() == query.getIsVip()){ |
| | | res.add(vo); |
| | | } |
| | | }else{ |
| | | res.add(vo); |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | |
| | | try { |
| | | ResultUtil smsCode = appUserService.getSMSCode(type, phone); |
| | | return smsCode; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private TStudentService studentService; |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/logOff") |
| | | @ApiOperation(value = "注销", tags = {"注销"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "账号id", name = "appId", dataType = "int", required = true) |
| | | }) |
| | | public ResultUtil<String> logOff(Integer appId){ |
| | | try { |
| | | |
| | | appUserService.removeById(appId); |
| | | studentService.remove(new QueryWrapper<TStudent>().eq("appUserId",appId)); |
| | | |
| | | return ResultUtil.success("注销成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/bind") |
| | | @ApiOperation(value = "微信登录绑定手机号", tags = {"APP-登录注册"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil bind(BindDto dto){ |
| | | try { |
| | | return appUserService.bind(dto); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/appUser/bind") |
| | | @ApiOperation(value = "微信登录--绑定手机号", tags = {"APP-登录注册"}) |
| | | @PostMapping("/api/appUser/updateInfo") |
| | | @ApiOperation(value = "修改个人信息", tags = {"APP-登录注册"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<String> bind(String phone){ |
| | | public ResultUtil<String> updateInfo(UpdateInfoDto dto){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | TAppUser byId = appUserService.getById(uid); |
| | | byId.setPhone(phone); |
| | | appUserService.updateById(byId); |
| | | return ResultUtil.success(); |
| | | return appUserService.updateInfo(dto,uid); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<JoinPlayPaiVo> queryJoinPlayPai(String lon, String lat){ |
| | | |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | |
| | | @PostMapping("/base/appUser/addVipPaymentAliCallback") |
| | | public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | System.err.println("==============购买优惠卷回调========="); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | | String out_trade_no = map.get("out_trade_no"); |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private UserIntegralChangesService userIntegralChangesService; |
| | | /** |
| | | * 修改用户信息 |
| | | * @param appUser |
| | |
| | | public void updateAppUser(@RequestBody TAppUser appUser){ |
| | | try { |
| | | appUserService.updateById(appUser); |
| | | UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); |
| | | userIntegralChanges.setAppUserId(appUser.getId()); |
| | | userIntegralChanges.setOldIntegral(appUser.getIntegral()+appUser.getPoints()); |
| | | userIntegralChanges.setType(5); |
| | | userIntegralChanges.setNewIntegral(appUser.getIntegral()); |
| | | userIntegralChanges.setInsertTime(new Date()); |
| | | userIntegralChanges.setCategory(2); |
| | | userIntegralChangesService.save(userIntegralChanges); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据名称模糊搜索用户 |
| | | * @param name |
| | |
| | | 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); |
| | | } |
| | | } |