From ed02b20b31e013159c55ab14b81772e41b36649c Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期六, 26 七月 2025 17:37:59 +0800
Subject: [PATCH] 修改下单逻辑和抢单等相关逻辑

---
 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java |  114 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 59 insertions(+), 55 deletions(-)

diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java
index bad9032..de9e68d 100644
--- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java
+++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java
@@ -6,7 +6,6 @@
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.alipay.api.internal.util.file.IOUtils;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.stylefeng.guns.config.properties.GunsProperties;
@@ -22,7 +21,6 @@
 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.ALiSendSms;
 import com.stylefeng.guns.modular.system.util.ResultUtil;
 import com.stylefeng.guns.modular.system.util.WeChatUtil;
 import com.stylefeng.guns.modular.system.util.qianyuntong.NCOSSUtil;
@@ -38,7 +36,9 @@
 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.*;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.bind.annotation.*;
@@ -46,7 +46,6 @@
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -57,8 +56,6 @@
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
-
-import static org.bouncycastle.cms.RecipientId.password;
 
 /**
  * 司机控制器
@@ -531,7 +528,7 @@
     }
 
 
-    @ApiOperation(value = "个人的小程序码(分享码)生成", tags = {"司机端-首页"}, notes = "")
+    @ApiOperation(value = "个人的小程序码(分享码)/链接", tags = {"司机端-首页"}, notes = "")
     @GetMapping("/api/driver/person-code")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@@ -544,48 +541,66 @@
             if (null == uid) {
                 return ResultUtil.tokenErr();
             }
+            Driver driver = driverService.selectById(uid);
+            String accessToken=null;
             // 获取调用凭证accessToken
-            String accessToken = getAccessToken();
-            RestTemplate rest = new RestTemplate();
+            if(ToolUtil.isEmpty(driver.getShareImg())|| ToolUtil.isEmpty(driver.getShareImg())){
+                accessToken = getAccessToken();
+            }
+            String img=driver.getShareImg();
+            int index=0;
 
-            String imgUrl = "";
-            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); //二维码尺寸
-            MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
-            HttpEntity requestEntity = new HttpEntity(param, headers);
-            ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
-            byte[] result = entity.getBody();
-            inputStream = new ByteArrayInputStream(result);
+            if(ToolUtil.isEmpty(driver.getShareImg())) {
+                index=1;
+                RestTemplate rest = new RestTemplate();
+                String imgUrl = "";
+                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); //二维码尺寸
+                MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
+                HttpEntity requestEntity = new HttpEntity(param, headers);
+                ResponseEntity<byte[]> entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]);
+                byte[] result = entity.getBody();
+                inputStream = new ByteArrayInputStream(result);
 
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-            // 最后上传生成的文件名
-            String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg";
-            // oss中的文件夹名
-            String objectName = sdf.format(new Date()) + "/" + finalFileName;
-            String key = "imgs/management/" + objectName;
-            String object = NCOSSUtil.putObject( qianYunTongConfig.getBucketName(), key, inputStream);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+                // 最后上传生成的文件名
+                String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg";
+                // oss中的文件夹名
+                String objectName = sdf.format(new Date()) + "/" + finalFileName;
+                String key = "imgs/management/" + objectName;
+                String object = NCOSSUtil.putObject(qianYunTongConfig.getBucketName(), key, inputStream);
+                System.out.println(object);
+                driver.setShareImg(object);
+                img= object;
+            }
 
-            System.out.println(object);
+            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);
 
-            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);
+            }
 
-            HttpRequest post = HttpUtil.createPost(url1);
-            // map转json
-            String jsonString = JSON.toJSONString(param1);
-            post.body(jsonString);
-            HttpResponse execute = post.execute();
-            String body = execute.body();
-            String urlLink = JSONObject.parseObject(body).get("url_link").toString();
-
+            if(index==1){
+                driverService.updateById(driver);
+            }
 
             HashMap<String, String> stringStringHashMap = new HashMap<>();
             stringStringHashMap.put("url_link",urlLink);
-            stringStringHashMap.put("img",object);
+            stringStringHashMap.put("img",img);
 
 
 //            inputStream = new ByteArrayInputStream(result);
@@ -992,17 +1007,18 @@
      */
     @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();
@@ -1826,18 +1842,6 @@
         }
     }
     
-    
-    @ResponseBody
-    @GetMapping("/base/driver/getDriverInfo")
-    public void getDriverInfo(String lsu, String ssologinid, String ticket, HttpSession session) {
-        try {
-            String onconParam = edu.yale.its.tp.cas.client.Util.getOnconParam(session);
-            onconParam = new String(Base64.getDecoder().decode(onconParam), "UTF-8");
-            System.err.println("lsu: " + lsu + ",ticket: " + ticket + ",ssologinid: " + ssologinid);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
 
 
 //    @ResponseBody

--
Gitblit v1.7.1