<?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.hzya.frame.bip.v3.v2207.dao.impl.BipSupplierDaoImpl">
	<resultMap id="get-BipSupplierEntity-result" type="com.hzya.frame.bip.v3.v2207.entity.BipSupplierEntity">
		<result property="taxpayerid" column="taxpayerid" />
		<result property="def1" column="def1" />
		<result property="def2" column="def2" />
		<result property="def3" column="def3" />
		<result property="code" column="code" />
		<result property="name" column="name" />
		<result property="ts" column="ts" />
		<result property="tripartiteId" column="tripartiteId" />
	</resultMap>

	<sql id="BipSupplierEntity_Base_Column_List">
		supplier.code,supplier.name,supplier.taxpayerid,bank.def1,bank.def2,bank.def3,supplier.ts,	supplier.pk_cust_sup as tripartiteId
	</sql>

	<sql id="BipSupplierEntity_Base_Column_List_details">
		splitbank,bankaccno,name,code
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-BipSupplierEntity-result">
		select
		<include refid="BipSupplierEntity_Base_Column_List" />
		from BD_SUPPLIER where pk_supplier = #{pk_supplier} and sdr='0'
	</select>

	<select id="thirdInterfaceGetSupplier" resultMap="get-BipSupplierEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipSupplierEntity">
		select
		<include refid="BipSupplierEntity_Base_Column_List" />
		FROM bd_cust_supplier supplier
		left join db_customerbank  bank ON supplier.code = bank.code
		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''">supplier.code=#{code}</if>
			<if test="name != null and name !='' "> and supplier.name = #{name}</if>
			<if test="taxpayerid != null and taxpayerid !='' "> and supplier.taxpayerid = #{taxpayerid}</if>
			<if test="def1 != null and def1 !='' "> and bank.def1 = #{def1}</if>
			<if test="def2 != null and def2 !='' "> and bank.def2 = #{def2}</if>
			<if test="def3 != null and def3 !='' "> and bank.def3 = #{def3}</if>
			<if test="tripartiteId != null and tripartiteId !='' "> and supplier.tripartiteId = #{tripartiteId}</if>
            <if test="ts != null and ts !='' ">   and supplier.ts >'2023-09-30 14:18:39'   and supplier.ts > #{ts} </if>
		</trim>
		group by supplier.code,supplier.name,supplier.taxpayerid,bank.def1,bank.def2,bank.def3,supplier.ts,	supplier.pk_cust_sup
	</select>

	<!-- 查询 采用==查询 -->
	<select id="thirdInterfaceGetSupplierDetails" resultMap="get-BipSupplierEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipSupplierEntity">
		select
		<include refid="BipSupplierEntity_Base_Column_List_details" />
		FROM db_customerbank
		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''">code=#{code}</if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="bankaccno != null and bankaccno !='' "> and bankaccno = #{bankaccno}</if>
			<if test="splitbank != null and splitbank !='' "> and splitbank = #{splitbank}</if>
		</trim>
	</select>


	<!-- 查询 采用==查询 -->
	<select id="BipSupplierEntity_list_base" resultMap="get-BipSupplierEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipSupplierEntity">
		select
		<include refid="BipSupplierEntity_Base_Column_List" />
		FROM bd_cust_supplier supplier
		left join db_customerbank  bank ON supplier.code = bank.code
		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''">supplier.code=#{code}</if>
			<if test="name != null and name !='' "> and supplier.name = #{name}</if>
			<if test="taxpayerid != null and taxpayerid !='' "> and supplier.taxpayerid = #{taxpayerid}</if>
			<if test="def1 != null and def1 !='' "> and bank.def1 = #{def1}</if>
			<if test="def2 != null and def2 !='' "> and bank.def2 = #{def2}</if>
			<if test="def3 != null and def3 !='' "> and bank.def3 = #{def3}</if>
		</trim>
	</select>


	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-BipSupplierEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipSupplierEntity">
		select
		<include refid="BipSupplierEntity_Base_Column_List" />
		FROM bd_cust_supplier supplier
		left join db_customerbank  bank ON supplier.code = bank.code
		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''"> supplier.code like concat('%',#{code},'%')</if>
			<if test="name != null and name !='' "> and supplier.name like concat('%',#{name},'%')</if>
			<if test="taxpayerid != null and taxpayerid !='' "> and supplier.taxpayeridlike concat('%',#{taxpayeridlike},'%')</if>
			<if test="def1 != null and def1 !='' "> and bank.def1 like concat('%',#{def1},'%')</if>
			<if test="def2 != null and def2 !='' "> and bank.def2 like concat('%',#{def2},'%')</if>
			<if test="def3 != null and def3 !='' "> and bank.def3 like concat('%',#{def3},'%')</if>
		</trim>
	</select>

</mapper>

