Jelajahi Sumber

优化代码和自动退费提示

lighter 2 tahun lalu
induk
melakukan
479d7cd909

+ 9 - 8
src/main/java/thyyxxk/wxservice_server/service/IdCardAnalyzeService.java

@@ -1,8 +1,8 @@
 package thyyxxk.wxservice_server.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baidu.aip.ocr.AipOcr;
 import lombok.extern.slf4j.Slf4j;
-import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -57,7 +57,7 @@ public class IdCardAnalyzeService {
         options.put("detect_risk", "false");
         String idCardSide = "front";
         byte[] file = Base64.getMimeDecoder().decode(param.getContent().split("base64,")[1]);
-        JSONObject res = client.idcard(file, idCardSide, options);
+        org.json.JSONObject res = client.idcard(file, idCardSide, options);
         log.info("解析身份证图像结果:{}", res);
         if (!res.toString().contains("idcard_number_type")) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "解析身份证服务出现异常,预计明日恢复,请手动输入您的信息。");
@@ -68,9 +68,9 @@ public class IdCardAnalyzeService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请上传正确的身份证图像!");
     }
 
-    private IdCardAnalyzeResult readIdCardInfoFromAipOcr(JSONObject res) {
+    private IdCardAnalyzeResult readIdCardInfoFromAipOcr(org.json.JSONObject res) {
         IdCardAnalyzeResult idCard = new IdCardAnalyzeResult();
-        JSONObject result = res.getJSONObject("words_result");
+        org.json.JSONObject result = res.getJSONObject("words_result");
         String socialNo = result.getJSONObject("公民身份号码").getString("words");
         idCard.setName(result.getJSONObject("姓名").getString("words"));
         idCard.setSocialNo(socialNo);
@@ -110,13 +110,13 @@ public class IdCardAnalyzeService {
         }
         param.setIsDefault(param.getRelation() == 1 ? 1 :0);
         RestTemplate template = new RestTemplate();
-        com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject();
+        JSONObject obj = new JSONObject();
         obj.put("patIdType", "11");
         obj.put("patIdNo", param.getSocialNo());
         String result = template.postForObject(hrgApiUrl + "/queryPatientInfo", obj, String.class);
         log.info("在绑卡前查询患者信息:\n参数:{}\n结果:{}", obj, result);
         if (null != result) {
-            com.alibaba.fastjson.JSONObject resobj = com.alibaba.fastjson.JSONObject.parseObject(result);
+            JSONObject resobj = JSONObject.parseObject(result);
             if (resobj.getInteger("resultCode") == 0) {
                 param.setPatientId(resobj.getString("patHisNo"));
                 param.setIcCardNo(resobj.getString("patCardNo"));
@@ -125,8 +125,9 @@ public class IdCardAnalyzeService {
             }
         }
         CreatCardParam card = makeCreateCardParam(param);
+        log.info("首诊患者建档参数:{}", JSONObject.toJSONString(card));
         CreateCardResponse hrgResponse = template.postForObject(hrgApiUrl + "/savePatientInfo", card, CreateCardResponse.class);
-        log.info("首诊患者建档:\n参数:{},\n结果:{}", card, hrgResponse);
+        log.info("首诊患者建档结果:{}", hrgResponse);
         if (null == hrgResponse) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
@@ -189,7 +190,7 @@ public class IdCardAnalyzeService {
                 "\"url\":\"\"}";
         PushMessageParam pojo = new PushMessageParam();
         pojo.setCardNo(temp.getIcCardNo());
-        pojo.setMsgContext(com.alibaba.fastjson.JSONObject.parseObject(msgContent));
+        pojo.setMsgContext(JSONObject.parseObject(msgContent));
         pushWxMessageService.pushMessage(pojo);
         return ResultVoUtil.success(map);
     }

+ 9 - 4
src/main/java/thyyxxk/wxservice_server/service/SavePayResultService.java

@@ -23,6 +23,7 @@ import thyyxxk.wxservice_server.entity.wxapi.WxPayOrder;
 import thyyxxk.wxservice_server.utils.DateUtil;
 import thyyxxk.wxservice_server.utils.DecimalTool;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.StringUtil;
 
 import java.util.Date;
 
@@ -193,14 +194,18 @@ public class SavePayResultService {
             }
             return ResultVoUtil.success("保存门诊缴费信息成功。");
         }
-        ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), "保存门诊缴费信息失败,自动退款。");
+        String message = "保存门诊缴费信息失败,自动退款。";
+        if (null != saveMzFeeResponse && StringUtil.notBlank(saveMzFeeResponse.getResultMessage())) {
+            message = saveMzFeeResponse.getResultMessage();
+        }
+        ResultVo<String> refund = refundService.autoRefund(order.getTradeNo(), message);
         log.info("【订单号:{}】保存门诊缴费信息失败,自动退款结果:{}", order.getTradeNo(), refund);
         if (refund.getCode() == ExceptionEnum.SUCCESS.getCode()) {
-            dao.refundOrder(order.getTradeNo(), "保存门诊缴费信息失败,自动退款。");
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,已为您自动退款,请留意到账信息。");
+            dao.refundOrder(order.getTradeNo(), message);
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + message +  "】已为您自动退款,请留意到账信息。");
         }
         dao.updatePayStatusOnly(order.getTradeNo(), 7);
-        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存门诊缴费信息失败,自动退款失败,请联系服务中心进行退款。");
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + message +  "】自动退款失败,请联系服务中心进行退款。");
     }
 
     private void updateSiMzSavedFlag(String hisOrdNum) {