| | |
| | | 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.util.zhenglian.CallbackUtil; |
| | | import com.stylefeng.guns.modular.system.util.zhenglian.TokenUtil; |
| | | import com.stylefeng.guns.modular.system.util.zhenglian.model.MessageBody; |
| | | import com.stylefeng.guns.modular.system.util.zhenglian.model.TokenRequest; |
| | | import com.stylefeng.guns.modular.system.util.zhenglian.model.TradeTerminalInfo; |
| | | import com.stylefeng.guns.modular.system.warpper.*; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | /** |
| | | * 获取短信验证码 |
| | |
| | | |
| | | if(ToolUtil.isEmpty(img)) { |
| | | RestTemplate rest = new RestTemplate(); |
| | | String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("path", "pages/home/home?driverId=" + uid); |
| | | param.put("page", "pages/home/home"); |
| | | param.put("width", 430); //二维码尺寸 |
| | | param.put("scene", "driverId=" + uid); //二维码尺寸 |
| | | param.put("env_version", "trial"); //二维码尺寸 |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.body(JSON.toJSONString(param)); |
| | | |
| | |
| | | if(null == position){ |
| | | position = new DriverPosition(); |
| | | } |
| | | position.setDriverId(orderPosition.getDriverId()); |
| | | position.setPoint(point); |
| | | mongoTemplate.save(position); |
| | | //处理业务上的功能 |
| | |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getDriverCode") |
| | |
| | | driver.setAuthState(3); |
| | | driverService.updateById(driver); |
| | | //开始验证当前账号是否在别处登录 |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER_" + driverId); |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER_" + driverId); |
| | | if (ToolUtil.isNotEmpty(value)) {//将另外设备上的强迫下线 |
| | | //开始清除redis中无效的数据 |
| | | String key = (String) redisTemplate.opsForValue().get("DRIVER_" + driver.getPhone()); |
| | | String key = (String) redisTemplate.opsForValue().get("dache:DRIVER_" + driver.getPhone()); |
| | | redisTemplate.delete(key);//删除个人信息数据 |
| | | redisTemplate.delete("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisTemplate.delete("DRIVER_" + driverId);//清除存储的token |
| | | redisTemplate.delete("dache:DRIVER_" + driver.getPhone());//删除后台冻结相关缓存 |
| | | redisTemplate.delete("dache:DRIVER_" + driverId);//清除存储的token |
| | | } |
| | | return ResultUtil.success(); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // @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(); |
| | | // } |
| | | // } |
| | | @ResponseBody |
| | | @PostMapping("/api/driver/getZLToken") |
| | | @ApiOperation(value = "获取证联token(黔云通)", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "当前设备IP地址", name = "ip", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "当前设备mac地址", name = "mac", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "01 证联收银台支付\n" + |
| | | "\t 04 HOME 页\n" + |
| | | "\t 06 申请免密签约\n" + |
| | | "\t 07 商户收银台支付\n" + |
| | | "\t 08 开户(绑卡)\n" + |
| | | "\t 09 开通支付账户\n" + |
| | | "\t 10 打开付款码", name = "type", required = true, dataType = "String"), |
| | | }) |
| | | public ResultUtil<String> getZLToken(String ip, String mac, String type, HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if (null == driverId) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(driverId); |
| | | TokenRequest tokenRequest = new TokenRequest(); |
| | | tokenRequest.setAppUserId(driver.getEmpId().toString()); |
| | | tokenRequest.setUserName(driver.getName()); |
| | | tokenRequest.setCertNo(driver.getIdCard()); |
| | | tokenRequest.setPhone(driver.getPhone()); |
| | | TradeTerminalInfo tradeTerminalInfo = new TradeTerminalInfo(); |
| | | tradeTerminalInfo.setIp(ip); |
| | | tradeTerminalInfo.setTerminal("1"); |
| | | tradeTerminalInfo.setMac(mac); |
| | | tokenRequest.setTradeTerminalInfo(tradeTerminalInfo); |
| | | tokenRequest.setType(type); |
| | | String token = TokenUtil.getToken(tokenRequest); |
| | | return ResultUtil.success(token); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 证联通知回调 |
| | | * @param messageBody |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/driver/zlCallback") |
| | | public void zlCallback(@RequestBody MessageBody messageBody, HttpServletRequest request){ |
| | | String callback = CallbackUtil.callback(messageBody); |
| | | System.err.println("证联通知回调:" + callback); |
| | | log.info("证联通知回调:" + callback); |
| | | } |
| | | } |