2 Commits c7b3e5e3d1 ... e909761243

Author SHA1 Message Date
  wangyuanbo e909761243 Merge branch 'master' of http://106.14.142.95:3000/wangyuanbo/bt 2 years ago
  wangyuanbo 83909f7d81 修改微信支付相关逻辑 2 years ago

+ 3 - 0
imcs-bt-be/imcs-authority-biz/src/main/java/com/github/zuihou/authority/event/listener/LoginListener.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.authority.event.listener;
 
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.github.zuihou.authority.event.LoginEvent;
 import com.github.zuihou.authority.event.model.LoginStatusDTO;
 import com.github.zuihou.authority.service.auth.UserService;
@@ -32,7 +33,9 @@ public class LoginListener {
     @Async
     @EventListener({LoginEvent.class})
     public void saveSysLog(LoginEvent event) {
+        System.out.println("saveSysLog方法中loginEvent==="+ JSON.toJSONString(event));
         LoginStatusDTO loginStatus = (LoginStatusDTO) event.getSource();
+        System.out.println("saveSysLog方法中LoginStatusDTO==="+ JSON.toJSONString(loginStatus));
 
         if (StrUtil.isEmpty(loginStatus.getTenant())) {
             log.warn("忽略记录登录日志:{}", loginStatus);

+ 23 - 1
imcs-bt-be/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/common/impl/LoginLogServiceImpl.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.authority.service.common.impl;
 
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.github.zuihou.authority.dao.common.LoginLogMapper;
 import com.github.zuihou.authority.entity.auth.User;
 import com.github.zuihou.authority.entity.common.LoginLog;
@@ -75,16 +76,37 @@ public class LoginLogServiceImpl extends SuperServiceImpl<LoginLogMapper, LoginL
         }
 
         UserAgent userAgent = UserAgent.parseUserAgentString(ua);
+        System.out.println("UserAgent userAgent = UserAgent.parseUserAgentString(ua)===" + JSON.toJSONString(userAgent));
         Browser browser = userAgent.getBrowser();
+        System.out.println("获取到的浏览器==" + JSON.toJSONString(browser));
         OperatingSystem operatingSystem = userAgent.getOperatingSystem();
+//        LoginLog loginLog = LoginLog.builder()
+//                .location(location)
+//                .loginDate(LocalDate.now())
+//                .description(description)
+//                .requestIp(ip).ua(ua)
+//                .browser(simplifyBrowser(browser.getName())).browserVersion(userAgent.getBrowserVersion().getVersion())
+//                .operatingSystem(simplifyOperatingSystem(operatingSystem.getName()))
+//                .build();
+
         LoginLog loginLog = LoginLog.builder()
                 .location(location)
                 .loginDate(LocalDate.now())
                 .description(description)
                 .requestIp(ip).ua(ua)
-                .browser(simplifyBrowser(browser.getName())).browserVersion(userAgent.getBrowserVersion().getVersion())
                 .operatingSystem(simplifyOperatingSystem(operatingSystem.getName()))
                 .build();
+        if (browser != Browser.UNKNOWN) {
+            loginLog.setBrowser(browser.getName());
+        }
+        if (userAgent != null&&userAgent.getBrowserVersion()!=null) {
+            loginLog.setBrowserVersion(userAgent.getBrowserVersion().getVersion());
+        }
+        if (operatingSystem != null) {
+            loginLog.setOperatingSystem(simplifyOperatingSystem(operatingSystem.getName()));
+        }
+
+
         if (user != null) {
             loginLog.setAccount(user.getAccount()).setUserId(user.getId()).setUserName(user.getName())
                     .setCreateUser(user.getId());

+ 104 - 20
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/AndroidApi.java

@@ -48,6 +48,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import static com.github.zuihou.exception.code.ExceptionCode.SYSTEM_BUSY;
+
 /**
  * @author User
  */
@@ -92,12 +94,22 @@ public class AndroidApi {
     public R<List<EquGoodsDto>> goodsList(@RequestParam(name = "equId", required = true) Long equId) {
         BaseContextHandler.setTenant("0000");
         List<EquGoodsDto> equGoods = productionTenantResourceService.getEquGoods(equId);
+        QueryWrap<EquBarrel> barrelQueryWrap = new QueryWrap<>();
+//        barrelQueryWrap.eq("")
+//        barrelService.list()
         equGoods.forEach((item) ->
                 {
                     QueryWrap<Spe> speQueryWrap = new QueryWrap<>();
                     speQueryWrap.eq("goods_id", item.getGoodsId());
                     List<Spe> list = speService.list(speQueryWrap);
                     item.setSpeList(list);
+//                    判断是否缺料
+
+//                    list.forEach(spe -> {
+//                        QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
+//                        formulaQueryWrap.eq("formula_spe_id",spe.getId());
+//                        List<Formula> formulaList = formulaService.list(formulaQueryWrap);
+//                    });
                 }
         );
         return R.success(equGoods);
@@ -166,30 +178,96 @@ public class AndroidApi {
 
 //    订单查询接口
 
+//    @ApiOperation("订单状态查询接口")
+//    @GetMapping({"/getOrder"})
+//    public R<Map<String, Object>> getOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
+//        BaseContextHandler.setTenant("0000");
+//        HashMap<String, Object> resultMap = new HashMap<>();
+//
+//        String status = null;
+//        try {
+//            System.out.println("订单状态查询接口入参out_trade_no==" + orderId + "");
+//            status = wxPayService.wxQueryOrder(orderId + "");
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            return R.fail(e);
+//        }
+//
+//        if (status.equals("NOTPAY")) {
+////未支付
+//            resultMap.put("orderStatus", "0");
+//            return R.success(resultMap);
+//        } else if (status.equals("SUCCESS")) {
+////支付成功
+//            Order order = orderService.getById(orderId);
+//            Long equId = order.getOrderEquId();
+//            QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
+//            formulaQueryWrap.eq("formula_spe_id", order.getOrderSpecs());
+//            List<Formula> formulaList = formulaService.list(formulaQueryWrap);
+//            formulaList.forEach(item -> {
+//                QueryWrap<EquBarrel> barrelQueryWrap = new QueryWrap<>();
+//                barrelQueryWrap.eq("mtr_id", item.getFormulaMtId());
+//                barrelQueryWrap.eq("equ_id", equId);
+//
+//                List<EquBarrel> list = barrelService.list(barrelQueryWrap);
+//                if (null != list) {
+//                    item.setBarrelCode(list.get(0).getBarrelCode());
+//                }
+//            });
+//            resultMap.put("productConfig", formulaList);
+//            resultMap.put("orderStatus", "1");
+//            return R.success(resultMap);
+//        } else if (status.equals("REFUND")) {
+////转入退款
+//            resultMap.put("orderStatus", "5");
+//            return R.success(resultMap);
+//        } else if (status.equals("CLOSED")) {
+////已关闭
+//            resultMap.put("orderStatus", "2");
+//            return R.success(resultMap);
+//        }
+//
+//        resultMap.put("orderStatus", "0");
+//
+//        return R.success(resultMap);
+//    }
+
+
     @ApiOperation("订单状态查询接口")
     @GetMapping({"/getOrder"})
     public R<Map<String, Object>> getOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
         BaseContextHandler.setTenant("0000");
         HashMap<String, Object> resultMap = new HashMap<>();
 
-        String status = null;
+        System.out.println("订单状态查询接口入参out_trade_no==" + orderId + "");
+        Map<String, String> returnMap = new HashMap<>();
+
         try {
-            status = wxPayService.wxQueryOrder(orderId + "");
+            returnMap = wxPayService.wxQueryOrder(orderId + "");
         } catch (Exception e) {
-            e.printStackTrace();
-            return R.fail(e);
+            return R.fail(SYSTEM_BUSY);
+        }
+        if (returnMap.get("errCode") != null) {
+            return R.fail(returnMap.get("message"));
         }
 
-        if (status.equals("NOTPAY")) {
+        String wxStatus = returnMap.get("tradeState");
+
+        System.out.println("微信返回的订单状态:" + wxStatus);
+
+        Order localOrder = orderService.getById(orderId);
+        String localStatus = localOrder.getOrderStatus();
+        String newStatus = "";
+
+        if (wxStatus.equals("NOTPAY")) {
 //未支付
-            resultMap.put("orderStatus", "0");
-            return R.success(resultMap);
-        } else if (status.equals("SUCCESS")) {
+            newStatus = "0";
+        } else if (wxStatus.equals("SUCCESS")) {
 //支付成功
-            Order order = orderService.getById(orderId);
-            Long equId = order.getOrderEquId();
+            newStatus = "1";
+            Long equId = localOrder.getOrderEquId();
             QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
-            formulaQueryWrap.eq("formula_spe_id", order.getOrderSpecs());
+            formulaQueryWrap.eq("formula_spe_id", localOrder.getOrderSpecs());
             List<Formula> formulaList = formulaService.list(formulaQueryWrap);
             formulaList.forEach(item -> {
                 QueryWrap<EquBarrel> barrelQueryWrap = new QueryWrap<>();
@@ -202,20 +280,25 @@ public class AndroidApi {
                 }
             });
             resultMap.put("productConfig", formulaList);
-            resultMap.put("orderStatus", "1");
-            return R.success(resultMap);
-        } else if (status.equals("REFUND")) {
+        } else if (wxStatus.equals("REFUND")) {
 //转入退款
-            resultMap.put("orderStatus", "5");
-            return R.success(resultMap);
-        } else if (status.equals("CLOSED")) {
+            newStatus = "5";
+        } else if (wxStatus.equals("CLOSED")) {
 //已关闭
-            resultMap.put("orderStatus", "2");
-            return R.success(resultMap);
+            newStatus = "2";
+        } else {
+            newStatus = wxStatus;
         }
 
-        resultMap.put("orderStatus", "0");
 
+        resultMap.put("orderStatus", newStatus);
+//       更新本地订单状态
+        if (newStatus != localStatus) {
+            UpdateWrapper<Order> orderUpdateWrapper = new UpdateWrapper<>();
+            orderUpdateWrapper.set("order_status", newStatus).eq("id", orderId);
+            orderService.update(orderUpdateWrapper);
+
+        }
         return R.success(resultMap);
     }
 
@@ -378,6 +461,7 @@ public class AndroidApi {
 //        安卓端超时后取消订单
         if (orderStatus == "2") {
             //调用微信支付api,关闭订单
+            System.out.println("安卓超时取消订单,订单号:" + orderId);
             int i = wxPayService.wxCloseOrder(orderId);
             if (i == 204) {
 //                订单关闭成功,修改本地订单状态

+ 121 - 10
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/MiniApp.java

@@ -34,6 +34,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static com.github.zuihou.exception.code.ExceptionCode.SYSTEM_BUSY;
+
 /**
  * @author User
  */
@@ -51,14 +53,118 @@ public class MiniApp {
     private WxPayCfg wxPayCfg;
     @Autowired
     private WxPayService wxPayService;
-
-    //    @Autowired
-//    private ProductionresourceService productionresourceService;
     @Autowired
     ProductionTenantResourceService productionTenantResourceService;
 
 
-    //关联本地订单号和openId并且调用微信统一下单接口接口
+    /**
+     * 关联本地订单号和openId并且调用微信统一下单接口接口
+     *
+     * @param param
+     * @return
+     * @throws Exception
+     */
+//    @ApiOperation("微信统一下单接口")
+//    @PostMapping({"/relatUserAndOrder"})
+//    public R<Map<String, String>> relatUserAndOrder(@RequestBody Map<String, String> param) throws Exception {
+//        BaseContextHandler.setTenant("0000");
+//        String openId = (String) BaseContextHandler.get("openId");
+//
+//        String orderId = param.get("orderId");
+//
+//        QueryWrap<Member> memberQueryWrap = new QueryWrap<>();
+//        memberQueryWrap.eq("member_openId", openId);
+//
+//        Member member = memberService.getOne(memberQueryWrap);
+//
+//        Order localOrder = orderService.getById(orderId);
+//        localOrder.setOrderMemberId(member.getId());
+//
+//        BigDecimal orderAmount = localOrder.getOrderAmount();
+//
+//        int fenAmount = orderAmount.movePointRight(2).intValue();
+//
+//
+//        String speId = localOrder.getOrderSpecs() + "";
+//        Map<String, String> goodsMap = speService.getGoods(speId);
+//        String goodsName = goodsMap.get("goodsName");
+//        String speName = goodsMap.get("speName");
+//        String goodsPic = goodsMap.get("goodsPic");
+//
+//        UnifiedorderDto unifiedorderDto = new UnifiedorderDto();
+//
+//        unifiedorderDto.setAppid(wxPayCfg.getAppId());
+//        AmountDto amountDto = new AmountDto();
+//        amountDto.setTotal(fenAmount);
+//        amountDto.setCurrency("CNY");
+//        unifiedorderDto.setAmount(amountDto);
+//        unifiedorderDto.setDescription(goodsName + speName);
+//        unifiedorderDto.setMchid(wxPayCfg.getMchId());
+//        PayerDto payer = new PayerDto();
+//        payer.setOpenid(openId);
+//        unifiedorderDto.setPayer(payer);
+//        unifiedorderDto.setOut_trade_no(orderId);
+//        unifiedorderDto.setNotify_url(wxPayCfg.getPaymentNotify());
+//
+//        LocalDateTime createTime = localOrder.getCreateTime();
+//        LocalDateTime expireTime = createTime.plusSeconds(59);
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss+08:00").withZone(ZoneId.of("Asia/Shanghai"));
+//        ;
+//        String strET = expireTime.format(formatter);
+//        unifiedorderDto.setTime_expire(strET);
+//
+//
+//        String prepayId = null;
+//        try {
+//
+//            prepayId = wxPayService.wxUnifiedorder(unifiedorderDto);
+//        } catch (Exception e) {
+//
+//            e.printStackTrace();
+//            return R.fail(e);
+//        }
+//        String signType = "RSA";
+//        String nonceStr = WXPayUtil.generateNonceStr();
+//        String timeStamp = System.currentTimeMillis() / 1000 + "";
+//        String appId = wxPayCfg.getAppId();
+//
+//        StringBuilder stringBuilder = new StringBuilder();
+//
+//        stringBuilder.append(appId).append("\n");
+//        stringBuilder.append(timeStamp).append("\n");
+//        stringBuilder.append(nonceStr).append("\n");
+//        stringBuilder.append("prepay_id=" + prepayId).append("\n");
+//        String data = stringBuilder.toString();
+//
+//
+//        Verifier verifier = WxPayUtil.getVerifier(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key());
+//
+//        X509Certificate validCertificate = verifier.getValidCertificate();
+//
+//        String paySign = WxPayUtil.getSign(data, wxPayCfg.getPrivateKeyPath());
+//
+//        HashMap<String, String> returnMap = new HashMap<>();
+//        returnMap.put("appId", appId);
+//        returnMap.put("timeStamp", timeStamp);
+//        returnMap.put("nonceStr", nonceStr);
+//        returnMap.put("package", "prepay_id=" + prepayId);
+//        returnMap.put("signType", signType);
+//        returnMap.put("paySign", paySign);
+//        returnMap.put("prepayId", prepayId);
+//        returnMap.put("goodsName", goodsName);
+//        returnMap.put("speName", speName);
+//        returnMap.put("goodsPic", goodsPic);
+//        returnMap.put("orderAmount", orderAmount.toString());
+//
+//        localOrder.setOrderPrepayId(prepayId);
+//        localOrder.setOrderUnitPrice(orderAmount);
+//        localOrder.setOrderGoodsAmount(1);
+//        boolean b = orderService.updateById(localOrder);
+//
+//
+//        return R.success(returnMap);
+//
+//    }
     @ApiOperation("微信统一下单接口")
     @PostMapping({"/relatUserAndOrder"})
     public R<Map<String, String>> relatUserAndOrder(@RequestBody Map<String, String> param) throws Exception {
@@ -103,20 +209,25 @@ public class MiniApp {
 
         LocalDateTime createTime = localOrder.getCreateTime();
         LocalDateTime expireTime = createTime.plusSeconds(59);
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss+08:00").withZone(ZoneId.of("Asia/Shanghai"));;
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss+08:00").withZone(ZoneId.of("Asia/Shanghai"));
+        ;
         String strET = expireTime.format(formatter);
         unifiedorderDto.setTime_expire(strET);
 
 
-        String prepayId = null;
+        Map<String, String> resultMap = null;
         try {
-
-            prepayId = wxPayService.wxUnifiedorder(unifiedorderDto);
+            resultMap = wxPayService.wxUnifiedorder(unifiedorderDto);
         } catch (Exception e) {
-
             e.printStackTrace();
-            return R.fail(e);
+            return R.fail(SYSTEM_BUSY);
+        }
+
+
+        if (resultMap.get("errCode") != null) {
+            return R.fail(resultMap.get("errCode"), resultMap.get("message"));
         }
+        String prepayId = resultMap.get("prepayId");
         String signType = "RSA";
         String nonceStr = WXPayUtil.generateNonceStr();
         String timeStamp = System.currentTimeMillis() / 1000 + "";

+ 1 - 1
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -29,7 +29,6 @@ import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.utils.DateUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
@@ -314,6 +313,7 @@ public class OpsAppApi {
         if (bool) {
             bool = equRecordService.save(equRecord);
         }
+
         return R.success(bool);
     }
 

+ 107 - 45
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/service/WxPayService.java

@@ -9,13 +9,14 @@ import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.io.IOException;
 import java.nio.charset.Charset;
 import java.util.HashMap;
+import java.util.Map;
 
 import static org.apache.http.HttpHeaders.ACCEPT;
 import static org.apache.http.entity.ContentType.APPLICATION_JSON;
@@ -29,8 +30,42 @@ public class WxPayService {
     private WxPayCfg wxPayCfg;
 
     //    调用微信统一下单接口
-    public String wxUnifiedorder(UnifiedorderDto unifiedorderDto) throws Exception {
-        System.out.println("微信统一下单接口入参,外部订单号="+unifiedorderDto.getOut_trade_no());
+//    public String wxUnifiedorder(UnifiedorderDto unifiedorderDto) throws Exception {
+//        System.out.println("微信统一下单接口入参,外部订单号=" + unifiedorderDto.getOut_trade_no());
+//        HttpPost httpPost = new HttpPost(wxPayCfg.getWxUnifiedorder());
+//        Object o = JSONArray.toJSON(unifiedorderDto);
+//        String reqData = o.toString();
+//        StringEntity entity = new StringEntity(reqData, Charset.forName("UTF-8"));
+//        entity.setContentType("application/json");
+//        httpPost.setEntity(entity);
+//        httpPost.addHeader("Accept", "application/json");
+//        httpPost.addHeader("Content-type", "application/json; charset=utf-8");
+//        CloseableHttpResponse response = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key()).execute(httpPost);
+//
+//        try {
+//            int statusCode = response.getStatusLine().getStatusCode();
+//            if (statusCode == 200) {
+//                String s = EntityUtils.toString(response.getEntity());
+//                JSONObject jsonObject = JSONObject.parseObject(s);
+//                String prepayId = jsonObject.getString("prepay_id");
+//
+//                return prepayId;
+//            } else if (statusCode == 204) {
+//
+//            } else {
+//                String msg = EntityUtils.toString(response.getEntity());
+//                System.out.println("微信统一下单返回异常,body=" + msg);
+//                throw new IOException(msg);
+//            }
+//        } finally {
+//            response.close();
+//        }
+//
+//        return "";
+//    }
+
+    public Map<String, String> wxUnifiedorder(UnifiedorderDto unifiedorderDto) throws Exception {
+        System.out.println("微信统一下单接口入参,外部订单号=" + unifiedorderDto.getOut_trade_no());
         HttpPost httpPost = new HttpPost(wxPayCfg.getWxUnifiedorder());
         Object o = JSONArray.toJSON(unifiedorderDto);
         String reqData = o.toString();
@@ -39,30 +74,33 @@ public class WxPayService {
         httpPost.setEntity(entity);
         httpPost.addHeader("Accept", "application/json");
         httpPost.addHeader("Content-type", "application/json; charset=utf-8");
+
+
         CloseableHttpResponse response = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key()).execute(httpPost);
 
-        try {
-            int statusCode = response.getStatusLine().getStatusCode();
-            if (statusCode == 200) {
-                String s = EntityUtils.toString(response.getEntity());
-                JSONObject jsonObject = JSONObject.parseObject(s);
-                String prepayId = jsonObject.getString("prepay_id");
-
-                return prepayId;
-            } else if (statusCode == 204) {
-
-            } else {
-                String msg = EntityUtils.toString(response.getEntity());
-                System.out.println("微信统一下单返回异常,body="+msg);
-                throw new IOException(msg);
-            }
-        } finally {
-            response.close();
+
+        int statusCode = response.getStatusLine().getStatusCode();
+
+        String res = EntityUtils.toString(response.getEntity());
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        HashMap<String, String> resultMap = new HashMap<>();
+
+        if (statusCode != 200) {
+            String errCode = jsonObject.getString("code");
+            String message = jsonObject.getString("message");
+            resultMap.put("errCode", errCode);
+            resultMap.put("message", message);
+            return resultMap;
+
         }
 
-        return "";
+        String prepayId = jsonObject.getString("prepay_id");
+        resultMap.put("prepayId", prepayId);
+        return resultMap;
+
     }
 
+
     /**
      * 调用关闭订单接口
      *
@@ -90,7 +128,6 @@ public class WxPayService {
         CloseableHttpResponse response = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key()).execute(httpPost);
 
 
-
         try {
             //响应码
             statusCode = response.getStatusLine().getStatusCode();
@@ -115,35 +152,60 @@ public class WxPayService {
      * @return
      * @throws Exception
      */
-    public String wxQueryOrder(String out_trade_no) throws Exception {
+//    public String wxQueryOrder(String out_trade_no) throws Exception {
+//        String mchId = wxPayCfg.getMchId();
+//        String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + out_trade_no + "?mchid=" + mchId;
+//        System.out.println("订单查询接口url==="+url);
+//        HashMap<String, String> resultMap = new HashMap<>();
+//        HttpGet httpGet = new HttpGet(url);
+//        httpGet.addHeader(ACCEPT, APPLICATION_JSON.toString());
+//        CloseableHttpResponse response = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key()).execute(httpGet);
+//
+//        try {
+//            int statusCode = response.getStatusLine().getStatusCode();
+//            if (statusCode == 200) {
+//                String s = EntityUtils.toString(response.getEntity());
+//                JSONObject jsonObject = JSONObject.parseObject(s);
+//                String tradeState = jsonObject.getString("trade_state");
+//                resultMap.put("code", "0");
+//                resultMap.put("code", "ok");
+//                resultMap.put("status", "tradeState");
+//                return tradeState;
+//            } else if (statusCode == 204) {
+//
+//            } else {
+//                String msg = EntityUtils.toString(response.getEntity());
+//                throw new IOException(msg);
+//            }
+//        } finally {
+//            response.close();
+//        }
+//        return "";
+//    }
+    public Map<String, String> wxQueryOrder(String out_trade_no) throws Exception {
         String mchId = wxPayCfg.getMchId();
         String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + out_trade_no + "?mchid=" + mchId;
+        System.out.println("订单查询接口url===" + url);
         HashMap<String, String> resultMap = new HashMap<>();
         HttpGet httpGet = new HttpGet(url);
         httpGet.addHeader(ACCEPT, APPLICATION_JSON.toString());
-        CloseableHttpResponse response = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key()).execute(httpGet);
-
-        try {
-            int statusCode = response.getStatusLine().getStatusCode();
-            if (statusCode == 200) {
-                String s = EntityUtils.toString(response.getEntity());
-                JSONObject jsonObject = JSONObject.parseObject(s);
-                String tradeState = jsonObject.getString("trade_state");
-                resultMap.put("code", "0");
-                resultMap.put("code", "ok");
-                resultMap.put("status", "tradeState");
-
-                return tradeState;
-            } else if (statusCode == 204) {
-
-            } else {
-                String msg = EntityUtils.toString(response.getEntity());
-                throw new IOException(msg);
-            }
-        } finally {
-            response.close();
+        CloseableHttpClient clint = WxPayUtil.getClint(wxPayCfg.getMchId(), wxPayCfg.getCertNo(), wxPayCfg.getPrivateKeyPath(), wxPayCfg.getApiV3Key());
+        CloseableHttpResponse response = clint.execute(httpGet);
+        int statusCode = response.getStatusLine().getStatusCode();
+
+        String res = EntityUtils.toString(response.getEntity());
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        if (statusCode != 200) {
+            String code = jsonObject.getString("code");
+            String message = jsonObject.getString("message");
+            resultMap.put("errCode", code);
+            resultMap.put("message", message);
+            return resultMap;
         }
-        return "";
+
+        String tradeState = jsonObject.getString("trade_state");
+        resultMap.put("tradeState", tradeState);
+        return resultMap;
     }