<?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.dgtly.order.mapper.OrderSalesGroupMapper">
    
    <resultMap type="OrderSalesGroup" id="OrderSalesGroupResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDelete"    column="is_delete"    />
        <result property="companyCode"    column="company_code"    />
        <result property="companyName"    column="company_name"    />
        <result property="saledeptCode"    column="saledept_code"    />
        <result property="saledeptName"    column="saledept_name"    />
        <result property="officeCode"    column="office_code"    />
        <result property="officeName"    column="office_name"    />
        <result property="subofficeCode"    column="suboffice_code"    />
        <result property="subofficeName"    column="suboffice_name"    />
        <result property="customerGroup"    column="customer_group"    />
        <result property="customerGroupName"    column="customer_group_name"    />
        <result property="calMonth"    column="cal_month"    />
        <result property="nowYearAct"    column="now_year_act"    />
        <result property="nowYearBud"    column="now_year_bud"    />
        <result property="reviewNo"    column="review_no"    />
        <result property="uncleared"    column="uncleared"    />
        <result property="freeze"    column="freeze"    />
        <result property="runTime"    column="run_time"    />
    </resultMap>

    <sql id="selectOrderSalesGroupVo">
        select id, create_by, create_time, update_by, update_time, is_delete, company_code, company_name, saledept_code, saledept_name, office_code, office_name, suboffice_code, suboffice_name, customer_group, customer_group_name, cal_month, now_year_act, now_year_bud, review_no, uncleared, freeze, run_time from order_sales_group
    </sql>

    <select id="selectOrderSalesGroupList" parameterType="OrderSalesGroup" resultMap="OrderSalesGroupResult">
        <include refid="selectOrderSalesGroupVo"/>
        <where>  
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="saledeptCode != null  and saledeptCode != ''"> and saledept_code = #{saledeptCode}</if>
            <if test="saledeptName != null  and saledeptName != ''"> and saledept_name like concat('%', #{saledeptName}, '%')</if>
            <if test="officeCode != null  and officeCode != ''"> and office_code = #{officeCode}</if>
            <if test="officeName != null  and officeName != ''"> and office_name like concat('%', #{officeName}, '%')</if>
            <if test="subofficeCode != null  and subofficeCode != ''"> and suboffice_code = #{subofficeCode}</if>
            <if test="subofficeName != null  and subofficeName != ''"> and suboffice_name like concat('%', #{subofficeName}, '%')</if>
            <if test="customerGroup != null  and customerGroup != ''"> and customer_group = #{customerGroup}</if>
            <if test="customerGroupName != null  and customerGroupName != ''"> and customer_group_name like concat('%', #{customerGroupName}, '%')</if>
            <if test="calMonth != null  and calMonth != ''"> and cal_month = #{calMonth}</if>
            <if test="nowYearAct != null  and nowYearAct != ''"> and now_year_act = #{nowYearAct}</if>
            <if test="nowYearBud != null  and nowYearBud != ''"> and now_year_bud = #{nowYearBud}</if>
            <if test="reviewNo != null  and reviewNo != ''"> and review_no = #{reviewNo}</if>
            <if test="uncleared != null  and uncleared != ''"> and uncleared = #{uncleared}</if>
            <if test="freeze != null  and freeze != ''"> and freeze = #{freeze}</if>
            <if test="runTime != null  and runTime != ''"> and run_time = #{runTime}</if>
        </where>
    </select>
    
    <select id="selectOrderSalesGroupById" parameterType="Long" resultMap="OrderSalesGroupResult">
        <include refid="selectOrderSalesGroupVo"/>
        where id = #{id}
    </select>
    
</mapper>