xiaoyong931011
2021-05-28 19b5281d009c9bd70f15c6bfabc916942f892103
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?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.xcong.excoin.modules.yunding.dao.YdOrderDao">
 
    <select id="getOrderList" resultType="com.xcong.excoin.modules.yunding.vo.YdOrderVo">
        SELECT
        *
        FROM
        yd_order a
        inner join yd_product b on b.id = a.product_id
        <if test="record != null">
            <where>
                and a.member_id = #{record.memberId}
                and a.type=1
                <if test="record.state != null" >
                    and a.state=#{record.state}
                </if>
            </where>
        </if>
        ORDER BY a.create_time DESC
    </select>
 
    <select id="selectNeedReturnOrders" resultType="com.xcong.excoin.modules.yunding.entity.YdOrderEntity">
        select a.*, b.* from yd_order a
        left join yd_product b on a.product_id=b.id
        where a.state=2 and a.return_state=1
    </select>
 
    <resultMap id="orderMap" type="com.xcong.excoin.modules.yunding.entity.YdOrderEntity">
        <id column="id" property="id" />
        <result column="member_id" property="memberId" />
        <result column="product_id" property="productId" />
        <result column="quantity" property="quantity" />
        <result column="amount" property="amount" />
        <result column="member_id" property="memberId" />
        <result column="total_profit" property="totalProfit" />
        <result column="today_profit" property="totalProfit" />
        <result column="state" property="state" />
        <result column="buy_time" property="buyTime" />
        <result column="work_time" property="workTime" />
        <result column="end_time" property="endTime" />
        <result column="create_by" property="createBy" />
        <result column="return_state" property="returnState" />
        <result column="return_type" property="returnType" />
        <association property="ydProductEntity" javaType="com.xcong.excoin.modules.yunding.entity.YdProductEntity">
            <id column="p_id" property="id" />
            <result column="pro_unit" property="proUnit" />
            <result column="manage_expense" property="manageExpense" />
        </association>
    </resultMap>
 
    <select id="selectAllValidOrders" resultMap="orderMap">
        select a.*, b.id p_id, b.pro_unit, b.manage_expense from yd_order a
        inner join yd_product b on a.product_id=b.id
        where a.state=2 and a.type = 1
    </select>
 
    <update id="UpdateByIdAndState">
        UPDATE yd_order s
        SET s.state = #{state}
        WHERE
            id = #{id}
    </update>
 
    <select id="selectOrderByMemberIdAndId" resultType="com.xcong.excoin.modules.yunding.vo.YdOrderVo">
        SELECT
        *
        FROM
        yd_order a
        inner join yd_product b on b.id = a.product_id
        where a.member_id = #{memberId}
        and a.id = #{id}
    </select>
 
    <select id="getAgentList" resultType="com.xcong.excoin.modules.yunding.vo.AgentVo">
        SELECT
        *
        FROM
        yd_basic_level_setting a
        ORDER BY a.id ASC
    </select>
 
    <update id="updateAgentLevel">
        UPDATE member s
        SET s.agent_level = #{levelId}
        WHERE
            s.id = #{id}
    </update>
 
    <select id="selectTeamAllPower" resultMap="orderMap">
        select a.*, c.id p_id, c.pro_unit
            from yd_order a
        inner join (select * from member a where find_in_set(#{inviteId}, a.referer_ids) or invite_id=#{inviteId}) b on a.member_id=b.id
        inner join yd_product c on c.id = a.product_id
        where a.type=1
    </select>
 
    <update id="updateOrderProfit">
        update yd_order
            set total_profit=total_profit+#{profit},
                today_profit=#{profit}
        where id=#{id}
    </update>
 
    <select id="selectAllPowerByMemberIdAndElse" resultType="java.lang.Integer">
        select ifnull(sum(quantity),0) from yd_order where type = 1 and member_id in (
            select id from member
            where find_in_set(#{inviteId}, referer_ids) or invite_id=#{inviteId}
            )
    </select>
 
    <select id="getTeamInfoList" resultType="com.xcong.excoin.modules.yunding.vo.TeamInfoVo">
        SELECT
            a.invite_id invitephone
        FROM
            member a
        WHERE
            a.referer_id = #{record.inviteId}
    </select>
 
    <select id="selectMemberByInviteId" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
        select * from member
        where find_in_set(#{inviteId}, referer_ids) or invite_id=#{inviteId}
    </select>
 
    <select id="selectListByMemberIdAndElse" resultType="com.xcong.excoin.modules.yunding.entity.YdOrderEntity">
        select * from yd_order where type = 1 and member_id in (
            select id from member
            where find_in_set(#{inviteId}, referer_ids) or invite_id=#{inviteId}
        )
    </select>
 
</mapper>