From 14f9208da19b7030a1c65a40897f9f4146a74d44 Mon Sep 17 00:00:00 2001
From: 赵文轩 <1652863494@qq.com>
Date: 星期五, 01 十一月 2024 08:37:14 +0800
Subject: [PATCH] 增加申请业务类型

---
 ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java |   98 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 84 insertions(+), 14 deletions(-)

diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java
index 73d6e78..c404c7b 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java
@@ -65,17 +65,31 @@
      */
     public int deleteTbTransitionByIds(String[] ids);
 
-    @Delete("DELETE  FROM tb_transition WHERE cus_id=#{cusId}")
+    @Delete("DELETE  FROM tb_transition WHERE cus_id=#{cusId} and isnull(tj_num)")
     public boolean deletedTbTransitionByCusId(String cusId);
 
 
-    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} AND pac_id=#{pacId}")
+    @Delete("DELETE  FROM tb_transition WHERE tj_num=#{tjNum}")
+    public boolean deletedTbTransitionByTjNum(String tjNum);
+
+    @Delete("DELETE  FROM tb_transition WHERE isnull(tj_num)  and  cus_id=#{cdId} and parent_pro_id=#{proId}")
+    public boolean delTbBycusCardIdAndProId(@Param("cdId") String cdId,@Param("proId")String proId);
+
+    @Update("UPDATE tb_transition a SET "+
+            "a.tj_num=null" +
+            " WHERE a.tj_num=#{tjNum}")
+    boolean updateTbTransitionByTjNum(String tjNum);
+
+    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} AND pac_id=#{pacId} and isnull(tj_num)")
     public List<TbTransition> getTbTransitionListByCusIdAndPac(@Param("cusId") String cusId,@Param("pacId") String pacId);
 
     @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} and card_id=#{cardId}")
     public List<TbTransition> getTbTransitionListByCusId(@Param("cusId")String cusId,@Param("cardId")String cardId);
 
-    @Delete("DELETE FROM tb_transition WHERE cus_id=#{cusId} AND !ISNULL(pac_id) and card_id=#{cardId}")
+    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} and card_id=#{cardId} and jxbz=#{jxbz}")
+    public List<TbTransition> getBlTbTransitionListByCusId(@Param("cusId")String cusId,@Param("cardId")String cardId,@Param("jxbz") String jxbz);
+
+    @Delete("DELETE FROM tb_transition WHERE cus_id=#{cusId} AND !ISNULL(pac_id) and isnull(tj_num)")
     public boolean deletedTbTransitionListByCusIdAndPac(@Param("cusId")String cusId,@Param("cardId")String cardId);
 
     @Delete("DELETE FROM tb_transition WHERE cus_id=#{cusId} AND ISNULL(tj_num)and card_id=#{cardId}")
@@ -85,7 +99,7 @@
 //    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} AND ISNULL(pac_id)  AND pro_id =#{proId}")
 //    public List<TbTransition> getTbTransitionListByCusIdAndPacIdAndProId(@Param("cusId") String cusId,@Param("proId") String proId);
 
-    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId}  AND pro_id =#{proId}")
+    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId}  AND pro_id =#{proId} and ISNULL(tj_num)")
     public List<TbTransition> getTbTransitionListByCusIdAndPacIdAndProId(@Param("cusId") String cusId,@Param("proId") String proId);
 
     @Select("SELECT DISTINCT pac_id FROM tb_transition WHERE cus_id=#{cusId} AND !ISNULL(pac_id)")
@@ -100,10 +114,19 @@
 
     @Update("UPDATE tb_transition a SET \n" +
             "a.ord_price=a.now_price,\n" +
-            "a.now_price=a.ord_price*#{discount}," +
+            "a.now_price=a.ord_price*(#{discount}/10)," +
             "a.tj_num=#{tjNum}"+
-            " WHERE a.cus_id=#{cusId} ")
+            " WHERE a.cus_id=#{cusId}  AND ISNULL(a.tj_num) ")
     boolean updateTbTransitionPriceByCusId(@Param("cusId")String cusId,@Param("discount")BigDecimal discount,@Param("tjNum")String tjNum);
+
+
+    @Update("UPDATE tb_transition a SET \n" +
+            "           a.now_price=#{jg},\n" +
+            "           a.tj_num=#{tjNum},\n" +
+            "           a.card_id=#{cardId},\n" +
+            "           a.jxbz=#{jxbz}\n" +
+            "            WHERE a.id=#{id}")
+    public boolean updateTbTransitionById(@Param("id")String id,@Param("jxbz")String jxbz,@Param("tjNum")String tjNum,@Param("cardId")String cardId,@Param("jg")BigDecimal jg);
 
 
     @Insert("INSERT INTO tb_transition(\n" +
@@ -118,7 +141,8 @@
             "   now_price,\n" +
             "   create_time,\n" +
             "   pro_check_method,\n" +
-            "   pro_type\n" +
+            "   pro_type,\n" +
+            "   card_id\n" +
             ")\n" +
             "SELECT\n" +
             "\t#{cusId},\n" +
@@ -128,11 +152,13 @@
             "\tc.pro_name,\n" +
             "\tb.pro_id,\n" +
             "\tb.pro_name,\n" +
-            "\tTRUNCATE(c.pro_price * (TRUNCATE ( a.price_now / b.pro_price, 5 )),2),\n" +
-            "\tTRUNCATE(c.pro_price * (TRUNCATE ( a.price_now / b.pro_price, 5 )),2),\n" +
+            "\tTRUNCATE(c.pro_price,2),\n" +
+            "\tTRUNCATE(c.pro_price,2),\n" +
+//            " IFNULL(TRUNCATE(c.pro_price * (TRUNCATE ( a.price_now / b.pro_price, 5 )),2),0), " +
             "\tSYSDATE(),\n" +
             "\tc.pro_check_method,\n" +
-            "\tIFNULL(c.pro_type,'')\n" +
+            "\tIFNULL(c.pro_type,''),\n" +
+            "\t#{cardId}\n" +
             "FROM\n" +
             "\ttj_package_project a\n" +
             "\tLEFT JOIN tj_project b ON a.pro_id = b.pro_id\n" +
@@ -140,15 +166,16 @@
             "\tLEFT JOIN tj_package d ON a.pac_id=d.pac_id\n" +
             "\t\n" +
             "\tWHERE a.pac_id=#{pacId} and c.deleted=0")
-    void saveRedisTransitionByPacId(@Param("cusId") String cusId,@Param("pacId") Long pacId);
+    void saveRedisTransitionByPacId(@Param("cusId") String cusId,@Param("cardId")String cardId,@Param("pacId") Long pacId);
 
 
     @Insert("INSERT INTO tb_transition \n" +
-            "(cus_id, pro_id, pro_name, parent_pro_id, parent_pro_name, ord_price, now_price, create_time, pro_check_method, pro_type ) \n" +
+            "(cus_id, pro_id, pro_name, parent_pro_id, parent_pro_name, ord_price, now_price, create_time, pro_check_method, pro_type,card_id ) \n" +
             "SELECT\n" +
             "#{cusId},\n" +
             "a.pro_id,a.pro_name,b.pro_id,b.pro_name,a.pro_price,a.pro_price,SYSDATE(),a.pro_check_method,\n" +
-            "IFNULL ( a.pro_type, '' ) \n" +
+            "IFNULL ( a.pro_type, '' ), \n" +
+            "#{cardId}\n" +
             "FROM\n" +
             "\ttj_project a\n" +
             "\tLEFT JOIN \n" +
@@ -156,7 +183,7 @@
             "\tON a.pro_parent_id = b.pro_id \n" +
             "WHERE\n" +
             "\ta.pro_id = #{proId}")
-    void saveRedisTransitionByProId(@Param("cusId")String cusId,@Param("proId") Long proId);
+    void saveRedisTransitionByProId(@Param("cusId")String cusId,@Param("cardId")String cardId,@Param("proId") Long proId);
 
 
     @Insert("INSERT INTO tb_transition(\n" +
@@ -211,4 +238,47 @@
 
     @Select("SELECT DISTINCT a.pac_id FROM tb_transition a WHERE a.tj_num=#{tjNum}AND a.card_id=#{cardId} AND !ISNULL(a.pac_id)")
     String selectPacIdByTbTransitionTjNumAndProId(@Param("tjNum")String tjNum,@Param("cardId")String cardId);
+
+    @Select("SELECT SUM(a.now_price) FROM tb_transition a WHERE a.cus_id=#{cusId} AND a.parent_pro_id=#{proId} and a.card_id=#{cardId} and a.pac_id=#{pacId}")
+    BigDecimal getTbTransitionDxPriceByPac(@Param("cusId")String cusId,@Param("proId")Long proId,@Param("cardId")String cardId,@Param("pacId")Long pacId);
+
+
+    @Update("UPDATE tb_transition a \n" +
+            "SET \n" +
+            "a.card_id=#{cardId}\n" +
+            "WHERE\n" +
+            "\ta.cus_id =#{idCard}\n" +
+            "\tAND a.tj_num = #{tjNumber}")
+    boolean updateCardIdByTjNumAndIdCard(@Param("idCard")String idCard,@Param("cardId")String cardId,@Param("tjNumber") String tjNumber);
+
+
+    @Delete("DELETE  FROM tb_transition WHERE jxbz=#{bldh}")
+    void deleteTjOrderDetailByjxbz(String bldh);
+
+    /**
+     * 鏍规嵁tjNum鍜宲arentProId鏌ヨ鎬讳环
+     * @param tjNum
+     * @param parentProId
+     * @return
+     */
+    @Select("SELECT SUM(now_price) FROM `tb_transition` WHERE `tj_num` = #{tjNum} AND `parent_pro_id` = #{parentProId}")
+    BigDecimal getLisPriceByTjNumAndParentProId(@Param("tjNum")String tjNum,@Param("parentProId")String parentProId);
+
+    /**
+     * 鏍规嵁tjNum鍜宲arentProId鏌ヨ鎬讳环
+     * @param tjNum
+     * @param parentProId
+     * @return
+     */
+    @Select({
+            "<script>",
+            "SELECT SUM(now_price) FROM `tb_transition`",
+            "WHERE `tj_num` = #{tjNum}",
+            "AND `parent_pro_id` IN",
+            "<foreach item='item' index='index' collection='parentProId' open='(' separator=',' close=')'>",
+            "#{item}",
+            "</foreach>",
+            "</script>"
+    })
+    BigDecimal getLisPriceByTjNumAndInParentProId(@Param("tjNum") String tjNum, @Param("parentProId") List<String> parentProId);
 }

--
Gitblit v1.8.0