<?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.sunxung.factoring.mapper.salescontractmanagement.SalesContractSettleInfoMapper">
	<resultMap type="SalesContractSettleInfo" id="baseResultMap">
		<result property="id" column="id" />
		<result property="settleCycle" column="settle_cycle" />
		<result property="planPaybackDays" column="plan_payback_days" />
		<result property="estimatePaybackDays" column="estimate_payback_days" />
		<result property="salesContractBasicInfoId" column="sales_contract_basic_info_id" />
		<result property="receivableType" column="receivable_type" />
		<result property="userCreate" column="user_create" />
		<result property="userModified" column="user_modified" />
		<result property="gmtCreate" column="gmt_create" />
		<result property="gmtModified" column="gmt_modified" />
		<association property="settleCycleMethodDict" column="settle_cycle_method" resultMap="dictionaryResult" />
	</resultMap>

	<resultMap id="dictionaryResult" type="Dictionary">
		<result property="id" column="did" />
		<result property="name" column="dname" />
		<result property="code" column="dcode" />
	</resultMap>

	<select id="findByBasicInfoId" parameterType="java.lang.Long" resultMap="baseResultMap">
		SELECT DISTINCT
			t1.id,
			t1.settle_cycle_method,
			t1.settle_cycle,
			t1.plan_payback_days,
			t1.estimate_payback_days,
			t1.receivable_type,
			t2.id did,
			t2.code dcode,
			t2.name dname
		FROM
			sales_contract_settle_info t1
				LEFT JOIN t_dictionary t2 ON t1.settle_cycle_method = t2.id
		WHERE t1.sales_contract_basic_info_id = #{basicInfoId}
	</select>

</mapper>
