<?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.dao.DmsMemberWithdrawApplyDao">

    <select id="selectByExample" resultType="com.buy507.mall.dto.MemberWithdrawApplyResult">
        SELECT mwa.id,
        	   member_id as memberId,
        	   value as value,
        	   poundage as poundage,
        	   actual_value as actualValue,
        	   account_name as accountName,
        	   bank_name as bankName,
        	   bank_card_num as bankCardNum,
        	   open_bank_address as openBankAddress,
        	   mwa.real_name as realName,
        	   alipay_account as alipayAccount,
        	   wechat_account as wechatAccount,
        	   wechat_nickname as wechatNickname,
        	   withdraw_type as withdrawType,
        	   payment_status as paymentStatus,
        	   failed_reason as failedReason,
        	   payment_time as paymentTime,
        	   mwa.create_time as createTime,
        	   m.real_name as name,
        	   m.phone as phone
          FROM
            dms_member_withdraw_apply mwa
          LEFT JOIN ums_member m ON mwa.member_id = m.id
        WHERE
       		1=1
        <if test="startTime!=null">
        	<![CDATA[   AND DATE_FORMAT(mwa.create_time, '%Y-%m-%d') >=  DATE_FORMAT(#{startTime}, '%Y-%m-%d')   ]]>
        </if>
        <if test="endTime!=null">
        	<![CDATA[   and DATE_FORMAT(mwa.create_time, '%Y-%m-%d') <=  DATE_FORMAT(#{endTime}, '%Y-%m-%d')   ]]>
        </if>
        
        <if test="paymentStatus!=null">
        	and mwa.payment_status = #{paymentStatus}
        </if>
        
     ORDER BY mwa.create_time desc
    </select>
    
</mapper>