zjh
2024-01-24 aa33bb96ba9f14b16c6c7832e21bfbd88983ba6d
ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TbTransitionMapper.java
@@ -72,13 +72,19 @@
    @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}")
//    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);
@@ -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" +
@@ -179,16 +186,29 @@
            "\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} ")
            "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} ")
//    @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}")
    String selectPacIdByTbTransitionTjNumAndProId(@Param("tjNum")String tjNum);
}