TdCBusinessAcctSMapper.xml 3.87 KB
<?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.zteits.business.mapper.smapper.TdCBusinessAcctSMapper">

    <!-- 分页查询商户账户余额充值与支出明细 -->
    <select id="queryAccountInOutDetailsForPage"
            resultType="com.zteits.clouds.api.dto.business.dto.BusinessAccountInOutDetailForPageDTO">

        <if test="kind == 1">
            select 1 as kind,b.examine_state as payState, b.rlt_payorder_id as payOrderId,
             b.recharge_type as 'type', b.recharge_fee as changeFee,b.create_date as createDate,b.rlt_order_id as orderId
            from td_c_business_acct_source b
            where b.business_id  =  #{businessId}
            and b.create_date >= #{beginDate}
            and b.create_date &lt; #{endDate}
            <if test="queryType != null">
                and b.recharge_type = #{queryType}
            </if>

            order by b.create_date desc
        </if>
        <if test="kind == 2">
            select
                   2 as kind,
                   b.rlt_payorder_id as payOrderId,
                   b.trade_type as 'type',
                   b.trade_fee as changeFee,
                   b.create_date as createDate,
                   b.rlt_order_id as orderId,
                   b.car_number as carNumber
            from
                 td_c_business_acct_payout b
            where
                  b.business_id  =  #{businessId}
              and b.create_date >= #{beginDate}
              and b.create_date &lt; #{endDate}
            <if test="queryType != null">
                and b.trade_type = #{queryType}
            </if>
            order by b.create_date desc
        </if>
        <if test="kind == null || kind == ''">
            select * from
            (  select 2 as kind, 0 as payState, a.rlt_payorder_id as payOrderId,
            a.trade_type as 'type', a.trade_fee as changeFee,a.create_date as createDate,a.rlt_order_id as orderId
            from td_c_business_acct_payout a
            where a.business_id  =  #{businessId}
            and a.create_date >= #{beginDate}
            and a.create_date &lt; #{endDate}

            union
            select 1 as kind,b.examine_state as payState, b.rlt_payorder_id as payOrderId,
            b.recharge_type as 'type', b.recharge_fee as changeFee,b.create_date as createDate,b.rlt_order_id as orderId
            from td_c_business_acct_source b
            where b.business_id  =  #{businessId}
            and b.create_date >= #{beginDate}
            and b.create_date &lt; #{endDate}

            )c
            order by c.createDate desc
        </if>
    </select>

    <!-- 余额明细总览 -->
    <select id="detailSummary"
            resultType="com.zteits.clouds.api.dto.business.dto.BusinessAccountDetailCountDTO">
        <if test="kind == 1">
            select
                b.recharge_type as 'type',
                count(b.id) as changeCount,
                sum(b.recharge_fee) as totalFee
            from td_c_business_acct_source b
            where b.business_id  =  #{businessId}
            and b.create_date >= #{beginDate}
            and b.create_date &lt; #{endDate}
            <if test="type != null">
                and  b.recharge_type = #{type}
            </if>

            GROUP BY  b.recharge_type
        </if>
        <if test="kind == 2">
            select
                b.trade_type as 'type',
                count(b.id) as changeCount,
                sum(b.trade_fee) as totalFee
            from td_c_business_acct_payout b
            where b.business_id  =  #{businessId}
            and b.create_date >= #{beginDate}
            and b.create_date &lt; #{endDate}
            <if test="type != null">
                and  b.trade_type = #{type}
            </if>
            GROUP BY b.trade_type
        </if>

    </select>
</mapper>