<?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.purchcontractmanagement.PurchContractSettleCycleMapper">
	<resultMap type="PurchContractSettleCycle" id="baseResultMap">
		<result column="id" property="id" />
		<result column="user_create" property="userCreate" />
		<result column="user_modified" property="userModified" />
		<result column="gmt_create" property="gmtCreate" />
		<result column="gmt_modified" property="gmtModified" />
		<result column="settle_cycle_method" property="settleCycleMethod" />
		<result column="settle_cycle" property="settleCycle" />
		<result column="plan_payback_days" property="planPaybackDays" />
		<result column="settle_min_amount" property="settleMinAmount" />
		<result column="purch_contract_basic_info_id" property="purchContractBasicInfoId" />
		<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="findByPurchContId" parameterType="java.lang.Long" resultMap="baseResultMap">
		SELECT
			t1.id,
			t1.settle_cycle_method,
			t1.settle_cycle,
			t1.plan_payback_days,
			t1.settle_min_amount,
			t1.purch_contract_basic_info_id,
			t1.user_create,
			t1.user_modified,
			t1.gmt_create,
			t1.gmt_modified,
			t2.id did,
			t2.code dcode,
			t2.name dname
		FROM
			purch_contract_settle_cycle t1
				LEFT JOIN t_dictionary t2 ON t1.settle_cycle_method = t2.id
		WHERE t1.purch_contract_basic_info_id = #{purchContId}
	</select>

</mapper>
