<?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.WxMsgCallbackMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMsgCallback">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
		<result column="batch_no" jdbcType="VARCHAR" property="batchNo" />
		<result column="phone" jdbcType="VARCHAR" property="phone" />
		<result column="begintime" jdbcType="INTEGER" property="begintime" />
		<result column="endtime" jdbcType="INTEGER" property="endtime" />
		<result column="status" jdbcType="INTEGER" property="status" />
		<result column="status_msg" jdbcType="VARCHAR" property="statusMsg" />
		<result column="sign" jdbcType="VARCHAR" property="sign" />
		<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
		<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
		<result column="callback_id" jdbcType="BIGINT" property="callbackId" />
		<result column="msg_id" jdbcType="BIGINT" property="msgId" />
		<result column="business_id" jdbcType="BIGINT" property="businessId"/>
	
	</resultMap>
	
	<sql id="allColumns">
	    `id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`,`business_id`
	</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 != batchNo "> 
		and `batch_no`  like concat('%', #{batchNo},'%')
       	
		</if>
		
		<if test=" null != phone and phone!=''">
		and `phone`  like concat('%', #{phone},'%')
       	
		</if>    
	    
		<if test=" null != begintime "> 
		and `begintime` = #{begintime} 
       	
		</if>    
	    
		<if test=" null != endtime "> 
		and `endtime` = #{endtime} 
       	
		</if>    
	    
		<if test=" null != status "> 
		and `status` = #{status} 
       	
		</if>    
	    
		<if test=" null != statusMsg "> 
		and `status_msg`  like concat('%', #{statusMsg},'%')
       	
		</if>    
	    
		<if test=" null != sign "> 
		and `sign`  like concat('%', #{sign},'%')
       	
		</if>    
	    
		<if test=" null != createtime "> 
		and `createtime` = #{createtime} 
       	
		</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.WxMsgCallback" resultMap="BaseResultMap">
		select <include refid="allColumns" /> from wx_msg_callback
		<include refid="dynamicWhereConditions" />
	</select>
	
	
	<select id="queryCallbackByBatchNoAndPhone" parameterType="com.iformall.domain.po.WxMsgCallback" resultMap="BaseResultMap">
	
		select * from wx_msg_callback where batch_no=#{batchNo} and phone=#{phone}
		
	</select>
	
	
	<select id="queryMsgSendTotal" parameterType="hashmap" resultType="int">
		select count(*) from wx_msg_callback where msg_id=#{msgId} and status=#{status}
	</select>
	
	
	
</mapper>
