소스 검색

保存缴费信息失败时自动退费 。

lighter 4 년 전
부모
커밋
64b5203958

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>1.5</version>
+    <version>1.7</version>
     <name>wxservice-server</name>
     <description>vue3 web server</description>
 

+ 6 - 0
src/main/java/thyyxxk/wxservice_server/controller/PayMzFeeController.java

@@ -28,4 +28,10 @@ public class PayMzFeeController {
                                     @RequestParam("hisOrdNum") String hisOrdNum) {
         return service.getUnPaidDetail(patientId, hisOrdNum);
     }
+
+    @GetMapping("/saveMzChargeInfo")
+    public ResultVo<String> saveMzChargeInfo(@RequestParam("tradeNo") String tradeNo,
+                                           @RequestParam("hisOrdNum") String hisOrdNum) {
+        return service.saveMzChargeInfo(tradeNo, hisOrdNum);
+    }
 }

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

@@ -8,12 +8,8 @@ import thyyxxk.wxservice_server.pojo.ResultVo;
 import thyyxxk.wxservice_server.pojo.appointment.WeChatPayParam;
 import thyyxxk.wxservice_server.pojo.wxapi.*;
 import thyyxxk.wxservice_server.service.WxApiService;
-import thyyxxk.wxservice_server.utils.WxPaySignUtil;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.security.GeneralSecurityException;
 
 @Slf4j
 @RestController
@@ -39,23 +35,4 @@ public class WxApiController {
         param.setClientIp(request.getRemoteAddr());
         return service.createPayOrder(param);
     }
-
-    @GetMapping("/updatePayStatus")
-    public ResultVo<String> updatePayStatus(@RequestParam("tradeNo") String tradeNo,
-                                    @RequestParam("status") Integer status) {
-        return service.updatePayStatus(tradeNo, status);
-    }
-
-    @PostMapping("/paymentNotify")
-    public void paymentNotify(@RequestBody PaymentNotify param) throws GeneralSecurityException, IOException {
-        service.paymentNotify(param);
-    }
-
-    @PostMapping("/paymentNotify2")
-    public void paymentNotify2(@RequestBody PaymentNotify param) throws GeneralSecurityException {
-        log.info("微信支付回调2:{}", param);
-        String ciphertext = WxPaySignUtil.decryptToString(param.getResource().getAssociated_data().getBytes(StandardCharsets.UTF_8),
-                param.getResource().getNonce().getBytes(StandardCharsets.UTF_8),  param.getResource().getCiphertext());
-        log.info("微信支付回调解密2:{}", ciphertext);
-    }
 }

+ 61 - 0
src/main/java/thyyxxk/wxservice_server/controller/WxPayNotifyController.java

@@ -0,0 +1,61 @@
+package thyyxxk.wxservice_server.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.wxservice_server.dao.WxApiDao;
+import thyyxxk.wxservice_server.pojo.wxapi.PaymentNotify;
+import thyyxxk.wxservice_server.service.PayMzFeeService;
+import thyyxxk.wxservice_server.utils.DateUtil;
+import thyyxxk.wxservice_server.utils.WxPaySignUtil;
+
+import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
+import java.util.Date;
+
+@Slf4j
+@RestController
+@RequestMapping("/wxPayNotify")
+public class WxPayNotifyController {
+    private final WxApiDao dao;
+    private final PayMzFeeService payMzFeeService;
+
+    public WxPayNotifyController(WxApiDao dao, PayMzFeeService payMzFeeService) {
+        this.dao = dao;
+        this.payMzFeeService = payMzFeeService;
+    }
+
+    @PostMapping("/notify")
+    public void paymentNotify(@RequestBody PaymentNotify param) throws GeneralSecurityException {
+        log.info("微信支付通知: {}", param);
+        String nonce = param.getResource().getNonce();
+        String associatedData = param.getResource().getAssociated_data();
+        String ciphertext = param.getResource().getCiphertext();
+        ciphertext = WxPaySignUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8),
+                nonce.getBytes(StandardCharsets.UTF_8), ciphertext);
+        JSONObject cipherObj = JSONObject.parseObject(ciphertext);
+        log.info("微信支付通知解密:{}", ciphertext);
+        JSONObject payer = cipherObj.getJSONObject("payer");
+        String tradeNo = cipherObj.getString("out_trade_no");
+        String openId = payer.getString("openid");
+        if (cipherObj.getString("trade_state").equalsIgnoreCase("SUCCESS")) {
+            String successTime = cipherObj.getString("success_time");
+            successTime = successTime.split("\\+")[0].replace("T"," ");
+            payMzFeeService.saveMzChargeInfo(tradeNo, null);
+            dao.updatePayStatusAndOpenId(tradeNo, openId, 1, successTime);
+        } else {
+            dao.updatePayStatusAndOpenId(tradeNo, openId, 3, DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss"));
+        }
+    }
+
+    @PostMapping("/notify2")
+    public void paymentNotify2(@RequestBody PaymentNotify param) throws GeneralSecurityException {
+        log.info("微信支付回调2:{}", param);
+        String ciphertext = WxPaySignUtil.decryptToString(param.getResource().getAssociated_data().getBytes(StandardCharsets.UTF_8),
+                param.getResource().getNonce().getBytes(StandardCharsets.UTF_8),  param.getResource().getCiphertext());
+        log.info("微信支付回调解密2:{}", ciphertext);
+    }
+}

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

@@ -56,8 +56,8 @@ public interface InpatientDao {
     void payZyYjjSuccessful(@Param("inpatientNo") String inpatientNo,
                                         @Param("admissTimes") Integer admissTimes,
                                         @Param("totalFee") BigDecimal totalFee,
-                                        @Param("payDatetime") Date payDatetime,
+                                        @Param("payDatetime") String payDatetime,
                                         @Param("tradeNo") String tradeNo,
                                         @Param("serialNo") String serialNo,
-                                        @Param("returnTxt") byte[] returnTxt);
+                                        @Param("returnTxt") String returnTxt);
 }

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/pojo/covid/OrderCovidExamParam.java

@@ -9,7 +9,7 @@ import java.util.List;
 @Data
 public class OrderCovidExamParam {
     private String patientId;
-    private String visitDeptCode = "3060000";
+    private String visitDeptCode = "1400002";
     private String doctorCode = "99999";
     private String inspectPart = "";
     private String reqComment = "申请核酸检测";

+ 23 - 19
src/main/java/thyyxxk/wxservice_server/service/AppointmentService.java

@@ -1,6 +1,5 @@
 package thyyxxk.wxservice_server.service;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,30 +8,29 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.AppointmentDao;
+import thyyxxk.wxservice_server.dao.WxApiDao;
 import thyyxxk.wxservice_server.pojo.HrgResponse;
 import thyyxxk.wxservice_server.pojo.ResultVo;
 import thyyxxk.wxservice_server.pojo.appointment.*;
 import thyyxxk.wxservice_server.pojo.assessment.CovidPojo;
-import thyyxxk.wxservice_server.utils.CastUtil;
-import thyyxxk.wxservice_server.utils.ThmzUrls;
-import thyyxxk.wxservice_server.utils.PropertiesUtil;
-import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.*;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Slf4j
 @Service
 public class AppointmentService {
     private final AppointmentDao dao;
+    private final WxApiDao wxApiDao;
+    private final WxApiService wxApiService;
     private static List<MzClassPojo> mzClasses;
 
     @Autowired
-    public AppointmentService(AppointmentDao dao) {
+    public AppointmentService(AppointmentDao dao, WxApiDao wxApiDao, WxApiService wxApiService) {
         this.dao = dao;
+        this.wxApiDao = wxApiDao;
+        this.wxApiService = wxApiService;
     }
 
     public ResultVo<List<MzClassPojo>> getAllDepartments() {
@@ -122,10 +120,12 @@ public class AppointmentService {
     }
 
     public ResultVo<Object> getGhFee(GetGhFeeParam param) {
+        log.info("获取挂号费用:{}", param);
         String url = String.format(ThmzUrls.GET_MZ_CHARGE_TYPE_BY_REQUEST_ID_FOR_HAI_CI +
                 "mzyRequestId=%d&patientId=%s", param.getMzyRequestId(), param.getPatientId());
         RestTemplate template = new RestTemplate();
         HrgResponse data = template.getForObject(url, HrgResponse.class);
+        log.info("获取挂号费用结果:{}", data);
         if (null == data) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
         }
@@ -175,19 +175,23 @@ public class AppointmentService {
     }
 
     public ResultVo<String> saveAppointment(SaveAppointmentParam param) {
-        JSONObject jsonObj = (JSONObject) JSON.toJSON(param);
-        log.info("param: {}", jsonObj);
+        log.info("保存挂号信息: {}", param);
         RestTemplate template = new RestTemplate();
         HrgResponse data = template.postForObject(ThmzUrls.PAY_REGISTRATION_FORM_HAI_CI, param, HrgResponse.class);
-        log.info("return: {}", data);
-        if (null == data || null == data.getResultCode()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "远程调用HRG接口出错,请联系泰和医院服务中心。电话:88518702");
+        log.info("保存挂号信息结果: {}", data);
+        String tradeNo = param.getMzyReqrec().getPsordnum();
+        String datetime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
+        if (null != data && data.getResultCode() == 0) {
+            wxApiDao.updatePayStatus(tradeNo, 1, datetime);
+            return ResultVoUtil.success("保存挂号信息成功。");
         }
-        if (data.getResultCode() == 0) {
-            return ResultVoUtil.success(data.getMessage());
-        } else {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, data.getMessage());
+        log.info("保存挂号信息失败,将自动退款。");
+        ResultVo<String> refund = wxApiService.autoRefund(tradeNo, "保存挂号信息失败,自动退款。");
+        if (null != refund && refund.getCode() == 200) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,已为您自动退款,请留意到账信息。");
         }
+        wxApiDao.updatePayStatus(tradeNo, 5, datetime);
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存挂号信息失败,自动退款失败,请联系服务中心进行退款。");
     }
 
     public ResultVo<String> getDoctorQrCode(String doctorCode) {

+ 11 - 6
src/main/java/thyyxxk/wxservice_server/service/InpatientService.java

@@ -6,15 +6,17 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.InpatientDao;
+import thyyxxk.wxservice_server.dao.WxApiDao;
 import thyyxxk.wxservice_server.pojo.ResultVo;
 import thyyxxk.wxservice_server.pojo.inpatient.GetZyFeeParam;
 import thyyxxk.wxservice_server.pojo.inpatient.InpatientInfo;
 import thyyxxk.wxservice_server.pojo.inpatient.ZyFee;
 import thyyxxk.wxservice_server.pojo.wxapi.WxPayOrderPojo;
+import thyyxxk.wxservice_server.utils.DateUtil;
 import thyyxxk.wxservice_server.utils.DecimalTool;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
-import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -23,10 +25,12 @@ import java.util.Map;
 @Service
 public class InpatientService {
     private final InpatientDao dao;
+    private final WxApiDao wxApiDao;
 
     @Autowired
-    public InpatientService(InpatientDao dao) {
+    public InpatientService(InpatientDao dao, WxApiDao wxApiDao) {
         this.dao = dao;
+        this.wxApiDao = wxApiDao;
     }
 
     public ResultVo<InpatientInfo> getInpatientInfo(String patientId) {
@@ -72,11 +76,12 @@ public class InpatientService {
     }
 
     public ResultVo<String> payYjjSuccessful(WxPayOrderPojo param) {
-        log.info("缴纳住院预交金成功:{}", JSON.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
-        param.setTotalFee(new BigDecimal("-10"));
+        String datetime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
         dao.payZyYjjSuccessful(param.getInpatientNo(), param.getAdmissTimes(), param.getTotalFee(),
-                param.getPayDatetime(), param.getTradeNo(), param.getSerialNo(), null);
-        return ResultVoUtil.success();
+                datetime, param.getTradeNo(), param.getSerialNo(), "");
+        wxApiDao.updatePayStatus(param.getTradeNo(), 1, datetime);
+        log.info("缴纳住院预交金成功:{}", JSON.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
+        return ResultVoUtil.success("缴纳住院预交金成功。");
     }
 
 }

+ 51 - 0
src/main/java/thyyxxk/wxservice_server/service/PayMzFeeService.java

@@ -1,16 +1,33 @@
 package thyyxxk.wxservice_server.service;
 
 import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.dao.WxApiDao;
 import thyyxxk.wxservice_server.pojo.HrgResponse;
 import thyyxxk.wxservice_server.pojo.ResultVo;
+import thyyxxk.wxservice_server.pojo.wxapi.WxPayOrderPojo;
+import thyyxxk.wxservice_server.utils.DateUtil;
+import thyyxxk.wxservice_server.utils.DecimalTool;
 import thyyxxk.wxservice_server.utils.ThmzUrls;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
+import java.util.Date;
+
+@Slf4j
 @Service
 public class PayMzFeeService {
+    private final WxApiDao dao;
+    private final WxApiService wxApiService;
+
+    @Autowired
+    public PayMzFeeService(WxApiDao dao, WxApiService wxApiService) {
+        this.dao = dao;
+        this.wxApiService = wxApiService;
+    }
 
     public ResultVo<Object> getUnPaidFee(String patientId) {
         JSONObject obj = new JSONObject();
@@ -29,6 +46,39 @@ public class PayMzFeeService {
         return getObjectResultVoFromGrg(obj, url);
     }
 
+    public ResultVo<String> saveMzChargeInfo(String tradeNo, String hisOrdNum) {
+        WxPayOrderPojo order = dao.selectOrderByTradeNo(tradeNo);
+        if (null == hisOrdNum) {
+            hisOrdNum = order.getHisOrdNum();
+        }
+        String payTime = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss");
+        JSONObject hrgParam = new JSONObject();
+        hrgParam.put("patCardType", 1);
+        hrgParam.put("patCardNo", order.getPatientId());
+        hrgParam.put("hisOrdNum", hisOrdNum);
+        hrgParam.put("psOrdNum", tradeNo);
+        hrgParam.put("payMode", "WX");
+        hrgParam.put("payAmt", DecimalTool.moneyYuanToFen(order.getTotalFee()));
+        hrgParam.put("agtOrdNum", order.getSerialNo());
+        hrgParam.put("payTime", payTime);
+        log.info("保存门诊缴费信息:{}", hrgParam);
+        RestTemplate template = new RestTemplate();
+        HrgResponse response = template.postForObject(ThmzUrls.PAY_CHARGE_DETAIL_FORM_HAI_CI,
+                hrgParam, HrgResponse.class);
+        log.info("保存门诊缴费信息结果:{}", response);
+        if (null != response && response.getResultCode() == 0) {
+            dao.updatePayStatus(tradeNo, 1, payTime);
+            return ResultVoUtil.success("保存门诊缴费信息成功。");
+        }
+        log.info("保存门诊缴费信息失败,将自动退款。");
+        ResultVo<String> refund = wxApiService.autoRefund(tradeNo, "保存门诊缴费信息失败,自动退款。");
+        if (null != refund && refund.getCode() == 200) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,已为您自动退款,请留意到账信息。");
+        }
+        dao.updatePayStatus(tradeNo, 5, payTime);
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,自动退款失败,请联系服务中心进行退款。");
+    }
+
     private ResultVo<Object> getObjectResultVoFromGrg(JSONObject obj, String url) {
         RestTemplate template = new RestTemplate();
         HrgResponse data = template.postForObject(url, obj, HrgResponse.class);
@@ -40,4 +90,5 @@ public class PayMzFeeService {
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, data.getResultMessage());
     }
+
 }

+ 16 - 82
src/main/java/thyyxxk/wxservice_server/service/WxApiService.java

@@ -13,18 +13,13 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.WxApiDao;
-import thyyxxk.wxservice_server.pojo.HrgResponse;
 import thyyxxk.wxservice_server.pojo.ResultVo;
 import thyyxxk.wxservice_server.pojo.wxapi.JsApiSHA1;
 import thyyxxk.wxservice_server.pojo.appointment.WeChatPayParam;
-import thyyxxk.wxservice_server.pojo.wxapi.PaymentNotify;
 import thyyxxk.wxservice_server.pojo.wxapi.WxPayOrderPojo;
 import thyyxxk.wxservice_server.utils.*;
 
-import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.security.GeneralSecurityException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.TreeMap;
@@ -62,7 +57,7 @@ public class WxApiService {
         String tradeNo = SnowFlakeId.instance().nextId();
         String nonceStr = SnowFlakeId.instance().nextId();
         String totalFee = DecimalTool.moneyYuanToFen(param.getTotalFee());
-        String notifyUrl = "http://staticweb.hnthyy.cn/wxserver/wxApi/paymentNotify2";
+        String notifyUrl = "http://staticweb.hnthyy.cn/wxserver/wxPayNotify/notify2";
         TreeMap<String, String> map = new TreeMap<>();
         map.put("appid", appId);
         map.put("mch_id", merchantId);
@@ -141,27 +136,22 @@ public class WxApiService {
         }
     }
 
-    public ResultVo<String> updatePayStatus(String tradeNo, Integer status) {
-        String successTime = getDatetime();
-        if (status == 1) {
-            WxPayOrderPojo order = dao.selectOrderByTradeNo(tradeNo);
-            if (null != order && null != order.getHisOrdNum()) {
-                HrgResponse hrgResponse = confirmPayStatus(tradeNo, successTime, order);
-                if (null == hrgResponse) {
-                    dao.updatePayStatus(tradeNo, 3, successTime);
-                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您已支付成功,但是更新订单状态失败。" +
-                            "请联系管理员手动更新或者退费。");
-                }
-                if (hrgResponse.getResultCode() == -1) {
-                    dao.updatePayStatus(tradeNo, 3, successTime);
-                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您已支付成功,但是更新订单状态失败。" +
-                            "请联系管理员手动更新或者退费。");
-                }
-            }
+    public ResultVo<String> autoRefund(String tradeNo, String reason) {
+        WxPayOrderPojo order = dao.selectOrderByTradeNo(tradeNo);
+        if (null == order) {
+            log.info("自动退款失败,未找到订单号为【{}】的订单。", tradeNo);
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR);
         }
-        dao.updatePayStatus(tradeNo, status, successTime);
-        log.info("更新订单状态:{},{}", tradeNo, status);
-        return ResultVoUtil.success("更新订单状态成功。");
+        String url = "http://webhis.thyy.cn:8706/wxRefund/refundOrder";
+        JSONObject param = new JSONObject();
+        param.put("id", order.getId());
+        param.put("refundDatetime", DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss"));
+        param.put("totalFee", order.getTotalFee());
+        param.put("tradeNo", tradeNo);
+        param.put("refundOpCode", "99999");
+        param.put("refundReason", reason);
+        RestTemplate template = new RestTemplate();
+        return template.postForObject(url, param, ResultVo.class);
     }
 
     private RestTemplate getRestTemplate() {
@@ -175,60 +165,4 @@ public class WxApiService {
         }
         return restTemplate;
     }
-
-    public void paymentNotify(PaymentNotify param) throws GeneralSecurityException, IOException {
-        log.info("微信支付通知: {}", param);
-        String nonce = param.getResource().getNonce();
-        String associatedData = param.getResource().getAssociated_data();
-        String ciphertext = param.getResource().getCiphertext();
-        ciphertext = WxPaySignUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8),
-                nonce.getBytes(StandardCharsets.UTF_8), ciphertext);
-        JSONObject cipherObj = JSONObject.parseObject(ciphertext);
-        log.info("微信支付通知解密:{}", ciphertext);
-        JSONObject payer = cipherObj.getJSONObject("payer");
-        String tradeNo = cipherObj.getString("out_trade_no");
-        String openId = payer.getString("openid");
-        if (cipherObj.getString("trade_state").equalsIgnoreCase("SUCCESS")) {
-            String successTime = cipherObj.getString("success_time");
-            successTime = successTime.split("\\+")[0].replace("T"," ");
-            WxPayOrderPojo order = dao.selectOrderByTradeNo(tradeNo);
-            if (null != order && null != order.getHisOrdNum()) {
-                HrgResponse hrgResponse = confirmPayStatus(tradeNo, successTime, order);
-                if (null == hrgResponse) {
-                    dao.updatePayStatusAndOpenId(tradeNo, openId, 3, successTime);
-                    return;
-                }
-                if (hrgResponse.getResultCode() == -1) {
-                    dao.updatePayStatusAndOpenId(tradeNo, openId, 3, successTime);
-                    return;
-                }
-            }
-            dao.updatePayStatusAndOpenId(tradeNo, openId, 1, successTime);
-        } else {
-            dao.updatePayStatusAndOpenId(tradeNo, openId, 3, getDatetime());
-        }
-    }
-
-    private HrgResponse confirmPayStatus(String tradeNo, String successTime, WxPayOrderPojo order) {
-        JSONObject hrgParam = new JSONObject();
-        hrgParam.put("patCardType", 1);
-        hrgParam.put("patCardNo", order.getPatientId());
-        hrgParam.put("hisOrdNum", order.getHisOrdNum());
-        hrgParam.put("psOrdNum", tradeNo);
-        hrgParam.put("payMode", "WX");
-        hrgParam.put("payAmt", DecimalTool.moneyYuanToFen(order.getTotalFee()));
-        hrgParam.put("agtOrdNum", order.getSerialNo());
-        hrgParam.put("payTime", successTime);
-        RestTemplate template = new RestTemplate();
-        HrgResponse response = template.postForObject(ThmzUrls.PAY_CHARGE_DETAIL_FORM_HAI_CI,
-                hrgParam, HrgResponse.class);
-        log.info("门诊缴费订单支付:{}", response);
-        return response;
-    }
-
-    private String getDatetime() {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        return sdf.format(new Date());
-    }
-
 }

+ 14 - 0
src/main/java/thyyxxk/wxservice_server/utils/DateUtil.java

@@ -0,0 +1,14 @@
+package thyyxxk.wxservice_server.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DateUtil {
+    public static String formatDatetime(Date date, String pattern) {
+        if (null == date) {
+            date = new Date();
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        return sdf.format(date);
+    }
+}

+ 10 - 10
src/main/resources/weChatOfficialAccounts.properties

@@ -1,18 +1,18 @@
 access_token=
 ticket=
 #长沙泰和医院1
-appId=wx19fc85fd5bfcc164
-appSecret=ffdf6f4ae704d374966dfb82bc300257
-mchId=1375971802
-mchKey=zxKl2oaid8KXA8dkai2DKk23ZIQE2X2e
-mchApiV3Key=ialfilajiDOAJLJ7232Lzlcjiw2s32dz
+#appId=wx19fc85fd5bfcc164
+#appSecret=ffdf6f4ae704d374966dfb82bc300257
+#mchId=1375971802
+#mchKey=zxKl2oaid8KXA8dkai2DKk23ZIQE2X2e
+#mchApiV3Key=ialfilajiDOAJLJ7232Lzlcjiw2s32dz
 
 #湖南泰和医院
-#appId=wxbde6b16acad84204
-#appSecret=
-#mchId=1574204121
-#mchKey=
-#mchApiV3Key=
+appId=wxbde6b16acad84204
+appSecret=57026648f9a5771f2a5deb34ef5212dc
+mchId=1574204121
+mchKey=lilaiwflzIOLJI2320JLZL2Llisd02ak
+mchApiV3Key=zxkkOIL9Z909lkjl2lzczi2KLsol2wct
 
 #企业微信
 qywxCorpId=wwf0b23c8b36012b34