<?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="cn.com.ty.lift.ud.payment.mapper.TyBillMapper" >
  <resultMap id="BaseResultMap" type="cn.com.ty.lift.ud.payment.mapper.entity.TyBillEntity" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="balance" property="balance" jdbcType="DECIMAL" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="business_type" property="businessType" jdbcType="INTEGER" />
    <result column="flow_num" property="flowNum" jdbcType="VARCHAR" />
    <result column="descr" property="descr" jdbcType="VARCHAR" />
    <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>


  <!--列表查询-->
  <select id="selectByQuery" resultType="cn.com.ty.lift.ud.payment.mapper.entity.TyBillEntity" >
    select * from ty_bill
    <where>
        ${ew.sqlSegment}
    </where>
    limit #{page.pageIndex},#{page.pageSize}
  </select>

  <!--查询总数量-->
  <select id="countByQuery" resultType="java.lang.Integer">
    select count(0)
    from ty_bill
    <where>
        ${ew.sqlSegment}
    </where>
  </select>

  <!--计算总收入和总支出-->
  <select id="sumByType" resultType="java.lang.Double">
    select IFNULL(sum(amount),0)  from ty_bill t where type = #{type} and ${ew.sqlSegment}
  </select>
</mapper>