<?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.bonus.canteen.core.customer.mapper.CustCasualMapper">

    <resultMap id="custCasualMap" type="com.bonus.common.houqin.domain.CustCasual">
        <id property="id" column="id"/>
        <result property="casualId" column="casual_id"/>
        <result property="casualName" column="casual_name"/>
        <result property="custId" column="cust_id"/>
        <result property="mobile" column="mobile"/>
        <result property="email" column="email"/>
        <result property="address" column="address"/>
        <result property="openid" column="openid"/>
        <result property="sourceType" column="source_type"/>
        <result property="ifDel" column="if_del"/>
        <result property="revision" column="revision"/>
        <result property="crby" column="crby"/>
        <result property="crtime" column="crtime"/>
        <result property="upby" column="upby"/>
        <result property="uptime" column="uptime"/>
    </resultMap>

    <resultMap id="custCasualModel" extends="custCasualMap"
               type="com.bonus.common.houqin.domain.CustCasualModel">
        <result property="custNum" column="cust_num"/>
        <result property="custName" column="cust_name"/>
        <result property="age" column="age"/>
    </resultMap>

    <!-- 分页查询临时人员，并关联查询相关人员信息 -->
    <select id="queryPageCustCasual" resultMap="custCasualModel"
            parameterType="com.bonus.common.houqin.domain.CustCasual">
        select *
        from cust_casual t1
        left join cust_info t2 on t1.cust_id = t2.cust_id
        where
        t2.cust_state = 1
        <if test="custCasual.casualName != null and custCasual.casualName != ''">
            and t1.casual_name = #{custCasual.casualName,jdbcType=VARCHAR}
        </if>
        <if test="custCasual.custId != null">
            and t1.cust_id = #{custCasual.custId,jdbcType=BIGINT}
        </if>
        <if test="custCasual.mobile != null and custCasual.mobile != ''">
            and t1.mobile = #{custCasual.mobile,jdbcType=VARCHAR}
        </if>
        <if test="custCasual.openid != null and custCasual.openid != ''">
            and t1.openid = #{custCasual.openid,jdbcType=VARCHAR}
        </if>
        <if test="custCasual.sourceType != null">
            and t1.source_type = #{custCasual.sourceType,jdbcType=INTEGER}
        </if>
        <if test="custCasual.ifDel != null">
            and t1.if_del = #{custCasual.ifDel,jdbcType=INTEGER}
        </if>

    </select>

</mapper>
