| | |
| | | package com.stylefeng.guns.modular.system.controller.general; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.base.tips.SuccessTip; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | 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.controller.util.ExcelUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.HttpUtils; |
| | | import com.stylefeng.guns.modular.system.controller.util.TokenUtils; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.dao.AccountChangeDetailMapper; |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITAgentService; |
| | | import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | private HttpUtils httpUtils; |
| | | @Autowired |
| | | private TokenUtils tokenUtils; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private ITRechargeRecordService tRechargeRecordService; |
| | | |
| | | @Autowired |
| | | private ITSystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private AccountChangeDetailMapper accountChangeDetailMapper; |
| | | |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping("/auditPage") |
| | | public String auditPage( Integer id, |
| | | Model model) { |
| | | public String auditPage( Integer id,Model model) { |
| | | tDriverService.auditPage(id,model); |
| | | return PREFIX + "tDriverAudit.html"; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面 |
| | | * 佣金跳转详情页面 |
| | | */ |
| | | @RequestMapping("/areaPage") |
| | | public String areaDetail(String area,String areaId,Model model) { |
| | | @RequestMapping("/commission/driverCommissionDetail") |
| | | public String driverCommissionDetail(Integer tDriverId,Integer levelFlag, Model model) { |
| | | tDriverService.driverCommissionDetail(tDriverId,levelFlag,model); |
| | | return PREFIX + "tDriverCommissionDetail.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面编辑 |
| | | */ |
| | | @RequestMapping("/areaPageUpdate") |
| | | public String areaPageUpdate(String area,String areaId,Model model) { |
| | | |
| | | String[] split = area.split("/"); |
| | | model.addAttribute("provinceName",split[0]); |
| | | model.addAttribute("cityName",split[1]); |
| | | model.addAttribute("districtName",split[2]); |
| | | |
| | | String[] split1 = areaId.split("/"); |
| | | model.addAttribute("provinceId",split1[0]); |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | |
| | | |
| | | 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()); |
| | | |
| | | |
| | | // 查询市 |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds)); |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | | List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", split1[1])); |
| | | model.addAttribute("districtList",tRegions2); |
| | | |
| | | return PREFIX + "tDriverAreaUpdate.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面新增 |
| | | */ |
| | | @RequestMapping("/areaPageAdd") |
| | | public String areaPageAdd(String area,String areaId,Model model) { |
| | | String[] split1 = areaId.split("/"); |
| | | 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()); |
| | | // // 查询市 |
| | | // List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | // model.addAttribute("cityList",tRegions1); |
| | | // |
| | | // // 查询区 |
| | | // List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | // List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds)); |
| | | // model.addAttribute("districtList",tRegions2); |
| | | |
| | | if(StringUtils.hasLength(area) && StringUtils.hasLength(areaId)){ |
| | | String[] split = area.split("/"); |
| | | model.addAttribute("provinceName",split[0]); |
| | | model.addAttribute("cityName",split[1]); |
| | | model.addAttribute("districtName",split[2]); |
| | | if(split.length>2){ |
| | | model.addAttribute("districtName",split[2]); |
| | | }else { |
| | | model.addAttribute("districtName",""); |
| | | } |
| | | |
| | | String[] split1 = areaId.split("/"); |
| | | model.addAttribute("provinceId",split1[0]); |
| | | model.addAttribute("cityId",split1[1]); |
| | | model.addAttribute("districtId",split1[2]); |
| | | if(split1.length>2) { |
| | | model.addAttribute("districtId", split1[2]); |
| | | }else { |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | |
| | | List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0])); |
| | | model.addAttribute("cityList",tRegions1); |
| | | |
| | | // 查询区 |
| | | List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", split1[1])); |
| | | model.addAttribute("districtList",tRegions2); |
| | | }else { |
| | | model.addAttribute("cityList",new ArrayList<>()); |
| | | model.addAttribute("districtList",new ArrayList<>()); |
| | | |
| | | model.addAttribute("provinceName",""); |
| | | model.addAttribute("cityName","split[1]"); |
| | | model.addAttribute("districtName",""); |
| | | |
| | | model.addAttribute("provinceId",""); |
| | | model.addAttribute("cityId","split1[1]"); |
| | | model.addAttribute("districtId", ""); |
| | | } |
| | | return PREFIX + "tDriverArea.html"; |
| | | return PREFIX + "tDriverAreaAdd.html"; |
| | | } |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | public Object list(String createTime,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.ne("isException",2); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(tDrivers); |
| | | for (TDriverResp driverResp : tDriverResp) { |
| | | TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() |
| | | .eq("driverId", driverResp.getId()) |
| | | .orderBy("workTime", false) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tDriverWork)){ |
| | | // 如果是下班状态,计算未上线天数,,如果为上班状态,则设置为0 |
| | | if(tDriverWork.getStatus() == 1){ |
| | | driverResp.setNotOnlineCount(0); |
| | | }else { |
| | | Period period = Period.between(DateUtil.dateToLocalDate(tDriverWork.getOffWorkTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(period.getYears()*365 + period.getMonths()*30 + Math.abs(period.getDays())); |
| | | } |
| | | }else { |
| | | if(Objects.nonNull(driverResp.getApprovalTime())){ |
| | | // 没有上班记录,计算审核时间 |
| | | Period period = Period.between(DateUtil.dateToLocalDate(driverResp.getApprovalTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(period.getYears()*365 + period.getMonths()*30 + Math.abs(period.getDays())); |
| | | }else { |
| | | driverResp.setNotOnlineCount(0); |
| | | } |
| | | } |
| | | } |
| | | return tDriverResp; |
| | | } |
| | | /** |
| | | * 获取佣金列表 |
| | |
| | | @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); |
| | | List<TDriverCommissionResp> commissionResp = tDriverService.getTDriverCommissionResp(tDrivers); |
| | | for (TDriverCommissionResp tDriverCommissionResp : commissionResp) { |
| | | tDriverCommissionResp.setLevelFlag(0); |
| | | } |
| | | return commissionResp; |
| | | } |
| | | /** |
| | | * 获取异常列表 |
| | |
| | | public Object exceptionList(String createTime,String phone,Integer status) { |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.eq("isException",2); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | return tDriverService.getTDriverResp(tDrivers); |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(tDrivers); |
| | | for (TDriverResp driverResp : tDriverResp) { |
| | | TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() |
| | | .eq("driverId", driverResp.getId()) |
| | | .orderBy("workTime", false) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tDriverWork)){ |
| | | // 如果是下班状态,计算未上线天数,,如果为上班状态,则设置为0 |
| | | if(tDriverWork.getStatus() == 1){ |
| | | driverResp.setNotOnlineCount(0); |
| | | }else { |
| | | Period period = Period.between(DateUtil.dateToLocalDate(tDriverWork.getOffWorkTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(period.getYears()*365 + period.getMonths()*30 + Math.abs(period.getDays())); |
| | | } |
| | | }else { |
| | | if(Objects.nonNull(driverResp.getApprovalTime())){ |
| | | // 没有上班记录,计算审核时间 |
| | | Period period = Period.between(DateUtil.dateToLocalDate(driverResp.getApprovalTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(period.getYears()*365 + period.getMonths()*30 + Math.abs(period.getDays())); |
| | | }else { |
| | | driverResp.setNotOnlineCount(0); |
| | | } |
| | | } |
| | | } |
| | | return tDriverResp; |
| | | } |
| | | |
| | | /** |
| | | * 佣金关联列表 |
| | | */ |
| | | @RequestMapping(value = "/commission/connect/list") |
| | | @ResponseBody |
| | | public Object commissionConnectList(String driverId,Integer levelFlag) { |
| | | // 查询当前用户的用户信息 |
| | | TDriver tDriver = tDriverService.selectById(driverId); |
| | | |
| | | EntityWrapper<TDriver> wrapper = new EntityWrapper<>(); |
| | | if(StringUtils.hasLength(driverId)){ |
| | | wrapper.eq("inviterId",driverId); |
| | | } |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | List<TDriverCommissionResp> commissionResp = new ArrayList<>(); |
| | | try{ |
| | | commissionResp = tDriverService.getTDriverCommissionResp(list); |
| | | for (TDriverCommissionResp tDriverCommissionResp : commissionResp) { |
| | | if(Objects.nonNull(tDriver)){ |
| | | tDriverCommissionResp.setInviterName(tDriver.getName()); |
| | | tDriverCommissionResp.setInviterPhone(tDriver.getPhone()); |
| | | if(levelFlag == 0){ |
| | | tDriverCommissionResp.setLevelFlag(1); |
| | | tDriverCommissionResp.setLevel("一级"); |
| | | } |
| | | if(levelFlag == 1){ |
| | | tDriverCommissionResp.setLevelFlag(2); |
| | | tDriverCommissionResp.setLevel("二级"); |
| | | } |
| | | if(levelFlag == 2){ |
| | | tDriverCommissionResp.setLevelFlag(3); |
| | | tDriverCommissionResp.setLevel("三级"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return commissionResp; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping(value = "/ocr") |
| | | @ResponseBody |
| | | public Object ocr(String imgUrl) { |
| | | public JSONObject ocr(MultipartFile multipartFile) { |
| | | /*String accessToken = redisTemplate.opsForValue().get(TokenUtils.ACCESS_TOKEN_CACHE_KEY); |
| | | if (!StringUtils.hasLength(accessToken)) { |
| | | accessToken = tokenUtils.getSimpleAccessToken(); |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | System.err.println(jsonObject); |
| | | return jsonObject;*/ |
| | | return tDriverService.ocr(imgUrl); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String[] filename = originalFilename.split("\\."); |
| | | log.info("tupian::"+filename[0]+"//"+filename[1]); |
| | | File file= null; |
| | | try { |
| | | file = File.createTempFile(filename[0], "."+filename[1]); |
| | | multipartFile.transferTo(file); |
| | | file.deleteOnExit(); |
| | | log.info("file:"+file.getName()); |
| | | } catch (IOException e) { |
| | | log.error("ocr识别失败:{}",e.getMessage()); |
| | | } |
| | | return tDriverService.ocr(file); |
| | | } |
| | | |
| | | /** |
| | |
| | | tDriver.setApprovalUserId(shiroUser.getId()); |
| | | tDriver.setApprovalTime(new Date()); |
| | | tDriverService.updateById(tDriver); |
| | | |
| | | //增加积分奖励 |
| | | if(approvalStatus == 2 && null != tDriver.getInviterId()){ |
| | | TSystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 4)); |
| | | Integer num7 = JSON.parseObject(systemConfig.getContent()).getInteger("num7"); |
| | | TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId()); |
| | | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(tDriver1.getId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setChangeType(10); |
| | | accountChangeDetail.setOldData(tDriver1.getIntegral().doubleValue()); |
| | | tDriver1.setIntegral(tDriver1.getIntegral() + num7); |
| | | accountChangeDetail.setNewData(tDriver1.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("推荐奖励"); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetailMapper.insert(accountChangeDetail); |
| | | tDriverService.updateById(tDriver1); |
| | | } |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | |
| | | 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.setName(tDriver.getName().replace(" ","")); |
| | | tDriver.setEmergencyContact(tDriver.getEmergencyContact().replace(" ","")); |
| | | tDriver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tDriver.setBalance(BigDecimal.ZERO); |
| | | tDriver.setBackgroundBalance(BigDecimal.ZERO); |
| | | tDriver.setCommission(BigDecimal.ZERO); |
| | | tDriverService.insert(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | TDriver tDriver = tDriverService.selectById(id); |
| | | 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); |
| | |
| | | */ |
| | | @ApiOperation(value = "充值余额") |
| | | @RequestMapping(value = "/recharge-balance") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @ResponseBody |
| | | public Object rechargeBalance(Integer id, String money) { |
| | | TDriver tDriver = tDriverService.selectById(id); |
| | | tDriver.setBackgroundBalance(new BigDecimal(money).add(tDriver.getBackgroundBalance())); |
| | | tDriverService.updateById(tDriver); |
| | | |
| | | // 添加充值记录 |
| | | TRechargeRecord tRechargeRecord = new TRechargeRecord(); |
| | | tRechargeRecord.setType(UserTypeEnum.AGENT.getCode()); |
| | | tRechargeRecord.setUserId(id); |
| | | tRechargeRecord.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tRechargeRecord.setAmount(new BigDecimal(money)); |
| | | tRechargeRecord.setPayType(2); |
| | | tRechargeRecord.setPayTime(new Date()); |
| | | tRechargeRecord.setPayStatus(2); |
| | | tRechargeRecord.setCreateTime(new Date()); |
| | | Integer id1 = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); |
| | | tRechargeRecord.setAgentId(id1); |
| | | tRechargeRecordService.insert(tRechargeRecord); |
| | | 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; |
| | | } |
| | | tDriver.setName(tDriver.getName().replace(" ","")); |
| | | tDriver.setEmergencyContact(tDriver.getEmergencyContact().replace(" ","")); |
| | | tDriverService.updateById(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | String time1 = format.format(date); |
| | | String fileName = "DriverInfo"+time1+".xls"; |
| | | String[] title = new String[] {"编号","姓名","手机号","性别","驾驶证号码","身份证号码", |
| | | "身份证","所属代理商","所属分公司","钱包余额","累计订单量","当月订单量","积分","拒单次数","状态","添加时间"}; |
| | | "身份证","所属代理商","所属分公司","钱包余额","累计订单量","当月订单量","积分","拒单次数","状态","审核状态","添加时间"}; |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | // 是否异常 |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(list); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(tDrivers); |
| | | |
| | | String[][] values = new String[tDriverResp.size()][]; |
| | | for (int i = 0; i < tDriverResp.size(); i++) { |
| | |
| | | }else { |
| | | values[i][14] = "删除"; |
| | | } |
| | | values[i][15] = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(d.getCreateTime()); |
| | | Integer approvalStatus = d.getApprovalStatus(); |
| | | if(1 == approvalStatus){ |
| | | values[i][15] = "待审核"; |
| | | }else if(2 == approvalStatus){ |
| | | values[i][15] = "已同意"; |
| | | }else { |
| | | values[i][15] = "已拒绝"; |
| | | } |
| | | values[i][16] = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(d.getCreateTime()); |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | |
| | | "身份证","累计订单量","当月订单量","积分","连续未上线(天)","状态","添加时间"}; |
| | | EntityWrapper<TDriver> wrapper = tDriverService.getPageList(createTime,phone,status); |
| | | wrapper.eq("isException",2); |
| | | // 是否异常 |
| | | List<TDriver> list = tDriverService.selectList(wrapper); |
| | | |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(list); |
| | | wrapper.orderBy("createTime",false); |
| | | List<TDriver> tDrivers = tDriverService.selectList(wrapper); |
| | | List<TDriverResp> tDriverResp = tDriverService.getTDriverResp(tDrivers); |
| | | for (TDriverResp driverResp : tDriverResp) { |
| | | TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() |
| | | .eq("driverId", driverResp.getId()) |
| | | .orderBy("workTime", false) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tDriverWork)){ |
| | | // 如果是下班状态,计算未上线天数,,如果为上班状态,则设置为0 |
| | | if(tDriverWork.getStatus() == 1){ |
| | | driverResp.setNotOnlineCount(0); |
| | | }else { |
| | | Period period = Period.between(DateUtil.dateToLocalDate(tDriverWork.getOffWorkTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(Math.abs(period.getDays())); |
| | | } |
| | | }else { |
| | | // 没有上班记录,计算审核时间 |
| | | Period period = Period.between(DateUtil.dateToLocalDate(driverResp.getApprovalTime()), LocalDate.now()); |
| | | driverResp.setNotOnlineCount(Math.abs(period.getDays())); |
| | | } |
| | | } |
| | | |
| | | String[][] values = new String[tDriverResp.size()][]; |
| | | for (int i = 0; i < tDriverResp.size(); i++) { |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | } |