zjh
2024-05-16 adaaa23c789be3313a0e554fbf7beaa8ab261e68
ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java
@@ -72,14 +72,20 @@
    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} AND pac_id=#{pacId}")
    public List<TbTransition> getTbTransitionListByCusIdAndPac(@Param("cusId") String cusId,@Param("pacId") String pacId);
    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId}")
    public List<TbTransition> getTbTransitionListByCusId(String cusId);
    @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)")
    public boolean deletedTbTransitionListByCusIdAndPac(String cusId);
    @Delete("DELETE FROM tb_transition WHERE cus_id=#{cusId} AND !ISNULL(pac_id) and card_id=#{cardId}")
    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}")
    public boolean deletedTbTransitionListByCusIdAndTjNum(@Param("cusId")String cusId,@Param("cardId")String cardId);
    //根据身份证号和套餐id查询和项目id
    @Select("SELECT * FROM tb_transition WHERE cus_id=#{cusId} AND ISNULL(pac_id) AND pro_id =#{proId}")
//    @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}")
    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)")
@@ -94,9 +100,10 @@
    @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}," +
            "a.tj_num=#{tjNum}"+
            " WHERE a.cus_id=#{cusId} ")
    boolean updateTbTransitionPriceByCusId(@Param("cusId")String cusId,@Param("discount")BigDecimal discount);
    boolean updateTbTransitionPriceByCusId(@Param("cusId")String cusId,@Param("discount")BigDecimal discount,@Param("tjNum")String tjNum);
    @Insert("INSERT INTO tb_transition(\n" +
@@ -121,8 +128,8 @@
            "\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" +
            " 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" +
@@ -132,8 +139,24 @@
            "\tLEFT JOIN tj_project c ON b.pro_id = c.pro_parent_id\n" +
            "\tLEFT JOIN tj_package d ON a.pac_id=d.pac_id\n" +
            "\t\n" +
            "\tWHERE a.pac_id=#{pacId}")
            "\tWHERE a.pac_id=#{pacId} and c.deleted=0")
    void saveRedisTransitionByPacId(@Param("cusId") String cusId,@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" +
            "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" +
            "FROM\n" +
            "\ttj_project a\n" +
            "\tLEFT JOIN \n" +
            "\ttj_project b \n" +
            "\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);
    @Insert("INSERT INTO tb_transition(\n" +
@@ -149,20 +172,46 @@
            "   pro_type\n" +
            ")\n" +
            "SELECT\n" +
            "\t#{cusId},\n" +
            "\tb.pro_id,\n" +
            "\tb.pro_name,\n" +
            "\ta.pro_id,\n" +
            "\ta.pro_name,\n" +
            "\tb.pro_price,\n" +
            "\tb.pro_price,\n" +
            "\tSYSDATE(),\n" +
            "\tb.pro_check_method,\n" +
            "\tIFNULL(b.pro_type,'')\n" +
            "#{cusId},\n" +
            "c.pro_id,\n" +
            "c.pro_name,\n" +
            "b.pro_id,\n" +
            "b.pro_name,\n" +
            "c.pro_price * (a.limits/10),\n" +
            "c.pro_price * (a.limits/10),\n" +
            "SYSDATE(),\n" +
            "c.pro_check_method,\n" +
            "c.pro_type\n" +
            "FROM\n" +
            "\ttj_project a\n" +
            "\tLEFT JOIN tj_project b ON b.pro_parent_id = a.pro_id \n" +
            "WHERE\n" +
            "\ta.pro_id = #{proId} ")
    void saveRedisTransitionByProId(@Param("cusId")String cusId,@Param("proId") Long proId);
            "\ttj_grouping_pro a\n" +
            "\tLEFT JOIN tj_project b ON a.pro_id = b.pro_id \n" +
            "\tLEFT JOIN tj_project c ON c.pro_parent_id=b.pro_id\n" +
            "WHERE 1=1 AND a.grouping_id =#{groupingId} and c.deleted=0 ")
    boolean saveTemoTransitionByGroupingId(@Param("cusId")String cusId,@Param("groupingId")String groupingId);
//    @Select("SELECT b.price_now FROM \n" +
//            "(SELECT a.pac_id FROM tb_transition a  WHERE\n" +
//            "\ta.cus_id = #{cusId} \n" +
//            "GROUP BY\n" +
//            "\ta.pac_id) aa \n" +
//            "LEFT JOIN tj_package_project b\n" +
//            "\tON aa.pac_id=b.pac_id WHERE b.pro_id=#{proId} ")
//    BigDecimal getTbTransitionPriceAndOrdPrice(@Param("cusId")String cusId,@Param("proId")Long proId);
    @Select("SELECT SUM(a.now_price) FROM tb_transition a WHERE a.cus_id=#{cusId} AND a.parent_pro_id=#{proId}")
    BigDecimal getTbTransitionPriceAndOrdPrice(@Param("cusId")String cusId,@Param("proId")Long proId);
    @Select("SELECT SUM(c.pro_price) FROM tj_project c WHERE c.pro_id IN " +
            "(SELECT b.pro_id FROM tb_transition b WHERE" +
            " b.cus_id=(SELECT a.cus_idcard FROM tj_customer a " +
            "WHERE a.cus_id=#{cusId}) AND b.parent_pro_id=#{proId})  ")
    BigDecimal getTbTransitionDxPriceAndOrdPrice(@Param("cusId")String cusId,@Param("proId")Long proId);
    @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);
}