admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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.yeshi.fanli.dao.mybatis.user.vip.UserVIPLevelMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.dto.vip.UserVIPLevel">
        <id column="level" property="level" jdbcType="INTEGER" />
        <result column="success_time" property="successTime" jdbcType="TIMESTAMP" />
    </resultMap>
    
    <select id="getLevelByUid" resultMap="BaseResultMap">
        SELECT IFNULL(A.grade,B.vpi_process) AS 'level',IF(A.grade IS NULL,B.vpi_create_time,A.uvi_success_time) AS 'success_time' 
        FROM (SELECT p.`vpi_process`,p.`vpi_uid`,p.`vpi_create_time` FROM `yeshi_ec_user_vip_pre_info` p
          WHERE p.`vpi_uid` = #{uid}  ORDER BY p.`vpi_process` DESC LIMIT 1)B
            LEFT JOIN (SELECT 10 AS grade,d.`uvi_uid`,d.`uvi_success_time` FROM `yeshi_ec_user_vip_info` d
         WHERE d.`uvi_uid` = #{uid} AND d.`uvi_state` = 2 LIMIT 1)A ON A.uvi_uid = B.vpi_uid
    </select>
 
</mapper>