<?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.com.countrygarden.bi.main.dao.ck.CkPublicBenefitsZationMapper">

    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.ck.CkPublicBenefitsZation">
        <id column="id" property="id"/>
        <result column="org_code" property="orgCode"/>
        <result column="org_name" property="orgName"/>
        <result column="comm_name" property="commName"/>
        <result column="comm_code" property="commCode"/>
        <result column="book_time" property="bookTime"/>
        <result column="year" property="year"/>
        <result column="aobamount" property="aobamount"/>
        <result column="uncollected" property="uncollected"/>
        <result column="payablebut" property="payablebut"/>
        <result column="create_name" property="createName"/>
        <result column="update_name" property="updateName"/>
        <result column="status" property="status"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="uct" property="uct"/>
        <result column="ledtax" property="ledtax"/>
        <result column="edutax" property="edutax"/>
        <result column="other" property="other"/>
        <result column="bacirate" property="bacirate"/>
        <result column="stampduty" property="stampduty"/>
    </resultMap>

    <select id="queryPageList" resultType="cn.com.countrygarden.bi.main.dto.ck.CkPublicBenefitsZationVo">
        SELECT
            `id` as id,
            `org_code` as orgCode,
            `org_name` as orgName,
            `comm_code` as commCode,
            `comm_name` as commName,
            `book_time` as bookTime,
            `aobamount` as aobamount,
            `uncollected` as uncollected,
            `payablebut` as payablebut
        FROM `ck_public_benefits_zation`
        WHERE `status`=1
        <if test="ckPublicBenefitsZation.orgCode!=null and ckPublicBenefitsZation.orgCode!=''">
             and org_code=#{ckPublicBenefitsZation.orgCode}
        </if>
        <if test="ckPublicBenefitsZation.commCode!=null and ckPublicBenefitsZation.commCode!=''">
            and comm_code=#{ckPublicBenefitsZation.commCode}
        </if>
        <if test="ckPublicBenefitsZation.year!=null">
            and book_time LIKE CONCAT("%",#{ckPublicBenefitsZation.year},"%")
        </if>
        <if test="ckPublicBenefitsZation.month!=null">
            and book_time LIKE CONCAT("%",#{ckPublicBenefitsZation.month})
        </if>
        <if test="organCodeString!=null and organCodeString.size()!=0">
            and (org_code in
            <foreach collection="organCodeString" item="organCodeString" index="index" open="(" close=")" separator=",">
                #{organCodeString}
            </foreach>
        </if>
        <if test="commIdString!=null and commIdString.size()!=0">
            or comm_code in
            <foreach collection="commIdString" item="commIdString" index="index" open="(" close=")" separator=",">
                #{commIdString}
            </foreach>
            )
        </if>
        ORDER BY book_time DESC
    </select>

    <select id="selectCher" resultType="cn.com.countrygarden.bi.main.model.ck.CkPublicBenefitsZation">
        SELECT
            `id` as id,
            `org_code` as orgCode,
            `org_name` as orgName,
            `comm_code` as commCode,
            `comm_name` as commName,
            `book_time` as bookTime,
            `aobamount` as aobamount,
            `uncollected` as uncollected,
            `payablebut` as payablebut
        FROM `ck_public_benefits_zation`
        WHERE `status`=1
        <if test="orgCode!=null and orgCode!=''">
            and org_code=#{orgCode}
        </if>
        <if test="commCode!=null and commCode!=''">
            and comm_code=#{commCode}
        </if>
        <if test="bookTime!=null and bookTime!=''">
            and book_time=#{bookTime}
        </if>
    </select>
</mapper>