<?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.BipOrgsDaoImpl">
	<resultMap id="get-BipOrgsEntity-result" type="com.hzya.frame.bip.v3.v2207.entity.BipOrgsEntity">
		<result property="tripartiteId" column="tripartiteId" />
		<result property="code" column="code" />
		<result property="name" column="name" />
		<result property="pk_financeorg" column="pk_financeorg"/>
		<result property="orgsts" column="orgsts"/>
	</resultMap>

	<sql id="BipOrgsEntity_Base_Column_List">
			orgs.pk_financeorg as tripartiteId,
			orgs.name ,
			orgs.code,
	        max(org_bank.ts)as ts

	</sql>

	<sql id="BipOrgsEntity_Base_Column_List_details">
		 bankdoc.code as bankCode,bankdoc.name as bankName,bankaccbas.accnum,bankaccbas.controlorg
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-BipOrgsEntity-result">
		select
		<include refid="BipOrgsEntity_Base_Column_List" />
		from org_financeorg where pk_financeorg = #{pk_financeorg}
	</select>

	<select id="thirdInterfaceGetOrgs" resultMap="get-BipOrgsEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipOrgsEntity">
		select
		<include refid="BipOrgsEntity_Base_Column_List" />
		FROM
        org_financeorg orgs
        left join v_hzya_org_bank  org_bank on org_bank.controlorg = orgs.pk_financeorg

		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''"> orgs.code = #{code}</if>
			<if test="name != null and name !='' "> and orgs.name = #{name}</if>
			<if test="pk_financeorg != null and pk_financeorg !='' "> and orgs.pk_financeorg = #{tripartiteId}</if>
			<if test="orgsts != null and orgsts !='' "> and orgs.ts >'2023-09-30 14:18:39' and orgs.ts > #{orgsts}</if>
		     and orgs.dr='0'
		</trim>
        GROUP BY  orgs.pk_financeorg ,orgs.name,orgs.code
	</select>

	<!-- 查询 采用==查询 -->
	<select id="thirdInterfaceGetSupplierDetails" resultMap="get-BipOrgsEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipOrgsEntity">
		select
		<include refid="BipOrgsEntity_Base_Column_List_details" />
		 from bd_bankaccbas bankaccbas
		left join bd_bankdoc bankdoc on bankdoc.pk_bankdoc=bankaccbas.pk_bankdoc
		<trim prefix="where" prefixOverrides="and">
			<if test="code != null and code !=''">bankdoc.code=#{code}</if>
			<if test="name != null and name !='' "> and bankdoc.name = #{name}</if>
			<if test="accnum != null and accnum !='' "> and bankaccbas.accnum = #{accnum}</if>
			<if test="controlorg != null and controlorg !='' "> and bankaccbas.controlorg = #{controlorg}</if>
			and bankaccbas.dr='0' and bankdoc.dr='0'  and bankaccbas.pk_banktype!='0001Z01000000000036S'
		</trim>
	</select>


	<!-- 查询 采用==查询 -->
	<!--<select id="BipOrgsEntity_list_base" resultMap="get-BipOrgsEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipOrgsEntity">
		select
		<include refid="BipOrgsEntity_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-BipOrgsEntity-result" parameterType="com.hzya.frame.bip.v3.v2207.entity.BipOrgsEntity">
		select
		<include refid="BipOrgsEntity_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>

