<?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.CkPublicBenefitsMapper">
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.ck.CkPublicBenefits">
        <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="month" property="month"/>
        <result column="year" property="year"/>
        <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"/>
        <result column="monthday" property="monthday"/>
        <result column="yearday" property="yearday"/>
        <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="is_auto" property="isAuto"/>
    </resultMap>

    <select id="queryPageList" resultType="cn.com.countrygarden.bi.main.dto.ck.CkPublicBenefitsDTO">
          SELECT `id` as id,`org_code` as orgCode,`org_name` as orgName,`comm_code` as commCode,`comm_name` as commName, `month` as `month`,`year` as `year`, `status` as `status`,
   `uct` as uct,`edutax` as edutax,`ledtax` as ledtax,`other` as other,`bacirate` as bacirate,`stampduty` as stampduty,`monthday` as monthday, `yearday` as yearday, `create_by` as createBy,
  `create_time` as createTime, `update_by` as updateBy,`update_time` as updateTime,`create_name` as createName,`update_name` as updateName
   FROM `ck_public_benefits`
    WHERE `status`=1
    <if test="ckPublicBenefits.orgCode!=null and ckPublicBenefits.orgCode!=''">
        and org_code=#{ckPublicBenefits.orgCode}
    </if>
        <if test="ckPublicBenefits.commCode!=null and ckPublicBenefits.commCode!=''">
            and comm_code=#{ckPublicBenefits.commCode}
        </if>
        <if test="ckPublicBenefits.year!=null and ckPublicBenefits.year!=''">
            and `year`=#{ckPublicBenefits.year}
        </if>
        <if test="ckPublicBenefits.month!=null and ckPublicBenefits.month!=''">
            and `month`=#{ckPublicBenefits.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 org_code ASC,comm_code ASC,`year` DESC,`month` ASC
    </select>

    <select id="revenueList" resultType="cn.com.countrygarden.bi.main.dto.CkPublicBenefitsDTOVO">
           <![CDATA[
        SELECT `id` as id,`org_code` as orgCode,`org_name` as orgName,`comm_code` as commCode,`comm_name` as commName, `month` as `month`,`year` as `year`,
        `uct` as `uct`,`edutax` as `edutax`,`ledtax` as `ledtax`,`other` as `other`,`bacirate` as `bacirate`,`stampduty` as `stampduty`,`monthday` as `monthday`, `yearday` as `yearday`
        FROM `ck_public_benefits`
        WHERE `status`=1 and update_time>= #{updateDate}
         ]]>
    </select>

    <select id="seletcOnt" resultMap="BaseResultMap">
        SELECT `id`,`org_code`,`org_name`,`comm_code`,`comm_name`, `month`,`year`,
        `uct`,`edutax`,`ledtax`,`other`,`bacirate`,`stampduty`
        FROM `ck_public_benefits`
        WHERE `status`=1 and id=#{id}
    </select>

</mapper>