| | |
| | | import com.dsh.course.feignClient.activity.model.QueryBodySideAppointmentVO; |
| | | import com.dsh.course.feignClient.other.StoreClient; |
| | | 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.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.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 跳转体测预约管理首页 |
| | | */ |
| | | @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()); |
| | | } |
| | | } |
| | | 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); |
| | | |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | List<User> sales = userService.list(new QueryWrapper<User>().eq("deptid", 2)); |
| | | model.addAttribute("list",list); |
| | | model.addAttribute("roleType",roleType); |
| | | model.addAttribute("sales",sales); |
| | | return PREFIX + "TAppUser_add.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); |
| | | } |
| | | 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); |
| | | 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())); |
| | | List<TCity> city = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, province1.getId())); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format1 = format.format(data.getBirthday()); |
| | | 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); |
| | | } |
| | | return PREFIX + "TAppUser_edit.html"; |
| | | } |
| | | |
| | |
| | | queryAppUser.setPhone(phone); |
| | | queryAppUser.setIsVip(isVip); |
| | | queryAppUser.setSalesmanUserName(salesmanUserName); |
| | | return appUserClient.listAll(queryAppUser); |
| | | 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()); |
| | | } |
| | | List<QueryAppUserVO> queryAppUserVOS = appUserClient.listAll(queryAppUser); |
| | | for (QueryAppUserVO queryAppUserVO : queryAppUserVOS) { |
| | | if (queryAppUserVO.getSalesmanUserId()!=null){ |
| | | queryAppUserVO.setSalesmanUserName(userService.getById(queryAppUserVO.getSalesmanUserId()).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() == sale.getId()){ |
| | | result.add(queryAppUserVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | return queryAppUserVOS; |
| | | } |
| | | /** |
| | | * 新增用户信息 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/addAppUser") |
| | | @ResponseBody |
| | | public ResultUtil addAppUser(TAppUser appUser){ |
| | | appUserClient.addAppUser(appUser); |
| | | return ResultUtil.success("添加成功"); |
| | | public Object addAppUser(@RequestBody TAppUser appUser){ |
| | | Object o = appUserClient.addAppUser1(appUser); |
| | | return o; |
| | | } |
| | | /** |
| | | * 添加/修改体测预约记录 |