<?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.sqx.modules.integral.dao.UserIntegralDetailsDao">

    <select id="isSignIn" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select * from user_integral_details where user_id = #{userId} and classify = 1
        and date_format(create_time,'%Y-%m-%d')=date_format(#{format},'%Y-%m-%d')
    </select>

    <select id="selectIntegraldetailsList" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select * from user_integral_details where user_id = #{userId}
        <if test="classify!=null ">
            and classify = #{classify}
        </if>
        order by create_time desc
    </select>

    <select id="selectSignIn" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select * from user_integral_details where user_id = #{userId} order by create_time desc
    </select>

    <select id="selectUserIntegralDetails" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select * from user_integral_details where user_id = #{userId} and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d') and classify = 1 limit 1
    </select>

    <select id="queryIntegralList" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select uid.*,tu.phone as phone ,tu.user_name as userName
        from user_integral_details uid left join tb_user tu on uid.user_id =tu.user_id
        where 1=1
        <if test="classify!=null and classify!=''">
            and uid.classify = #{classify}
        </if>
        <if test="phone!=null and phone!=''">
            and tu.phone like CONCAT('%',#{phone},'%')
        </if>
        <if test="orderNumber!=null and orderNumber!=''" >
            and uid.order_number like CONCAT('%',#{orderNumber},'%')
        </if>
        order by create_time desc
    </select>
    <select id="selectUserIntegralDetailsByExp" resultType="com.sqx.modules.integral.entity.UserIntegralDetails">
        select * from user_integral_details where date_format(exp_time,'%Y-%m-%d') &lt;=date_format(#{date},'%Y-%m-%d') and classify = 4
    </select>
</mapper>