<?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.buy507.mall.portal.dao.PortalMemberDao">

	<select id="selectMemberTeamList" parameterType="java.lang.Long" resultType="com.buy507.mall.portal.domain.TeamMemberResult">
        SELECT 
        	   (SELECT nickname FROM ums_member m where m.id = tl.member_id) as username, 
               tl.member_id as memberId,
               IFNULL((SELECT total FROM dms_team_member_number tmn where tmn.member_id = tl.member_id), 0) as teamNum,
               (SELECT value FROM dms_team_total_consume ttc where ttc.member_id = tl.member_id) as teamConsume
          FROM
            dms_team_level tl
        WHERE
            tl.parent_id = #{member_id}
    </select>
    
    <select id="selectMemberWithdrawApplyList" parameterType="java.lang.Long" resultType="java.util.HashMap">
        SELECT value,
        	   poundage,
        	   actual_value as actualValue,
        	   account_name as accountName,
        	   bank_name as bankName,
        	   bank_card_num as bankCardNum,
        	   open_bank_address as openBankAddress,
        	   wechat_account as wechatAccount,
        	   wechat_nickname as wechatNickname,
        	   payment_status as paymentStatus,
        	   withdraw_type as withdrawType,
        	   (CASE payment_status WHEN 1 THEN '已打款' WHEN 2 THEN '打款失败' ELSE '未打款' END) as paymentStatusName,
        	   failed_reason as failedReason,
        	   payment_time as paymentTime,
        	   create_time as createTime
          FROM
            dms_member_withdraw_apply mwa
        WHERE
            mwa.member_id = #{member_id}
     ORDER BY mwa.create_time desc
    </select>
    
    <select id="selectMemberTransferList" parameterType="java.lang.Long" resultType="java.util.HashMap">
        SELECT value,
               receiver_nickname as receiverNickname,
               receiver_phone as receiverPhone,
               create_time as createTime
          FROM
            dms_member_transfer_record mtr
        WHERE
            mtr.member_id = #{member_id}
     ORDER BY mtr.create_time desc
    </select>
    
    
</mapper>