Browse Source

Merge branch 'master' of https://gitlab.taihe.com/lighter/web-server

xiaochan 3 years ago
parent
commit
5aa886182c

+ 3 - 2
src/main/java/thyyxxk/webserver/constants/sidicts/SiFunction.java

@@ -275,8 +275,9 @@ public enum SiFunction {
      * 定点医药机构发起某项交易时,因网络中断或超时等原因导致无法获取接收方状态,
      * 导致多方数据不一致或已确认接收方数据多时,可通过冲正取消接收方相应数据,保持双方数据一致(冲正交易)
      * 重点说明:
-     * 1、可被冲正的交易包括:【2102】药店结算、【2103】药店结算撤销、【2207】门诊结算、【2208】门诊结算撤销、
-     *                    【2304】住院结算、【2305】住院结算撤销、【2401】入院办理。
+     * 1、可被冲正的交易包括:【2102】药店结算、【2103】药店结算撤销、
+     *                    【2207】门诊结算、【2208】门诊结算撤销、
+     *                    【2401】入院办理、【2304】住院结算、【2305】住院结算撤销。
      * 2、将需要冲正的交易信息(原交易)中的“msgid 发送方报文ID”放入本次输入的“omsgid 原发送方报文ID”中;
      * 3、将需要冲正的交易信息(原交易)中的“infno 交易编号”放入本次输入的“oinfno 原交易编号”中;
      * */

+ 28 - 18
src/main/java/thyyxxk/webserver/dao/his/yibao/DismissDao.java

@@ -129,6 +129,13 @@ public interface DismissDao {
                      @Param("begntime") Date begntime,
                      @Param("endtime") Date endtime);
 
+    @Update("update zy_ledger_file set deposit=(select sum(depo_amount) from zy_deposit_file f with(nolock) " +
+            "where f.inpatient_no=#{zyh} and f.admiss_times=#{times} and f.ledger_sn=#{ledger}) " +
+            "where inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger}")
+    void recountDeposit(@Param("zyh") String zyh,
+                        @Param("times") int times,
+                        @Param("ledger") int ledger);
+
     @Delete("delete zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
     void deleteZyLedgerFileYb(@Param("patNo") String patNo,
                               @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
@@ -178,30 +185,33 @@ public interface DismissDao {
                               @Param("deptCode") String deptCode, @Param("codeRs") String codeRs,
                               @Param("dismissDate") Date dismissDate);
 
-    @Update("update zy_ledger_file set account_date=#{dismissDate},settle_type='1',balance=0,last_balance=" +
-            "isnull((CASE WHEN b.xjzf!=0.00 then b.xjzf when b.xjzf=0.00 then b.total_cost-b.charge_yb end),0)," +
-            "settle=deposit-(isnull((CASE WHEN b.xjzf!=0.00 then b.xjzf when " +
-            "b.xjzf=0.00 then b.total_cost-b.charge_yb end),0))-0.00,ward_code=#{wardCode}," +
-            "dept_code=#{deptCode},op_id_code=#{codeRs},charge_yb=0 from zy_ledger_file," +
-            "zy_ledger_file_yb b where zy_ledger_file.inpatient_no=#{patNo} and zy_ledger_file.admiss_times=#{times} " +
-            "and zy_ledger_file.ledger_sn=#{ledgerSn} and zy_ledger_file.inpatient_no=b.inpatient_no and " +
-            "zy_ledger_file.admiss_times=b.admiss_times and zy_ledger_file.ledger_sn=b.ledger_sn")
+    @Select("select case when isnull(xjzf,0)!=0 then xjzf else total_cost-tczf end from zy_ledger_file_yb " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
+    String selectMedinsCashPay(@Param("patNo") String patNo,
+                               @Param("times") Integer times,
+                               @Param("ledgerSn") int ledgerSn);
+
+    @Update("update zy_ledger_file set account_date=#{dismissDate},settle_type='1',balance=0,last_balance=#{cash}, " +
+            "settle=(deposit-#{cash}),ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{codeRs},charge_yb=0 " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
     int updateCostStatusWithoutInfant(@Param("patNo") String patNo, @Param("times") Integer times,
                                       @Param("ledgerSn") int ledgerSn, @Param("wardCode") String wardCode,
                                       @Param("deptCode") String deptCode, @Param("codeRs") String codeRs,
-                                      @Param("dismissDate") Date dismissDate);
-
-    @Update("update zy_ledger_file set account_date=#{dismissDate},settle_type='1',balance=0,last_balance=" +
-            "(zy_ledger_file.total_charge-b.tczf),settle=deposit-(zy_ledger_file.total_charge-b.tczf)," +
-            "ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{codeRs}," +
-            "charge_yb=0 from zy_ledger_file,zy_ledger_file_yb b where zy_ledger_file.inpatient_no=#{patNo} " +
-            "and zy_ledger_file.admiss_times=#{times} and zy_ledger_file.ledger_sn=#{ledgerSn} and " +
-            "zy_ledger_file.inpatient_no=b.inpatient_no and zy_ledger_file.admiss_times=b.admiss_times and " +
-            "zy_ledger_file.ledger_sn=b.ledger_sn")
+                                      @Param("dismissDate") Date dismissDate, @Param("cash") String cash);
+
+    @Select("select tczf from zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
+    String selectMedinsFundPay(@Param("patNo") String patNo,
+                               @Param("times") Integer times,
+                               @Param("ledgerSn") int ledgerSn);
+
+    @Update("update zy_ledger_file set account_date=#{dismissDate},settle_type='1',balance=0, " +
+            "last_balance=(total_charge-#{fund}),settle=(deposit-total_charge+#{fund}), " +
+            "ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{codeRs}, " +
+            "charge_yb=0 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
     int updateCostStatusWithInfant(@Param("patNo") String patNo, @Param("times") Integer times,
                                    @Param("ledgerSn") int ledgerSn, @Param("wardCode") String wardCode,
                                    @Param("deptCode") String deptCode, @Param("codeRs") String codeRs,
-                                   @Param("dismissDate") Date dismissDate);
+                                   @Param("dismissDate") Date dismissDate, @Param("fund") String fund);
 
     @Update("update zy_detail_charge set charge_status=3 where charge_status=2 and " +
             "inpatient_no=#{patNo} AND admiss_times=#{times} AND ledger_sn=#{ledgerSn}")

+ 18 - 5
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -183,6 +183,8 @@ public class DismissService {
             throw new BizException(exception);
         }
 
+        dao.recountDeposit(patNo, times, ledgerSn);
+
         Date begntime = getBegntime(patNo,times,"zy_actpatient");
         dismissFeeAnalyse(patNo, times, ledgerSn, begntime, tmpendtime);
 
@@ -387,11 +389,22 @@ public class DismissService {
         final int code;
         if (medins) {
             final int hasInfant = dao.hasInfant(param.getInpatientNo(), param.getAdmissTimes());
-            code = hasInfant == 0 ?
-                    dao.updateCostStatusWithoutInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
-                            param.getWardCode(), param.getDeptCode(), param.getStaffId(), date) :
-                    dao.updateCostStatusWithInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
-                            param.getWardCode(), param.getDeptCode(), param.getStaffId(), date);
+            if (hasInfant == 0) {
+                String cash = dao.selectMedinsCashPay(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn());
+                if (StringUtil.isBlank(cash)) {
+                    cash = "0";
+                }
+                code = dao.updateCostStatusWithoutInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
+                        param.getWardCode(), param.getDeptCode(), param.getStaffId(), date, cash);
+            } else {
+                String fund = dao.selectMedinsFundPay(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn());
+                if (StringUtil.isBlank(fund)) {
+                    fund = "0";
+                }
+                code = dao.updateCostStatusWithInfant(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
+                        param.getWardCode(), param.getDeptCode(), param.getStaffId(), date, fund);
+            }
+
         } else {
             code = dao.updateZifeiCostStatus(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(),
                     param.getWardCode(), param.getDeptCode(), param.getStaffId(), date);