|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.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.controller.util.MD5; | 
|---|
|  |  |  | import com.dsh.guns.modular.system.model.*; | 
|---|
|  |  |  | import com.dsh.guns.modular.system.service.ICityService; | 
|---|
|  |  |  | import com.dsh.guns.modular.system.service.IRoleService; | 
|---|
|  |  |  | import com.dsh.guns.modular.system.service.IUserService; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 跳转体测预约管理首页 | 
|---|
|  |  |  | 
|---|
|  |  |  | Integer roleType = UserExt.getUser().getObjectType(); | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.addAttribute("list",list); | 
|---|
|  |  |  | model.addAttribute("roleType",roleType); | 
|---|
|  |  |  | model.addAttribute("sales",sales); | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 跳转体测预约管理添加页面 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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("birthday",format1); | 
|---|
|  |  |  | model.addAttribute("city",city); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | //        queryAppUser.setSalesmanUser(salesmanUserName); | 
|---|
|  |  |  | if (province!=null && (!province.equals(""))){ | 
|---|
|  |  |  | TCity p = cityService.getOne(new QueryWrapper<TCity>().eq("code", province)); | 
|---|
|  |  |  | queryAppUser.setProvince(p.getName()); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | List<Integer> users = new ArrayList<>(); | 
|---|
|  |  |  | users.addAll(list); | 
|---|
|  |  |  | users.addAll(siteUsers); | 
|---|
|  |  |  | users.addAll(cpUsers); | 
|---|
|  |  |  | users.addAll(gameUsers); | 
|---|
|  |  |  | // 去重后的用户id | 
|---|
|  |  |  | List<Integer> collect = users.stream().distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | queryAppUserVO.setSalesmanUserName(userService.getById(queryAppUserVO.getSalesmanUserId()).getName()); | 
|---|
|  |  |  | User byId = userService.getById(queryAppUserVO.getSalesmanUserId()); | 
|---|
|  |  |  | if (byId!=null){ | 
|---|
|  |  |  | queryAppUserVO.setSalesmanUserName(byId.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (salesmanUserName!=null && (!salesmanUserName.equals(""))){ | 
|---|
|  |  |  | 
|---|
|  |  |  | for (QueryAppUserVO queryAppUserVO : queryAppUserVOS) { | 
|---|
|  |  |  | if (queryAppUserVO.getSalesmanUserId()!=null){ | 
|---|
|  |  |  | for (User sale : sales) { | 
|---|
|  |  |  | if (queryAppUserVO.getSalesmanUserId() == sale.getId()){ | 
|---|
|  |  |  | if (queryAppUserVO.getSalesmanUserId().equals(sale.getId())){ | 
|---|
|  |  |  | result.add(queryAppUserVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping("/addAppUser") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *  添加/修改体测预约记录 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *  添加/修改体测预约记录 | 
|---|
|  |  |  | * 新增学员 | 
|---|
|  |  |  | * @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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|