yeguodong hai 1 mes
pai
achega
e8eb4f4f09

+ 3 - 2
src/main/java/cn/hnthyy/thmz/SpringContextUreport.java

@@ -8,7 +8,8 @@ import org.springframework.context.annotation.ImportResource;
 
 import javax.servlet.Servlet;
 
-@Configuration
+
+/*@Configuration
 @ImportResource("classpath:ureport-console-context.xml") // 加载ureport对应的xml配置文件
 public class SpringContextUreport {
 
@@ -16,4 +17,4 @@ public class SpringContextUreport {
     public ServletRegistrationBean<Servlet> ureportServlet(){
         return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");
     }
-}
+}*/

+ 35 - 1
src/main/java/cn/hnthyy/thmz/controller/mz/MzChargeDetailController.java

@@ -10,6 +10,7 @@ import cn.hnthyy.thmz.Utils.Tools;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.common.exception.BizException;
+import cn.hnthyy.thmz.common.model.ResultCode;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.*;
 import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
@@ -31,6 +32,7 @@ import cn.hnthyy.thmz.enums.MzfzStatusEnum;
 import cn.hnthyy.thmz.enums.NumberEnum;
 import cn.hnthyy.thmz.enums.PayMarkEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
+import cn.hnthyy.thmz.mapper.his.mz.MzDepositFileMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzOrderLockMapper;
 import cn.hnthyy.thmz.pageDto.MzChargeDetailPageDto;
 import cn.hnthyy.thmz.service.his.mz.*;
@@ -42,6 +44,7 @@ import cn.hnthyy.thmz.service.his.zd.ZdChargeItemService;
 import cn.hnthyy.thmz.service.his.zd.ZdChequeTypeService;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.his.zy.ZyZdAuditItemService;
+import cn.hnthyy.thmz.service.pay.NongPayService;
 import cn.hnthyy.thmz.service.thmz.*;
 import cn.hnthyy.thmz.vo.ChargeFeeParamsVo;
 import cn.hnthyy.thmz.vo.MzDepositFileVo;
@@ -124,6 +127,13 @@ public class MzChargeDetailController {
     private MzVisitTableService mzVisitTableService;
     @Autowired
     private RationalUseService rationalUseService;
+
+    @Autowired
+    private NongPayService nongPayService;
+
+    @Autowired
+    private MzDepositFileMapper mzDepositFileMapper;
+
     @Autowired
     private WindowsService windowsService;
     @Autowired
@@ -847,7 +857,7 @@ public class MzChargeDetailController {
             BigDecimal tempAmount = price.multiply(BigDecimal.valueOf(md.getQuantity() == null ? 1D : md.getQuantity())).multiply(BigDecimal.valueOf(md.getDrugWin() == null ? 1D : md.getDrugWin()));
             returnMzChargeDetail.setAmount(returnMzChargeDetail.getAmount().add(tempAmount));
         }
-        returnMzChargeDetail.setAmount(returnMzChargeDetail.getAmount().setScale(1, BigDecimal.ROUND_HALF_UP));
+        returnMzChargeDetail.setAmount(returnMzChargeDetail.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
         return returnMzChargeDetail;
     }
 
@@ -1032,6 +1042,30 @@ public class MzChargeDetailController {
             List<MzDepositFile> needRefundList = (List<MzDepositFile>) map.get("needRefundList");
             if (YesNoEnum.YES.code.equals(mzDepositFileVo.getRefundType()) && needRefundList != null && needRefundList.size() > 0 && StringUtils.isNotBlank(windowsDb.getMisPosRouterCode())) {
                 for (MzDepositFile mzDepositFile : needRefundList) {
+
+                    // 如果是聚合支付退款
+                    if(Constants.JHZF.equals(mzDepositFile.getChequeType())) {
+                        Map<String, String> body = new HashMap<>();
+                        body.put("refundAmount", mzDepositFile.getAmountStr());
+                        body.put("mchOrderNo", mzDepositFile.getTraceNo());
+                        body.put("refundReason", "门诊缴费退款");
+                        com.alibaba.fastjson.JSONObject response = nongPayService.refundOrder(body);
+                        if(Objects.equals(response.getInteger("code"), ResultCode.pay_error.getCode())) {
+                            resultMap.put("code", -2);
+                            resultMap.put("message", "退费失败,请询问收费处!");
+                            return resultMap;
+                        }
+                        System.out.println("com.alibaba.fastjson.JSONObject.toJSONString(response)");
+                        System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(response));
+                        com.alibaba.fastjson.JSONObject data = response.getJSONObject("data");
+                        String refundNo = data.getString("mchRefundNo");
+                        String outRefundNo = data.getString("refundOrderId");
+                        System.out.println("mchRefundNo = " + refundNo);
+                        System.out.println("refundOrderId = " + outRefundNo);
+                        mzDepositFileMapper.updateRefundByPatientId(mzDepositFile.getPatientId(), mzDepositFile.getTimes(), refundNo, outRefundNo);
+                        continue;
+                    }
+
                     JSONObject jsonObject = transactionService.refund(windowsDb.getMisPosRouterCode(), mzDepositFile.getAmount(), mzDepositFile.getPsordnum() + "_" + mzDepositFile.getAmountStr(), null, mzDepositFile.getChequeType(), mzDepositFile.getParChannel(), mzDepositFile.getPsordnum(), mzDepositFile.getTransDate(), mzDepositFile.getAgtordnum());
                     if (jsonObject == null) {
                         resultMap.put("code", -2);

+ 6 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzDepositFile.java

@@ -64,6 +64,12 @@ public class MzDepositFile extends PageBean implements Serializable {
     private String transDate;
     //凭证号
     private String traceNo;
+    //外部凭证号
+    private String outTraceNo;
+    //退款凭证号
+    private String refundNo;
+    //外部退款凭证号
+    private String outRefundNo;
     //抖音团购号
     private String dyTgNo;
     //退费标识  1退费

+ 5 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDepositFileMapper.java

@@ -37,12 +37,12 @@ public interface MzDepositFileMapper {
     @Insert({
             "<script>",
             "INSERT INTO mz_deposit_file(patient_id,times,receipt_no,pay_mark,cheque_type,cheque_no,amount,charge_date,dcount_date,dcount_no,",
-            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no,warn_code,doctor_code) VALUES ",
+            "op_id,receipt_sn,serial_no,responce_type,yb_jlh,yb_ywh,dept_no,psordnum,agtordnum,hisrefundnum,contract_id,par_channel,trans_date,trace_no,out_trace_no,warn_code,doctor_code) VALUES ",
             "<foreach collection='mzDepositFileList' item='item' index='index' separator=','>",
             " (#{item.patientId,jdbcType=CHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},#{item.payMark,jdbcType=CHAR},#{item.chequeType,jdbcType=CHAR},#{item.chequeNo,jdbcType=CHAR}",
             ",#{item.amountStr,jdbcType=DECIMAL},#{item.chargeDate,jdbcType=TIMESTAMP},#{item.dcountDate,jdbcType=TIMESTAMP},#{item.dcountNo,jdbcType=CHAR},#{item.opId,jdbcType=CHAR},",
             "#{item.receiptSn,jdbcType=INTEGER},#{item.serialNo,jdbcType=INTEGER},#{item.responceType,jdbcType=CHAR},#{item.ybJlh,jdbcType=VARCHAR},#{item.ybYwh,jdbcType=VARCHAR},",
-            "#{item.deptNo,jdbcType=VARCHAR},#{item.psordnum,jdbcType=VARCHAR},#{item.agtordnum,jdbcType=VARCHAR},#{item.hisrefundnum,jdbcType=VARCHAR},#{item.contractId},#{item.parChannel},#{item.transDate},#{item.traceNo},#{item.warnCode},#{item.doctorCode}) ",
+            "#{item.deptNo,jdbcType=VARCHAR},#{item.psordnum,jdbcType=VARCHAR},#{item.agtordnum,jdbcType=VARCHAR},#{item.hisrefundnum,jdbcType=VARCHAR},#{item.contractId},#{item.parChannel},#{item.transDate},#{item.traceNo},#{item.outTraceNo},#{item.warnCode},#{item.doctorCode}) ",
             "</foreach>",
             "</script>"
     })
@@ -395,4 +395,7 @@ public interface MzDepositFileMapper {
     @Select(" select sum(amount) from  mz_deposit_file where patient_id =#{patientId} and times =#{times} and abs(receipt_no) < #{receiptNo} ")
     BigDecimal selectBeforeReceiptNo(@Param("patientId") String patientId, @Param("times")Integer times, @Param("receiptNo")Integer receiptNo);
 
+    @Update( " update mz_deposit_file set refund_no =#{refundNo},out_refund_no=#{outRefundNo}  where patient_id=#{patientId} and times = #{times} and cheque_type = 'O' " )
+    void updateRefundByPatientId(@Param("patientId") String patientId, @Param("times")Integer times, @Param("refundNo") String refundNo, @Param("outRefundNo")String outRefundNo);
+
 }

+ 30 - 0
src/main/java/cn/hnthyy/thmz/service/pay/NongPayService.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 @Slf4j
@@ -59,6 +60,35 @@ public class NongPayService {
         return result;
     }
 
+    /**
+     * 统一退款
+     * @param body
+     * @return
+     */
+    public JSONObject refundOrder(Map<String, String> body) {
+        JSONObject result = new JSONObject();
+        result.put("code", ResultCode.pay_error.getCode());
+        String refundAmount = body.get("refundAmount");
+        BigDecimal refundAmountBigDecimal = new BigDecimal(refundAmount);
+        String payAmount = String.valueOf(refundAmountBigDecimal.multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP));
+        body.put("refundAmount", payAmount);
+        try {
+            log.info("--------------------门诊退费开始-------------------------");
+            log.info("param={}", JSONObject.toJSONString(body));
+            String postResponse = RestApiUtil.doPost(payUrl + "/refundOrder", JSONObject.toJSONString(body));
+            JSONObject response = JSONObject.parseObject(postResponse);
+            log.info("response={}", response);
+            if(Objects.equals(response.getInteger("code"), ResultCode.pay_refund_success.getCode())) {
+                result.put("code", ResultCode.pay_refund_success.getCode());
+                result.put("data", response.getJSONObject("data"));
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            log.error("退款失败:" + e.getMessage());
+        }
+        return result;
+    }
+
     /**
      * 通过收费凭条上的二维码进行扫码支付
      * @param body

+ 6 - 6
src/main/resources/application-mhyy.yml

@@ -41,15 +41,15 @@ spring:
       max-request-size: 1000MB
   datasource:
     his:
-#      jdbc-url: "jdbc:sqlserver://130.150.161.71:1433;databaseName=hisdb"
-#      username: "sa"
-#      password: "Symhyy@123"
+      jdbc-url: "jdbc:sqlserver://130.150.161.71:1433;databaseName=hisdb"
+      username: "sa"
+      password: "Symhyy@123"
       # jdbc-url: "jdbc:sqlserver://130.150.161.124:1433;databaseName=po"
       # username: "sa"
       # password: "root"
-      jdbc-url: "jdbc:sqlserver://localhost:1433;databaseName=his"
-      username: "sa"
-      password: "123456"
+#      jdbc-url: "jdbc:sqlserver://localhost:1433;databaseName=his"
+#      username: "sa"
+#      password: "123456"
       driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
     durid:
       #type: com.alibaba.druid.pool.DruidDataSource

+ 2 - 1
src/main/resources/static/js/mz/toll_administration.js

@@ -1900,13 +1900,14 @@ function saveConfirmFee() {
             if (temp == null || temp == 0) {
                 continue;
             }
-            var tempJson = JSON.parse('{"chequeType":"","amount":"","contractId":"","psordnum":"","agtordnum":"","parChannel":"","transDate":"","traceNo":"","dyTgNo":""}');
+            var tempJson = JSON.parse('{"chequeType":"","amount":"","contractId":"","psordnum":"","agtordnum":"","parChannel":"","transDate":"","traceNo":"","outTraceNo":"","dyTgNo":""}');
             tempJson.chequeType = $(arr[i]).find("select").val();
             tempJson.psordnum = refNo;
             tempJson.agtordnum = $("#paymentCode").val();
             tempJson.parChannel = "1";
             tempJson.transDate = transDate;
             tempJson.traceNo = traceNo;
+            tempJson.outTraceNo = outTraceNo;
 //            tempJson.chequeType = "1";
             //现金有可能会多收,比入实收37,对方给了100,需要找零63. 所以必须减去找零金额,才是实收金额
             if (tempJson.chequeType == "1") {