From 362b69712b793217d0d50e48792be6db3e1bd041 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 05 八月 2025 13:57:03 +0800 Subject: [PATCH] 修改bug --- DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java | 95 +++++++-------- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java | 5 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianConfig.java | 6 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java | 34 +++++ DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/Driver.java | 33 +++++ DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianUtil.java | 93 +++++++++++++++ DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/model/ZLUserInfo.java | 37 ++++++ 7 files changed, 253 insertions(+), 50 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/Driver.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/Driver.java index f3e772c..6882b6a 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/Driver.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/Driver.java @@ -390,6 +390,15 @@ @ApiModelProperty("分享链接") private String shareLink; + + @ApiModelProperty("证联客户号") + private String custId; + + @ApiModelProperty("是否已开通支付账户(0:否,1:是)") + private Integer accOpenFlag; + + @ApiModelProperty("是否已同步到中台(0:否,1:是)") + private Integer isSynchronous; public String getShareImg() { return shareImg; @@ -1009,6 +1018,30 @@ this.entercode = entercode; } + public String getCustId() { + return custId; + } + + public void setCustId(String custId) { + this.custId = custId; + } + + public Integer getAccOpenFlag() { + return accOpenFlag; + } + + public void setAccOpenFlag(Integer accOpenFlag) { + this.accOpenFlag = accOpenFlag; + } + + public Integer getIsSynchronous() { + return isSynchronous; + } + + public void setIsSynchronous(Integer isSynchronous) { + this.isSynchronous = isSynchronous; + } + @Override public String toString() { return "Driver{" + diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java index 83b5f5e..0aceb7e 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java @@ -21,8 +21,13 @@ import com.stylefeng.guns.modular.system.model.OrderPosition; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.*; +import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil; import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.AddAccountInfoRequest; import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyTravelItineraryRequest; +import com.stylefeng.guns.modular.system.util.zhenglian.ZhengLianUtil; +import com.stylefeng.guns.modular.system.util.zhenglian.model.TradeTerminalInfo; +import com.stylefeng.guns.modular.system.util.zhenglian.model.ZLUserInfo; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.OrderListWarpper; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; @@ -119,6 +124,35 @@ */ @Override public List<Map<String, Object>> queryOrderList(Integer state, Integer pageNum, Integer size, Integer uid) throws Exception { + Driver driver = driverService.selectById(uid); + //获取证联数据 + if(null == driver.getCustId() || 0 == driver.getAccOpenFlag()){ + TradeTerminalInfo tradeTerminalInfo = new TradeTerminalInfo(); + tradeTerminalInfo.setIp("127.0.0.1"); + tradeTerminalInfo.setTerminal("1"); + tradeTerminalInfo.setMac(""); + ZLUserInfo userInfo = ZhengLianUtil.getUserInfo(driver.getEmpId().toString(), tradeTerminalInfo); + if(null != userInfo){ + driver.setCustId(userInfo.getCustId()); + driver.setAccOpenFlag(userInfo.getAccOpenFlag()); + driverService.updateById(driver); + } + } + //同步到中台 + if(null != driver.getAccOpenFlag() && 1 == driver.getAccOpenFlag() && 0 == driver.getIsSynchronous()){ + AddAccountInfoRequest request = new AddAccountInfoRequest(); + request.setCustId(driver.getCustId()); + request.setAccountNo(driver.getEmpId().toString()); + request.setAccountName(driver.getName()); + request.setMobile(driver.getPhone()); + Integer status = EmployeeUtil.addAccountInfo(request); + if(0 == status){ + driver.setIsSynchronous(1); + driverService.updateById(driver); + } + } + + Integer page = pageNum; pageNum = (pageNum - 1) * size; List<Map<String, Object>> datas = new ArrayList<>(); diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java index 1402758..7cf16e1 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java @@ -212,6 +212,11 @@ * @return 状态 0 成功 其他失败 */ public static Integer addAccountInfo(AddAccountInfoRequest request){ + request.setPartnerId("522700"); + request.setIndustryCode("100"); + request.setPayModeId("501101"); + request.setAccessMode("APP"); + //请求路径 String url = QianYunTongProperties.apiUrl + "/openapi/rest/1.0/addAccountInfo"; //私钥文件 diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianConfig.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianConfig.java index 002db53..af07db3 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianConfig.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianConfig.java @@ -58,8 +58,10 @@ this.merchNo = "B00000871"; this.encrpNo = "1055490595"; this.signNo = "1066348524"; - this.cer = "C:\\Users\\Administrator\\Desktop\\1055490595.cer"; - this.sm2 = "C:\\Users\\Administrator\\Desktop\\871_111111.sm2"; + this.cer = "C:\\Users\\39373\\Desktop\\黔云通\\UAT-demo-公用\\1055490595.cer"; + this.sm2 = "C:\\Users\\39373\\Desktop\\黔云通\\UAT-demo-公用\\871_111111.sm2"; +// this.cer = "C:\\Users\\Administrator\\Desktop\\1055490595.cer"; +// this.sm2 = "C:\\Users\\Administrator\\Desktop\\871_111111.sm2"; this.password = "111111"; } if("test".equals(activeProfile)){ diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianUtil.java index b6d723e..7789cd7 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianUtil.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/ZhengLianUtil.java @@ -1,7 +1,15 @@ package com.stylefeng.guns.modular.system.util.zhenglian; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.stylefeng.guns.modular.system.util.SpringContextsUtil; +import com.stylefeng.guns.modular.system.util.UUIDUtil; +import com.stylefeng.guns.modular.system.util.zhenglian.model.MessageBody; +import com.stylefeng.guns.modular.system.util.zhenglian.model.TradeTerminalInfo; +import com.stylefeng.guns.modular.system.util.zhenglian.model.ZLUserInfo; +import com.zlpay.assist.encrypt.sm4.SM4Util; import com.zlpay.assist.sign.sm2.SM2Cert; +import com.zlpay.assist.sign.sm2.SM2Util; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.RandomStringUtils; @@ -9,7 +17,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.security.cert.X509Certificate; +import java.text.SimpleDateFormat; import java.util.Base64; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * @author zhibing.pu @@ -20,6 +32,87 @@ private static ZhengLianConfig zhengLianConfig = SpringContextsUtil.getBean(ZhengLianConfig.class).getZhengLianConfig(); + + + + + /** + * 获取用户详情 + * @param appUserId + * @param tradeTerminalInfo + * @return + * @throws Exception + */ + public static ZLUserInfo getUserInfo(String appUserId, TradeTerminalInfo tradeTerminalInfo) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + Map<String,String> headerMap = new HashMap<String,String>(); + MessageBody body = new MessageBody(); + headerMap.put("msgId", UUIDUtil.getRandomCode()); + headerMap.put("merchNo", "B00000871"); + headerMap.put("txCode", "ZLPAY.ACC.T0009"); + headerMap.put("version", "1.0.1"); + headerMap.put("signa", "1"); + headerMap.put("signNo", zhengLianConfig.getSignNo()); + headerMap.put("encrp", "1"); + headerMap.put("encrpNo", zhengLianConfig.getEncrpNo()); + headerMap.put("timestamp", sdf.format(new Date())); + + Map<String, Object> map = new HashMap<>(); + map.put("appId", zhengLianConfig.getAppid()); + map.put("appUserId", appUserId); + map.put("tradeTerminalInfo", tradeTerminalInfo); + String reqBO = JSON.toJSONString(map); + // 生成对称加密秘钥 + String key = ZhengLianUtil.generateKey(16); + // 加密数据 + String jsonData = SM4Util.sm4EcbEncrypt(key, reqBO, "NoPadding"); + //加密对称加密的秘钥 + // 获取公钥 + String publicKey = ZhengLianUtil.getPublicKey(); + String secrtKey = SM2Util.encrypt(publicKey, key); + + // 将密文放入body + body.setData(jsonData); + body.setSign(ZhengLianUtil.sign(jsonData)); + body.setSecret(secrtKey); + String result = ZLHttpClientUtil.doPost(zhengLianConfig.getUrl(), headerMap, JSON.toJSONString(body)); + + System.out.println("应答内容:"+ result); + MessageBody respBody = JSON.parseObject(result,MessageBody.class); + // 验签 + boolean checkResult = SM2Util.verify(publicKey, zhengLianConfig.getEncrpNo(), respBody.getSign(), respBody.getData()); + System.out.println("验签结果:" + checkResult); + // 获取私钥 + String privateKey = ZhengLianUtil.getPrivateKey(); + // 解密对称秘钥 + String k = SM2Util.decrypt(privateKey, respBody.getSecret()); + System.out.println("对称秘钥:" + k); + // 解密业务报文 + String backData = SM4Util.sm4EcbDecrypt(k, respBody.getData()); + System.out.println("返回业务报文:" + backData); + JSONObject jsonObject = JSON.parseObject(backData); + String sysRtnCode = jsonObject.getString("sysRtnCode"); + if(!"000000".equals(sysRtnCode)){ + log.error("查询用户信息失败!{}", jsonObject.getString("sysRtnMsg")); + throw new Exception(jsonObject.getString("sysRtnMsg")); + } + JSONObject bizData = jsonObject.getJSONObject("bizData"); + String resCode = bizData.getString("resCode"); + if(!"S010000".equals(resCode)){ + log.error("查询用户信息失败!{}", bizData.getString("resMsg")); + throw new Exception(jsonObject.getString("resMsg")); + } + JSONObject resData = bizData.getJSONObject("resData"); + ZLUserInfo zlUserInfo = resData.toJavaObject(ZLUserInfo.class); + return zlUserInfo; + } + + + + + + + /** * @Description: 从公钥证书获取公钥串 * @return diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/model/ZLUserInfo.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/model/ZLUserInfo.java new file mode 100644 index 0000000..b17f4a4 --- /dev/null +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/zhenglian/model/ZLUserInfo.java @@ -0,0 +1,37 @@ +package com.stylefeng.guns.modular.system.util.zhenglian.model; + +import lombok.Data; + +/** + * @author zhibing.pu + * @Date 2025/8/5 10:10 + */ +@Data +public class ZLUserInfo { + /** + * appid + */ + private String appId; + /** + * APP端用户唯一标识 + */ + private String appUserId; + /** + * 姓名 + */ + private String userName; + /** + * 证件号码 + */ + private String certNo; + /** + * 证联客户号 + */ + private String custId; + /** + * 是否已开通支付账户 + * 1:是 + * 0:否 + */ + private Integer accOpenFlag; +} diff --git a/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java b/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java index 66223bd..9d80039 100644 --- a/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java +++ b/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java @@ -1,48 +1,47 @@ -//package com.stylefeng.guns; -// -//import com.stylefeng.guns.modular.system.model.Driver; -//import com.stylefeng.guns.modular.system.service.IDriverService; -//import com.stylefeng.guns.modular.system.util.zhenglian.TokenUtil; -//import com.stylefeng.guns.modular.system.util.zhenglian.model.TokenRequest; -//import com.stylefeng.guns.modular.system.util.zhenglian.model.TradeTerminalInfo; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.data.mongodb.core.MongoTemplate; -//import org.springframework.test.context.junit4.SpringRunner; -// -//@RunWith(SpringRunner.class) -//@SpringBootTest -//public class GunsApplicationTest { -// -// @Autowired -// private MongoTemplate mongoTemplate; -// @Autowired -// private IDriverService driverService; -// -// -// @Test -// public void test() { -// -// 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("127.0.0.1"); -// tradeTerminalInfo.setTerminal("1"); -// tradeTerminalInfo.setMac(""); -// tokenRequest.setTradeTerminalInfo(tradeTerminalInfo); -// tokenRequest.setType(type); -// String token = null; -// try { -// token = TokenUtil.getToken(tokenRequest); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// System.err.println(token); -// } -//} +package com.stylefeng.guns; + +import com.stylefeng.guns.modular.system.model.Driver; +import com.stylefeng.guns.modular.system.service.IDriverService; +import com.stylefeng.guns.modular.system.util.zhenglian.ZhengLianUtil; +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.util.zhenglian.model.ZLUserInfo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class GunsApplicationTest { + + @Autowired + private MongoTemplate mongoTemplate; + @Autowired + private IDriverService driverService; + + + @Test + public void test() { + + Driver driver = driverService.selectById(14); + 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("127.0.0.1"); + tradeTerminalInfo.setTerminal("1"); + tradeTerminalInfo.setMac(""); + ZLUserInfo userInfo = null; + try { + userInfo = ZhengLianUtil.getUserInfo("11448158", tradeTerminalInfo); + } catch (Exception e) { + throw new RuntimeException(e); + } + System.err.println(userInfo); + } +} -- Gitblit v1.7.1