<?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="cn.superdesk.uniorder.dao.mapper.invoice.customer.fundrestream.InvoiceBankStatementOffMapperEx">

	<resultMap id="VoResultMap" type="cn.superdesk.uniorder.dto.vo.unified.UnifiedInvBankOffVo">
		<id column="id" property="id" jdbcType="BIGINT"/>
		<result column="hx_sn" property="hxSn" jdbcType="VARCHAR"/>
		<result column="inv_bank_ids" property="invBankIds" jdbcType="VARCHAR"/>
		<result column="inv_ids" property="invIds" jdbcType="VARCHAR"/>
		<result column="inv_names" property="invNames" jdbcType="VARCHAR"/>
		<result column="hx_status" property="hxStatus" jdbcType="TINYINT"/>
		<result column="inv_bank_amount" property="invBankAmount" jdbcType="DECIMAL"/>
		<result column="inv_amount" property="invAmount" jdbcType="DECIMAL"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="create_user_id" property="createUserId" jdbcType="BIGINT"/>
		<result column="create_user_name" property="createUserName" jdbcType="VARCHAR"/>
		<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
		<result column="update_user_id" property="updateUserId" jdbcType="BIGINT"/>
	</resultMap>

	
	<select id="findAllVo" resultMap="VoResultMap">
	SELECT
		invbo.id,
		invbo.hx_sn,
		invbo.inv_bank_ids,
		invbo.inv_ids,
		invbo.hx_status,
		invbo.inv_bank_amount,
		invbo.inv_amount,
		invbo.create_time,
		invbo.create_user_id,
		invbo.update_time,
		invbo.update_user_id,
		su.fullname as create_user_name,
		(SELECT GROUP_CONCAT(invoice_number) as nos from invoice_apply where  FIND_IN_SET(id,invbo.inv_ids)) as inv_names
	FROM
		invoice_bank_statement_off AS invbo
		LEFT JOIN sys_user su on invbo.create_user_id=su.id
	<where>
	</where>
	order by invbo.create_time desc
	</select>


	<select id="getOrderIdsByInv" resultType="java.lang.Long" parameterType="java.lang.Long">
    SELECT
    	auco.order_id
    from
    	invoice_apply_x_goods invo
		LEFT JOIN accounting_unified_customer_order B on invo.unified_order_id = auco.id
    where
    	invo.invoice_apply_id = #{id}
	</select>


	<select id="findAll" resultMap="cn.superdesk.uniorder.dao.mapper.invoice.customer.fundrestream.InvoiceBankStatementOffMapper.BaseResultMap">
		select
		<include refid="cn.superdesk.uniorder.dao.mapper.invoice.customer.fundrestream.InvoiceBankStatementOffMapper.Base_Column_List"/>
		from
			invoice_bank_statement_off
		<where>
		<if test="hxSn !=null and hxSn != ''">
			and hx_sn like CONCAT('%',#{hxSn},'%')
		</if>
		<if test="hxStatus !=null and hxStatus != ''">
			and hx_status = #{hxStatus}
		</if>
		</where>

		order by create_time desc
	</select>

</mapper>