fix
wzy
2022-10-31 3468c100b9ef9747f5202c412a4ecbd4789d8a5d
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
<?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="cc.mrbird.febs.dapp.mapper.IgtOnHookPlanOrderDao">
 
    <select id="selectByState" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrder">
        SELECT
            a.*
        FROM igt_on_hook_plan_order a
        where a.state = #{state}
    </select>
 
    <update id="updateAvaAmountById">
        update igt_on_hook_plan_order
        set
            ava_amount = ava_amount - #{amount}
        where
            id = #{id}
          and ava_amount - #{amount} <![CDATA[ >= ]]> 0
    </update>
 
    <update id="addAvaAmountById">
        update igt_on_hook_plan_order
        set
            ava_amount = ava_amount + #{amount}
        where
            id = #{id}
    </update>
 
    <select id="selectByMemberId" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrder">
        SELECT
            a.*
        FROM igt_on_hook_plan_order a
        where a.member_id = #{memberId}
        and a.state = 1
        order by id desc
            limit 1
    </select>
 
    <update id="AddProfitById">
        update igt_on_hook_plan_order
        set
            profit = profit + #{profit}
        where
            id = #{id}
    </update>
 
    <select id="selectSumProfitByMemberId" resultType="java.math.BigDecimal">
        SELECT
            ifnull(sum(a.profit),0)
        FROM igt_on_hook_plan_order a
        where a.member_id = #{memberId}
    </select>
 
    <select id="selectByCreateTime" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrder">
        SELECT
            a.*
        FROM igt_on_hook_plan_order a
        where and date_format(a.create_time, '%Y-%m-%d') = #{createTime}
    </select>
 
    <select id="findMemberPlanListInPage" resultType="cc.mrbird.febs.dapp.vo.AdminIgtOnHookPlanOrderVo">
        SELECT
        s.*,
        m.username username
        FROM
        igt_on_hook_plan_order s
        left join dapp_member m on m.id = s.member_id
        <where>
            <if test="record != null" >
                <if test="record.description!=null and record.description!=''">
                    (s.member_id in (select id from dapp_member where FIND_IN_SET(#{record.description}, referer_ids)))
                </if>
                <if test="record.state!=null and record.state!=''">
                    and s.state= #{record.state}
                </if>
                <if test="record.profitState!=null and record.profitState!=''">
                    and s.profit_state= #{record.profitState}
                </if>
            </if>
        </where>
        order by s.create_time desc
    </select>
 
</mapper>