<?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.willalp.yiqing.mapper.HsPositiveContiguityUserMapper">
    <resultMap type="com.willalp.yiqing.domain.HsPositiveContiguityUser" id="HsPositiveContiguityUserResult">
        <result property="dataId" column="data_id"/>
        <result property="userNo" column="user_no"/>
        <result property="userName" column="user_name"/>
        <result property="otherAttest" column="other_attest"/>
        <result property="attestNo" column="attest_no"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="houseNo" column="house_no"/>
        <result property="areaName" column="area_name"/>
        <result property="belongName" column="belong_name"/>
        <result property="belongPhone" column="belong_phone"/>
        <result property="exceptionRegisterType" column="exception_register_type"/>
        <result property="exceptionRegisterTime" column="exception_register_time"/>
        <result property="transferType" column="transfer_type"/>
        <result property="transferTime" column="transfer_time"/>
        <result property="normalStatus" column="normal_status"/>
        <result property="normalTime" column="normal_time"/>
        <result property="isDelete" column="is_delete"/>
        <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="remark" column="remark"/>
    </resultMap>

    <resultMap type="com.willalp.yiqing.domain.vo.PcuVo" id="PcuVo">
        <result property="dataId" column="data_id"/>
        <result property="userNo" column="user_no"/>
        <result property="userName" column="user_name"/>
        <result property="otherAttest" column="other_attest"/>
        <result property="attestNo" column="attest_no"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="houseNo" column="house_no"/>
        <result property="areaName" column="area_name"/>
        <result property="belongName" column="belong_name"/>
        <result property="belongPhone" column="belong_phone"/>
        <result property="exceptionRegisterType" column="exception_register_type"/>
        <result property="exceptionRegisterTime" column="exception_register_time"/>
        <result property="transferType" column="transfer_type"/>
        <result property="transferTime" column="transfer_time"/>
        <result property="normalStatus" column="normal_status"/>
        <result property="normalTime" column="normal_time"/>
        <result property="isDelete" column="is_delete"/>
        <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="remark" column="remark"/>
    </resultMap>
    <sql id="selectHsPositiveContiguityUserVo">
        select data_id,
               user_no,
               user_name,
               other_attest,
               attest_no,
               phone,
               address,
               house_no,
               area_name,
               belong_name,
               belong_phone,
               seven_send_orders,
               fourteen_send_orders,
               exception_register_type,
               exception_register_time,
               transfer_type,
               transfer_time,
               normal_status,
               normal_time,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_yiqing_positive_contiguity_user
    </sql>

    <select id="selectHsPositiveContiguityUserList" parameterType="PcuVo"
            resultMap="HsPositiveContiguityUserResult">
        <include refid="selectHsPositiveContiguityUserVo"/>
        <where>
            is_delete = 0
            <if test="userNo != null  and userNo != ''">
                and user_no like concat('%', #{userNo}, '%')
            </if>
            <if test="userName != null  and userName != ''">
                and user_name like concat('%', #{userName}, '%')
            </if>
            <if test="otherAttest != null  and otherAttest != ''">
                and other_attest = #{otherAttest}
            </if>
            <if test="attestNo != null  and attestNo != ''">
                and attest_no like concat('%', #{attestNo}, '%')
            </if>
            <if test="phone != null  and phone != ''">
                and phone like concat('%', #{phone}, '%')
            </if>
            <if test="address != null  and address != ''">
                and address like concat('%', #{address}, '%')
            </if>
            <if test="houseNo != null  and houseNo != ''">
                and house_no like concat('%', #{houseNo}, '%')
            </if>
            <if test="areaName != null  and areaName != ''">
                and areaName like concat('%', #{areaName}
                , '%')
            </if>
            <if test="exceptionRegisterType != null  and exceptionRegisterType != ''">
                and exception_register_type = #{exceptionRegisterType}
            </if>
            <if test="exceptionRegisterTime != null ">
                and datediff(exception_register_time, #{exceptionRegisterTime}) = 0
            </if>
            <if test="transferType != null  and transferType != ''">
                and transfer_type = #{transferType}
            </if>
            <if test="transferTime != null ">
                and datediff(transfer_time, #{transferTime}) = 0
            </if>
            <if test="normalStatus != null  and normalStatus != ''">
                and normal_status = #{normalStatus}
            </if>
            <if test="normalTime != null ">
                and datediff(normal_time, #{normalTime}) = 0
            </if>
            order by exception_register_time desc
        </where>
    </select>
    <select id="selectPcuJJGlList" parameterType="PcuVo"
            resultMap="HsPositiveContiguityUserResult">
        <include refid="selectHsPositiveContiguityUserVo"/>
        <where>
            is_delete = 0 AND (
            transfer_type = '1'
            AND normal_status NOT IN ('5'))
            <if test="userNo != null  and userNo != ''">
                and user_no like concat('%', #{userNo}, '%')
            </if>
            <if test="userName != null  and userName != ''">
                and user_name like concat('%', #{userName}, '%')
            </if>
            <if test="otherAttest != null  and otherAttest != ''">
                and other_attest = #{otherAttest}
            </if>
            <if test="attestNo != null  and attestNo != ''">
                and attest_no like concat('%', #{attestNo}, '%')
            </if>
            <if test="phone != null  and phone != ''">
                and phone like concat('%', #{phone}, '%')
            </if>
            <if test="address != null  and address != ''">
                and address like concat('%', #{address}, '%')
            </if>
            <if test="houseNo != null  and houseNo != ''">
                and house_no like concat('%', #{houseNo}, '%')
            </if>
            <if test="areaName != null  and areaName != ''">
                and area_name like concat('%', #{areaName}
                , '%')
            </if>
            <if test="exceptionRegisterType != null  and exceptionRegisterType != ''">
                and exception_register_type = #{exceptionRegisterType}
            </if>
            <if test="exceptionRegisterTime != null ">
                and datediff(exception_register_time, #{exceptionRegisterTime}) = 0
            </if>
            <if test="transferType != null  and transferType != ''">
                and transfer_type = #{transferType}
            </if>
            <if test="transferTime != null ">
                and datediff(transfer_time, #{transferTime}) = 0
            </if>
            <if test="normalStatus != null  and normalStatus != ''">
                and normal_status = #{normalStatus}
            </if>
            <if test="normalTime != null ">
                and datediff(normal_time, #{normalTime}) = 0
            </if>
        </where>
        order by normal_time desc
    </select>

    <update id="updateListById">
        UPDATE
        hs_yiqing_positive_contiguity_user
        SET user_no=?, exception_register_time=?, exception_register_type=?, normal_status=?, transfer_type=?,
        normal_time=?, transfer_time=?, user_name=?, other_attest=?, attest_no=?, phone=?, address=?, area_name=?,
        house_no=?, belong_name=?, belong_phone=?, remark=?, seven_send_orders=?, fourteen_send_orders=?, create_by=?,
        create_time=?, update_by=?, update_time=? WHERE data_id=? AND is_delete=0
        <foreach collection="list" open="(" separator="," close=")" item="item">
        </foreach>
    </update>
</mapper>
