Ver código fonte

修复支付时的bug

lighter 2 anos atrás
pai
commit
43ac1455fc

+ 1 - 1
pom.xml

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

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

@@ -20,7 +20,7 @@ public interface WxApiDao {
     WxPayOrder selectSameGhOrder(@Param("patientId") String patientId,
                                  @Param("mzyRequestId") Integer mzyRequestId);
 
-    @Select("select * from t_wechat_pay_order with(nolock) where his_ord_num=#{hisOrdNum}")
+    @Select("select top 1 * from t_wechat_pay_order with(nolock) where his_ord_num=#{hisOrdNum} order by create_datetime desc")
     WxPayOrder selectSameMzPayOrder(@Param("hisOrdNum") String hisOrdNum);
 
     @Select("select count(1) from mzy_reqrec WITH(NOLOCK) where psordnum=#{tradeNo} and cancel_mark=0")

+ 15 - 15
src/main/java/thyyxxk/wxservice_server/service/WxApiService.java

@@ -303,32 +303,32 @@ public class WxApiService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请求微信支付二维码失败,请联系管理员。");
     }
 
-    public ResultVo<Map<String, String>> getWxPayQrcode(WxPyQrcdPrm prm) throws Exception {
-        String patName = dao.selectPatientName(prm.getPatientId());
+    public ResultVo<Map<String, String>> getWxPayQrcode(WxPyQrcdPrm param) throws Exception {
+        String patName = dao.selectPatientName(param.getPatientId());
         if (null == patName) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到患者信息,请检查patientId是否正确!");
         }
         WxPayOrder order = new WxPayOrder();
-        if (prm.getOrderType() == OrderType.INPATIENT_PRE_PAY.getCode()) {
-            if (StringUtil.isBlank(prm.getInpatientNo())) {
+        if (param.getOrderType() == OrderType.INPATIENT_PRE_PAY.getCode()) {
+            if (StringUtil.isBlank(param.getInpatientNo())) {
                 return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "费用类型为住院预交金时,住院号不能为空!");
             }
-            if (null == prm.getAdmissTimes()) {
+            if (null == param.getAdmissTimes()) {
                 return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "费用类型为住院预交金时,住院次数不能为空!");
             }
-            order.setInpatientNo(prm.getInpatientNo());
-            order.setAdmissTimes(prm.getAdmissTimes());
+            order.setInpatientNo(param.getInpatientNo());
+            order.setAdmissTimes(param.getAdmissTimes());
         }
         String outTradeNo = SnowFlakeId.instance().nextId();
         JSONObject body = new JSONObject();
         body.put("appid", PropertiesUtil.getProperty("appId"));
         body.put("mchid", PropertiesUtil.getProperty("mchId"));
-        body.put("description", prm.getDescription());
-        body.put("attach", prm.getDescription());
+        body.put("description", param.getDescription());
+        body.put("attach", param.getDescription());
         body.put("out_trade_no", outTradeNo);
         body.put("notify_url", PropertiesUtil.getProperty("notifyUrl"));
         JSONObject cny = new JSONObject();
-        cny.put("total", prm.getTotalAmt());
+        cny.put("total", param.getTotalAmt());
         cny.put("currency", "CNY");
         body.put("amount", cny);
         String reqdata = JSONObject.toJSONString(body);
@@ -344,15 +344,15 @@ public class WxApiService {
         int statusCode = response.getStatusLine().getStatusCode();
         String ret = EntityUtils.toString(response.getEntity());
         httpClient.close();
-        log.info("请求微信支付二维码:{},结果:{}", prm, ret);
+        log.info("请求微信支付二维码:{},结果:{}", param, ret);
         if (statusCode == ExceptionEnum.SUCCESS.getCode()) {
             long timesStamp = System.currentTimeMillis() / 1000;
-            String orderTypeName = OrderType.get(prm.getOrderType()).getLabel();
+            String orderTypeName = OrderType.get(param.getOrderType()).getLabel();
             order.setAppId(PropertiesUtil.getProperty("appId"));
             order.setBody(orderTypeName);
             order.setOpenId("");
-            order.setTotalFee(DecimalTool.moneyFenToYuan(prm.getTotalAmt()));
-            order.setPatientId(prm.getPatientId());
+            order.setTotalFee(DecimalTool.moneyFenToYuan(param.getTotalAmt()));
+            order.setPatientId(param.getPatientId());
             order.setPatientName(patName);
             order.setMchId(PropertiesUtil.getProperty("mchId"));
             order.setTimeStamp(String.valueOf(timesStamp));
@@ -360,7 +360,7 @@ public class WxApiService {
             order.setCreateDatetime(new Date());
             order.setPayStatus(TradeState.NOTPAY.getCode());
             order.setSerialNo(SnowFlakeId.instance().nextId());
-            order.setOrderType(prm.getOrderType());
+            order.setOrderType(param.getOrderType());
             dao.insertNewOrder(order);
             JSONObject retObj = JSONObject.parseObject(ret);
             Map<String, String> map = new HashMap<>();