<?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.qunzhixinxi.hnqz.admin.mapper.WmTaskSettleNoteMapper">

	<resultMap id="wmTaskSettleNoteMap" type="com.qunzhixinxi.hnqz.admin.entity.WmTaskSettleNote">
		<id property="id" column="id"/>
		<result property="packageId" column="package_id"/>
		<result property="packageStatusId" column="package_status_id"/>
		<result property="taskId" column="task_id"/>
		<result property="settleAmount" column="settle_amount"/>
		<result property="userId" column="user_id"/>
		<result property="invoiceType" column="invoice_type"/>
		<result property="settleNo" column="settle_no"/>
		<result property="discount" column="discount"/>
		<result property="settleNoteStatus" column="settle_note_status"/>
		<result property="remark" column="remark"/>
		<result property="categoryName" column="category_name"/>
		<result property="createTime" column="create_time"/>
		<result property="updateTime" column="update_time"/>
		<result property="subTime" column="sub_time"/>
		<result property="notifyTime" column="notify_time"/>
		<result property="streamId" column="stream_id"/>
		<result property="idCardNumber" column="id_card_number"/>
	</resultMap>

	<select id="getWmTaskSettleInfoPage" resultType="com.qunzhixinxi.hnqz.admin.entity.output.WmTaskSettleNoteOutput">
				SELECT
				t.id,
				t.task_type_id,
				t.create_time,
		u.realname real_name,
				t.score_package_id,
				t.task_user_id,
				c.temp3 xmbm,
				e.id noteId,
				e.category_name,
				e.discount,
				e.stream_id,
				e.settle_no,
				e.settle_amount,
				e.settle_note_status,
				e.sub_time,
				e.notify_time
			FROM wm_task t
				left JOIN wm_task_content c on t.task_content_id = c.id
				left JOIN wm_task_settle_note e on t.id = e.task_id
		LEFT JOIN sys_user u on t.task_user_id = u.user_id
			WHERE  1= 1
			<if test="query.userId!=null and query.userId!=''">
				AND t.task_user_id =#{query.userId}
			</if>
			<if test="query.packageId!=null and query.packageId!=''">
				AND t.score_package_id =#{query.packageId}
			</if>

	</select>
	<select id="getWmTaskForSettlePage" resultType="com.qunzhixinxi.hnqz.admin.entity.output.WmTaskSettleNoteOutput">
				SELECT
				t.id,
				t.task_type_id,
				t.create_time,
				t.score_package_id,
				t.task_user_id,
		u.realname real_name,
				c.temp3 xmbm,
				e.id noteId,
				e.category_name,
				e.discount,
				e.stream_id,
				e.settle_no,
				e.settle_amount,
				e.settle_note_status,
				e.sub_time,
				e.notify_time
			FROM wm_task t
				LEFT JOIN wm_task_content c on t.task_content_id = c.id
				LEFT JOIN wm_task_settle_note e on t.id = e.task_id
		LEFT JOIN sys_user u on t.task_user_id = u.user_id
			WHERE  1= 1
			<if test="query.userId!=null and query.userId!=''">
				AND t.task_user_id =#{query.userId}
			</if>
			<if test="query.packageId!=null and query.packageId!=''">
				AND t.score_package_id =#{query.packageId}
			</if>
		    ORDER BY e.sub_time DESC
	</select>
</mapper>
