<?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.ruoyi.cai.mapper.AccountCashMapper">

    <resultMap type="com.ruoyi.cai.domain.AccountCash" id="CaiAccountCashResult">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="orderNo" column="order_no"/>
        <result property="cashMoney" column="cash_money"/>
        <result property="realCashMoney" column="real_cash_money"/>
        <result property="cashFees" column="cash_fees"/>
        <result property="bank" column="bank"/>
        <result property="cardName" column="card_name"/>
        <result property="cardAccount" column="card_account"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="operateIp" column="operate_ip"/>
        <result property="verifyTime" column="verify_time"/>
        <result property="verifyRemark" column="verify_remark"/>
        <result property="isPay" column="is_pay"/>
        <result property="isExport" column="is_export"/>
        <result property="exportTime" column="export_time"/>
    </resultMap>
    <select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AccountCashAdminVo">
        select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.status
        from cai_account_cash t1
        left join cai_user t2 on t1.user_id = t2.id
        <where>
            <if test="bo.cardName != null and bo.cardName != ''">
                and t1.card_name like concat('%',#{bo.cardName},'%')
            </if>
            <if test="bo.cardAccount != null and bo.cardAccount != ''">
                and t1.card_account like concat('%',#{bo.cardAccount},'%')
            </if>
            <if test="bo.mobile != null and bo.mobile != ''">
                and t2.mobile = #{bo.mobile}
            </if>
            <if test="bo.usercode != null and bo.usercode != ''">
                and t2.usercode = #{bo.usercode}
            </if>
            <if test="bo.status != null">
                and t1.status = #{bo.status}
            </if>
            <if test="bo.id != null">
                and t1.id = #{bo.id}
            </if>
        </where>
        order by t1.create_time desc
    </select>
    <select id="incomeStatistics" resultType="com.ruoyi.cai.dto.admin.incomeStatis.AccountCashCountDTO">
        select
            sum(cash_money) as cash_money,
            count(id) as cash_money
        from cai_account_cash
        where status = 2 and verify_time between #{startTime} and #{endTime}
    </select>


</mapper>
