<?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.iformall.mapper.WxBillSettleRecordMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillSettleRecord">
		<id column="id" property="id"/>
		<result column="tenant_id" property="tenantId"/>
		<result column="settle_id" property="settleId"/>
		<result column="userid" property="userid"/>
		<result column="user_name" property="userName"/>
		<result column="settle_money" property="settleMoney"/>
		<result column="settle_time" property="settleTime"/>
		<result column="settle_way" property="settleWay"/>
		<result column="balance" property="balance"/>
		<result column="detail" property="detail"/>
		<result column="remark" property="remark"/>
		<result column="createtime" property="createtime"/>
		<result column="updatetime" property="updatetime"/>

	</resultMap>

	<sql id="allColumns">
	    `id`,`tenant_id`,`settle_id`,`userid`,`user_name`,`settle_money`,
	    `settle_time`,`settle_way`,`balance`,detail,`createtime`,`updatetime`,`remark`
	</sql>

	<sql id="dynamicWhereConditions">
		where 1=1
		<if test=" null != id ">and `id` = #{id}</if>
		<if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
		<if test=" null != settleId ">and `settle_id` = #{settleId}</if>

		<if test=" null != ids ">
			and id in
			<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
				#{idItem}
			</foreach>
		</if>
		<if test=" null != sortColumns">order by ${sortColumns}</if>
	</sql>

	<select id="findList" parameterType="com.iformall.domain.po.WxBillSettleRecord" resultMap="BaseResultMap">
		select
		<include refid="allColumns"/>
		from wx_bill_settle_record
		<include refid="dynamicWhereConditions"/>
	</select>

	<select id="getSumMoneyBySettleId" parameterType="com.iformall.domain.po.WxBillSettle" resultType="long">
		select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = #{id}
	</select>


</mapper>

