<?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.u8c.Encapsulation.dao.impl.EncapsulationDaoImpl">

    <select id="queryCgrkddh" resultType="com.hzya.frame.u8c.Encapsulation.entity.EncapsulationEntity" parameterType = "com.hzya.frame.u8c.Encapsulation.entity.EncapsulationEntity">
        SELECT
        h.vbillcode as code,
        a.unitcode
        FROM
        ic_general_h h
        LEFT JOIN bd_corp a  on a.pk_corp = h.pk_corp
        WHERE
        h.cgeneralhid in (
        SELECT cgeneralhid FROM ic_general_b WHERE vfirstbillcode = #{code}
        <if test="type != null and type != ''"> and csourcetype = #{type} </if>
        )
        <if test="cbilltypecode != null and cbilltypecode != ''"> and h.cbilltypecode = #{cbilltypecode} </if>

    </select>


</mapper>

