<?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.UserInfoMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="identifycode" property="openid" jdbcType="VARCHAR" />
|
<result column="login_type" property="loginType" jdbcType="INTEGER" />
|
<result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
|
<result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
|
<result column="nick_name" property="nickName" jdbcType="VARCHAR" />
|
<result column="tbName" property="tbName" jdbcType="VARCHAR" />
|
<result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
|
<result column="wxName" property="wxName" jdbcType="VARCHAR" />
|
<result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
|
<result column="portrait" property="portrait" jdbcType="VARCHAR" />
|
<result column="createtime" property="createtime" jdbcType="BIGINT" />
|
<result column="last_logintime" property="lastLoginTime"
|
jdbcType="BIGINT" />
|
<result column="loginip" property="lastLoginIp" jdbcType="VARCHAR" />
|
<result column="tuiguang_code" property="tuiGuangCode"
|
jdbcType="VARCHAR" />
|
<result column="appid" property="appId" jdbcType="VARCHAR" />
|
<result column="my_hongBao" property="myHongBao" jdbcType="DECIMAL" />
|
<result column="pay_password" property="payPassword" jdbcType="VARCHAR" />
|
<result column="rank" property="rank" jdbcType="INTEGER" />
|
<result column="phone" property="phone" jdbcType="VARCHAR" />
|
<result column="state" property="state" jdbcType="INTEGER" />
|
<result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
|
<!-- <association property="system" column="sid" resultMap="com.yeshi.fanli.dao.mybatis.SystemMapper.BaseResultMap"
|
/> -->
|
|
|
</resultMap>
|
<sql id="Base_Column_List">id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where id = #{id,jdbcType=BIGINT} and `state`=0
|
</select>
|
|
<select id="selectByPKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where id = #{id,jdbcType=BIGINT}
|
</select>
|
|
<select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where id = #{id,jdbcType=BIGINT} for update
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_user where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
|
useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user
|
(id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc)
|
values
|
(#{id,jdbcType=BIGINT},#{openid,jdbcType=VARCHAR},#{loginType,jdbcType=INTEGER},#{wxOpenId,jdbcType=VARCHAR},#{wxUnionId,jdbcType=VARCHAR},#{nickName,jdbcType=VARCHAR},#{tbName,jdbcType=VARCHAR},#{tbPic,jdbcType=VARCHAR},#{wxName,jdbcType=VARCHAR},#{wxPic,jdbcType=VARCHAR},#{portrait,jdbcType=VARCHAR},#{createtime,jdbcType=BIGINT},#{lastLoginTime,jdbcType=BIGINT},#{lastLoginIp,jdbcType=VARCHAR},#{tuiGuangCode,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},#{myHongBao,jdbcType=DECIMAL},#{payPassword,jdbcType=VARCHAR},#{system.id,jdbcType=BIGINT},#{rank,jdbcType=INTEGER},#{phone,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{stateDesc,jdbcType=VARCHAR})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_user
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="openid != null">identifycode,</if>
|
<if test="loginType != null">login_type,</if>
|
<if test="wxOpenId != null">wx_open_id,</if>
|
<if test="wxUnionId != null">wx_union_id,</if>
|
<if test="nickName != null">nick_name,</if>
|
<if test="tbName != null">tbName,</if>
|
<if test="tbPic != null">tbPic,</if>
|
<if test="wxName != null">wxName,</if>
|
<if test="wxPic != null">wxPic,</if>
|
<if test="portrait != null">portrait,</if>
|
<if test="createtime != null">createtime,</if>
|
<if test="lastLoginTime != null">last_logintime,</if>
|
<if test="lastLoginIp != null">loginip,</if>
|
<if test="tuiGuangCode != null">tuiguang_code,</if>
|
<if test="appId != null">appid,</if>
|
<if test="myHongBao != null">my_hongBao,</if>
|
<if test="payPassword != null">pay_password,</if>
|
<if test="system != null">sid,</if>
|
<if test="rank != null">rank,</if>
|
<if test="phone != null">phone,</if>
|
<if test="state != null">state,</if>
|
<if test="stateDesc != null">state_desc,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="openid != null">#{openid,jdbcType=VARCHAR},</if>
|
<if test="loginType != null">#{loginType,jdbcType=INTEGER},</if>
|
<if test="wxOpenId != null">#{wxOpenId,jdbcType=VARCHAR},</if>
|
<if test="wxUnionId != null">#{wxUnionId,jdbcType=VARCHAR},</if>
|
<if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if>
|
<if test="tbName != null">#{tbName,jdbcType=VARCHAR},</if>
|
<if test="tbPic != null">#{tbPic,jdbcType=VARCHAR},</if>
|
<if test="wxName != null">#{wxName,jdbcType=VARCHAR},</if>
|
<if test="wxPic != null">#{wxPic,jdbcType=VARCHAR},</if>
|
<if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if>
|
<if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
|
<if test="lastLoginTime != null">#{lastLoginTime,jdbcType=BIGINT},</if>
|
<if test="lastLoginIp != null">#{lastLoginIp,jdbcType=VARCHAR},</if>
|
<if test="tuiGuangCode != null">#{tuiGuangCode,jdbcType=VARCHAR},</if>
|
<if test="appId != null">#{appId,jdbcType=VARCHAR},</if>
|
<if test="myHongBao != null">#{myHongBao,jdbcType=DECIMAL},</if>
|
<if test="payPassword != null">#{payPassword,jdbcType=VARCHAR},</if>
|
<if test="system != null">#{system.id,jdbcType=BIGINT},</if>
|
<if test="rank != null">#{rank,jdbcType=INTEGER},</if>
|
<if test="phone != null">#{phone,jdbcType=VARCHAR},</if>
|
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
<if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR}</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">update
|
yeshi_ec_user set identifycode = #{openid,jdbcType=VARCHAR},login_type
|
= #{loginType,jdbcType=INTEGER},wx_open_id =
|
#{wxOpenId,jdbcType=VARCHAR},wx_union_id =
|
#{wxUnionId,jdbcType=VARCHAR},nick_name =
|
#{nickName,jdbcType=VARCHAR},tbName = #{tbName,jdbcType=VARCHAR},tbPic
|
= #{tbPic,jdbcType=VARCHAR},wxName = #{wxName,jdbcType=VARCHAR},wxPic
|
= #{wxPic,jdbcType=VARCHAR},portrait =
|
#{portrait,jdbcType=VARCHAR},createtime =
|
#{createtime,jdbcType=BIGINT},last_logintime =
|
#{lastLoginTime,jdbcType=BIGINT},loginip =
|
#{lastLoginIp,jdbcType=VARCHAR},tuiguang_code =
|
#{tuiGuangCode,jdbcType=VARCHAR},appid =
|
#{appId,jdbcType=VARCHAR},my_hongBao =
|
#{myHongBao,jdbcType=DECIMAL},pay_password =
|
#{payPassword,jdbcType=VARCHAR},sid =
|
#{system.id,jdbcType=BIGINT},rank = #{rank,jdbcType=INTEGER} ,phone
|
=#{phone,jdbcType=VARCHAR} ,state =#{state,jdbcType=INTEGER}
|
,state_desc =#{stateDesc,jdbcType=VARCHAR} where id =
|
#{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
update yeshi_ec_user
|
<set>
|
<if test="openid != null">identifycode=#{openid,jdbcType=VARCHAR},</if>
|
<if test="loginType != null">login_type=#{loginType,jdbcType=INTEGER},</if>
|
<if test="wxOpenId != null">wx_open_id=#{wxOpenId,jdbcType=VARCHAR},</if>
|
<if test="wxUnionId != null">wx_union_id=#{wxUnionId,jdbcType=VARCHAR},</if>
|
<if test="nickName != null">nick_name=#{nickName,jdbcType=VARCHAR},</if>
|
<if test="tbName != null">tbName=#{tbName,jdbcType=VARCHAR},</if>
|
<if test="tbPic != null">tbPic=#{tbPic,jdbcType=VARCHAR},</if>
|
<if test="wxName != null">wxName=#{wxName,jdbcType=VARCHAR},</if>
|
<if test="wxPic != null">wxPic=#{wxPic,jdbcType=VARCHAR},</if>
|
<if test="portrait != null">portrait=#{portrait,jdbcType=VARCHAR},</if>
|
<if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
|
<if test="lastLoginTime != null">last_logintime=#{lastLoginTime,jdbcType=BIGINT},</if>
|
<if test="lastLoginIp != null">loginip=#{lastLoginIp,jdbcType=VARCHAR},</if>
|
<if test="tuiGuangCode != null">tuiguang_code=#{tuiGuangCode,jdbcType=VARCHAR},</if>
|
<if test="appId != null">appid=#{appId,jdbcType=VARCHAR},</if>
|
<if test="myHongBao != null">my_hongBao=#{myHongBao,jdbcType=DECIMAL},</if>
|
<if test="payPassword != null">pay_password=#{payPassword,jdbcType=VARCHAR},</if>
|
<if test="system != null">sid=#{system.id,jdbcType=BIGINT},</if>
|
<if test="rank != null">rank=#{rank,jdbcType=INTEGER},</if>
|
<if test="phone !=null">phone =#{phone,jdbcType=VARCHAR},</if>
|
<if test="state !=null">state =#{state,jdbcType=INTEGER},</if>
|
<if test="stateDesc !=null">state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="subHongBaoByUid">update yeshi_ec_user set my_hongBao=
|
my_hongBao-#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
|
</update>
|
<update id="addHongBaoByUid">update yeshi_ec_user set my_hongBao=
|
my_hongBao+#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
|
</update>
|
<!-- 清除手势密码 -->
|
<delete id="cleanPassword">DELETE FROM `yeshi_ec_extract_record` WHERE uid =
|
#{id};
|
</delete>
|
<!-- 查询新人红包 -->
|
<select id="getNewPeopleHB" resultType="BigDecimal">SELECT sum(hb.`money`)
|
FROM `yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id} AND hb.`type` = '4';
|
</select>
|
<!-- 查询我的红包 -->
|
<select id="getMyHB" resultType="BigDecimal">SELECT SUM(hb.`money`) FROM
|
`yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id};
|
</select>
|
<!-- 根据AppId与微信unionID获取用户 -->
|
<select id="getUserInfoByAppIdAndWXUnionId" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where appid=#{appId} and wx_union_id=#{unionId}
|
limit 1
|
</select>
|
<!-- 根据AppId与淘宝OpenId获取用户 -->
|
<select id="getUserInfoByAppIdAndTaoBaoOpenId" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where appid=#{appId} and identifycode=#{openId}
|
limit 1
|
</select>
|
<!-- 根据AppId与电话号码获取用户 -->
|
<select id="getUserInfoByAppIdAndPhone" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user where appid=#{appId} and phone=#{phone} limit 1
|
</select>
|
<select id="getMaxUid" resultType="java.lang.Long">select max(id) from
|
yeshi_ec_user
|
</select>
|
<!-- 两个账号的业务融合 -->
|
<select id="connectUser" >
|
call procedure_connect_user(#{mainUid},#{lessUid})
|
</select>
|
|
<select id="query" resultMap="BaseResultMap">
|
SELECT u.*
|
<if test="orderField != null and orderField != 5 and orderField != 6">
|
,(SELECT COUNT(hb.id) FROM `yeshi_ec_hongbao` hb
|
WHERE hb.uid = u.id AND TYPE IN (1,2)
|
<if test="orderMode == 2">
|
<!-- AND TO_DAYS(FROM_UNIXTIME(hb.`createtime`/1000)) = TO_DAYS(NOW()) -->
|
AND DATE_FORMAT( FROM_UNIXTIME(hb.`createtime`/1000), '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
|
</if>
|
)AS total
|
</if>
|
<if test="orderMode == 3">
|
,(SELECT COUNT(tr.`id`) FROM `yeshi_ec_threesale` tr
|
WHERE tr.`boss_id`=u.id AND tr.state = 1) AS totalThree
|
</if>
|
|
FROM yeshi_ec_user u
|
LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid`
|
where 1=1
|
<if test="key != null and key !='' ">
|
AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}' ]]>
|
</if>
|
<if test="userType != null">
|
AND u.rank = #{userType}
|
</if>
|
<if test="days != null">
|
<!-- 时间 -->
|
AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
|
</if>
|
|
ORDER BY
|
<if test="orderField == 1">
|
total,
|
</if>
|
<if test="orderField == 2">
|
total DESC,
|
</if>
|
<if test="orderField == 3">
|
total,
|
</if>
|
<if test="orderField == 4">
|
total DESC,
|
</if>
|
<if test="orderField == 5">
|
totalThree,
|
</if>
|
<if test="orderField == 6">
|
totalThree DESC,
|
</if>
|
|
createtime DESC LIMIT ${start},${count}
|
|
</select>
|
|
<select id="queryCount" resultType="java.lang.Long">
|
SELECT count(u.id) FROM yeshi_ec_user u
|
LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid`
|
where <![CDATA[ 1>0 ]]>
|
<if test="key != null and key !='' ">
|
AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}' ]]>
|
</if>
|
<if test="userType != null">
|
AND u.rank = #{userType}
|
</if>
|
<if test="days != null">
|
<!-- 时间 -->
|
AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
|
</if>
|
|
</select>
|
|
<select id="querySumMoney" resultType="java.lang.Double">
|
SELECT COALESCE(sum(u.my_hongBao),0) FROM yeshi_ec_user u
|
LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid`
|
where <![CDATA[ 1>0 ]]>
|
<if test="key != null and key !='' ">
|
AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
|
</if>
|
<if test="startTime != null and startTime !='' ">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
|
</if>
|
<if test="endTime != null and endTime !=''">
|
<![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}' ]]>
|
</if>
|
<if test="userType != null">
|
AND u.rank = #{userType}
|
</if>
|
<if test="days != null">
|
<!-- 时间 -->
|
AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
|
</if>
|
</select>
|
|
|
<select id="countNewUser" resultType="java.lang.Long">
|
<!-- 自购订单 -->
|
SELECT COALESCE(count(id),0) FROM `yeshi_ec_user`
|
WHERE 1 > 0
|
<if test="isToday != null and isToday == 1">
|
AND TO_DAYS(FROM_UNIXTIME(createtime/1000)) = TO_DAYS(NOW())
|
</if>
|
<if test="isMonth != null and isMonth == 1">
|
AND DATE_FORMAT( FROM_UNIXTIME(createtime/1000), '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
|
</if>
|
</select>
|
|
<select id="countRank" resultType="java.lang.Long">
|
<!-- 等级统计 -->
|
SELECT COALESCE(count(id),0) FROM `yeshi_ec_user` WHERE rank = #{rank}
|
</select>
|
|
<select id="countAllMoney" resultType="java.lang.Double">
|
<!-- 金额统计 -->
|
SELECT COALESCE(sum(my_hongBao),0) FROM `yeshi_ec_user`
|
WHERE 1=1
|
<if test="minMoney != null">
|
AND <![CDATA[ my_hongBao >= #{minMoney}]]>
|
</if>
|
</select>
|
|
<select id="countShareAndInviteMoney" resultMap="BaseResultMap">
|
SELECT IFNULL(SUM(h.`money`),0),h.`uid` FROM `yeshi_ec_hongbao` h
|
WHERE DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )= '2018-08-02'
|
<![CDATA[AND h.state <>4]]>
|
AND ( h.`type` =5 OR h.`type` =6 OR h.`type` =7 OR h.`type` =20 OR h.`type` =21 OR h.`type` =22 )
|
GROUP BY h.`uid`
|
ORDER BY SUM(h.`money`) DESC
|
LIMIT ${start},${count}
|
</select>
|
|
<select id="longTimeNoLogin" resultType="java.lang.Long">
|
|
SELECT u.`id` FROM `yeshi_ec_user` u
|
WHERE u.`id` IN <foreach item="item" collection="list" open="(" separator=","
|
close=")">#{item}</foreach>
|
AND <![CDATA[ (DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`last_logintime`/1000))
|
OR (u.`last_logintime` IS NULL
|
AND DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`createTime`/1000)))) ]]>
|
</select>
|
|
|
</mapper>
|