<?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.timer.api.dao.qyzx.QyzxLogBuyMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.qyzx.QyzxLogBuy" >
                <id column="id" property="id" />
                <result column="emp_num" property="empNum" />
                <result column="pay_serve_id" property="payServeId" />
    </resultMap>
	<resultMap id="queryMap" type="cn.timer.api.dto.qyzx.AttaFpglQueryDto">
			<result column="query" property="query"/>
			<result column="startTime" property="startTime"/>
			<result column="endTime" property="endTime"/>
	</resultMap>
	
	
	
	
    <sql id="Base_Column_List">
                id,
                emp_num,
                org_code,
                user_type
    </sql>
	

	<select id="selectByName" resultType="cn.timer.api.dto.qyzx.LogBuyDto" parameterType="cn.timer.api.dto.qyzx.AttaFpglQueryDto"  >
	    SELECT
	    	qps.type,qps.name,qlb.money,qlb.num,qlb.create_time qlbt
	    FROM
			qyzx_pay_serve qps
	    LEFT JOIN
	    	qyzx_log_buy qlb
	    ON
	  		qlb.pay_serve_id = qps.id
		WHERE
			<if test="param.empNum != null and param.empNum != ''">
        		qlb.emp_num = #{param.empNum}
        	</if>
			<if test="param.query != null and param.query != ''">
        		and qps.name like CONCAT('%',#{param.query},'%')
        	</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and qlb.create_time > #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
        		and qlb.create_time <![CDATA[ < ]]> #{param.endTime}
        	</if>
	</select>
	
	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.qyzx.QyzxEmpEntAsso">
        INSERT INTO qyzx_emp_ent_asso
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != empNum'>
                        emp_num,
                        </if>
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != userType'>
                        user_type
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != empNum'>
                        #{empNum},
                        </if>
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != userType'>
                        #{userType}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM qyzx_emp_ent_asso
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.qyzx.QyzxEmpEntAsso">
        UPDATE qyzx_emp_ent_asso
        <set>
                    <if test ='null != empNum'>emp_num = #{empNum},</if>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != userType'>user_type = #{userType}</if>
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_emp_ent_asso
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM qyzx_emp_ent_asso
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM qyzx_emp_ent_asso
    </select>

	 -->

</mapper>