| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverCommissionResp; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面 |
| | | * 佣金跳转详情页面 |
| | | */ |
| | | @RequestMapping("/areaPage") |
| | | public String areaDetail(String area,String areaId,Model model) { |
| | | @RequestMapping("/commission/driverCommissionDetail") |
| | | public String driverCommissionDetail(Integer tDriverId, Model model) { |
| | | tDriverService.driverCommissionDetail(tDriverId,model); |
| | | return PREFIX + "tDriverCommissionDetail.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面编辑 |
| | | */ |
| | | @RequestMapping("/areaPageUpdate") |
| | | public String areaPageUpdate(String area,String areaId,Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",tRegions); |
| | | List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | } |
| | | return PREFIX + "tDriverArea.html"; |
| | | return PREFIX + "tDriverAreaUpdate.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面新增 |
| | | */ |
| | | @RequestMapping("/areaPageAdd") |
| | | public String areaPageAdd(Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("provinceList",tRegions); |
| | | return PREFIX + "tDriverAreaAdd.html"; |
| | | } |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | public Object commissionList(String name,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status); |
| | | wrapper.ne("isException",2); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | return tDriverService.getTDriverCommissionResp(tDrivers); |
| | | } |
| | | /** |
| | | * 获取异常列表 |
| | |
| | | wrapper.eq("isException",2); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | } |
| | | |
| | | /** |
| | | * 佣金关联列表 |
| | | */ |
| | | @RequestMapping(value = "/commission/connect/list") |
| | | @ResponseBody |
| | | public Object commissionConnectList(String driverId) { |
| | | |
| | | // 查询当前用户的用户信息 |
| | | TDriver tDriver = tDriverService.selectById(driverId); |
| | | |
| | | EntityWrapper<TDriver> wrapper = new EntityWrapper<>(); |
| | | if(StringUtils.hasLength(driverId)){ |
| | | wrapper.eq("inviterId",driverId); |
| | | } |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | List<TDriverCommissionResp> commissionResp = tDriverService.getTDriverCommissionResp(list); |
| | | for (TDriverCommissionResp tDriverCommissionResp : commissionResp) { |
| | | if(Objects.nonNull(tDriver)){ |
| | | tDriverCommissionResp.setInviterName(tDriver.getName()); |
| | | tDriverCommissionResp.setInviterPhone(tDriver.getPhone()); |
| | | } |
| | | } |
| | | return commissionResp; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | int count = tDriverService.selectCount(new EntityWrapper<TDriver>().eq("phone", tDriver.getPhone())); |
| | | if(count>0){ |
| | | return "该司机已存在!"; |
| | | return new SuccessTip(500,"该司机已存在!"); |
| | | } |
| | | tDriverService.addOrUpdate(tDriver); |
| | | Object o = tDriverService.addOrUpdate(tDriver); |
| | | if(Objects.nonNull(o)){ |
| | | return o; |
| | | } |
| | | // 默认值板块 |
| | | tDriver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tDriver.setBalance(BigDecimal.ZERO); |
| | | tDriver.setBackgroundBalance(BigDecimal.ZERO); |
| | | tDriver.setCommission(BigDecimal.ZERO); |
| | | tDriverService.insert(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | @RequestMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update(TDriver tDriver) { |
| | | TDriver driver = tDriverService.selectOne(new EntityWrapper<TDriver>().eq("phone", tDriver.getPhone()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(driver) && !tDriver.getId().equals(driver.getId())){ |
| | | return new SuccessTip(500,"该司机已存在!"); |
| | | } |
| | | // Object ocr = ocr("E:\\071bf986db0b00355c0ed190bbd3b16.png"); |
| | | // System.err.println(ocr); |
| | | tDriverService.addOrUpdate(tDriver); |
| | | Object o = tDriverService.addOrUpdate(tDriver); |
| | | if(Objects.nonNull(o)){ |
| | | return o; |
| | | } |
| | | tDriverService.updateById(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @ApiOperation(value = "导出司机异常列表",notes="导出司机异常列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | @RequestMapping(value = "/export-commission") |
| | | @ResponseBody |
| | | public void exportCommission(String name,String phone,Integer status,HttpServletResponse response) { |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName = "CommissionInfo"+time1+".xls"; |
| | | String[] title = new String[] {"姓名","手机号","所属代理商","推广人数","关联人数", |
| | | "累计获得佣金","可提现佣金","已提现金额","状态"}; |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getCommissionPageList(name,phone,status); |
| | | // wrapper.ne("isException",2); |
| | | // 是否异常 |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | |
| | | List<TDriverCommissionResp> commissionResp = tDriverService.getTDriverCommissionResp(list); |
| | | |
| | | String[][] values = new String[commissionResp.size()][]; |
| | | for (int i = 0; i < commissionResp.size(); i++) { |
| | | TDriverCommissionResp d = commissionResp.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = d.getName(); |
| | | values[i][1] = d.getPhone(); |
| | | values[i][2] = d.getAgentName(); |
| | | values[i][3] = String.valueOf(Objects.isNull(d.getNumberPromoters()) ? 0:d.getNumberPromoters()); |
| | | values[i][4] = String.valueOf(d.getConnectedPersons()); |
| | | values[i][5] = String.valueOf(d.getAccumulatedCommission()); |
| | | values[i][6] = String.valueOf(Objects.isNull(d.getCommission())?0:d.getCommission()); |
| | | values[i][7] = String.valueOf(d.getWithdrawnAmount()); |
| | | Integer status1 = d.getStatus(); |
| | | if(1 == status1){ |
| | | values[i][8] = "正常"; |
| | | }else if(2 == status1){ |
| | | values[i][8] = "冻结"; |
| | | }else if(3 == status1){ |
| | | values[i][8] = "已删除"; |
| | | } |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |