lighter 3 years ago
parent
commit
e5a0ec7d44

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>6.3</version>
+    <version>6.5</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 5 - 0
src/main/java/thyyxxk/wxservice_server/controller/WxApiController.java

@@ -75,6 +75,11 @@ public class WxApiController {
         return service.getWxPayQrcode(prm);
     }
 
+    @PostMapping("/closeWxOrder")
+    public ResultVo<String> closeWxOrder(@RequestBody WxPayOrder order) throws Exception {
+        return service.closeWxOrder(order);
+    }
+
     @PostMapping("/refund")
     public ResultVo<String> refund(@RequestBody @Validated RfndPrm prm) {
         return refundService.refund(prm);

+ 2 - 2
src/main/java/thyyxxk/wxservice_server/dao/HomePageDao.java

@@ -17,7 +17,7 @@ public interface HomePageDao {
             "rtrim(dept_code) as deptCode, " +
             "deptName=(select rtrim(name) from zd_unit_code where code=dept_code), " +
             "doctorTitle=(select rtrim(name) from zd_emp_title where code=emp_tit_code), " +
-            "portrait,introduction " +
-            "from a_employee_mi where wx_homepage_flag=1 order by wx_homepage_order")
+            "portrait,introduction from a_employee_mi where wx_homepage_flag=1 and " +
+            "isnull(del_flag,0)!=1 order by wx_homepage_order")
     List<DoctorInfo> selectHomePageDoctors();
 }

+ 5 - 1
src/main/java/thyyxxk/wxservice_server/dao/WxApiDao.java

@@ -47,7 +47,8 @@ public interface WxApiDao {
     @Select("select * from t_wechat_pay_order where trade_no=#{tradeNo}")
     WxPayOrder selectOrderByTradeNo(@Param("tradeNo") String tradeNo);
 
-    @Select("select * from t_wechat_pay_order where pay_status in (99, 0, 5, 6, 100) and isnull(query_state_times,0) < 10")
+    @Select("select * from t_wechat_pay_order where order_type<=3 and " +
+            "pay_status in (99, 0, 5, 6, 100) and isnull(query_state_times,0) < 10")
     List<WxPayOrder> selectOrdersForScheduleTask();
 
     @Select("select open_id from t_wechat_patient_bind where patient_id=#{cardNo} and del_flag=0")
@@ -74,4 +75,7 @@ public interface WxApiDao {
             "a.code not in ('00000', '00026') and " +
             "isnull(a.del_flag,0)<>1")
     DoctorInfo selectDoctorInfo(@Param("doctorCode") String doctorCode);
+
+    @Select("select pay_status from t_wechat_pay_order where trade_no=#{tradeNo}")
+    Integer selectOrderStatus(@Param("tradeNo") String tradeNo);
 }

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/entity/wxapi/WxPyQrcdPrm.java

@@ -32,7 +32,7 @@ public class WxPyQrcdPrm {
     private String payMode;
 
     /**
-     * orderType = 3 时,住院号和住院次数不能为空。
+     * orderType=3(住院预交金) 时,住院号和住院次数不能为空。
      * */
     private String inpatientNo;
     private Integer admissTimes;

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/service/SavePayResultService.java

@@ -58,7 +58,7 @@ public class SavePayResultService {
         obj.put("payTime", DateUtil.formatDatetime(order.getPayDatetime(), "yyyy-MM-dd HH:mm:ss"));
         try {
             RestTemplate template = new RestTemplate();
-            QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/getPayStatusForRegistration",
+            QueryMzPayStatusResponse response = template.postForObject(hrgApiUrl + "/ getPayStatusForRegistration",
                     obj, QueryMzPayStatusResponse.class);
             log.info("门诊挂号订单支付状态查询:参数:{},结果:{}", obj, response);
             int hasSaved = 0;

+ 4 - 5
src/main/java/thyyxxk/wxservice_server/service/SoapInvokeService.java

@@ -36,7 +36,6 @@ public class SoapInvokeService {
         log.info("查询检验报告:方法:{},参数:{}", operation, parameters[0]);
         JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
         Client client = dcf.createClient(inspectionUrl);
-        //处理webService接口和实现类namespace不同的情况,CXF动态客户端在处理此问题时,会报No operation was found with the name的异常
         Endpoint endpoint = client.getEndpoint();
         QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), operation);
         BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
@@ -52,7 +51,7 @@ public class SoapInvokeService {
         try {
             res = client.invoke(opName, parameters);
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("【" + operation + "】查询检验报告出错", e);
         }
         return Arrays.toString(res);
     }
@@ -64,7 +63,7 @@ public class SoapInvokeService {
             Element root = document.getRootElement();
             retEle = root.element("return");
         } catch (DocumentException e) {
-            e.printStackTrace();
+            log.error("【SoapInvokeService.class: line 67】解析检验报告出错", e);
         }
         if (retEle == null) {
             return new ArrayList<>();
@@ -85,7 +84,7 @@ public class SoapInvokeService {
                         Method m = pojo.getClass().getMethod("set" + name, String.class);
                         m.invoke(pojo, item.elementTextTrim(name));
                     } catch (Exception e) {
-                        e.printStackTrace();
+                        log.error("【SoapInvokeService.class: line 88】解析检验报告出错", e);
                     }
                 }
                 examList.add(pojo);
@@ -109,7 +108,7 @@ public class SoapInvokeService {
                 Method m = pojo.getClass().getMethod("set" + name, String.class);
                 m.invoke(pojo, element.elementTextTrim(name));
             } catch (Exception e) {
-                e.printStackTrace();
+                log.error("【SoapInvokeService.class: line 112】解析检验报告反射实体类出错", e);
             }
         }
         return pojo;

+ 37 - 1
src/main/java/thyyxxk/wxservice_server/service/WxApiService.java

@@ -378,12 +378,48 @@ public class WxApiService {
             JSONObject retObj = JSONObject.parseObject(ret);
             Map<String, String> map = new HashMap<>();
             map.put("qrcodeUrl", retObj.getString("code_url"));
-            map.put("tradeNo", outTradeNo);
+            map.put("tradeNo", order.getTradeNo());
+            map.put("serialNo", order.getSerialNo());
             return ResultVoUtil.success(map);
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请求微信支付二维码失败,请联系管理员。");
     }
 
+    public ResultVo<String> closeWxOrder(WxPayOrder order) throws Exception {
+        Integer payStatus = dao.selectOrderStatus(order.getTradeNo());
+        if (null == payStatus) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "订单不存在,请检查订单号是否正确。");
+        }
+        if (2 == payStatus) {
+            return ResultVoUtil.success("订单已是关闭状态,请勿重复关闭订单。");
+        }
+        String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + order.getTradeNo() + "/close";
+        JSONObject body = new JSONObject();
+        body.put("mchid", PropertiesUtil.getProperty("mchId"));
+        String reqdata = JSONObject.toJSONString(body);
+        HttpPost httpPost = new HttpPost(url);
+        StringEntity entity = new StringEntity(reqdata, StandardCharsets.UTF_8);
+        entity.setContentEncoding("UTF-8");
+        entity.setContentType("application/json");
+        httpPost.setEntity(entity);
+        httpPost.addHeader("Content-Type", "application/json;charset=UTF-8");
+        httpPost.addHeader("Accept", "application/json");
+        CloseableHttpClient httpClient = WxHttpUtil.getClosableHttpClient();
+        CloseableHttpResponse response = httpClient.execute(httpPost);
+        int statusCode = response.getStatusLine().getStatusCode();
+        log.info("关闭微信订单:{},结果:{}", order.getTradeNo(), statusCode);
+        if (statusCode == 204) {
+            httpClient.close();
+            dao.updatePayStatusOnly(order.getTradeNo(), 2);
+            return ResultVoUtil.success("关闭订单成功。");
+        }
+        if (null != response.getEntity()) {
+            String ret = EntityUtils.toString(response.getEntity());
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, ret);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "关闭订单失败。");
+    }
+
     public ResultVo<DoctorInfo> getDoctorInfo(String doctorCode) {
         DoctorInfo doctorInfo = dao.selectDoctorInfo(doctorCode);
         if (null == doctorInfo) {

+ 3 - 2
src/main/java/thyyxxk/wxservice_server/utils/DecimalTool.java

@@ -1,6 +1,7 @@
 package thyyxxk.wxservice_server.utils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 /**
  * @author dj
@@ -14,12 +15,12 @@ public class DecimalTool {
 
     public static String moneyYuanToFen(BigDecimal fee) {
         BigDecimal hundred = new BigDecimal("100");
-        return fee.multiply(hundred).setScale(0, BigDecimal.ROUND_CEILING).toPlainString();
+        return fee.multiply(hundred).setScale(0, RoundingMode.CEILING).toPlainString();
     }
 
     public static BigDecimal moneyFenToYuan(Integer fee) {
         BigDecimal cents = new BigDecimal(fee);
         BigDecimal hundred = new BigDecimal("100");
-        return cents.divide(hundred, 2, BigDecimal.ROUND_DOWN);
+        return cents.divide(hundred, 2, RoundingMode.DOWN);
     }
 }

+ 2 - 1
src/main/resources/application-prod.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8083
+  port: 8085
   servlet:
     context-path: /wxserver
 spring:
@@ -20,6 +20,7 @@ spring:
       connection-timeout: 30000
       validation-timeout: 3000
       max-lifetime: 60000
+      leak-detection-threshold: 6000
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss