<?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.superdesk.uniorder.dao.mapper.unified.UnifiedDrowMoneyMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
		<result column="amount" property="amount" jdbcType="DECIMAL"/>
		<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="create_user_id" property="createUserId" jdbcType="BIGINT"/>
		<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
		<result column="update_user_id" property="updateUserId" jdbcType="BIGINT"/>
	</resultMap>
	<resultMap id="PageResultMap" type="cn.superdesk.uniorder.dto.vo.unified.UnifiedDrowMoneyPage">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
		<result column="channel_name" property="channelName" jdbcType="VARCHAR"/>
		<result column="amount" property="amount" jdbcType="DECIMAL"/>
		<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>

	</resultMap>
	<select id="getPageData" resultMap="PageResultMap">
		SELECT A.amount,A.channel_id,A.create_time,A.id,A.remarks,B.channel_name from unified_drow_money A
		LEFT JOIN unified_channel_sync B on A.channel_id = B.channel_id
		WHERE 1=1
		<if test="channelId !=null and channelId != ''">
			and A.channel_id = #{channelId}
		</if>
		<if test="startime != null and startime != ''">
			and DATE_FORMAT(A.create_time,'%Y-%m-%d') &gt;= #{startime,jdbcType=VARCHAR}
		</if>
		<if test="endtime != null and endtime != ''">
			and DATE_FORMAT(A.create_time,'%Y-%m-%d') &lt;= #{endtime,jdbcType=VARCHAR}
		</if>
		order by A.create_time desc
	</select>
	<select id="findAll" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List"/>
		from unified_drow_money where 1=1
		<if test="channelId !=null and channelId != ''">
			and channel_id = #{channelId}
		</if>

		order by create_time desc
	</select>

	<sql id="Base_Column_List">
    id, channel_id, amount, remarks, create_time, create_user_id, update_time, update_user_id
  </sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="Base_Column_List"/>
		from unified_drow_money
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from unified_drow_money
    where id = #{id,jdbcType=BIGINT}
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into unified_drow_money (channel_id, amount, remarks,
		create_time, create_user_id, update_time,
		update_user_id)
		values (#{channelId,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL}, #{remarks,jdbcType=VARCHAR},
		#{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
		#{updateUserId,jdbcType=BIGINT})
	</insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney">
		<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into unified_drow_money
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="channelId != null">
				channel_id,
			</if>
			<if test="amount != null">
				amount,
			</if>
			<if test="remarks != null">
				remarks,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
			<if test="createUserId != null">
				create_user_id,
			</if>
			<if test="updateTime != null">
				update_time,
			</if>
			<if test="updateUserId != null">
				update_user_id,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="channelId != null">
				#{channelId,jdbcType=BIGINT},
			</if>
			<if test="amount != null">
				#{amount,jdbcType=DECIMAL},
			</if>
			<if test="remarks != null">
				#{remarks,jdbcType=VARCHAR},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				#{createUserId,jdbcType=BIGINT},
			</if>
			<if test="updateTime != null">
				#{updateTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateUserId != null">
				#{updateUserId,jdbcType=BIGINT},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney">
		update unified_drow_money
		<set>
			<if test="channelId != null">
				channel_id = #{channelId,jdbcType=BIGINT},
			</if>
			<if test="amount != null">
				amount = #{amount,jdbcType=DECIMAL},
			</if>
			<if test="remarks != null">
				remarks = #{remarks,jdbcType=VARCHAR},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				create_user_id = #{createUserId,jdbcType=BIGINT},
			</if>
			<if test="updateTime != null">
				update_time = #{updateTime,jdbcType=TIMESTAMP},
			</if>
			<if test="updateUserId != null">
				update_user_id = #{updateUserId,jdbcType=BIGINT},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney">
    update unified_drow_money
    set channel_id = #{channelId,jdbcType=BIGINT},
      amount = #{amount,jdbcType=DECIMAL},
      remarks = #{remarks,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>