liujie
6 天以前 dd2a17ce4ebdfcaecc971f17c0f4d648ec5c2095
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.TbCompanyMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TbCompany">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="company_name" property="companyName" />
        <result column="city" property="city" />
        <result column="city_code" property="cityCode" />
        <result column="province" property="province" />
        <result column="province_code" property="provinceCode" />
        <result column="area" property="area" />
        <result column="area_code" property="areaCode" />
        <result column="establish_time" property="establishTime" />
        <result column="company_category" property="companyCategory" />
        <result column="company_industry_id" property="companyIndustryId" />
        <result column="taxpayer_type" property="taxpayerType" />
        <result column="tax_credit" property="taxCredit" />
        <result column="estimated_days" property="estimatedDays" />
        <result column="official_seal_num" property="officialSealNum" />
        <result column="paid_in_funds" property="paidInFunds" />
        <result column="link" property="link" />
        <result column="invoice_limit" property="invoiceLimit" />
        <result column="registered_capital" property="registeredCapital" />
        <result column="high_tech_enterprise_technology" property="highTechEnterpriseTechnology" />
        <result column="social_security" property="socialSecurity" />
        <result column="tendering" property="tendering" />
        <result column="have_trademark" property="haveTrademark" />
        <result column="trademark_num" property="trademarkNum" />
        <result column="have_patent" property="havePatent" />
        <result column="patent_num" property="patentNum" />
        <result column="have_soft_works" property="haveSoftWorks" />
        <result column="soft_works_num" property="softWorksNum" />
        <result column="rename_money" property="renameMoney" />
        <result column="rename_day" property="renameDay" />
        <result column="relocation_area_money" property="relocationAreaMoney" />
        <result column="relocation_area_day" property="relocationAreaDay" />
        <result column="sale_money" property="saleMoney" />
        <result column="phone" property="phone" />
        <result column="recipient" property="recipient" />
        <result column="recipient_address" property="recipientAddress" />
        <result column="information" property="information" />
        <result column="remark" property="remark" />
        <result column="create_time" property="createTime" />
    </resultMap>
 
 
    <select id="getMyPushCompanyList" resultType="com.ruoyi.system.vo.MyPushCompanyListVo">
        select * from (
        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
 
 
    </select>
    <select id="getMyPushCompanyListNum" resultType="com.ruoyi.system.vo.MyPushCompanyListVo"
            parameterType="java.lang.Long">
        select * from (
                          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>