| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.base.tips.SuccessTip; |
| | | import com.stylefeng.guns.core.common.constant.state.ManagerStatus; |
| | | import com.stylefeng.guns.core.exception.GunsException; |
| | | import com.stylefeng.guns.core.exception.ServiceExceptionEnum; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TAgentResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | @Autowired |
| | | private ITDriverService tDriverService; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private IUserService userService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index() { |
| | | public String index(Model model) { |
| | | model.addAttribute("userType", Objects.requireNonNull(ShiroKit.getUser()).getRoleType()); |
| | | return PREFIX + "tAgent.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public Object list(String principal,String principalPhone,String createTime) { |
| | | EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime); |
| | | public Object list(String principal,String principalPhone,String createTime,Integer status) { |
| | | EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime,status); |
| | | List<TAgent> tAgents = tAgentService.selectList(wrapper); |
| | | // 代理商列表数据封装(导出共用) |
| | | return tAgentService.getAgentResp(tAgents); |
| | |
| | | */ |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public Object add(TAgent tAgent) { |
| | | |
| | | String[] split1 = tAgent.getArea().split("/"); |
| | |
| | | return new SuccessTip(500,"该代理商已存在!"); |
| | | } |
| | | |
| | | int count1 = userService.selectCount(new EntityWrapper<User>().eq("account", tAgent.getAccount())); |
| | | if (count1 > 0){ |
| | | return new SuccessTip(500,"该账号已存在!"); |
| | | } |
| | | |
| | | tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); |
| | | |
| | | |
| | | String[] split = tAgent.getAreaId().split("/"); |
| | | // 查询省市 |
| | | // 黑龙江省/大兴安岭地区 |
| | |
| | | tAgent.setProvinceName(province.getName()); |
| | | tAgent.setProvinceCode(province.getCode()); |
| | | TRegion city = tRegionService.selectById(split[1]); |
| | | if(Objects.isNull(city)){ |
| | | city = tRegionService.selectOne(new EntityWrapper<TRegion>() |
| | | .eq("name",split[1]) |
| | | .last("LIMIT 1")); |
| | | } |
| | | tAgent.setCityName(city.getName()); |
| | | tAgent.setCityCode(city.getCode()); |
| | | tAgentService.insert(tAgent); |
| | | |
| | | //添加User对象 |
| | | User user = new User(); |
| | | user.setAccount(tAgent.getAccount()); |
| | | user.setSalt(ShiroKit.getRandomSalt(5)); |
| | | user.setPassword(ShiroKit.md5(tAgent.getPassword(), user.getSalt())); |
| | | user.setStatus(ManagerStatus.OK.getCode()); |
| | | user.setRoleid("2"); |
| | | user.setDeptid(25); |
| | | user.setCreatetime(new Date()); |
| | | user.setRoleType(3); |
| | | user.setObjectId(tAgent.getId()); |
| | | user.setName(tAgent.getPrincipal()); |
| | | user.setSex(1); |
| | | userService.insert(user); |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | for (TDriver tDriver : list) { |
| | | if(1 == status){ |
| | | tDriver.setStatus(2); |
| | | String value = redisUtil.getValue("DRIVER_" + tDriver.getPhone()); |
| | | redisUtil.remove(value); |
| | | redisUtil.remove("DRIVER_" + tDriver.getPhone()); |
| | | TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() |
| | | .eq("driverId", tDriver.getId()) |
| | | .eq("status", 1) |
| | | .orderBy("workTime", false) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tDriverWork)){ |
| | | tDriverWork.setStatus(2); |
| | | tDriverWork.setOffWorkTime(new Date()); |
| | | tDriverWorkService.updateById(tDriverWork); |
| | | } |
| | | } |
| | | if(2 == status){ |
| | | tDriver.setStatus(1); |
| | | } |
| | | } |
| | | tDriverService.updateBatchById(list); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | tDriverService.updateBatchById(list); |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TAgent tAgent) { |
| | | tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); |
| | | tAgentService.updateById(tAgent); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | @ApiOperation(value = "导出代理商列表",notes="导出代理商列表") |
| | | @RequestMapping(value = "/export") |
| | | @ResponseBody |
| | | public void export(String principal,String principalPhone,String createTime, HttpServletResponse response) { |
| | | public void export(String principal,String principalPhone,Integer status,String createTime, HttpServletResponse response) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | |
| | | String fileName = "Agent"+time1+".xls"; |
| | | String[] title = new String[] {"时间","姓名","联系电话","代理区域","客服电话","订单数量", |
| | | "有效订单","已发放优惠券","已使用优惠券","累计优惠券金额","司机充值","司机数","状态"}; |
| | | EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime); |
| | | EntityWrapper<TAgent> wrapper = tAgentService.getAgentWrapper(principal,principalPhone,createTime,status); |
| | | // 是否异常 |
| | | List<TAgent> list = tAgentService.selectList(wrapper); |
| | | |