| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.feignClient.account.AppUserClient; |
| | | import com.dsh.course.feignClient.account.CityManagerClient; |
| | | import com.dsh.course.feignClient.account.StoreStaffClient; |
| | | import com.dsh.course.feignClient.account.StudentClient; |
| | | import com.dsh.course.feignClient.account.model.*; |
| | | import com.dsh.course.feignClient.activity.BodySideAppointmentClient; |
| | | import com.dsh.course.feignClient.activity.model.BodySideAppointment; |
| | | import com.dsh.course.feignClient.activity.model.QueryBodySideAppointment; |
| | | import com.dsh.course.feignClient.activity.model.QueryBodySideAppointmentVO; |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.StoreIds; |
| | | import com.dsh.course.feignClient.communityWorldCup.WorldCupClient; |
| | | import com.dsh.course.feignClient.competition.CompetitionClient; |
| | | import com.dsh.course.feignClient.competition.model.Competition; |
| | | import com.dsh.course.feignClient.competition.model.ListQuery; |
| | | import com.dsh.course.feignClient.course.CoursePackageClient; |
| | | import com.dsh.course.feignClient.other.BallClient; |
| | | import com.dsh.course.feignClient.other.StoreClient; |
| | | import com.dsh.course.feignClient.other.model.SiteChangeStateVO; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.model.Store; |
| | | import com.dsh.guns.modular.system.model.TCity; |
| | | import com.dsh.guns.modular.system.model.TSiteType; |
| | | import com.dsh.guns.modular.system.service.ICityService; |
| | | import com.dsh.guns.modular.system.controller.util.MD5; |
| | | import com.dsh.guns.modular.system.model.*; |
| | | import com.dsh.guns.modular.system.service.*; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | public class TAppUserController { |
| | | private String PREFIX = "/system/appUser/"; |
| | | @Autowired |
| | | private IUserService userService; |
| | | @Autowired |
| | | private StoreClient storeClient; |
| | | @Autowired |
| | | private BodySideAppointmentClient bodySideAppointmentClient; |
| | |
| | | private AppUserClient appUserClient; |
| | | @Autowired |
| | | private ICityService cityService; |
| | | @Autowired |
| | | private IRoleService roleService; |
| | | @Autowired |
| | | private StudentClient studentClient; |
| | | @Autowired |
| | | private IStoreService storeService; |
| | | @Autowired |
| | | private CompetitionClient competitionClient; |
| | | @Autowired |
| | | private ISiteBookingService siteBookingService; |
| | | @Autowired |
| | | private CoursePackageClient coursePackageClient; |
| | | @Autowired |
| | | private BallClient ballClient; |
| | | |
| | | /** |
| | | * 跳转体测预约管理首页 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index(Model model) { |
| | | Integer roleType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | List<Role> deptid = roleService.list(new QueryWrapper<Role>().eq("deptid", 2)); |
| | | model.addAttribute("roleType",roleType); |
| | | model.addAttribute("objectId",objectId); |
| | | List<CityManager> province = cityManagerClient.listAll(); |
| | | // 已有城市管理的省 |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | // 已有城市管理的市 |
| | | ArrayList<String> list2 = new ArrayList<>(); |
| | | for (CityManager cityManager : province) { |
| | | list1.add(cityManager.getProvince()); |
| | | list2.add(cityManager.getCity()); |
| | | } |
| | | HashSet<String> set = new HashSet<String>(list1); |
| | | model.addAttribute("list",set); |
| | | model.addAttribute("sales",deptid); |
| | | model.addAttribute("list",list); |
| | | return PREFIX + "TAppUser.html"; |
| | | } |
| | | /** |
| | |
| | | @RequestMapping("/add") |
| | | public String add(Model model) { |
| | | Integer roleType = UserExt.getUser().getObjectType(); |
| | | List<CityManager> province = cityManagerClient.listAll(); |
| | | Set<String> seenNames = new HashSet<>(); |
| | | List<CityManager> result = new ArrayList<>(); |
| | | for (CityManager cityManager : province) { |
| | | if(!seenNames.contains(cityManager.getProvince())){ |
| | | result.add(cityManager); |
| | | seenNames.add(cityManager.getProvince()); |
| | | } |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | List<User> sales = userService.list(new QueryWrapper<User>().eq("deptid", 2)); |
| | | if(UserExt.getUser().getObjectType()==3){ |
| | | sales = userService.list(new QueryWrapper<User>().eq("deptid", 2).eq("objectType",3).eq("objectId",UserExt.getUser().getObjectId())); |
| | | } |
| | | if (roleType == 2){ |
| | | Integer cityManagerId = UserExt.getUser().getObjectId(); |
| | | CityManager cityManager = cityManagerClient.queryCityManagerById(cityManagerId); |
| | | List<Store> stores = storeClient.getStoreByCityManagerId(cityManagerId); |
| | | model.addAttribute("stores",stores); |
| | | } |
| | | model.addAttribute("list",result); |
| | | |
| | | model.addAttribute("list",list); |
| | | model.addAttribute("roleType",roleType); |
| | | model.addAttribute("sales",sales); |
| | | return PREFIX + "TAppUser_add.html"; |
| | | } |
| | | |
| | |
| | | /** |
| | | * 跳转体测预约管理添加页面 |
| | | */ |
| | | @RequestMapping("/addStudent") |
| | | public String addStudent(Model model) { |
| | | @RequestMapping("/addStudent/{appUserId}") |
| | | public String addStudent(Model model,@PathVariable("appUserId") Integer appUserId) { |
| | | Integer roleType = UserExt.getUser().getObjectType(); |
| | | List<CityManager> province = cityManagerClient.listAll(); |
| | | Set<String> seenNames = new HashSet<>(); |
| | | List<CityManager> result = new ArrayList<>(); |
| | | for (CityManager cityManager : province) { |
| | | if(!seenNames.contains(cityManager.getProvince())){ |
| | | result.add(cityManager); |
| | | seenNames.add(cityManager.getProvince()); |
| | | } |
| | | } |
| | | if (roleType == 2){ |
| | | Integer cityManagerId = UserExt.getUser().getObjectId(); |
| | | CityManager cityManager = cityManagerClient.queryCityManagerById(cityManagerId); |
| | | List<Store> stores = storeClient.getStoreByCityManagerId(cityManagerId); |
| | | model.addAttribute("stores",stores); |
| | | } |
| | | model.addAttribute("list",result); |
| | | |
| | | model.addAttribute("roleType",roleType); |
| | | TAppUser tAppUser = appUserClient.queryById(appUserId); |
| | | model.addAttribute("data",tAppUser); |
| | | model.addAttribute("name",tAppUser.getName()); |
| | | return PREFIX + "TAppUser_addStudent.html"; |
| | | } |
| | | /** |
| | | * 跳转体测预约管理编辑页面 |
| | | * @param type 1 = 用户管理编辑 2 = 用户管理详情-非会员 3 = 用户管理详情-会员 |
| | | * @param type 1 = 用户管理编辑 2 = 用户管理详情 |
| | | */ |
| | | @RequestMapping("/update/{id}/{type}") |
| | | public String update(Model model,@PathVariable("id") Integer id,@PathVariable("type") Integer type) { |
| | | Integer roleType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | BodySideAppointment data = bodySideAppointmentClient.getInfoById(id); |
| | | if (roleType == 1){ |
| | | List<CityManager> cityManagers = cityManagerClient.listAll(); |
| | | List<CityManager> province = new ArrayList<>(); |
| | | List<CityManager> city = new ArrayList<>(); |
| | | Set<String> seenNames = new HashSet<>(); |
| | | Set<String> c = new HashSet<>(); |
| | | // 省列表 |
| | | List<CityManager> result = new ArrayList<>(); |
| | | // 市列表 |
| | | List<CityManager> cities = new ArrayList<>(); |
| | | // 对省/市去重 |
| | | for (CityManager cityManager : cityManagers) { |
| | | if(!seenNames.contains(cityManager.getProvince())){ |
| | | result.add(cityManager); |
| | | seenNames.add(cityManager.getProvince()); |
| | | } |
| | | if(!c.contains(cityManager.getProvince())){ |
| | | cities.add(cityManager); |
| | | c.add(cityManager.getProvince()); |
| | | } |
| | | } |
| | | List<Store> stores = storeClient.getStore(data.getCity()); |
| | | model.addAttribute("stores",stores); |
| | | model.addAttribute("list",result); |
| | | model.addAttribute("cities",cities); |
| | | }else if (roleType == 2){ |
| | | List<Store> stores = storeClient.getStoreByCityManagerId(objectId); |
| | | model.addAttribute("stores",stores); |
| | | TAppUser data = appUserClient.queryById(id); |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | String province = data.getProvince(); |
| | | TCity province1 = cityService.getOne(new QueryWrapper<TCity>().eq("name", data.getProvince())); |
| | | |
| | | if (province1!=null){ |
| | | List<TCity> city = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, province1.getId())); |
| | | model.addAttribute("city",city); |
| | | |
| | | } |
| | | String birthday = new SimpleDateFormat("yyyy-MM-dd").format(data.getBirthday()); |
| | | String appointmentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(data.getAppointmentTime()); |
| | | model.addAttribute("birthday",birthday); |
| | | model.addAttribute("appointmentTime",appointmentTime); |
| | | model.addAttribute("data",data); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | if (data.getBirthday()!=null){ |
| | | String format1 = format.format(data.getBirthday()); |
| | | model.addAttribute("birthday",format1); |
| | | } |
| | | List<User> sales = userService.list(new QueryWrapper<User>().eq("deptid", 2)); |
| | | model.addAttribute("list",list); |
| | | model.addAttribute("roleType",roleType); |
| | | model.addAttribute("sales",sales); |
| | | model.addAttribute("data",data); |
| | | |
| | | model.addAttribute("type",type); |
| | | model.addAttribute("isVip",data.getIsVip()); |
| | | if (data.getVipEndTime()!=null){ |
| | | SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format3 = format2.format(data.getVipEndTime()); |
| | | model.addAttribute("vipEndTime",format3); |
| | | }else { |
| | | model.addAttribute("vipEndTime",""); |
| | | |
| | | } |
| | | if (data.getViplevelId()!=null){ |
| | | |
| | | model.addAttribute("level","黄金"); |
| | | } |
| | | model.addAttribute("level","黄金"); |
| | | List<TStudent> tStudents = studentClient.queryStudentList(data.getId()); |
| | | model.addAttribute("students",tStudents); |
| | | return PREFIX + "TAppUser_edit.html"; |
| | | } |
| | | |
| | | @Autowired |
| | | private WorldCupClient worldCupClient; |
| | | /** |
| | | * 获取所有用户信息 |
| | | * @return |
| | |
| | | @ResponseBody |
| | | public List<QueryAppUserVO> listAll(String province, String city,String name, |
| | | String phone,Integer isVip, String salesmanUserName){ |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | |
| | | QueryAppUser queryAppUser = new QueryAppUser(); |
| | | queryAppUser.setProvince(province); |
| | | queryAppUser.setCity(city); |
| | | queryAppUser.setName(name); |
| | | queryAppUser.setPhone(phone); |
| | | queryAppUser.setIsVip(isVip); |
| | | queryAppUser.setSalesmanUserName(salesmanUserName); |
| | | return appUserClient.listAll(queryAppUser); |
| | | } |
| | | // queryAppUser.setSalesmanUser(salesmanUserName); |
| | | if (province!=null && (!province.equals(""))){ |
| | | TCity p = cityService.getOne(new QueryWrapper<TCity>().eq("code", province)); |
| | | queryAppUser.setProvince(p.getName()); |
| | | } |
| | | if (city!=null && (!city.equals(""))){ |
| | | TCity c = cityService.getOne(new QueryWrapper<TCity>().eq("code", city)); |
| | | queryAppUser.setCity(c.getName()); |
| | | } |
| | | queryAppUser.setInsertType(objectType); |
| | | queryAppUser.setTypeId(UserExt.getUser().getObjectId()); |
| | | if (objectType == 2){ |
| | | // 获取运营商下的所有门店id集合 |
| | | List<Integer> storeIds = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId)) |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | // 根据门店id集合查询 属于该运营商下的门店举办的赛事 |
| | | ListQuery listQuery = new ListQuery(); |
| | | listQuery.setIds(storeIds); |
| | | // 通过门店ids 获取赛事的支付记录 获取到用户的ids |
| | | List<Integer> list = competitionClient.getUserIds(listQuery); |
| | | |
| | | // 获取场地预约记录 拿到用户ids |
| | | List<Integer> siteUsers = siteBookingService.list(new QueryWrapper<SiteBooking>().in("storeId", storeIds)) |
| | | .stream().map(SiteBooking::getAppUserId).collect(Collectors.toList()); |
| | | // 获取课程购买记录 拿到用户ids |
| | | List<Integer> cpUsers = coursePackageClient.getCoursePackageByStoreIds(storeIds); |
| | | // 获取游戏记录 拿到用户ids |
| | | List<Integer> gameUsers = ballClient.getGameByStoreIds(storeIds); |
| | | // 查询世界杯记录 获取用户ids |
| | | StoreIds storeIds1 = new StoreIds(); |
| | | storeIds1.setStoreIds(storeIds); |
| | | List<Integer> userIds = worldCupClient.getUserIds(storeIds1); |
| | | // 用户ids |
| | | List<Integer> users = new ArrayList<>(); |
| | | users.addAll(list); |
| | | users.addAll(siteUsers); |
| | | users.addAll(cpUsers); |
| | | users.addAll(gameUsers); |
| | | users.addAll(userIds); |
| | | // 去重后的用户id |
| | | List<Integer> collect = users.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1); |
| | | } |
| | | queryAppUser.setUserIds(collect); |
| | | // List<QueryAppUserVO> queryAppUserVOS1 = new ArrayList<>(); |
| | | // // 根据用户消费记录 去查询用户ids |
| | | // for (Integer integer : collect) { |
| | | // if (!collect1.contains(integer)){ |
| | | // TAppUser tAppUser = appUserClient.queryAppUser1(integer); |
| | | // QueryAppUserVO queryAppUserVO = new QueryAppUserVO(); |
| | | // BeanUtils.copyProperties(tAppUser,queryAppUserVO); |
| | | // queryAppUserVOS.add(queryAppUserVO); |
| | | // } |
| | | // } |
| | | } |
| | | if (objectType == 3){ |
| | | // 获取运营商下的所有门店id集合 |
| | | List<Integer> storeIds = new ArrayList<>(); |
| | | storeIds.add(objectId); |
| | | // 根据门店id集合查询 属于该运营商下的门店举办的赛事 |
| | | ListQuery listQuery = new ListQuery(); |
| | | listQuery.setIds(storeIds); |
| | | // 通过门店ids 获取赛事的支付记录 获取到用户的ids |
| | | List<Integer> list = competitionClient.getUserIds(listQuery); |
| | | // 获取场地预约记录 拿到用户ids |
| | | List<Integer> siteUsers = siteBookingService.list(new QueryWrapper<SiteBooking>().in("storeId", storeIds) |
| | | .ne("status",0) |
| | | .ne("status",5) |
| | | ) |
| | | .stream().map(SiteBooking::getAppUserId).collect(Collectors.toList()); |
| | | // 获取课程购买记录 拿到用户ids |
| | | List<Integer> cpUsers = coursePackageClient.getCoursePackageByStoreIds(storeIds); |
| | | // 获取游戏记录 拿到用户ids |
| | | List<Integer> gameUsers = ballClient.getGameByStoreIds(storeIds); |
| | | StoreIds storeIds1 = new StoreIds(); |
| | | storeIds1.setStoreIds(storeIds); |
| | | // 查询世界杯记录 获取用户ids |
| | | List<Integer> userIds = worldCupClient.getUserIds(storeIds1); |
| | | // 用户ids |
| | | List<Integer> users = new ArrayList<>(); |
| | | users.addAll(list); |
| | | users.addAll(siteUsers); |
| | | users.addAll(cpUsers); |
| | | users.addAll(gameUsers); |
| | | users.addAll(userIds); |
| | | // 去重后的用户id |
| | | List<Integer> collect = users.stream().distinct().collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1); |
| | | } |
| | | queryAppUser.setUserIds(collect); |
| | | // List<QueryAppUserVO> queryAppUserVOS1 = new ArrayList<>(); |
| | | // // 根据用户消费记录 去查询用户ids |
| | | // for (Integer integer : collect) { |
| | | // if (!collect1.contains(integer)){ |
| | | // TAppUser tAppUser = appUserClient.queryAppUser1(integer); |
| | | // QueryAppUserVO queryAppUserVO = new QueryAppUserVO(); |
| | | // BeanUtils.copyProperties(tAppUser,queryAppUserVO); |
| | | // queryAppUserVOS.add(queryAppUserVO); |
| | | // } |
| | | // } |
| | | } |
| | | List<QueryAppUserVO> queryAppUserVOS = appUserClient.listAll(queryAppUser); |
| | | List<Integer> collect1 = queryAppUserVOS.stream().map(QueryAppUserVO::getId).collect(Collectors.toList()); |
| | | for (QueryAppUserVO queryAppUserVO : queryAppUserVOS) { |
| | | if (queryAppUserVO.getSalesmanUserId()!=null){ |
| | | User byId = userService.getById(queryAppUserVO.getSalesmanUserId()); |
| | | if (byId!=null){ |
| | | queryAppUserVO.setSalesmanUserName(byId.getName()); |
| | | } |
| | | } |
| | | } |
| | | if (salesmanUserName!=null && (!salesmanUserName.equals(""))){ |
| | | List<QueryAppUserVO> result = new ArrayList<>(); |
| | | List<User> sales = userService.list(new QueryWrapper<User>().like("name", salesmanUserName)); |
| | | for (QueryAppUserVO queryAppUserVO : queryAppUserVOS) { |
| | | if (queryAppUserVO.getSalesmanUserId()!=null){ |
| | | for (User sale : sales) { |
| | | if (queryAppUserVO.getSalesmanUserId().equals(sale.getId())){ |
| | | result.add(queryAppUserVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | return queryAppUserVOS; |
| | | } |
| | | /** |
| | | * 新增用户信息 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/addAppUser") |
| | | @ResponseBody |
| | | public ResultUtil addAppUser(TAppUser appUser){ |
| | | appUserClient.addAppUser(appUser); |
| | | return ResultUtil.success("添加成功"); |
| | | } |
| | | /** |
| | | * 添加/修改体测预约记录 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping(value = "/addBodySideAppointments") |
| | | public ResultUtil addBodySideAppointments(@RequestBody QueryBodySideAppointmentVO vo) { |
| | | Integer roleType = UserExt.getUser().getObjectType(); |
| | | // 获取当前登录人id |
| | | Integer cityManagerId = UserExt.getUser().getObjectId(); |
| | | if (roleType == 2){ |
| | | CityManager cityManager = cityManagerClient.queryCityManagerById(cityManagerId); |
| | | vo.setProvince(cityManager.getProvince()); |
| | | vo.setProvinceCode(cityManager.getProvinceCode()); |
| | | vo.setCity(cityManager.getCity()); |
| | | vo.setCityCode(cityManager.getCityCode()); |
| | | }else if (roleType == 3){ |
| | | TStoreStaff storeByStoreStaffId = storeStaffClient.getStoreByStoreStaffId(cityManagerId); |
| | | Store storeById = storeClient.getStoreById(storeByStoreStaffId.getStoreId()); |
| | | vo.setProvince(storeById.getProvince()); |
| | | vo.setProvinceCode(storeById.getProvinceCode()); |
| | | vo.setCity(storeById.getCity()); |
| | | vo.setCityCode(storeById.getCityCode()); |
| | | } |
| | | bodySideAppointmentClient.addBodySideAppointments(vo); |
| | | return ResultUtil.success("添加成功"); |
| | | public Object addAppUser(@RequestBody TAppUser appUser){ |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | appUser.setPassword(MD5.md5("111111")); |
| | | appUser.setProvince(""); |
| | | appUser.setProvinceCode(""); |
| | | appUser.setCity(""); |
| | | appUser.setCityCode(""); |
| | | appUser.setInsertType(objectType); |
| | | appUser.setAddUserId(UserExt.getUser().getObjectId()); |
| | | Object o = appUserClient.addAppUser1(appUser); |
| | | return o; |
| | | } |
| | | |
| | | /** |
| | | * 添加/修改体测预约记录 |
| | | * 新增学员 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/addAppUserStudent") |
| | | @ResponseBody |
| | | @RequestMapping(value = "/getInfoById") |
| | | public BodySideAppointment getInfoById(@RequestBody Integer id) { |
| | | return bodySideAppointmentClient.getInfoById(id); |
| | | public Object addAppUser(@RequestBody TStudent student){ |
| | | Double height = student.getHeight(); |
| | | Double weight = student.getWeight(); |
| | | double v = weight / (height * height); |
| | | student.setBmi(v); |
| | | return studentClient.addStudent(student); |
| | | } |
| | | |
| | | /** |
| | | * 手动标记用户已经到店并完成体测 |
| | | * 上/下架 1为上架 2为下架 3为删除 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping("/changeState") |
| | | @ResponseBody |
| | | @RequestMapping(value = "/changeState") |
| | | public Object changeState(@RequestBody List<Integer> ids) { |
| | | return bodySideAppointmentClient.changeState(ids); |
| | | public Object changeState(@RequestBody AdvertisementChangeStateDTO dto){ |
| | | appUserClient.changeState(dto); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | } |