123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?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.mapper.VipMapper">
- <insert id="insertVipPackage">
- insert into auth_vip_package(originalPrice, price, duration, unit, addTime)
- VALUES (#{originalPrice}, #{price}, #{duration}, #{unit}, NOW());
- </insert>
- <insert id="insertVipService">
- insert into auth_vip_service(name)
- values (#{service})
- </insert>
- <insert id="insertVipHistory" keyColumn="id" keyProperty="id"
- parameterType="com.caimei.model.po.VipHistoryPo" useGeneratedKeys="true">
- insert into auth_vip_history (authUserId, packageId, duration, beginTime, endTime, payStatus, payWay, payType, price, services, payTime)
- values (#{authUserId}, #{packageId}, #{duration}, #{beginTime}, #{endTime}, #{payStatus}, #{payWay}, null, #{price}, #{services}, #{payTime})
- </insert>
- <insert id="insertAuthVipInfo">
- INSERT INTO auth_vip_user(authUserId, beginTime, endTime, delFlag, updateTime)
- VALUES (#{authUserId}, #{beginTime}, #{endTime}, #{delFlag}, #{updateTime})
- </insert>
- <update id="updateVipHistory">
- UPDATE auth_vip_history
- set payStatus=#{payStatus},
- payWay=#{payWay},
- payType=#{payType},
- duration=#{duration},
- beginTime=#{beginTime},
- endTime=#{endTime},
- price=#{price},
- services=#{services},
- payTime=#{payTime}
- WHERE id = #{id}
- </update>
- <update id="updateAuthVipInfo">
- UPDATE auth_vip_user set authUserId=#{authUserId}, beginTime=#{beginTime}, endTime=#{endTime}, delFlag=#{delFlag}, updateTime=#{updateTime}
- WHERE authUserId = #{authUserId}
- </update>
- <delete id="deleteVipPackages">
- delete from auth_vip_package;
- </delete>
- <delete id="deleteVipServices">
- delete from auth_vip_service;
- </delete>
- <select id="getVipPackageList" resultType="com.caimei.model.vo.VipPackageVo">
- select id, originalPrice, price, duration, unit from auth_vip_package;
- </select>
- <select id="getVipServiceList" resultType="com.caimei.model.vo.VipServiceVo">
- select id, name from auth_vip_service;
- </select>
- <select id="getVipEndTime" resultType="java.util.Date">
- select endTime from auth_vip_user where authUserId = #{authUserId} and endTime > now()
- </select>
- <select id="getVipPackageById" resultType="com.caimei.model.vo.VipPackageVo">
- select duration, unit, price
- from auth_vip_package
- where id = #{packageId}
- </select>
- <select id="getVipHistoryId" resultType="java.lang.Integer">
- SELECT id
- FROM auth_vip_history
- WHERE payStatus = 0
- AND authUserId = #{authUserId}
- AND packageId = #{packageId}
- ORDER BY id DESC
- LIMIT 1
- </select>
- <select id="getVipList" resultType="com.caimei.model.vo.VipListVo">
- select avu.id as vipUserId, avu.authUserId, u.name as shopName, u.shopType,
- u.loginAccount, u.mobile, u.linkMan, if(avu.endTime >NOW(),1,0) as vipStatus
- from auth_vip_user avu
- left join cm_brand_auth_user u on avu.authUserId = u.authUserId
- <where>
- <if test="shopName != null and shopName != ''">
- and u.name like concat('%',#{shopName},'%')
- </if>
- <if test="mobile != null and mobile != ''">
- and u.mobile like concat('%',#{mobile},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- and u.linkMan like concat('%',#{linkMan},'%')
- </if>
- <if test="shopType != null">
- and u.shopType = #{shopType}
- </if>
- <if test="vipStatus != null">
- <if test="vipStatus == 0">
- and NOW() <![CDATA[>]]> avu.endTime
- </if>
- <if test="vipStatus == 1">
- and NOW() <![CDATA[<]]> avu.endTime and NOW() <![CDATA[>]]> avu.beginTime
- </if>
- </if>
- </where>
- order by avu.id desc
- </select>
- <select id="getVipHistoryList" resultType="com.caimei.model.vo.VipHistoryListVo">
- select id as historyId,duration,price,
- if(payWay=2,1,(case payType when 14 then 2
- when 13 or 15 then 3
- when 12 then 4
- when 17 then 5
- end )) as payWay,
- case when NOW() <![CDATA[>]]> endTime then 0
- when NOW() <![CDATA[<]]> beginTime then 2
- else 1 end
- as vipStatus,
- payTime,endTime,services
- from auth_vip_history
- where authUserId = #{authUserId}
- <if test="vipPackageId != null">
- and packageId = #{vipPackageId}
- </if>
- <if test="vipStatus != null">
- <if test="vipStatus == 0">
- and NOW() <![CDATA[>]]> endTime
- </if>
- <if test="vipStatus == 1">
- and NOW() <![CDATA[<]]> endTime and NOW() <![CDATA[>]]> beginTime
- </if>
- <if test="vipStatus == 2">
- and NOW() <![CDATA[<]]> beginTime
- </if>
- </if>
- <if test="payBeginTime != null and payBeginTime != ''">
- and payTime <![CDATA[>=]]> #{payBeginTime}
- </if>
- <if test="payEndTime != null and payEndTime != ''">
- and payTime <![CDATA[<=]]> #{payEndTime}
- </if>
- <if test="endBeginTime != null and endBeginTime != ''">
- and endTime <![CDATA[>=]]> #{endBeginTime}
- </if>
- <if test="endEndTime != null and endEndTime != ''">
- and endTime <![CDATA[<=]]> #{endEndTime}
- </if>
- order by payTime desc
- </select>
- <select id="getVipInfo" resultType="com.caimei.model.vo.VipInfoVo">
- select avu.id as vipUserId,
- u.authUserId,
- u.mobile,
- u.loginAccount,
- avu.endTime,
- if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus,
- 90 - timestampdiff(day, u.createTime, NOW()) as freeDayLeft,
- timestampdiff(day,NOW(),avu.endTime) as endDayLeft,
- date_add(u.createTime, interval 90 day) as freeEndTime
- from cm_brand_auth_user u
- left join auth_vip_user avu on u.authUserId = avu.authUserId
- where u.authUserId = #{authUserId}
- and u.userIdentity = 2
- and u.status = 1
- </select>
- <select id="getAuthVipInfo" resultType="com.caimei.model.po.AuthVipPo">
- SELECT id, authUserId as userId, beginTime, endTime, updateTime, delFlag
- FROM auth_vip_user
- WHERE authUserId = #{authUserId};
- </select>
- <select id="getBaseMenuList" resultType="com.caimei.model.po.SysMenu">
- select m.id, m.title,m.base_flag as baseFlag, m.move_flag as moveFlag, m.status
- from auth_menu m
- left join auth_role_menu arm on m.id = arm.menu_id
- where m.menu_type = 2
- and m.base_flag = 1
- and m.parent_id = 0
- </select>
- <select id="getUpMenuList" resultType="com.caimei.model.po.SysMenu">
- select m.id, m.title,m.base_flag as baseFlag, m.move_flag as moveFlag, m.status
- from auth_menu m
- where m.menu_type = 2
- and m.base_flag = 0
- and m.parent_id = 0
- </select>
- </mapper>
|