xiaoyong931011
2023-01-10 73b3813c2d110bf446f251350f120bb1e2b51d0c
src/main/resources/mapper/modules/MallMemberMapper.xml
@@ -31,6 +31,9 @@
                <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
@@ -47,16 +50,13 @@
               a.account_status,
               a.CREATED_TIME,
               IFNULL(c.balance,0) balance,
               IFNULL(c.score,0) score,
               IFNULL(c.prize_score,0) prizeScore,
               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.code = a.level
            LEFT JOIN data_dictionary_custom d on d.description = a.level
            where a.id = #{id}
            GROUP BY a.id
    </select>
    <select id="selectInfoByAccount" resultType="cc.mrbird.febs.mall.entity.MallMember">
@@ -77,22 +77,20 @@
            a.name,
            a.phone,
            a.invite_id,
            a.account_level,
            a.level,
            2 isCurrent,
            a.created_time,
            p.prize_score,
            u.description levelName,
            (select sum(e.amount)
             from mall_order_info e
                      inner join mall_member b on e.member_id=b.ID
                      inner join mall_order_item c on e.id = c.order_id -- and c.is_normal=2
             where e.status in (2, 3, 4) and e.order_type=1 and (b.invite_id=a.invite_id or b.referrer_id=a.invite_id)) amount,
            (select count(1) from mall_member e
                      inner join mall_order_info b on e.id=b.member_id and b.status in (2, 3, 4)
             where find_in_set(a.invite_id, e.referrer_ids)) orderCnt,
             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
        left join data_dictionary_custom u on a.level=u.code and u.type='AGENT_LEVEL'
        where a.referrer_id=#{inviteId}
    </select>
@@ -137,22 +135,12 @@
    <select id="getAgentListInPage" resultType="cc.mrbird.febs.mall.vo.AdminAgentVo">
        SELECT m.*,a.description levelName,
        ifnull((
        SELECT
        sum(b.amount)
        FROM
        mall_member e
        INNER JOIN mall_order_info b ON e.id = b.member_id
        AND b. STATUS = 4
        WHERE
        e.invite_id = m.invite_id
        OR e.referrer_id = m.invite_id
        or find_in_set(m.invite_id, e.referrer_ids)
        ),0) amount
        SELECT m.*,a.description levelName
        FROM mall_member m
        left join data_dictionary_custom a on a.code = m.level
        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},'%')
@@ -188,12 +176,10 @@
    <select id="getAgentLevelListInPage" resultType="cc.mrbird.febs.mall.vo.AdminAgentLevelVo">
        SELECT
            a.id,b.description name
            a.id,a.description name
        FROM
            data_dictionary_custom a
                left JOIN data_dictionary_custom b on a.code = b.code
        where a.type = 'AGENT_LEVEL_REQUIRE'
        GROUP BY a.id
        where a.type = 'MEMBER_AGENT_LEVEL'
        ORDER BY
            a.CREATED_TIME DESC
    </select>
@@ -216,12 +202,11 @@
            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 = 4
                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 e.referrer_id = #{inviteId}
               or find_in_set(#{inviteId}, e.referrer_ids)
    </select>
@@ -263,10 +248,10 @@
    <select id="getAgentLevelSetInfoByMemberId" resultType="cc.mrbird.febs.mall.vo.AdminAgentLevelSetInfoVo">
        SELECT a.id,d.code levelCode
        SELECT d.description levelCode
        FROM mall_member a
                 LEFT JOIN data_dictionary_custom d on d.code = a.level
        where a.id = #{id} and d.type = 'AGENT_LEVEL'
                 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>
@@ -357,14 +342,25 @@
    <select id="selectAchieveByMemberId" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(a.amount, 0)), 0)
        from mall_achieve_record a
             inner join mall_member b on a.member_id=b.ID
        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 find_in_set(#{inviteId}, b.referrer_ids)
            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>
@@ -439,4 +435,41 @@
        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>