<?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="vip.xiaonuo.biz.modular.consumptionrecord.mapper.ConsumptionRecordMapper">

    <select id="getPageList" resultType="vip.xiaonuo.biz.modular.consumptionrecord.entity.ConsumptionRecord">
        select
            cr.id,
            su.name userName,
            cr.consumption_type,
            IFNULL(cr.voucher_money,0) voucher_money,
            IFNULL(cr.account_money,0) account_money,
            cr.consumption_time,
            so.name orgName,
            cr.consumption_remark,
            cr.consumption_operate,
            IFNULL(cr.consumption_money,0) consumption_money,
            IFNULL(cr.voucher_balance,0) voucher_balance,
            IFNULL(cr.account_balance,0) account_balance,
            su.PHONE,
            su.ACCOUNT_BALANCE newAccountBalance,
            su.VOUCHER_BALANCE newVoucherBalance
        from biz_consumption_record cr
        left join SYS_USER su on cr.user_id = su.id
        left join SYS_ORG so on so.id = cr.consumption_org
        <where>
            ${ew.sqlSegment}
        </where>
    </select>

    <select id="getRecordTotal" resultType="vip.xiaonuo.biz.modular.consumptionrecord.param.ConsumptionResult">
        select
            count(*) orderCount,
            sum(bcr.consumption_money) orderMoney
        from biz_consumption_record bcr
        <where>
            ${ew.sqlSegment}
        </where>
    </select>
</mapper>
