xiaoyong931011
2023-09-21 54be1e5481d58ea7fa39a34c0bd0e442c406a4b8
src/main/resources/mapper/dapp/DappMemberDao.xml
@@ -4,28 +4,513 @@
    <select id="selectByAddress" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where address=#{address}
        <if test="chain != null and chain != ''">
            and chain_type=#{chain}
        </if>
    </select>
    <select id="selectMemberInfoByInviteId" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where invite_id=#{inviteId}
        select * from dapp_member where invite_id = #{inviteId}
    </select>
    <select id="selectInPage" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        select a.*,
        IFNULL(b.available_amount, 0) coinAmount,
        IFNULL(c.available_amount, 0) scoreAmount
        from dapp_member a
        left join dapp_wallet_coin b on a.id = b.member_id
        left join dapp_wallet_mine c on a.id = c.member_id
        <where>
            <if test="record.currentUser != null">
                and a.referer_id = (select invite_id from dapp_user_member_relate where user_id=#{record.currentUser})
            </if>
            <if test="record.accountStatus != null">
                and account_status = #{record.accountStatus}
                and a.account_status = #{record.accountStatus}
            </if>
            <if test="record.accountType != null and record.accountType != ''">
                and a.account_type = #{record.accountType}
            </if>
            <if test="record.changeAble != null">
                and change_able = #{record.changeAble}
                and a.change_able = #{record.changeAble}
            </if>
            <if test="record.withdrawAble != null">
                and withdraw_able = #{record.withdrawAble}
                and a.withdraw_able = #{record.withdrawAble}
            </if>
            <if test="record.inviteId != null and record.inviteId != ''">
                and invite_id = #{record.inviteId}
                and (a.invite_id = #{record.inviteId} or a.address = #{record.inviteId})
            </if>
        </where>
        order by create_time desc
        order by a.create_time desc
    </select>
    <select id="selectAllMemberForInCome" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where balance > 0
    </select>
    <select id="selectAgentMemberList" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member a
        inner join dapp_user_member_relate b on a.id=b.member_id
        <where>
            1=1
            <if test="list != null">
                and a.invite_id in
                <foreach collection="list" close=")" open="(" item="item" separator=",">
                    ${item}
                </foreach>
            </if>
        </where>
        <if test="size != null">
            limit ${size}
        </if>
    </select>
    <select id="selectParentsList" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member a
        <where>
            1=1
            <if test="list != null">
                and a.invite_id in
                <foreach collection="list" close=")" open="(" item="item" separator=",">
                    ${item}
                </foreach>
            </if>
        </where>
        order by id desc
        <if test="size != null">
            limit ${size}
        </if>
    </select>
    <select id="selectAllBalance" resultType="java.math.BigDecimal">
        select ifnull(sum(balance), 0)
        from dapp_member
        <where>
            1=1
            <if test="accountType != null">
                and account_type=#{accountType}
            </if>
        </where>
    </select>
    <select id="selectMemberByAccountType" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        where
            active_status = 1
          and change_able = 1
            and account_type = #{accountType}
    </select>
    <select id="selectChildMemberDirectOrNot" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        <where>
            change_able = 1
            <if test="type==1">
                and referer_id=#{inviteId}
            </if>
            <if test="type==2">
                and find_in_set(#{inviteId}, fee_profit_ids)
            </if>
            <if test="status != null">
                and active_status=#{status}
            </if>
        </where>
    </select>
    <select id="selectChildHoldAmount" resultType="java.math.BigDecimal">
        select ifnull(sum(balance),0) from dapp_member
        where find_in_set(#{inviteId}, fee_profit_ids)
    </select>
    <select id="selectMakerAddress" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        where maker_type=1 and account_type='normal'
    </select>
    <update id="updateMemberActive">
        update dapp_member
            set active_status = 2
        where active_status = 1
    </update>
    <select id="selectNewestDirectMember" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        where referer_id=#{inviteId} and active_status=1
        order by id desc
        limit 1
    </select>
    <select id="selectMemberListNeedProfit" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
               *
        from dapp_member a
        inner join (
            select referer_id, count(1) from dapp_member a
            where active_status = 1
            group by referer_id having count(1) > 3
        ) b on a.invite_id=b.referer_id
    </select>
    <update id="updateMemberAccountType">
        update dapp_member
        set account_type = #{accountType}
        where id = #{id}
    </update>
    <update id="updateMemberActiveStatus">
        update dapp_member
        set active_status = #{accountStatus}
        where id = #{id}
    </update>
    <select id="selectMemberInfoByRefererId" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
            *
        from dapp_member a
        where referer_id = #{refererId}
    </select>
    <select id="selectAllMemberInfoByRefererId" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
            *
        from dapp_member a
        where FIND_IN_SET(#{inviteId}, referer_ids)
    </select>
    <select id="selectCountByAccountTypeAndRefererId" resultType="java.lang.Integer">
        select count(id)
        from dapp_member
        <where>
            referer_id = #{refererId}
            <if test="accountType != null">
                and account_type = #{accountType}
            </if>
        </where>
    </select>
    <select id="findTeamInfoListInPage" resultType="cc.mrbird.febs.dapp.vo.AdminTeamInfoVo">
        select
            a.address address,
            a.invite_id inviteId,
            a.account_type accountType,
            a.active_status activeStatus,
            a.id id
        from dapp_member a
        where
            (a.id in (select id from dapp_member where FIND_IN_SET(#{record.inviteId}, referer_ids)))
        order  by a.create_time desc
    </select>
    <select id="selectByMemberId" resultType="cc.mrbird.febs.dapp.vo.DappMemberInfoVo">
        select
            a.invite_id inviteId,
            a.address address,
            a.account_type accountType,
            a.active_status activeStatus
        from dapp_member a
        where a.id = #{id}
    </select>
    <select id="selectByInviteIds" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
               *
        from dapp_member
        where  invite_id IN
        <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" >
            #{item}
        </foreach >
        order by id desc
    </select>
    <select id="selectMemberByAccountTypeAnd" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
            a.*
        from dapp_member a
        where a.account_type = #{accountType}
        and a.invite_id in (
            select b.referer_id from dapp_member b where b.account_type = #{accountType}
            )
    </select>
    <select id="selectChildAgentListByAccountType" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select *
        from dapp_member
        where
              (find_in_set(#{inviteId}, referer_ids) or invite_id=#{inviteId})
          and account_type = #{accountType}
    </select>
    <select id="selectAllAchieveByInviteId" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(a.amount, 0)),0)
        from mall_achieve_record a
        inner join dapp_member b on a.member_id = b.id
        where find_in_set(#{inviteId}, b.referer_ids) or b.invite_id = #{inviteId}
    </select>
    <select id="selectAllAchieveByRefId" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(a.amount, 0)),0)
        from mall_achieve_record a
        inner join dapp_member b on a.member_id = b.id
        where find_in_set(#{inviteId}, b.referer_ids)
    </select>
    <select id="selectMemberByNotAccountType" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
            where active_status = 1
    </select>
    <select id="selectByNodetype" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
            where node_type = 1
    </select>
    <select id="selectAddress" resultType="java.lang.String">
        select
            address
        from dapp_member where active_status  = 1
    </select>
    <select id="selectMallGoodsListQueryInPage" resultType="cc.mrbird.febs.dapp.vo.MallGoodsListVo">
        select
        a.*
        from mall_goods a
        where a.is_sale = 1
        <if test="record.categoryId != null and record.categoryId != ''">
            and a.category_id = #{record.categoryId}
        </if>
        group by a.id
        order by a.sort_cnt asc
    </select>
    <select id="selectMallOrderListQueryInPage" resultType="cc.mrbird.febs.dapp.vo.MallOrderListVo">
        select a.*,
               b.goods_name goodsName,
               b.goods_id goodsId,
               c.thumb goodsThumb,
               b.cnt goodsCnt
        from mall_order_info a
        left join mall_order_item b on a.id = b.order_id
        left join mall_goods c on c.id = b.goods_id
        <where>
            a.member_id = #{record.memberId}
            <if test="record != null">
                <if test="record.status != null and record.status != ''">
                    and a.status = #{record.status}
                </if>
            </if>
        </where>
        order by a.create_time desc
    </select>
    <select id="selectMallOrderListVoById" resultType="cc.mrbird.febs.dapp.vo.MallOrderListVo">
        select a.*
        from mall_order_info a
        where id = #{orderId}
        order by a.create_time desc
    </select>
    <select id="selectMallOrderItemVoByOrderId" resultType="cc.mrbird.febs.dapp.vo.MallOrderItemVo">
        select a.*,
               b.thumb goodsThumb
        from mall_order_item a
        left join mall_goods b on a.goods_id = b.id
        where order_id = #{orderId}
    </select>
    <select id="selectMallGoodsListVoById" resultType="cc.mrbird.febs.dapp.vo.MallGoodsListVo">
        select
            a.*
        from mall_goods a
        where a.id = #{goodsId}
    </select>
    <select id="selectInviteLeft" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where invite_left = #{inviteId}
    </select>
    <select id="selectInviteRight" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where invite_right = #{inviteId}
    </select>
    <select id="selectMemberByActiveStatus" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member where active_status = 1 and change_able = 1
    </select>
    <select id="selectAchieveRecordByInviteId" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(a.amount, 0)),0)
        from mall_achieve_record a
                 inner join dapp_member b on a.member_id = b.id
        where find_in_set(#{inviteId}, b.referer_ids) or b.invite_id = #{inviteId}
    </select>
    <select id="selectChildAgentList" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        where (find_in_set(#{inviteId}, referer_ids) or invite_id=#{inviteId}) and account_type=#{accountType}
    </select>
    <select id="selectDappMemberInfoVoByMemberId" resultType="cc.mrbird.febs.dapp.vo.DappMemberInfoVo">
        select a.id,
               a.balance balance,
               (IFNULL(b.available_amount, 0)) amount,
               (IFNULL(c.available_amount, 0)) score
        from dapp_member a
        left join dapp_wallet_coin b on a.id = b.member_id
        left join dapp_wallet_mine c on a.id = c.member_id
        where a.id = #{memberId}
    </select>
    <select id="selectAddressListInPage" resultType="cc.mrbird.febs.dapp.entity.MallAddressInfo">
        select
            a.*
        from mall_address_info a
        where a.is_default = 1
        and a.member_id = #{record.memberId}
        order by a.CREATE_TIME desc
    </select>
    <select id="selectOrderCntByMemberIdAndStatus" resultType="java.lang.Integer">
        select count(a.id)
        from mall_order_info a
        where a.member_id = #{memberId}
        and status = #{status}
    </select>
    <select id="selectShopAddressListInPage" resultType="cc.mrbird.febs.dapp.entity.MallAddressInfo">
        select
            a.*
        from mall_address_info a
        where is_default = 1
        and a.member_id = #{record.memberId}
        order by a.CREATE_TIME desc
    </select>
    <update id="updateIsDefault">
        update mall_address_info
        set is_your = #{isDefault}
        where member_id = #{memberId}
        <if test="id != null">
            and id = #{id}
        </if>
    </update>
    <delete  id="deleteByOrderId">
        delete from mall_order_item where order_id = #{orderId}
    </delete>
    <select id="selectAddressOneByMemberId" resultType="cc.mrbird.febs.dapp.entity.MallAddressInfo">
        select a.*
        from mall_address_info a
        where a.member_id = #{memberId}
          and a.is_default = 1
        order by a.is_your asc
        limit 1
    </select>
    <select id="selectOrderAmountByTime" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(amount,0)),0)
        from mall_order_info
        where
        status = 2
        <if test='type == "D"'>
            and date_format(CREATE_TIME, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d');
        </if>
        <if test='type == "M"'>
            and date_format(CREATE_TIME, '%Y-%m') = date_format(#{date}, '%Y-%m');
        </if>
    </select>
    <select id="selectOrderCountByTime" resultType="java.lang.Integer">
        select count(id)
        from mall_order_info
        where
        status = 2
        <if test='type == "D"'>
            and date_format(CREATE_TIME, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d');
        </if>
        <if test='type == "M"'>
            and date_format(CREATE_TIME, '%Y-%m') = date_format(#{date}, '%Y-%m');
        </if>
    </select>
    <select id="selectAccountChangeAfterAmountByTime" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(after_amount,0)),0)
        from dapp_account_money_change
        where type = 3
        <if test='type == "D"'>
            and date_format(CREATE_TIME, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d');
        </if>
        <if test='type == "M"'>
            and date_format(CREATE_TIME, '%Y-%m') = date_format(#{date}, '%Y-%m');
        </if>
    </select>
    <select id="selectPackageRecordDayInPage" resultType="cc.mrbird.febs.dapp.vo.PackageRecordVo">
        SELECT
            b.address address,
            IFNULL(SUM(a.amount), 0) totalAmount
        FROM
            dapp_fund_flow a
                LEFT JOIN dapp_member b on a.member_id = b.id
        WHERE
            a.type = 22
          and date_format(a.CREATE_TIME, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
          and b.address is not NULL
          and b.address != 'SYSTEM'
        GROUP BY
            a.member_id
        order by totalAmount desc
            LIMIT 100;
    </select>
    <select id="selectPackageRecordMonthInPage" resultType="cc.mrbird.febs.dapp.vo.PackageRecordVo">
        SELECT
            b.address address,
            IFNULL(SUM(a.amount), 0) totalAmount
        FROM
            dapp_fund_flow a
                LEFT JOIN dapp_member b on a.member_id = b.id
        WHERE
            a.type = 22
          and date_format(a.CREATE_TIME, '%Y-%m') = date_format(#{date}, '%Y-%m')
          and b.address is not NULL
          and b.address != 'SYSTEM'
        GROUP BY
            a.member_id
        order by totalAmount desc
            LIMIT 100;
    </select>
    <select id="selectPackageRecordWeekInPage" resultType="cc.mrbird.febs.dapp.vo.PackageRecordVo">
        SELECT
            b.address address,
            IFNULL(SUM(a.amount), 0) totalAmount
        FROM
            dapp_fund_flow a
                LEFT JOIN dapp_member b on a.member_id = b.id
        WHERE
            a.type = 22
          and date_format(a.CREATE_TIME, '%Y-%m-%d') > date_format(#{date}, '%Y-%m-%d')
          and b.address is not NULL
          and b.address != 'SYSTEM'
        GROUP BY
            a.member_id
        order by totalAmount desc
            LIMIT 100;
    </select>
    <select id="selectOrderByOrderNo" resultType="cc.mrbird.febs.dapp.entity.MallOrderInfo">
        select a.*
        from mall_order_info a
        where a.order_no = #{orderNo}
            limit 1
    </select>
    <select id="selectSoccerLeaguesInPage" resultType="cc.mrbird.febs.dapp.soccer.entity.SoccerLeagues">
        select
        a.*
        from soccer_leagues a
        order by a.id asc
    </select>
</mapper>