fuliqi
2024-08-21 9da24a8dfa3766cec565b092fc105f7f006de070
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
<?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.ycl.platform.mapper.TContractMapper">
 
    <select id="selectAll" resultType="com.ycl.platform.domain.entity.TContract">
        select a.*, b.unit_name
        from t_contract a
                 left join t_yw_unit b on a.unit_id = b.id and b.deleted = 0
        where a.deleted = 0
        order by create_time desc
    </select>
 
    <select id="getPage" resultType="com.ycl.platform.domain.vo.ContractVO">
        select a.*, b.unit_name
        from t_contract a
        left join t_yw_unit b on a.unit_id = b.id and b.deleted = 0
        where a.deleted = 0
        <if test="query.name != null and query.name != ''">
            and a.name like concat('%', #{query.name}, '%')
        </if>
        <if test="query.status != null and query.status != ''">
            <choose>
                <when test="query.status == 'ACTIVE'">
                    and a.start_time &lt; sysdate() and a.end_time > sysdate()
                </when>
                <when test="query.status == 'NOT_START'">
                    and a.start_time > sysdate()
                </when>
                <when test="query.status == 'FINISHED'">
                    and a.end_time &lt; sysdate()
                </when>
            </choose>
        </if>
        order by create_time desc
    </select>
 
    <select id="selectByRuleName" resultType="com.ycl.platform.domain.vo.CalculateRuleVO">
        select tc.unit_id ,tcr.*
        from t_contract tc
        left join t_calculate_rule tcr on tc.id = tcr.contract_id
        <where>
            tc.deleted =0 and #{time} between tc.start_time and tc.end_time
            <if test="ruleName !=null and ruleName!=''">
                tcr.rule_name = #{ruleName}
            </if>
            <if test="ruleCondition !=null and ruleCondition!=''">
                tcr.rule_condition = #{ruleCondition}
            </if>
        </where>
 
    </select>
</mapper>