From f0b4d0e6bc47a18f4e10ca4c007dcaa01c9c9647 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 16 五月 2023 15:10:35 +0800 Subject: [PATCH] BUG修改 --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java | 75 +++++++++++++++++++++++++++++-------- 1 files changed, 59 insertions(+), 16 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java index 4cd62ee..6c988c0 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java @@ -5,6 +5,7 @@ import com.stylefeng.guns.core.base.tips.SuccessTip; 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; @@ -13,6 +14,7 @@ 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; @@ -56,12 +58,20 @@ @Autowired private ITRegionService tRegionService; + @Autowired + private ITDriverService tDriverService; + @Autowired + private ITDriverWorkService tDriverWorkService; + @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"; } @@ -127,8 +137,8 @@ */ @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); @@ -155,7 +165,11 @@ int count = tAgentService.selectCount(new EntityWrapper<TAgent>().eq("provinceName", split1[0]).eq("cityName",split1[1])); if(count>0){ return new SuccessTip(500,"该代理商已存在!"); + } + + tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); + String[] split = tAgent.getAreaId().split("/"); // 查询省市 @@ -195,6 +209,33 @@ tAgent.setStatus(1); } tAgentService.updateById(tAgent); + // 冻结下面所有的司机 + List<TDriver> list = tDriverService.selectList(new EntityWrapper<TDriver>() + .eq("agentId", id)); + 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); + } + } + if(!CollectionUtils.isEmpty(list)){ + tDriverService.updateBatchById(list); + } return SUCCESS_TIP; } @@ -204,6 +245,7 @@ @RequestMapping(value = "/update") @ResponseBody public Object update(TAgent tAgent) { + tAgent.setPrincipal(tAgent.getPrincipal().replace(" ","")); tAgentService.updateById(tAgent); return SUCCESS_TIP; } @@ -243,15 +285,15 @@ @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 time1 = format.format(date); String fileName = "Agent"+time1+".xls"; - String[] title = new String[] {"时间","姓名","联系电话","代理区域","订单数量", + 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); @@ -265,20 +307,21 @@ values[i][1] = d.getPrincipal(); values[i][2] = d.getPrincipalPhone(); values[i][3] = d.getProvinceName()+d.getCityName(); - values[i][4] = String.valueOf(d.getOrderSum()); - values[i][5] = String.valueOf(d.getValidOrder()); - values[i][6] = String.valueOf(d.getIssuedCoupon()); - values[i][7] = String.valueOf(d.getUsedCoupon()); - values[i][8] = String.valueOf(d.getCouponPriceSum()); - values[i][9] = String.valueOf(d.getDriverRecharge() == null ? "0":d.getDriverRecharge()); - values[i][10] = String.valueOf(d.getDriverCount()); + values[i][4] = StringUtils.hasLength(d.getServiceCalls())?d.getServiceCalls():""; + values[i][5] = String.valueOf(d.getOrderSum()); + values[i][6] = String.valueOf(d.getValidOrder()); + values[i][7] = String.valueOf(d.getIssuedCoupon()); + values[i][8] = String.valueOf(d.getUsedCoupon()); + values[i][9] = String.valueOf(d.getCouponPriceSum()); + values[i][10] = String.valueOf(d.getDriverRecharge() == null ? "0":d.getDriverRecharge()); + values[i][11] = String.valueOf(d.getDriverCount()); Integer status1 = d.getStatus(); if(1 == status1){ - values[i][11] = "正常"; + values[i][12] = "正常"; }else if(2 == status1){ - values[i][11] = "冻结"; + values[i][12] = "冻结"; }else { - values[i][11] = "删除"; + values[i][12] = "删除"; } } HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); -- Gitblit v1.7.1