Browse Source

暂时优化现金付款部分的逻辑

hurugang 2 years ago
parent
commit
0c8f21b329

+ 2 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzReceiptSerial.java

@@ -12,6 +12,8 @@ import java.util.Date;
  */
 @Data
 public class MzReceiptSerial implements Serializable {
+    //主键
+    private Integer id;
     //病人编码
     private String patientId;
     //病人就诊次数

+ 92 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzReceiptSerialNewMapper.java

@@ -0,0 +1,92 @@
+package cn.hnthyy.thmz.mapper.his.mz;
+
+import cn.hnthyy.thmz.entity.his.mz.MzReceiptSerial;
+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.Date;
+import java.util.List;
+import java.util.Map;
+
+public interface MzReceiptSerialNewMapper {
+
+
+
+
+
+
+    /**
+     * 新增门诊发票记录
+     *
+     * @param mzReceiptSerial
+     * @return
+     */
+    @Insert("INSERT INTO  mz_receipt_serial_new(patient_id,times,receipt_no,serial_no,operator_id,charge1,charge2,charge3,charge4,charge5,charge6,charge7,charge8,charge9," +
+            "charge10,charge11,charge12,charge13,charge14,charge15,charge16,charge17,charge18,charge19,charge20,pay_mark,total_charge,charge_date,receipt_bill,receipt_sn," +
+            "dcount_date,windows_no,dcount_no,serial_yb,fp_flag,responce_type,cheque_no,tf_flag,dept_no,charge_dcount_date,charge_dcount_no,pay_id," +
+            "obsolete_id,obsolete_date,obsolete_dcount_date,obsolete_dcount_no) VALUES " +
+            "(#{patientId,jdbcType=CHAR},#{times,jdbcType=INTEGER},#{receiptNo,jdbcType=SMALLINT},#{serialNo,jdbcType=INTEGER},#{operatorId,jdbcType=CHAR},#{charge1,jdbcType=DOUBLE}," +
+            "#{charge2,jdbcType=DOUBLE},#{charge3,jdbcType=DOUBLE},#{charge4,jdbcType=DOUBLE},#{charge5,jdbcType=DOUBLE},#{charge6,jdbcType=DOUBLE},#{charge7,jdbcType=DOUBLE}," +
+            "#{charge8,jdbcType=DOUBLE},#{charge9,jdbcType=DOUBLE},#{charge10,jdbcType=DOUBLE},#{charge11,jdbcType=DOUBLE},#{charge12,jdbcType=DOUBLE},#{charge13,jdbcType=DOUBLE}," +
+            "#{charge14,jdbcType=DOUBLE},#{charge15,jdbcType=DOUBLE},#{charge16,jdbcType=DOUBLE},#{charge17,jdbcType=DOUBLE},#{charge18,jdbcType=DOUBLE},#{charge19,jdbcType=DOUBLE}," +
+            "#{charge20,jdbcType=DOUBLE},#{payMark,jdbcType=CHAR},#{totalCharge,jdbcType=DOUBLE},#{chargeDate,jdbcType=TIMESTAMP},#{receiptBill,jdbcType=CHAR},#{receiptSn,jdbcType=INTEGER}," +
+            "#{dcountDate,jdbcType=TIMESTAMP},#{windowsNo,jdbcType=CHAR},#{dcountNo,jdbcType=INTEGER},#{serialYb,jdbcType=INTEGER},#{fpFlag,jdbcType=CHAR},#{responceType,jdbcType=CHAR}," +
+            "#{chequeNo,jdbcType=VARCHAR},#{tfFlag,jdbcType=CHAR},#{deptNo,jdbcType=VARCHAR},#{chargeDcountDate,jdbcType=TIMESTAMP},#{chargeDcountNo,jdbcType=INTEGER}," +
+            "#{payId,jdbcType=CHAR},#{obsoleteId,jdbcType=VARCHAR},#{obsoleteDate,jdbcType=TIMESTAMP},#{obsoleteDcountDate,jdbcType=TIMESTAMP},#{obsoleteDcountNo,jdbcType=VARCHAR})")
+    int insertMzReceiptSerial(MzReceiptSerial mzReceiptSerial);
+
+
+    /**
+     * 批量保存门诊发票记录
+     *
+     * @param mzReceiptSerials
+     * @return
+     */
+    @Insert({
+            "<script>",
+            "INSERT INTO  mz_receipt_serial_new(patient_id,times,receipt_no,serial_no,operator_id,charge1,charge2,charge3,charge4,charge5,charge6,charge7,charge8,charge9,charge10,charge11," +
+                    "charge12,charge13,charge14,charge15,charge16,charge17,charge18,charge19,charge20,pay_mark,total_charge,charge_date,receipt_bill,receipt_sn,dcount_date,windows_no," +
+                    "dcount_no,serial_yb,fp_flag,responce_type,cheque_no,tf_flag,dept_no,charge_dcount_date,charge_dcount_no,pay_id," +
+                    "obsolete_id,obsolete_date,obsolete_dcount_date,obsolete_dcount_no) VALUES ",
+            "<foreach collection='mzReceiptSerials' item='item' index='index' separator=','>",
+            " (#{item.patientId,jdbcType=CHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},#{item.serialNo,jdbcType=INTEGER},#{item.operatorId,jdbcType=CHAR}," +
+                    "cast(#{item.charge1,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge2,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge3,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge4,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge5,jdbcType=DECIMAL} as decimal(14,2))," +
+                    "cast(#{item.charge6,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge7,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge8,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge9,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge10,jdbcType=DECIMAL} as decimal(14,2))," +
+                    "cast(#{item.charge11,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge12,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge13,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge14,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge15,jdbcType=DECIMAL} as decimal(14,2))," +
+                    "cast(#{item.charge16,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge17,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge18,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge19,jdbcType=DECIMAL} as decimal(14,2)),cast(#{item.charge20,jdbcType=DECIMAL} as decimal(14,2))," +
+                    "#{item.payMark,jdbcType=CHAR},cast(#{item.totalCharge,jdbcType=DECIMAL} as decimal(14,2)),#{item.chargeDate,jdbcType=TIMESTAMP},#{item.receiptBill,jdbcType=CHAR},#{item.receiptSn,jdbcType=INTEGER}," +
+                    "#{item.dcountDate,jdbcType=TIMESTAMP},#{item.windowsNo,jdbcType=CHAR},#{item.dcountNo,jdbcType=INTEGER},#{item.serialYb,jdbcType=INTEGER},#{item.fpFlag,jdbcType=CHAR}," +
+                    "#{item.responceType,jdbcType=CHAR},#{item.chequeNo,jdbcType=VARCHAR},#{item.tfFlag,jdbcType=CHAR},#{item.deptNo,jdbcType=VARCHAR}," +
+                    "#{item.chargeDcountDate,jdbcType=TIMESTAMP},#{item.chargeDcountNo,jdbcType=INTEGER},#{item.payId,jdbcType=CHAR},#{item.obsoleteId,jdbcType=VARCHAR}," +
+                    "#{item.obsoleteDate,jdbcType=TIMESTAMP},#{item.obsoleteDcountDate,jdbcType=TIMESTAMP},#{item.obsoleteDcountNo,jdbcType=VARCHAR}) ",
+            "</foreach>",
+            "</script>"
+    })
+    int batchInsertMzReceiptSerial(@Param(value = "mzReceiptSerials") List<MzReceiptSerial> mzReceiptSerials);
+
+
+    /**
+     * 查询所有的发票记录
+     *
+     * @param patientId
+     * @param times
+     * @return
+     */
+    @Select({"<script>",
+            "select rtrim(patient_id) patient_id,times,receipt_no,serial_no,rtrim(operator_id) operator_id,charge1,charge2,charge3,charge4,charge5,charge6,charge7,charge8,charge9,",
+            "charge10,charge11,charge12,charge13,charge14,charge15,charge16,charge17,charge18,charge19,charge20,rtrim(pay_mark) pay_mark,total_charge,charge_date,rtrim(receipt_bill) receipt_bill,",
+            "receipt_sn,dcount_date,rtrim(windows_no) windows_no,dcount_no,serial_yb,rtrim(fp_flag) fp_flag,rtrim(responce_type) responce_type,rtrim(cheque_type) cheque_type,cheque_no," +
+                    "rtrim(tf_flag) tf_flag,dept_no,rtrim(pay_id) pay_id,charge_dcount_date,charge_dcount_no,obsolete_id,obsolete_date,obsolete_dcount_date,obsolete_dcount_no",
+            "from mz_receipt_serial_new WITH(NOLOCK) where patient_id =#{patientId,jdbcType=CHAR} and pay_mark=0  and times =#{times}  ",
+            "<when test='receiptNo!=null'>",
+            " and receipt_no=#{receiptNo}",
+            "</when>",
+            " order by receipt_bill desc ",
+            "</script>"})
+    List<MzReceiptSerial> selectReceiptDetails(@Param(value = "patientId") String patientId, @Param("times") Integer times, @Param("receiptNo") Integer receiptNo, @Param(value = "tableName") String tableName);
+
+
+}

+ 10 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -824,7 +824,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         mzYjReqService.modifyMzYjReq(updateMzYjReq);
         //新增收费方式记录
         mzDepositFileMapper.batchInsertMzDepositFile(mzDepositFiles);
-        if (mzReceiptSerial.getTotalCharge().compareTo(BigDecimal.ZERO) == 1) {
+        //是否有现金付款部分的发票
+        boolean haveOtherPay=mzReceiptSerial.getTotalCharge().compareTo(BigDecimal.ZERO) == 1;
+        if (haveOtherPay) {
             mzReceiptSerialMapper.insertMzReceiptSerial(mzReceiptSerial);
         }
         //本院记账金额
@@ -856,6 +858,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             MzReceiptSerial jhzfMzReceiptSerial = CloneUtil.clone(mzReceiptSerial);
             jhzfMzReceiptSerial.setTotalCharge(receiptSerialFee.getJhzfje());
             jhzfMzReceiptSerial.setChequeType(Constants.JHZF);
+            if(haveOtherPay){
+                jhzfMzReceiptSerial.resetParams();
+            }
             mzReceiptSerialMapper.insertMzReceiptSerial(jhzfMzReceiptSerial);
         }
         //银联卡金额
@@ -863,6 +868,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             MzReceiptSerial ylkMzReceiptSerial = CloneUtil.clone(mzReceiptSerial);
             ylkMzReceiptSerial.setTotalCharge(receiptSerialFee.getYlkje());
             ylkMzReceiptSerial.setChequeType(Constants.YLK);
+            if(haveOtherPay){
+                ylkMzReceiptSerial.resetParams();
+            }
             mzReceiptSerialMapper.insertMzReceiptSerial(ylkMzReceiptSerial);
         }
         MzVisitTable newMzVisitTable = new MzVisitTable();
@@ -4411,6 +4419,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 zfTotalPayable = zfTotalPayable.add(m.getAmount());
             } else {
                 excludeByjzPay = excludeByjzPay.add(m.getAmount());
+                zfTotalPayable = zfTotalPayable.add(m.getAmount());
             }
         }
         receiptSerialFee.setOtherje(excludeByjzPay.setScale(2, BigDecimal.ROUND_FLOOR));

+ 0 - 7
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzReceiptSerialServiceImpl.java

@@ -1,13 +1,10 @@
 package cn.hnthyy.thmz.service.impl.his.mz;
 
-import cn.hnthyy.thmz.Utils.CloneUtil;
-import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.Utils.NumberToCN;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.*;
 import cn.hnthyy.thmz.entity.thmz.Clinic;
-import cn.hnthyy.thmz.entity.thmz.PayInfo;
 import cn.hnthyy.thmz.entity.thmz.Receipt;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.PayMarkEnum;
@@ -59,10 +56,6 @@ public class MzReceiptSerialServiceImpl implements MzReceiptSerialService {
     @Autowired
     private MzVisitTableService mzVisitTableService;
     @Autowired
-    private MzChargeDetailService mzChargeDetailService;
-    @Autowired
-    private MzDrugWinService mzDrugWinService;
-    @Autowired
     private UserService userService;
     @Override
     public List<MzReceiptSerial> queryTallyReceiptSerial(String patientId) {