| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.config.properties.GunsProperties; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.model.vo.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.WeChatUtil; |
| | | import com.stylefeng.guns.modular.system.util.qianyuntong.QianYunTongConfig; |
| | | import com.stylefeng.guns.modular.system.warpper.*; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.http.*; |
| | | import org.springframework.util.Base64Utils; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.security.SecureRandom; |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @CrossOrigin |
| | | @RestController |
| | | @RequestMapping("") |
| | | @Slf4j |
| | | public class DriverController { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | |
| | | @Autowired |
| | | private ISmsrecordService smsrecordService; |
| | | |
| | | |
| | | @Autowired |
| | | private IDriverOrdersService driverOrdersService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | private RegionMapper regionMapper; |
| | | |
| | | @Autowired |
| | | private IOrderTaxiService orderTaxiService; |
| | | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderCrossCityService orderCrossCityService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderLogisticsService orderLogisticsService; |
| | | |
| | | @Autowired |
| | | private GunsProperties gunsProperties; |
| | | |
| | | |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | @Autowired |
| | | private TDriverPromotionActivityService driverPromotionActivityService; |
| | | |
| | | |
| | | @Autowired |
| | | private QianYunTongConfig qianYunTongConfig; |
| | | |
| | | /** |
| | | * 获取短信验证码 |
| | | * |
| | | * @param phone |
| | | * @return |
| | | */ |
| | |
| | | @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String") |
| | | }) |
| | | public ResultUtil queryCaptcha(String phone, Integer type){ |
| | | if(ToolUtil.isNotEmpty(phone)){ |
| | | public ResultUtil queryCaptcha(String phone, Integer type) { |
| | | if (ToolUtil.isNotEmpty(phone)) { |
| | | try { |
| | | return driverService.queryCaptcha(phone, type); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | }else{ |
| | | } else { |
| | | return ResultUtil.paranErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 验证短信验证码 |
| | | * |
| | | * @param phone |
| | | * @param code |
| | | * @return |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 司机注册审核后的短信 |
| | | * |
| | | * @param uid |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/sendsms") |
| | | public ResultUtil sendsms(Integer uid, Integer type){ |
| | | public ResultUtil sendsms(Integer uid, Integer type) { |
| | | try { |
| | | Driver driver = driverService.selectById(uid); |
| | | String templateCode = null; |
| | | switch (type){ |
| | | switch (type) { |
| | | case 1: |
| | | templateCode = "SMS_229648175";//身份验证 |
| | | break; |
| | |
| | | templateCode = "SMS_229613326";//司机注册失败 |
| | | break; |
| | | } |
| | | String s = aLiSendSms.sendSms(driver.getPhone(), templateCode, "{}"); |
| | | // String s = aLiSendSms.sendSms(driver.getPhone(), templateCode, "{}"); |
| | | // SMSUtil.sendVerifyCode(driver.getPhone()); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryHomeDataFromDriver") |
| | | @ApiOperation(value = "获取首页统计数据(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<DriverIndexVo> queryHomeDataFromDriver(HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | DriverIndexVo vo = driverService.queryHomeDataFromDriver(uid); |
| | | return ResultUtil.success(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryOrderDataFromDriver") |
| | | @ApiOperation(value = "获取订单统计数据(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "2022-02-02 - 2033-03-03", name = "time", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "pageNumber", name = "pageNumber", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "pageSize", name = "pageSize", required = true, dataType = "int") |
| | | }) |
| | | public ResultUtil<DriverOrderDataVo> queryOrderDataFromDriver(String time,Integer pageNumber,Integer pageSize,HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Page<DriverOrderDataNextVo> driverOrderDataVoPage = new Page<>(pageNumber, pageSize); |
| | | DriverOrderDataVo vo = driverService.queryOrderDataFromDriver(time,driverOrderDataVoPage,uid); |
| | | return ResultUtil.success(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryOrderMoneyFromDriver") |
| | | @ApiOperation(value = "获取订单收入统计数据(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "2022-02-02 - 2033-03-03", name = "time", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "pageNumber", name = "pageNumber", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "pageSize", name = "pageSize", required = true, dataType = "int") |
| | | }) |
| | | public ResultUtil<DriverOrderMoneyDataVo> queryOrderMoneyFromDriver(String time, Integer pageNumber, Integer pageSize, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Page<DriverOrderDataNextVo> driverOrderDataVoPage = new Page<>(pageNumber, pageSize); |
| | | DriverOrderMoneyDataVo vo = driverService.queryOrderMoneyFromDriver(time,driverOrderDataVoPage,uid); |
| | | return ResultUtil.success(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryOrderPromotionFromDriver") |
| | | @ApiOperation(value = "获取订单推广统计数据(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "2022-02-02 - 2033-03-03", name = "time", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "pageNumber", name = "pageNumber", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "pageSize", name = "pageSize", required = true, dataType = "int") |
| | | }) |
| | | public ResultUtil<DriverOrderPromotionDataVo> queryOrderPromotionFromDriver(String time, Integer pageNumber, Integer pageSize, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Page<DriverOrderDataNextVo> driverOrderDataVoPage = new Page<>(pageNumber, pageSize); |
| | | DriverOrderPromotionDataVo vo = driverService.queryOrderPromotionFromDriver(time,driverOrderDataVoPage,uid); |
| | | return ResultUtil.success(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getPromotionInfo") |
| | | @ApiOperation(value = "获取推广说明(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<String> getPromotionInfo(HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | String areaCode = driver.getAreaCode(); |
| | | TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>() |
| | | .eq("districtCode", areaCode) |
| | | .eq("status", 2) |
| | | .last("LIMIT 1")); |
| | | if(tDriverPromotionActivity!=null){ |
| | | return ResultUtil.success(tDriverPromotionActivity.getActivityDesc()); |
| | | } |
| | | return ResultUtil.success(""); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "个人的小程序码(分享码)/链接", tags = {"司机端-首页"}, notes = "") |
| | | @GetMapping("/api/driver/personCode") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<HashMap<String, Object>> personCode(HttpServletRequest request) { |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | String accessToken=null; |
| | | Object img = redisTemplate.opsForValue().get("DRIVER_WX_IMG" + uid); |
| | | // 获取调用凭证accessToken |
| | | if(ToolUtil.isEmpty(driver.getShareLink())|| ToolUtil.isEmpty(img)){ |
| | | accessToken = getAccessToken(); |
| | | } |
| | | int index=0; |
| | | |
| | | if(ToolUtil.isEmpty(img)) { |
| | | RestTemplate rest = new RestTemplate(); |
| | | String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("path", "pages/home/home?driverId=" + uid); |
| | | param.put("width", 430); //二维码尺寸 |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.body(JSON.toJSONString(param)); |
| | | |
| | | byte[] result = post.execute().bodyBytes(); |
| | | // base64 |
| | | img = Base64.getEncoder().encodeToString(result); |
| | | redisTemplate.opsForValue().set("DRIVER_WX_IMG" + uid, img,30, TimeUnit.DAYS); |
| | | } |
| | | |
| | | String urlLink = driver.getShareLink(); |
| | | if(ToolUtil.isEmpty(urlLink)) { |
| | | index=1; |
| | | String url1 = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessToken; |
| | | Map<String, Object> param1 = new HashMap<>(); |
| | | param1.put("path", "pages/home/home"); |
| | | param1.put("query", "driverId=" + uid); |
| | | |
| | | HttpRequest post = HttpUtil.createPost(url1); |
| | | // map转json |
| | | String jsonString = JSON.toJSONString(param1); |
| | | post.body(jsonString); |
| | | HttpResponse execute = post.execute(); |
| | | String body = execute.body(); |
| | | urlLink = JSONObject.parseObject(body).get("url_link").toString(); |
| | | driver.setShareLink(urlLink); |
| | | } |
| | | |
| | | if(index==1){ |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | HashMap<String, Object> stringStringHashMap = new HashMap<>(); |
| | | stringStringHashMap.put("url_link",urlLink); |
| | | stringStringHashMap.put("img",img); |
| | | return ResultUtil.success(stringStringHashMap); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("调用小程序生成微信永久小程序码URL接口异常", e); |
| | | } |
| | | return ResultUtil.error("获取二维码失败"); |
| | | } |
| | | |
| | | @Value("${wx.url}") |
| | | private String ACCESS_TOKEN_URL; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String memberAppSecret; |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppId; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | public String getAccessToken() { |
| | | String requestUrl = MessageFormat.format(ACCESS_TOKEN_URL,wxAppId,memberAppSecret); |
| | | String respBody = restTemplate.getForEntity(requestUrl, String.class).getBody(); |
| | | JSONObject jsonObject = JSONObject.parseObject(respBody); |
| | | return jsonObject.getString("access_token"); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryMyCar") |
| | | @ApiOperation(value = "获取当前车辆及空闲车辆", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiOperation(value = "获取当前车辆及空闲车辆 新增useState 1使用中 2空闲", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/queryPhone") |
| | | @ApiOperation(value = "获取客服电话", tags = {"司机端-个人中心"}, notes = "车队=franchisee,分公司=branch,平台=platform") |
| | | @ApiOperation(value = "获取客服电话(黔云通)", tags = {"司机端-个人中心"}, notes = "车队=franchisee,分公司=branch,平台=platform") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "当前行政区划代码", name = "code", required = true, dataType = "String"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil queryPhone(HttpServletRequest request){ |
| | | public ResultUtil queryPhone(String code, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Map<String, Object> map = driverService.queryPhone(uid); |
| | | Map<String, Object> map = driverService.queryPhone(uid, code); |
| | | return ResultUtil.success(map); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取省市区3级联动 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/base/driver/getRegion") |
| | | @ApiOperation(value = "获取省市区3级联动", tags = {"司机端-注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<Region>> getRegion(){ |
| | | try { |
| | | List<Region> regions = regionMapper.selectList(null); |
| | | List<Region> regionList = regions.stream().filter(e -> e.getParentId() == 0).collect(Collectors.toList()); |
| | | for (Region region : regionList) { |
| | | region.setTire(1); |
| | | List<Region> regionList1 = regions.stream().filter(e -> e.getParentId().equals(region.getId())).collect(Collectors.toList()); |
| | | for (Region region1 : regionList1) { |
| | | region1.setTire(2); |
| | | List<Region> regionList2 = regions.stream().filter(e -> e.getParentId().equals(region1.getId())).collect(Collectors.toList()); |
| | | region1.setChildren(regionList2); |
| | | } |
| | | region.setChildren(regionList1); |
| | | } |
| | | return ResultUtil.success(regionList); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/base/driver/getCompany") |
| | | @ApiOperation(value = "通过区code获取服务商", tags = {"司机端-注册"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "区code", name = "areaCode", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "name", name = "name", required = false, dataType = "String"), |
| | | |
| | | }) |
| | | public ResultUtil<List<CompanyVo>> getCompany(String areaCode,String name){ |
| | | try { |
| | | |
| | | ArrayList<CompanyVo> companyVos = new ArrayList<>(); |
| | | List<CompanyCity> companyCities = companyCityService.selectList(new EntityWrapper<CompanyCity>().eq("areaCode", areaCode).eq("state", 1)); |
| | | if(companyCities.isEmpty()){ |
| | | return ResultUtil.success(companyVos); |
| | | } |
| | | Wrapper<Company> in = new EntityWrapper<Company>().ne("type", 1).ne("flag", 3).in("id", companyCities.stream().map(CompanyCity::getCompanyId).collect(Collectors.toList())); |
| | | |
| | | if(ToolUtil.isNotEmpty( name)){ |
| | | in.like("name", name); |
| | | } |
| | | List<Company> companies = companyService.selectList(in); |
| | | for (Company company : companies) { |
| | | CompanyVo companyVo = new CompanyVo(company.getId(), company.getName()); |
| | | companyVos.add(companyVo); |
| | | } |
| | | return ResultUtil.success(companyVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置提现密码 |
| | | * @param withdrawPassword |
| | | * @param request |
| | |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getDriverCode") |
| | | @ApiOperation(value = "获取司机端的二维码", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil getDriverCode(HttpServletRequest request){ |
| | | public ResultUtil getDriverCode(HttpServletRequest request) { |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | | if(driver!=null){ |
| | | if (driver != null) { |
| | | String fileName = driver.getQrCode(); |
| | | if(fileName==null || "".equals(fileName) ){ |
| | | if (fileName == null || "".equals(fileName)) { |
| | | String appletPath = "pages/home/scanPage/scanPage"; |
| | | //HttpURLConnection httpURLConnection = weChatUtil.getwxacodeunlimit(appletPath, "d=" + driverId + "&k=" + 0, "release",driverId); |
| | | InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId , "release"); |
| | | if(inputStream!=null){ |
| | | fileName = OssUploadUtil.ossUploadByStream(driverId,inputStream); |
| | | System.out.println(fileName); |
| | | driver.setQrCode(fileName); |
| | | InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId, "release"); |
| | | if (inputStream != null) { |
| | | // 上传文件目录 |
| | | fileName = UUID.randomUUID().toString() + ".png"; |
| | | String fileSavePath = gunsProperties.getFileUploadPath() + "img\\"; |
| | | FileUtil.writeFromStream(inputStream, fileName); |
| | | String pictureName = gunsProperties.getPictureServerAddress() + "img/" + fileName; |
| | | // fileName = OssUploadUtil.ossUploadByStream(driverId, inputStream); |
| | | System.out.println(pictureName); |
| | | driver.setQrCode(pictureName); |
| | | driverService.updateById(driver); |
| | | } |
| | | } |
| | |
| | | public ResultUtil cancellation(HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | | driver.setAuthState(3); |
| | | driverService.updateById(driver); |
| | | //开始验证当前账号是否在别处登录 |
| | | String value = redisUtil.getValue("DRIVER_" + driverId); |
| | | if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线 |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER_" + driverId); |
| | | if (ToolUtil.isNotEmpty(value)) {//将另外设备上的强迫下线 |
| | | //开始清除redis中无效的数据 |
| | | String key = redisUtil.getValue("DRIVER_" + driver.getPhone()); |
| | | redisUtil.remove(key);//删除个人信息数据 |
| | | redisUtil.remove("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisUtil.remove("DRIVER_" + driverId);//清除存储的token |
| | | String key = (String) redisTemplate.opsForValue().get("DRIVER_" + driver.getPhone()); |
| | | redisTemplate.delete(key);//删除个人信息数据 |
| | | redisTemplate.delete("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisTemplate.delete("DRIVER_" + driverId);//清除存储的token |
| | | } |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // @ResponseBody |
| | | // @RequestMapping(value = "/base/driver/uploadImg", method = RequestMethod.POST) |
| | | // @ApiOperation(value = "上传图片", tags = {"司机端-注册"}, notes = "") |
| | | // public ResultUtil uploadImg(MultipartFile file) { |
| | | // try { |
| | | // String bucketName = "grjy_test"; |
| | | // Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName); |
| | | // if (null == grjyTest) { |
| | | // //创建桶 |
| | | // Boolean bucket = NCOSSUtil.createBucket(bucketName); |
| | | // if (!bucket) { |
| | | // return ResultUtil.error("创建存储桶失败"); |
| | | // } |
| | | // //设置桶策略 |
| | | // String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"]" + |
| | | // ",\"Effect\":\"Allow\",\"Resource\":[\"" + bucketName + "\"/*],\"Principal\":{*}}]}"; |
| | | // Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText); |
| | | // if (!bucketPolicy) { |
| | | // return ResultUtil.error("设置桶策略失败"); |
| | | // } |
| | | // } |
| | | // //上传对象 |
| | | // String key = "image/driver/" + UUID.randomUUID().toString() + ".png"; |
| | | // String object = NCOSSUtil.putObject(bucketName, key, file.getInputStream()); |
| | | // if (null == object) { |
| | | // return ResultUtil.error("上传图片失败"); |
| | | // } |
| | | // |
| | | // return ResultUtil.success("http://" + QianYunTongProperties.endPoint + "/" + key); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | } |