Jelajahi Sumber

住院收费退费功能开发完成

hurugang 4 tahun lalu
induk
melakukan
946ddc1f27

+ 17 - 0
src/main/java/cn/hnthyy/thmz/Utils/Md5Util.java

@@ -3,6 +3,8 @@ package cn.hnthyy.thmz.Utils;
 import java.io.UnsupportedEncodingException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import sun.misc.BASE64Encoder;
 
@@ -10,6 +12,7 @@ import sun.misc.BASE64Encoder;
  * MD5加密工具类
  */
 public class Md5Util {
+    private static int inc = 0;
     /**
      * 利用MD5进行加密
      */
@@ -33,4 +36,18 @@ public class Md5Util {
         else
             return false;
     }
+
+
+    /**
+     * 获取流水号
+     * @return
+     */
+    public static String getReceiptNo(){
+        long id = Long.parseLong(String.valueOf(System.currentTimeMillis())
+                .substring(1,10)
+                .concat(String.valueOf(inc)));
+        inc = (inc+1)%10;
+        SimpleDateFormat smf = new SimpleDateFormat("yyMMdd");
+        return smf.format(new Date())+id;
+    }
 }

+ 88 - 3
src/main/java/cn/hnthyy/thmz/controller/ZyDepositFileController.java

@@ -1,10 +1,12 @@
 package cn.hnthyy.thmz.controller;
 
+import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.Employee;
 import cn.hnthyy.thmz.entity.his.ZdChequeType;
 import cn.hnthyy.thmz.entity.his.ZyDepositFile;
 import cn.hnthyy.thmz.entity.his.ZyLedgerFile;
+import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.service.his.EmployeeService;
 import cn.hnthyy.thmz.service.his.ZdChequeTypeService;
 import cn.hnthyy.thmz.service.his.ZyDepositFileService;
@@ -14,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -75,15 +79,15 @@ public class ZyDepositFileController {
                     if(StringUtils.isNotBlank(zdf.getStatus())){
                         String status = zdf.getStatus().trim();
                         ZyLedgerFile zlf = zyLedgerFileMap.get(zdf.getLedgerSn());
-                        if("1".equals(status)){
+                        if(ZyDepositFile.PAY_STATUS.equals(status)){
                             zdf.setStatusName("预交");
-                        }else if("2".equals(status)){
+                        }else if(ZyDepositFile.REFUND_STATUS.equals(status)){
                             if(zlf==null || zlf.getAccountDate()==null || zlf.getAccountDate().after(zdf.getDepoDate())){
                                 zdf.setStatusName("直退");
                             }else {
                                 zdf.setStatusName("结算退款");
                             }
-                        }else if("4".equals(status)){
+                        }else if(ZyDepositFile.HAND_OVER_STATUS.equals(status)){
                             zdf.setStatusName("结算补交");
                         }else{
                             zdf.setStatusName("未知事物");
@@ -107,4 +111,85 @@ public class ZyDepositFileController {
         }
     }
 
+
+
+
+    /**
+     * 保存住院收费或者退费
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/saveZyDepositFile", method = {RequestMethod.POST})
+    public Map<String, Object> saveZyDepositFile(@RequestBody ZyDepositFile zyDepositFile, HttpServletRequest httpServletRequest) {
+        log.info("保存住院收费或者退费");
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (zyDepositFile == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "参数不能为空");
+                return resultMap;
+            }
+            if (StringUtils.isBlank(zyDepositFile.getStatus())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "事务类型不能为空");
+                return resultMap;
+            }
+            if (StringUtils.isBlank(zyDepositFile.getDepoType())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "支付方式不能为空");
+                return resultMap;
+            }
+            User tokenUser = TokenUtil.getUser(httpServletRequest);
+            zyDepositFile.setOpIdCode(tokenUser.getUserIdCode());
+            //缴费
+            if(ZyDepositFile.PAY_STATUS.equals(zyDepositFile.getStatus())){
+                if (StringUtils.isBlank(zyDepositFile.getInpatientNo())) {
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "病人住院号不能为空");
+
+                    return resultMap;
+                }
+                if (zyDepositFile.getDepoAmount() == null) {
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "缴费金额不能为空");
+                    return resultMap;
+                }
+            }else if(ZyDepositFile.REFUND_STATUS.equals(zyDepositFile.getStatus())){
+                ZyDepositFile dbZyDepositFile=zyDepositFileService.queryZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo());
+                if(dbZyDepositFile==null){
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "当前退费的收据号不存在。");
+                    return resultMap;
+                }
+                if(!dbZyDepositFile.getDepoType().equals(zyDepositFile.getDepoType())){
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "当前退费的退费方式与原收据的付款方式不一致。");
+                    return resultMap;
+                }
+                BigDecimal  depoAmount=zyDepositFileService.querySumDepoAmountByReceiptNo(zyDepositFile.getReceiptNo());
+                if(BigDecimal.ZERO.compareTo(depoAmount)==0){
+                    zyDepositFileService.modifyReportFlag(zyDepositFile.getReceiptNo());
+                    resultMap.put("code", -1);
+                    resultMap.put("message", "当前操作的费用已经退过费,请勿重复操作。");
+                    return resultMap;
+                }
+                //退费
+                zyDepositFile.setDepoAmount(BigDecimal.ZERO.subtract(dbZyDepositFile.getDepoAmount()));
+                zyDepositFile.setInpatientNo(dbZyDepositFile.getInpatientNo());
+                zyDepositFile.setAdmissTimes(dbZyDepositFile.getAdmissTimes());
+                zyDepositFile.setLedgerSn(dbZyDepositFile.getLedgerSn());
+            }
+            zyDepositFileService.saveZyDepositFile(zyDepositFile);
+            resultMap.put("code", 0);
+            resultMap.put("message", "操作成功");
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存住院收费或者退费记录出错,请联系管理员");
+            log.error("保存住院收费或者退费异常,错误信息{}", e.getMessage());
+            return resultMap;
+        }
+    }
 }

+ 1 - 1
src/main/java/cn/hnthyy/thmz/entity/his/ZyDepositFile.java

@@ -53,7 +53,7 @@ public class ZyDepositFile {
     private String deleted;
     //住院流水号
     private String zySerialNo;
-    //
+    //借用做退费标记,1 已退费
     private String reportFlag;
     //
     private String hsr;

+ 8 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/ZyActpatientMapper.java

@@ -152,4 +152,12 @@ public interface ZyActpatientMapper {
             "</when>",
             "</script>"})
     List<ZyActpatient> selectZyActpatientByInpatientNoOrMzNO(ZyActpatient zyActpatient);
+
+    /**
+     * 更新在院病人余额信息
+     * @param zyActpatient
+     * @return
+     */
+    @Update("update zy_actpatient SET balance =#{balance} WHERE inpatient_no =#{inpatientNo} AND admiss_times =#{admissTimes} ")
+    int updateBalance(ZyActpatient zyActpatient);
 }

+ 41 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/ZyDepositFileMapper.java

@@ -2,8 +2,11 @@ package cn.hnthyy.thmz.mapper.his;
 
 import cn.hnthyy.thmz.entity.his.ZyDepositFile;
 import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface ZyDepositFileMapper {
@@ -26,13 +29,21 @@ public interface ZyDepositFileMapper {
             "         op_id_code," +
             "         ledger_sn ," +
             "         printed   ," +
-            "         window_no  " +
+            "         window_no,report_flag  " +
             "    FROM zy_deposit_file " +
             "   WHERE " +
             "          inpatient_no = #{inpatientNo}  AND  " +
-            "          admiss_times = #{admissTimes}   ")
+            "          admiss_times = #{admissTimes}   order by depo_date desc")
     List<ZyDepositFile> selectZyDepositFileBYInpatientNoAndTimes(ZyDepositFile zyDepositFile);
 
+    /**
+     * 查询当前最大缴费次数
+     * @param zyDepositFile
+     * @return
+     */
+    @Select("select max ( depo_times ) from zy_deposit_file where inpatient_no =#{inpatientNo} and  admiss_times =#{admissTimes} ")
+    int selectMaxDepoTimes(ZyDepositFile zyDepositFile);
+
     /**
      * 入库住院收费记录
      * @param zyDepositFile
@@ -42,4 +53,32 @@ public interface ZyDepositFileMapper {
             " ( #{inpatientNo} , #{admissTimes} , #{depoTimes} , #{depoDate} , #{opIdCode} , #{depoAmount} , #{depoType} , #{status} , #{chequeNo} , #{printed} , #{receiptNo} , #{ledgerSn} , #{windowNo}, #{deleted} ) ")
     int insetZyDepositFile(ZyDepositFile zyDepositFile);
 
+
+
+    /**
+     * 按照收据号查询未退费的收据内容
+     * @param receiptNo
+     * @return
+     */
+    @Select("select * from zy_deposit_file where receipt_no=#{receiptNo} and depo_amount>0")
+    ZyDepositFile selectZyDepositFileByReceiptNo(@Param("receiptNo") String receiptNo);
+
+
+    /**
+     * 按照收据号查询该收据号的总费用  ==0 说明已经退了费  >0 说明未退费
+     * @param receiptNo
+     * @return
+     */
+    @Select("select sum(depo_amount) from zy_deposit_file where receipt_no=#{receiptNo}")
+    BigDecimal selectSumDepoAmountByReceiptNo(@Param("receiptNo") String receiptNo);
+
+
+    /**
+     * 根据收据号将状态标记为以退费
+     * @param receiptNo
+     * @return
+     */
+    @Update("update zy_deposit_file set report_flag=1 where receipt_no=#{receiptNo}")
+    int updateReportFlag(@Param("receiptNo") String receiptNo);
+
 }

+ 34 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/zyLedgerFileMapper.java → src/main/java/cn/hnthyy/thmz/mapper/his/ZyLedgerFileMapper.java

@@ -8,7 +8,19 @@ import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 
-public interface zyLedgerFileMapper {
+public interface ZyLedgerFileMapper {
+
+    /**
+     * 根据病人的住院号和住院次数和账页号查询账页信息
+     *
+     * @param inpatientNo
+     * @param admissTimes
+     * @return
+     */
+    @Select("select * from zy_ledger_file where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} AND ledger_sn =#{ledgerSn} ")
+    ZyLedgerFile selectZyLedgerFileByInpatientNoAndTimesAndLedgerSn(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes,@Param("ledgerSn") Integer ledgerSn);
+
+
     /**
      * 根据病人的住院号和住院次数查询账页信息
      *
@@ -35,6 +47,26 @@ public interface zyLedgerFileMapper {
             " #{settle} ,#{lastBalance}, #{settleType} , #{deptCode} , #{wardCode} , #{deptX} , #{wardX} , #{accountDate} , #{cashDate} , #{cashId} , #{dcountNo} , #{dcountDate} , #{zySerialNo} ) ")
     int insetZyLedgerFile(ZyLedgerFile zyLedgerFile);
 
+    /**
+     * 查询可以当前未结算的账页信息
+     * @param inpatientNo
+     * @param admissTimes
+     * @return
+     */
+    @Select("select ledger_sn from  zy_ledger_file where inpatient_no =#{inpatientNo} and admiss_times =#{admissTimes}  and  account_date is null ")
+    Integer selectCurrentLedgerSn(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+
+
+    /**
+     * 查询可以当前最大的已结算的账页信息
+     * @param inpatientNo
+     * @param admissTimes
+     * @return
+     */
+    @Select("select max(ledger_sn) from  zy_ledger_file where inpatient_no =#{inpatientNo} and admiss_times =#{admissTimes} ")
+    Integer selectMaxLedgerSn(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+
+
     /**
      * 更新金额
      * @param zyLedgerFile
@@ -44,4 +76,5 @@ public interface zyLedgerFileMapper {
     int updateZyLedgerFile(ZyLedgerFile zyLedgerFile);
 
 
+
 }

+ 26 - 1
src/main/java/cn/hnthyy/thmz/service/his/ZyDepositFileService.java

@@ -1,7 +1,9 @@
 package cn.hnthyy.thmz.service.his;
 
+import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.ZyDepositFile;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface ZyDepositFileService {
@@ -17,6 +19,29 @@ public interface ZyDepositFileService {
      * @param zyDepositFile
      * @return
      */
-    int saveZyDepositFile(ZyDepositFile zyDepositFile);
+    int saveZyDepositFile(ZyDepositFile zyDepositFile) throws MzException;
+
+
+    /**
+     * 按照收据号查询该收据号的总费用  ==0 说明已经退了费  >0 说明未退费
+     * @param receiptNo
+     * @return
+     */
+    BigDecimal querySumDepoAmountByReceiptNo(String receiptNo);
+
+    /**
+     * 根据收据号将状态标记为以退费
+     * @param receiptNo
+     * @return
+     */
+    int modifyReportFlag(String receiptNo);
+
+
+    /**
+     * 按照收据号查询未退费的收据内容
+     * @param receiptNo
+     * @return
+     */
+    ZyDepositFile queryZyDepositFileByReceiptNo(String receiptNo);
 
 }

+ 1 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/ZyActpatientServiceImpl.java

@@ -42,7 +42,7 @@ public class ZyActpatientServiceImpl implements ZyActpatientService {
     private ZyBedMiMapper zyBedMiMapper;
     @SuppressWarnings("all")
     @Autowired
-    private zyLedgerFileMapper zyLedgerFileMapper;
+    private ZyLedgerFileMapper zyLedgerFileMapper;
     @Autowired
     private ZyConfigService zyConfigService;
 

+ 74 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/ZyDepositFileServiceImpl.java

@@ -1,7 +1,14 @@
 package cn.hnthyy.thmz.service.impl.his;
 
+import cn.hnthyy.thmz.Utils.Md5Util;
+import cn.hnthyy.thmz.entity.MzException;
+import cn.hnthyy.thmz.entity.his.ZyActpatient;
 import cn.hnthyy.thmz.entity.his.ZyDepositFile;
+import cn.hnthyy.thmz.entity.his.ZyLedgerFile;
+import cn.hnthyy.thmz.enums.YesNoEnum;
+import cn.hnthyy.thmz.mapper.his.ZyActpatientMapper;
 import cn.hnthyy.thmz.mapper.his.ZyDepositFileMapper;
+import cn.hnthyy.thmz.mapper.his.ZyLedgerFileMapper;
 import cn.hnthyy.thmz.service.his.ZyDepositFileService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -9,12 +16,20 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 @Service
 public class ZyDepositFileServiceImpl implements ZyDepositFileService {
     @SuppressWarnings("all")
     @Autowired
     private ZyDepositFileMapper zyDepositFileMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private ZyActpatientMapper zyActpatientMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private ZyLedgerFileMapper zyLedgerFileMapper;
     @Override
     public List<ZyDepositFile> queryZyDepositFileBYInpatientNoAndTimes(ZyDepositFile zyDepositFile) {
         return zyDepositFileMapper.selectZyDepositFileBYInpatientNoAndTimes(zyDepositFile);
@@ -22,7 +37,64 @@ public class ZyDepositFileServiceImpl implements ZyDepositFileService {
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
-    public int saveZyDepositFile(ZyDepositFile zyDepositFile) {
-        return 0;
+    public int saveZyDepositFile(ZyDepositFile zyDepositFile) throws MzException {
+        ZyActpatient zyActpatient= zyActpatientMapper.selectByInpatientNo("zy_actpatient",zyDepositFile.getInpatientNo());
+        if(zyActpatient==null){
+            throw new MzException("住院号没有查询到对应的住院记录");
+        }
+        zyDepositFile.setAdmissTimes(Double.valueOf(zyActpatient.getAdmissTimes()));
+        int depoTimes=zyDepositFileMapper.selectMaxDepoTimes(zyDepositFile);
+        depoTimes++;
+        zyDepositFile.setDepoTimes(Double.valueOf(depoTimes));
+        zyDepositFile.setDepoDate(new Date());
+        zyDepositFile.setPrinted(Double.valueOf(1));
+        zyDepositFile.setWindowNo("1");
+        zyDepositFile.setDeleted(YesNoEnum.NO.code.toString());
+        //此时账页信息为空,是收费
+        if(zyDepositFile.getLedgerSn()==null){
+            Integer currentLedgerSn=zyLedgerFileMapper.selectCurrentLedgerSn(zyDepositFile.getInpatientNo(),zyActpatient.getAdmissTimes());
+            if(currentLedgerSn==null){
+                Integer maxLedgerSn=zyLedgerFileMapper.selectMaxLedgerSn(zyDepositFile.getInpatientNo(),zyActpatient.getAdmissTimes());
+                currentLedgerSn=maxLedgerSn++;
+            }
+            zyDepositFile.setLedgerSn(Double.valueOf(currentLedgerSn));
+        }
+        //查询账页信息
+        ZyLedgerFile zyLedgerFile=zyLedgerFileMapper.selectZyLedgerFileByInpatientNoAndTimesAndLedgerSn(zyDepositFile.getInpatientNo(),zyActpatient.getAdmissTimes(),zyDepositFile.getLedgerSn().intValue());
+        if(zyLedgerFile==null){
+            throw new MzException("没有找到当前病人本次住院的账页信息");
+        }
+        //缴费
+        if(ZyDepositFile.PAY_STATUS.equals(zyDepositFile.getStatus())){
+            zyDepositFile.setReceiptNo(Md5Util.getReceiptNo());
+        }else if(ZyDepositFile.REFUND_STATUS.equals(zyDepositFile.getStatus())){
+            //退费
+            zyDepositFile.setReportFlag(YesNoEnum.YES.code.toString());
+            zyDepositFileMapper.updateReportFlag(zyDepositFile.getReceiptNo());
+        }
+        int num=zyDepositFileMapper.insetZyDepositFile(zyDepositFile);
+        //设置账页信息
+        zyLedgerFile.setDeposit(zyLedgerFile.getDeposit().add(zyDepositFile.getDepoAmount()));
+        zyLedgerFile.setBalance(zyLedgerFile.getBalance().add(zyDepositFile.getDepoAmount()));
+        zyLedgerFileMapper.updateZyLedgerFile(zyLedgerFile);
+        //设置住院表的余额
+        zyActpatient.setBalance(zyActpatient.getBalance().add(zyDepositFile.getDepoAmount()));
+        zyActpatientMapper.updateBalance(zyActpatient);
+        return num;
+    }
+
+    @Override
+    public BigDecimal querySumDepoAmountByReceiptNo(String receiptNo) {
+        return zyDepositFileMapper.selectSumDepoAmountByReceiptNo(receiptNo);
+    }
+
+    @Override
+    public int modifyReportFlag(String receiptNo) {
+        return zyDepositFileMapper.updateReportFlag(receiptNo);
+    }
+
+    @Override
+    public ZyDepositFile queryZyDepositFileByReceiptNo(String receiptNo) {
+        return zyDepositFileMapper.selectZyDepositFileByReceiptNo(receiptNo);
     }
 }

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/zyLedgerFileServiceImpl.java

@@ -1,7 +1,7 @@
 package cn.hnthyy.thmz.service.impl.his;
 
 import cn.hnthyy.thmz.entity.his.ZyLedgerFile;
-import cn.hnthyy.thmz.mapper.his.zyLedgerFileMapper;
+import cn.hnthyy.thmz.mapper.his.ZyLedgerFileMapper;
 import cn.hnthyy.thmz.service.his.zyLedgerFileService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -11,7 +11,7 @@ import java.util.List;
 public class zyLedgerFileServiceImpl implements zyLedgerFileService {
     @SuppressWarnings("all")
     @Autowired
-    private zyLedgerFileMapper zyLedgerFileMapper;
+    private ZyLedgerFileMapper zyLedgerFileMapper;
     @Override
     public List<ZyLedgerFile> queryZyLedgerFileByInpatientNoAndTimes(String inpatientNo, Integer admissTimes) {
         return zyLedgerFileMapper.selectZyLedgerFileByInpatientNoAndTimes(inpatientNo,admissTimes);

+ 131 - 28
src/main/resources/static/js/accepting.js

@@ -15,14 +15,57 @@ $(function () {
     });
 
     /**
-     * 收费退费
+     * 收费
      */
     $("#chargeFee").on("click", function (t) {
         $("#chargeFeeModal").modal("show");
     });
 
     initChequeType();
-   // initStatus();
+
+    /**
+     * 收费保存
+     */
+    $("#saveEdit").on("click", function (t) {
+        $.ajax({
+            type: "POST",
+            url: '/thmz/saveZyDepositFile',
+            contentType: "application/json;charset=UTF-8",
+            dataType: "json",
+            async: false,
+            data: JSON.stringify({
+                "status": "1",
+                "inpatientNo": $("#admissionNumber").val(),
+                "depoType": $("#depoType").val(),
+                "depoAmount": $("#depoAmount").val(),
+                "chequeNo": $("#chequeNo").val()
+            }),
+            headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+            success: function (res) {
+                if (res == '401' || res == 401) {
+                    window.location.href = '/thmz/login/view'
+                    return;
+                }
+                if (res.code == 0) {
+                    $('#tb_table').bootstrapTable("refresh");
+                    $("#chargeFeeModal").modal("hide");
+                    successMesage(res);
+                } else {
+                    errorMesage(res);
+                }
+            }
+        });
+    });
+
+
+    /**
+     * 退费提交
+     */
+    $("#refundZyFee").on("click", function (t) {
+       saveRefundZyFee();
+    });
+
+    // initStatus();
 });
 
 
@@ -49,6 +92,11 @@ function initChequeType() {
             $('#depoType').selectpicker('refresh');
             $('#depoType').selectpicker('val', 1);
             $('#depoType').selectpicker('refresh');
+            $('#refundDepoType').empty();
+            $('#refundDepoType').html(html);
+            $('#refundDepoType').selectpicker('refresh');
+            $('#refundDepoType').selectpicker('val', 1);
+            $('#refundDepoType').selectpicker('refresh');
         }
     });
 }
@@ -62,6 +110,7 @@ function initStatus() {
     $('#status').html('<option value="1">预交</option><option value="2">退费</option>');
     $('#status').selectpicker('refresh');
 }
+
 /**
  * 获取按钮组选择的下标
  * @param id
@@ -98,11 +147,11 @@ function titleButtonChange(object) {
  * 根据病人门诊id或者住院号查询病人信息
  */
 function getZyActpatientByInpatientNoOrMzNO(id) {
-   var index = getIndex("regi_List_btn_group");
-   var tableName ='zy_actpatient';
-   if(index==1){
-       tableName ='zy_inactpatient';
-   }
+    var index = getIndex("regi_List_btn_group");
+    var tableName = 'zy_actpatient';
+    if (index == 1) {
+        tableName = 'zy_inactpatient';
+    }
     $.ajax({
         type: "POST",
         url: '/thmz/getZyActpatientByInpatientNoOrMzNO',
@@ -121,7 +170,7 @@ function getZyActpatientByInpatientNoOrMzNO(id) {
                 return;
             }
             if (res.code == 0) {
-                if(res.data.length>0){
+                if (res.data.length > 0) {
                     $("#patientModal").modal();
                     $("#patientTable").html(null);
                     for (var i = 0; i < res.data.length; i++) {
@@ -130,12 +179,12 @@ function getZyActpatientByInpatientNoOrMzNO(id) {
                             fillPatinet($(this).attr("data-target"));
                         });
                     }
-                }else {
-                   if(id=='admissionNumber'){
-                       $("#patientId").val(null);
-                   }else if(id=='patientId'){
-                       $("#admissionNumber").val(null);
-                   }
+                } else {
+                    if (id == 'admissionNumber') {
+                        $("#patientId").val(null);
+                    } else if (id == 'patientId') {
+                        $("#admissionNumber").val(null);
+                    }
                     $("#userName").val(null);
                     $("#gender").val(null);
                     $("#bedNo").val(null);
@@ -163,8 +212,6 @@ function getZyActpatientByInpatientNoOrMzNO(id) {
 }
 
 
-
-
 /**
  * 按照病人inpatientNo查询病人信息
  * @param patientId
@@ -174,13 +221,13 @@ function fillPatinet(inpatientNo) {
         return;
     }
     var index = getIndex("regi_List_btn_group");
-    var tableName ='zy_actpatient';
-    if(index==1){
-        tableName ='zy_inactpatient';
+    var tableName = 'zy_actpatient';
+    if (index == 1) {
+        tableName = 'zy_inactpatient';
     }
     $.ajax({
         type: "GET",
-        url: '/thmz/getByInpatientNo?inpatientNo=' + inpatientNo+"&tableName="+tableName,
+        url: '/thmz/getByInpatientNo?inpatientNo=' + inpatientNo + "&tableName=" + tableName,
         contentType: "application/json;charset=UTF-8",
         dataType: "json",
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
@@ -191,7 +238,7 @@ function fillPatinet(inpatientNo) {
             }
             if (res.code == 0) {
                 if (res.data != null) {
-                    inpatientNoFull=res.data.inpatientNo.trim();
+                    inpatientNoFull = res.data.inpatientNo.trim();
                     $("#admissionNumber").val(inpatientNoFull);
                     $("#patientId").val(res.data.mzNo);
                     $("#userName").val(res.data.name);
@@ -202,7 +249,7 @@ function fillPatinet(inpatientNo) {
                     $("#responceType").val(res.data.responceTypeName);
                     $("#totalAmount").val(res.data.totalCharge);
                     $("#balance").val(res.data.balance);
-                    admissTimesFull=res.data.admissTimes;
+                    admissTimesFull = res.data.admissTimes;
                     listDepositFile();
                 }
             } else {
@@ -213,11 +260,6 @@ function fillPatinet(inpatientNo) {
 }
 
 
-
-
-
-
-
 /**
  * 住院收费明细
  */
@@ -260,7 +302,7 @@ function listDepositFile() {
                 title: '账页号',
                 align: "center",
                 valign: 'middle'
-            },{
+            }, {
                 field: 'depoDate',
                 title: '时间',
                 align: "center",
@@ -298,6 +340,17 @@ function listDepositFile() {
                 title: '操作员',
                 align: "center",
                 valign: 'middle'
+            }, {
+                title: '操作',
+                align: "center",
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    var str='';
+                    if (row.reportFlag != 1 && row.depoAmount>0) {
+                        str ='<button type="button" class="btn btn-primary  btn-sm" onclick="refundZyFee(\'' + row.receiptNo + '\',\'' + row.depoAmount + '\',\'' + row.depoType + '\')">退费</button>';
+                    }
+                    return [str].join('');
+                }
             }
         ],
         responseHandler: function (res) {
@@ -343,6 +396,56 @@ function queryParams(params) {
 };
 
 
+/**
+ * 退费确认页面
+ * @param receiptNo
+ * @param depoAmount
+ * @param depoType
+ */
+function refundZyFee(receiptNo,depoAmount,depoType) {
+    $("#receiptNo").val(receiptNo);
+    $("#refungZyFeeModal").modal("show");
+    $("#refundDepoAmount").val(depoAmount);
+    $('#refundDepoType').selectpicker('val', depoType);
+    $('#refundDepoType').selectpicker('refresh');
+}
+
+
+/**
+ * 退住院预交金
+ * @param receiptNo
+ */
+function saveRefundZyFee() {
+    $.ajax({
+        type: "POST",
+        url: '/thmz/saveZyDepositFile',
+        contentType: "application/json;charset=UTF-8",
+        dataType: "json",
+        async: false,
+        data: JSON.stringify({
+            "status": "2",
+            "receiptNo": $("#receiptNo").val(),
+            "depoType": $("#refundDepoType").val()
+        }),
+        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+        success: function (res) {
+            if (res == '401' || res == 401) {
+                window.location.href = '/thmz/login/view'
+                return;
+            }
+            if (res.code == 0) {
+                $('#tb_table').bootstrapTable("refresh");
+                $("#refungZyFeeModal").modal("hide");
+                $("#receiptNo").val(null);
+                successMesage(res);
+            } else {
+                errorMesage(res);
+            }
+        }
+    });
+}
+
+
 /**
  * 清空
  */

+ 59 - 3
src/main/resources/templates/accepting.html

@@ -54,7 +54,7 @@
                 </div>
                 <div class="col-md-9 col-sm-9 col-xs-12">
                     <div class="clearRegistrationDiv">
-                        <a id="chargeFee"><i class="glyphicon glyphicon-plus">&nbsp;收费或退费</i></a>
+                        <a id="chargeFee"><i class="glyphicon glyphicon-plus">&nbsp;收费</i></a>
                         <a id="clearRegistration"><i class="fa fa-trash">&nbsp;清空</i></a>
                     </div>
                 </div>
@@ -196,7 +196,7 @@
 
 
 
-<!--缴费或者退费窗开始-->
+<!--缴费窗开始-->
 <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="chargeFeeModal">
     <div class="modal-dialog modal-lg">
         <div class="modal-content" style="width: 400px;margin-left: 200px;">
@@ -257,7 +257,63 @@
         </div>
     </div>
 </div>
-<!--缴费或者退费弹窗结尾-->
+<!--缴费弹窗结尾-->
+
+
+
+
+
+
+<!--退费窗开始-->
+<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="refungZyFeeModal">
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content" style="width: 400px;margin-left: 200px;">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
+                </button>
+                <!--<h4 class="modal-title">缴费退费</h4>-->
+                <h4 class="modal-title">退费</h4>
+            </div>
+            <div class="modal-body">
+                <form class="form-horizontal form-label-left" novalidate autocomplete="off">
+                    <!--<div class="item form-group">-->
+                    <!--<label class="control-label col-md-4 col-sm-4 col-xs-12" for="status">事务 <span-->
+                    <!--class="required">*</span>-->
+                    <!--</label>-->
+                    <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
+                    <!--<select class="form-control selectpicker show-tick" required="required"  title="请选择"-->
+                    <!--id="status">-->
+                    <!--</select>-->
+                    <!--</div>-->
+                    <!--</div>-->
+                    <div class="item form-group">
+                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="refundDepoType">支付方式 <span
+                                class="required">*</span>
+                        </label>
+                        <div class="col-md-6 col-sm-6 col-xs-12">
+                            <select class="form-control selectpicker show-tick" required="true"
+                                    id="refundDepoType"></select>
+                        </div>
+                    </div>
+                    <div class="item form-group">
+                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="refundDepoAmount">退款金额
+                        </label>
+                        <div class="col-md-6 col-sm-6 col-xs-12">
+                            <input type="number" id="refundDepoAmount" class="form-control col-md-7 col-xs-12" readonly>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <input type="hidden" id="receiptNo"/>
+                <button type="button" class="btn btn-primary" id="refundZyFee">确定退费</button>
+                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--退费弹窗结尾-->
+
 
 <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
     <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>