liujie
2025-07-21 87f979fb201a82ebad5926735ed6dfa75ca004d3
ruoyi-system/src/main/resources/mapper/system/TbCompanyMapper.xml
@@ -49,17 +49,23 @@
    <select id="getMyPushCompanyList" resultType="com.ruoyi.system.vo.MyPushCompanyListVo">
        select * from (
                          select t1.id,t1.company_name,t1.create_time,t1.sale_money ,t2.id orderId,
                                 case
                                     when t1.status=2 then 6
                                     else
                                 COALESCE(t2.status, 1) END AS status
                          from tb_company t1
                                   left join tb_order t2 on t1.id = t2.company_id
                          where t1.user_id = #{userId} and t1.is_delete =0
                      ) as t3 where 1= 1
            <if test="query.status!=null">
                and t3.status = #{query.status}
        select DISTINCT t1.id,t1.company_name,t1.create_time,t1.sale_money ,t1.status state,
        case
        when (select count(*) from tb_order where company_id = t1.id) = 0 then 1
        when (select count(*) from tb_order where company_id = t1.id and status = -1) >= 1 and (select count(*) from tb_order where company_id = t1.id and status != -1) = 0 then 1
        when (select count(*) from tb_order where company_id = t1.id and status != -1) >= 1 then (select status from tb_order where company_id = t1.id and status != -1 order by create_time desc limit 1)
        else
        COALESCE(t2.status, 1) END AS status
        from tb_company t1
        left join tb_order t2 on t1.id = t2.company_id
        where t1.user_id = #{userId} and t1.is_delete =0
        ) as t3 where 1=1
        <if test="query.status!=null and query.status!=6">
                and t3.status = #{query.status} and t3.state !=2
            </if>
            <if test="query.status!=null and  query.status==6">
                and t3.status  in (5,6)
            </if>
        order by t3.create_time desc
@@ -68,15 +74,18 @@
    <select id="getMyPushCompanyListNum" resultType="com.ruoyi.system.vo.MyPushCompanyListVo"
            parameterType="java.lang.Long">
        select * from (
        select t1.id,t1.company_name,t1.create_time,t1.sale_money ,t2.id orderId,
        case when t1.status=2 then 6
        else
        COALESCE(t2.status, 1) END AS status
        from tb_company t1
        left join tb_order t2 on t1.id = t2.company_id
        where t1.user_id = #{userId}  and t1.is_delete =0
                      ) as t3 where 1= 1
        order by t3.create_time desc
                          select DISTINCT t1.id,t1.company_name,t1.create_time,t1.sale_money ,t1.status state,
                                          case
                                              when (select count(*) from tb_order where company_id = t1.id) = 0 then 1
                                              when (select count(*) from tb_order where company_id = t1.id and status = -1) >= 1 and (select count(*) from tb_order where company_id = t1.id and status != -1) = 0 then 1
                                     when (select count(*) from tb_order where company_id = t1.id and status != -1) >= 1 then (select status from tb_order where company_id = t1.id and status != -1 order by create_time desc limit 1)
                                     else
                                 COALESCE(t2.status, 1) END AS status
                          from tb_company t1
                                   left join tb_order t2 on t1.id = t2.company_id
                          where t1.user_id = #{userId} and t1.is_delete =0
                      ) as t3 where t3.state !=2
    </select>
</mapper>