<?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.dxhy.core.job.dao.SysUserDao">

    <select id="getSpCode" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and status = '1'
          and sp_code is not null
          and (authorize_code is null or authorize_code = '' or last_date &lt; date_add(now(), interval 5 day))
    </select>
    <select id="getSpCodeByAuthCode" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and status = '1'
          and taxno = #{taxno}
          and sp_code = #{spCode}
          and authorize_code is not null
          and authorize_code !='' and last_date >= date_add(now(), interval 5 day)
        order by last_date desc limit 1
    </select>
    <select id="listUser" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and sp_type in ('1', '2')
          and locate('2', kp_type) > 0
          and fpzyztp is null
    </select>
    <select id="listUserByTaxno" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and fpzyztp is not null
          and fpzyztp != ''and taxno = #{taxno} limit 1
    </select>
    <select id="listUserToSignatureId" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and sp_type in ('1', '2')
          and locate('2', kp_type) > 0
          and fpzyztp is not null
          and signature_id is null
    </select>
    <select id="listUserToSignatureIdByTaxno" resultType="com.dxhy.core.job.entity.SysUserEntity">
        select *
        from sys_user
        where user_type = '2'
          and signature_id is not null
          and taxno = #{taxno} limit 1
    </select>
</mapper>