123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?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.caimei.modules.supervip.dao.CmSvipHistoryDao">
- <sql id="cmSvipHistoryColumns">
- a.id AS "id",
- a.userId AS "userId",
- a.packageId AS "packageId",
- a.beginTime AS "beginTime",
- a.endTime AS "endTime",
- a.payWay AS "payWay",
- a.payType AS "payType",
- a.price AS "price",
- a.userBeans AS "userBeans",
- a.payTime AS "payTime"
- </sql>
- <sql id="cmSvipHistoryJoins">
- </sql>
- <insert id="giveVip">
- insert into cm_svip_user (userId, beginTime, endTime, delFlag, updateTime)
- values (#{userId}, #{beginTime}, #{endTime}, 0, #{beginTime})
- </insert>
- <insert id="insertHistory">
- insert into cm_svip_history(userId, packageId, beginTime, endTime, payStatus, payWay, price, userBeans, payTime)
- values (#{userId}, 0, #{beginTime}, #{endTime}, 1, #{payWay}, 0, 0, #{payTime})
- </insert>
- <update id="updateVip">
- UPDATE cm_svip_user
- SET
- <if test="beginTime != null">
- beginTime = #{beginTime},
- </if>
- endTime = #{endTime},
- updateTime = now()
- WHERE userId = #{userId}
- </update>
- <select id="get" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- SELECT
- <include refid="cmSvipHistoryColumns"/>
- FROM cm_svip_history a
- <include refid="cmSvipHistoryJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- SELECT
- <include refid="cmSvipHistoryColumns"/>
- FROM cm_svip_history a
- <include refid="cmSvipHistoryJoins"/>
- <where>
- <if test="userId != null and userId != ''">
- AND a.userId = #{userId}
- </if>
- <if test="packageId != null and packageId != ''">
- AND a.packageId = #{packageId}
- </if>
- <if test="beginTime != null and beginTime != ''">
- AND a.beginTime = #{beginTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND a.endTime = #{endTime}
- </if>
- <if test="payTime != null and payTime != ''">
- AND a.payTime = #{payTime}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- SELECT
- <include refid="cmSvipHistoryColumns"/>
- FROM cm_svip_history a
- <include refid="cmSvipHistoryJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findHistory" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- select
- cs.userId,
- cs.packageId,
- u.name as clubName,
- u.userName as linkMan,
- u.bindMobile as mobile,
- cs.beginTime,
- cs.price,
- cs.payWay,
- cs.payType,
- cs.userBeans,
- cs.payTime,
- cs.endTime
- from cm_svip_history cs
- LEFT JOIN club cb ON cs.userId = cb.userId
- left join user u on cs.userId = u.userID
- left join cm_svip_package cp on cp.id = cs.packageId
- where cs.userId = #{userId}
- AND cs.payStatus = '1'
- <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
- and (cs.payTime between #{startPayTime} and #{endPayTime})
- </if>
- <if test="startEndTime != null and startEndTime != '' and endEndTime != null and endEndTime != ''">
- and (cs.endTime between #{startEndTime} and #{endEndTime})
- </if>
- <if test="packageId != null and packageId != 0">
- and cp.duration = #{packageId}
- </if>
- <if test="packageId == 0">
- and cs.packageId = 0
- </if>
- <if test='status == "1"'>
- and (NOW() between cs.beginTime and cs.endTime)
- </if>
- <if test='status == "2"'>
- and NOW() > cs.endTime
- </if>
- <if test='status == "3"'>
- and cs.beginTime > NOW()
- </if>
- order by cs.payTime desc
- </select>
- <select id="findEndTime" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- select beginTime, endTime, updateTime
- from cm_svip_user
- where userId = #{userId}
- and endTime > now()
- </select>
- <select id="superFind" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- SELECT u.name as clubName, u.username as linkMan, u.bindMobile as mobile,
- cs.userId,cs.beginTime,cs.endTime,cs.packageId
- FROM cm_svip_history cs
- LEFT JOIN club cb ON cs.userId = cb.userId
- LEFT JOIN cm_svip_user cu ON cs.userId = cu.userId
- left join user u on cs.userId = u.userID
- left join cm_svip_package cp on cp.id = cs.packageId
- <where>
- AND cs.payStatus = '1'
- <if test="clubName != null and clubName != ''">
- and u.name like concat('%',#{clubName},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- and u.username like concat('%',#{linkMan},'%')
- </if>
- <if test="mobile != null and mobile != ''">
- and u.bindMobile LIKE concat('%',#{mobile},'%')
- </if>
- <if test="startPayTime !=null and startPayTime != '' and endPayTime !=null and endPayTime!=''">
- and (cs.payTime between #{startPayTime} and #{endPayTime})
- </if>
- <if test="startEndTime !=null and startEndTime!='' and endEndTime!=null and endEndTime!=''">
- and (cu.endTime between #{startEndTime} and #{endEndTime})
- </if>
- <if test="packageId !=null and packageId != '' and packageId != 0">
- and cp.duration = #{packageId}
- </if>
- <if test="packageId == 0">
- and cs.packageId = 0
- </if>
- <if test='status == "1"'>
- and cu.endTime > NOW()
- </if>
- <if test='status == "2"'>
- and now() > cu.endTime
- </if>
- </where>
- group by cs.userId
- order by cs.payTime DESC
- </select>
- <select id="findOutEndTime" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- select beginTime, endTime, updateTime
- from cm_svip_user
- where userId = #{userId}
- and beginTime > now()
- </select>
- <select id="findPackage" resultType="java.lang.Integer">
- select id
- from cm_svip_package
- where duration = #{pac}
- </select>
- <select id="findDuration" resultType="java.lang.Integer">
- select duration
- from cm_svip_package
- where id = #{packageId}
- </select>
- <select id="findVipUser" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
- select beginTime, endTime, updateTime, userId
- from cm_svip_user
- where userId = #{userId}
- and delflag = 0
- </select>
- </mapper>
|