|  |  |  | 
|---|
|  |  |  | <mapper namespace="cc.mrbird.febs.mall.mapper.MallMemberMapper"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMallMemberListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | SELECT * FROM mall_member m | 
|---|
|  |  |  | SELECT m.*,a.name referrerName,IFNULL(c.balance,0) balance,IFNULL(c.score,0) score,IFNULL(c.prize_score,0) prizeScore,IFNULL(c.commission,0) commission | 
|---|
|  |  |  | ,d.description levelName | 
|---|
|  |  |  | FROM mall_member m | 
|---|
|  |  |  | left join mall_member a on m.referrer_id = a.invite_id | 
|---|
|  |  |  | LEFT JOIN mall_member_wallet c on c.member_id = m.id | 
|---|
|  |  |  | LEFT JOIN data_dictionary_custom d on d.code = m.level | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | m.id != 1 | 
|---|
|  |  |  | <if test="record != null" > | 
|---|
|  |  |  | <if test="record.name!=null and record.name!=''"> | 
|---|
|  |  |  | and m.name like concat('%',  #{record.name},'%') | 
|---|
|  |  |  | 
|---|
|  |  |  | and ( | 
|---|
|  |  |  | m.phone like concat('%',  #{record.account},'%') | 
|---|
|  |  |  | or m.email like concat('%',  #{record.account},'%') | 
|---|
|  |  |  | or m.bind_phone like concat('%',  #{record.account},'%') | 
|---|
|  |  |  | or m.invite_id like concat('%',  #{record.account},'%') | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | 
|---|
|  |  |  | <if test="record.accountType != null" > | 
|---|
|  |  |  | and m.account_type = #{record.accountType} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.level!=null and record.level!=''"> | 
|---|
|  |  |  | and m.level=#{record.level} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.accountLevel!=null and record.accountLevel!=''"> | 
|---|
|  |  |  | and m.account_level=#{record.accountLevel} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | order by m.CREATED_TIME desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getMallMemberInfoById" resultType="cc.mrbird.febs.mall.vo.MallMemberVo"> | 
|---|
|  |  |  | SELECT a.name, | 
|---|
|  |  |  | SELECT a.id, | 
|---|
|  |  |  | a.name, | 
|---|
|  |  |  | a.phone, | 
|---|
|  |  |  | a.email, | 
|---|
|  |  |  | a.sex, | 
|---|
|  |  |  | 
|---|
|  |  |  | a.level, | 
|---|
|  |  |  | a.account_status, | 
|---|
|  |  |  | a.CREATED_TIME, | 
|---|
|  |  |  | c.balance, | 
|---|
|  |  |  | IFNULL(c.balance,0) balance, | 
|---|
|  |  |  | d.description levelName, | 
|---|
|  |  |  | b.name | 
|---|
|  |  |  | FROM mall_member a | 
|---|
|  |  |  | LEFT JOIN mall_member b on a.referrer_id = b.invite_id | 
|---|
|  |  |  | LEFT JOIN mall_member_wallet c on c.member_id = a.id | 
|---|
|  |  |  | LEFT JOIN data_dictionary_custom d on d.description = a.level | 
|---|
|  |  |  | where a.id = #{id} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectInfoByAccount" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member where phone=#{account} or email=#{account} | 
|---|
|  |  |  | select * from mall_member where phone=#{account} or email=#{account} or invite_id=#{account} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectInfoByInviteId" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | 
|---|
|  |  |  | <select id="selectInfoByAccountAndPwd" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member where (phone=#{account} or email=#{account}) and password=#{password} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectTeamListByInviteId" resultType="cc.mrbird.febs.mall.vo.TeamListVo"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | a.id, | 
|---|
|  |  |  | a.name, | 
|---|
|  |  |  | a.phone, | 
|---|
|  |  |  | a.invite_id, | 
|---|
|  |  |  | a.account_level, | 
|---|
|  |  |  | a.level, | 
|---|
|  |  |  | 2 isCurrent, | 
|---|
|  |  |  | a.created_time, | 
|---|
|  |  |  | (select sum(e.amount) | 
|---|
|  |  |  | from mall_order_info e | 
|---|
|  |  |  | inner join mall_member b on e.member_id=b.ID | 
|---|
|  |  |  | where e.status = 4 and e.comment_state = 2 and (find_in_set(a.invite_id, b.referrer_ids) or b.invite_id = a.invite_id)) amount, | 
|---|
|  |  |  | (select count(1) from mall_order_info b | 
|---|
|  |  |  | inner join mall_member e on e.id=b.member_id and b.status = 4 and b.comment_state = 2 | 
|---|
|  |  |  | where find_in_set(a.invite_id, e.referrer_ids) OR e.invite_id = a.invite_id) orderCnt, | 
|---|
|  |  |  | (select count(1) from mall_member x where find_in_set(a.invite_id, x.referrer_ids)) cnt | 
|---|
|  |  |  | from mall_member a | 
|---|
|  |  |  | inner join mall_member_wallet p on a.id=p.member_id | 
|---|
|  |  |  | where a.referrer_id=#{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectOwnOrderAmountByInviteId" resultType="java.math.BigDecimal"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | IFNULL(sum(b.amount),0) | 
|---|
|  |  |  | from mall_member e | 
|---|
|  |  |  | inner join mall_order_info b on e.id=b.member_id and b.status in (2, 3, 4) | 
|---|
|  |  |  | where e.invite_id=#{inviteId} or e.referrer_id=#{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectOwnCntByInviteId" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select IFNULL(count(1),0) from mall_member x where x.referrer_id=#{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectOwnOrderCntByInviteId" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | IFNULL(count(1),0) | 
|---|
|  |  |  | from mall_member e | 
|---|
|  |  |  | inner join mall_order_info b on e.id=b.member_id and b.status in (2, 3, 4) | 
|---|
|  |  |  | where e.invite_id=#{inviteId} or e.referrer_id=#{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByRefererId" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where referrer_id=#{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectChildAgentList" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where (find_in_set(#{inviteId}, referrer_ids) or invite_id=#{inviteId}) and level=#{agentLevel} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByInviteIds" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where  invite_id IN | 
|---|
|  |  |  | <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" > | 
|---|
|  |  |  | #{item} | 
|---|
|  |  |  | </foreach > | 
|---|
|  |  |  | order by id desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAgentListInPage" resultType="cc.mrbird.febs.mall.vo.AdminAgentVo"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SELECT m.*,a.description levelName | 
|---|
|  |  |  | FROM mall_member m | 
|---|
|  |  |  | left join data_dictionary_custom a on a.description = m.level | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 1= 1 | 
|---|
|  |  |  | and m.level != 'VIP' | 
|---|
|  |  |  | <if test="record != null" > | 
|---|
|  |  |  | <if test="record.name!=null and record.name!=''"> | 
|---|
|  |  |  | and m.name like concat('%',  #{record.name},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.level!=null and record.level!=''"> | 
|---|
|  |  |  | and m.level = #{record.level} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.account!=null and record.account!=''"> | 
|---|
|  |  |  | and m.phone like concat('%',  #{record.account},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by m.id | 
|---|
|  |  |  | order by m.CREATED_TIME desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectChildAgentListByInviteId" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member where  referrer_id = #{inviteId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectAllChildAgentListByInviteId" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member where  find_in_set(#{inviteId}, referrer_ids) | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberParentAgentList" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where level not in  ('ZERO_LEVEL', 'FIRST_LEVEL') and invite_id!=#{refererId} and invite_id IN | 
|---|
|  |  |  | <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" > | 
|---|
|  |  |  | #{item} | 
|---|
|  |  |  | </foreach > | 
|---|
|  |  |  | order by id desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAgentLevelListInPage" resultType="cc.mrbird.febs.mall.vo.AdminAgentLevelVo"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | a.id,a.description name | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | data_dictionary_custom a | 
|---|
|  |  |  | where a.type = 'MEMBER_AGENT_LEVEL' | 
|---|
|  |  |  | ORDER BY | 
|---|
|  |  |  | a.CREATED_TIME DESC | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAgentChildInPage" resultType="cc.mrbird.febs.mall.vo.AdminAgentMemberVo"> | 
|---|
|  |  |  | select m.*,a.description levelName from mall_member m | 
|---|
|  |  |  | left join data_dictionary_custom a on a.description = m.level | 
|---|
|  |  |  | where  find_in_set(#{record.inviteId}, m.referrer_ids) | 
|---|
|  |  |  | GROUP BY m.id | 
|---|
|  |  |  | ORDER BY | 
|---|
|  |  |  | m.CREATED_TIME DESC | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getRankAwardListInPage" resultType="cc.mrbird.febs.mall.vo.AdminRankAwardVo"> | 
|---|
|  |  |  | select a.* from data_dictionary_custom a where a.type = 'RANK_AWARD' or a.type = 'RANK_AWARD_SETTING' | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAgentTeamAmountByInviteId" resultType="java.math.BigDecimal"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | ifnull(sum(b.amount),0) | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_order_info b | 
|---|
|  |  |  | INNER JOIN mall_member e ON e.id = b.member_id | 
|---|
|  |  |  | and b.comment_state = 2 | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | e.invite_id = #{inviteId} | 
|---|
|  |  |  | or find_in_set(#{inviteId}, e.referrer_ids) | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAppVersionListInPage" resultType="cc.mrbird.febs.mall.entity.AppVersion"> | 
|---|
|  |  |  | select a.* from app_version a | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByIdAndNoLevel" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member where level != #{level} | 
|---|
|  |  |  | <if test="refererId != null and refererId != ''"> | 
|---|
|  |  |  | and referrer_id=#{refererId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMallMemberByInviteIdAndLevel" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | m.*, b. | 
|---|
|  |  |  | VALUE | 
|---|
|  |  |  |  | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_member m | 
|---|
|  |  |  | LEFT JOIN data_dictionary_custom b ON m. LEVEL = b. CODE | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | find_in_set(#{inviteId}, m.referrer_ids) | 
|---|
|  |  |  | AND b.type = 'AGENT_LEVEL' | 
|---|
|  |  |  | AND b.VALUE > ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | VALUE | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | data_dictionary_custom a | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | a. CODE = #{level} | 
|---|
|  |  |  | AND a.type = 'AGENT_LEVEL' | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | m.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAgentLevelSetInfoByMemberId" resultType="cc.mrbird.febs.mall.vo.AdminAgentLevelSetInfoVo"> | 
|---|
|  |  |  | SELECT d.description levelCode | 
|---|
|  |  |  | FROM mall_member a | 
|---|
|  |  |  | LEFT JOIN data_dictionary_custom d on d.description = a.level | 
|---|
|  |  |  | where a.id = #{id} and d.type = 'MEMBER_AGENT_LEVEL' | 
|---|
|  |  |  | GROUP BY a.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getMallDataListInPage" resultType="cc.mrbird.febs.mall.vo.MallDataVo"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') createdTime, | 
|---|
|  |  |  | IFNULL(t1.tol, 0) *- 1 AS payMoney, | 
|---|
|  |  |  | IFNULL(t2.to2, 0) AS refundMoney, | 
|---|
|  |  |  | IFNULL(t3.to3, 0) *- 1 AS rewordMoney, | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | (IFNULL(t1.tol, 0)*- 1) - (IFNULL(t2.to2, 0)) + (IFNULL(t3.to3, 0)*- 1) | 
|---|
|  |  |  | ) AS surplusMoney | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_money_flow a | 
|---|
|  |  |  | LEFT JOIN ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | b.CREATED_TIME, | 
|---|
|  |  |  | IFNULL(SUM(b.amount), 0) AS tol | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_money_flow b | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | b.type = 3 | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | DATE_FORMAT(b.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | ) t1 ON DATE_FORMAT(t1.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | LEFT JOIN ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | c.CREATED_TIME, | 
|---|
|  |  |  | IFNULL(SUM(c.amount), 0) AS to2 | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_money_flow c | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | c.type = 4 | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | DATE_FORMAT(c.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | ) t2 ON DATE_FORMAT(t2.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | LEFT JOIN ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | d.CREATED_TIME, | 
|---|
|  |  |  | IFNULL(SUM(d.amount), 0) AS to3 | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_money_flow d | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | d.type IN (1, 2) | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | DATE_FORMAT(d.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | ) t3 ON DATE_FORMAT(t3.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') | 
|---|
|  |  |  | ORDER BY | 
|---|
|  |  |  | DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') DESC | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--    <select id="selectRankListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember">--> | 
|---|
|  |  |  | <!--        select a.*, b.*--> | 
|---|
|  |  |  | <!--        from mall_member a--> | 
|---|
|  |  |  | <!--            inner join (--> | 
|---|
|  |  |  | <!--                select b.referrer_id refererId, sum(a.amount) amount, max(a.order_time) orderTime--> | 
|---|
|  |  |  | <!--                    from mall_order_info a--> | 
|---|
|  |  |  | <!--                    inner join mall_member b on a.member_id=b.ID--> | 
|---|
|  |  |  | <!--                    inner join mall_order_item c on a.id = c.order_id and c.is_normal=2--> | 
|---|
|  |  |  | <!--                where a.status in (2, 3, 4) and a.order_type=1--> | 
|---|
|  |  |  | <!--                <!– 月 –>--> | 
|---|
|  |  |  | <!--                <if test="record.query == '2'">--> | 
|---|
|  |  |  | <!--                    and date_format(#{record.createdTime},'%Y-%m') = date_format(b.order_time,'%Y-%m')--> | 
|---|
|  |  |  | <!--                </if>--> | 
|---|
|  |  |  | <!--                group by b.referrer_id--> | 
|---|
|  |  |  | <!--            ) b  on a.invite_id=b.refererId--> | 
|---|
|  |  |  | <!--        order by b.amount desc, b.orderTime desc--> | 
|---|
|  |  |  | <!--    </select>--> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectRankListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select a.*, b.* | 
|---|
|  |  |  | from mall_member a | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | select b.referrer_id refererId, sum(a.amount) amount, max(a.pay_time) orderTime | 
|---|
|  |  |  | from mall_achieve_record a | 
|---|
|  |  |  | inner join mall_member b on a.member_id=b.ID | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | <!-- 月 --> | 
|---|
|  |  |  | <if test="record.query == 2"> | 
|---|
|  |  |  | and date_format(#{record.createdTime},'%Y-%m') = date_format(a.achieve_time,'%Y-%m') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | group by b.referrer_id | 
|---|
|  |  |  | ) b  on a.invite_id=b.refererId | 
|---|
|  |  |  | order by b.amount desc, b.orderTime desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectAchieveByMemberId" resultType="java.math.BigDecimal"> | 
|---|
|  |  |  | select IFNULL(sum(IFNULL(a.amount, 0)), 0) | 
|---|
|  |  |  | from mall_order_info a | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | and a.comment_state = 2 | 
|---|
|  |  |  | <if test="type == 1"> | 
|---|
|  |  |  | and b.invite_id=#{inviteId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="type == 2"> | 
|---|
|  |  |  | AND a.member_id IN ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | id | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_member | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | 1 = 1 | 
|---|
|  |  |  | AND ( | 
|---|
|  |  |  | find_in_set(#{inviteId}, referrer_ids) | 
|---|
|  |  |  | OR invite_id = #{inviteId} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberByName" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where name=#{name} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberListHasChild" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select distinct a.* from mall_member a, mall_member b | 
|---|
|  |  |  | where a.invite_id=b.referrer_id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberDirectForHasLevel" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where referrer_id=#{inviteId} and level != 'ZERO_LEVEL' | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectDirectorsOrStoreMaster" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 1=1 | 
|---|
|  |  |  | <if test="type == 1"> | 
|---|
|  |  |  | and director = 1 | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="type == 2"> | 
|---|
|  |  |  | and store_master = 1 | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberWithLevel" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where level=#{level} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByAccountLevel" resultType="cc.mrbird.febs.mall.entity.MallMember"> | 
|---|
|  |  |  | select * from mall_member | 
|---|
|  |  |  | where account_level = #{accountLevel} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByRefererIdAndAccountLevel" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select count(id) from mall_member | 
|---|
|  |  |  | where account_level != #{accountLevel} | 
|---|
|  |  |  | and referer_id = #{refererId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByReferersIdAndAccountLevel" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select count(id) from mall_member | 
|---|
|  |  |  | where account_level != #{accountLevel} | 
|---|
|  |  |  | and FIND_IN_SET(#{inviteId}, referrer_ids) | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <update id="updateLevelById"> | 
|---|
|  |  |  | update mall_member | 
|---|
|  |  |  | set | 
|---|
|  |  |  | level = #{level} | 
|---|
|  |  |  | where | 
|---|
|  |  |  | id = #{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByReferersIdAndLevel" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select count(id) from mall_member | 
|---|
|  |  |  | where level = #{level} | 
|---|
|  |  |  | and FIND_IN_SET(#{inviteId}, referrer_ids) | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <update id="updateAccountLevelById"> | 
|---|
|  |  |  | update mall_member | 
|---|
|  |  |  | set | 
|---|
|  |  |  | account_level = #{accountLevel} | 
|---|
|  |  |  | where | 
|---|
|  |  |  | id = #{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <update id="updateLevelStatusById"> | 
|---|
|  |  |  | update mall_member | 
|---|
|  |  |  | set | 
|---|
|  |  |  | level_status = #{levelStatus} | 
|---|
|  |  |  | where | 
|---|
|  |  |  | id = #{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectMemberChargeListInPage" resultType="cc.mrbird.febs.mall.entity.MemberCoinChargeEntity"> | 
|---|
|  |  |  | SELECT a.*, | 
|---|
|  |  |  | b.name name | 
|---|
|  |  |  | FROM member_coin_charge a | 
|---|
|  |  |  | inner join mall_member b on a.member_id = b.id | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="record != null" > | 
|---|
|  |  |  | <if test="record.name!=null and record.name!=''"> | 
|---|
|  |  |  | and b.name like concat('%',  #{record.name},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.address!=null and record.address!=''"> | 
|---|
|  |  |  | and a.address like concat('%',  #{record.address},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | order by a.CREATED_TIME desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getSumAmountByMemberId" resultType="java.math.BigDecimal"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | IFNULL(sum(IFNULL(a.amount, 0)), 0) | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | mall_order_info a | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | 1 = 1 | 
|---|
|  |  |  | AND a.comment_state = 2 | 
|---|
|  |  |  | and a.member_id = #{memberId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|