<?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.daemon.quartz.mapper.WmTaskSettleNoteMapper">

	<resultMap id="wmTaskSettleNoteMap" type="com.qunzhixinxi.hnqz.daemon.quartz.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="listSettleAmountByDeptId" resultMap="wmTaskSettleNoteMap">
		SELECT n.settle_amount
		FROM wm_task_settle_note n
				 LEFT JOIN wm_score_package p ON p.id = n.package_id
		WHERE settle_note_status = 1
		  AND n.settle_amount IS NOT NULL
		  AND p.dept_id = #{deptId}
		  AND p.sub_type = #{subType}
		  AND n.notify_time BETWEEN #{startTime} AND #{endTime}
	</select>
</mapper>
