<?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.ruoyi.account.mapper.AppUserMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.AppUser">
|
<id column="id" property="id" />
|
<result column="name" property="name" />
|
<result column="phone" property="phone" />
|
<result column="avatar" property="avatar" />
|
<result column="vip_id" property="vipId" />
|
<result column="wx_openid" property="wxOpenid" />
|
<result column="ali_openid" property="aliOpenid" />
|
<result column="status" property="status" />
|
<result column="create_time" property="createTime" />
|
<result column="del_flag" property="delFlag" />
|
<result column="first_add" property="firstAdd" />
|
<result column="last_login_time" property="lastLoginTime" />
|
<result column="invite_user_id" property="inviteUserId" />
|
<result column="shop_id" property="shopId" />
|
<result column="part_point" property="partPoint" />
|
<result column="part_grow_point" property="partGrowPoint" />
|
<result column="shop_point" property="shopPoint" />
|
<result column="share_point" property="sharePoint" />
|
<result column="shop_amount" property="shopAmount" />
|
<result column="last_shop_time" property="lastShopTime" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, name, phone, avatar, vip_id, wx_openid, ali_openid, status, create_time, del_flag, first_add, last_login_time, invite_user_id, shop_id, part_point, part_grow_point, shop_point, share_point, shop_amount, last_shop_time
|
</sql>
|
|
|
|
|
<select id="getNearbyReferrer" resultType="com.ruoyi.account.vo.NearbyReferrerVo">
|
select * from (
|
select
|
id,
|
avatar,
|
`name`,
|
vip_id as vip,
|
ST_Distance_Sphere(
|
point(#{nearbyReferrer.longitude},#{nearbyReferrer.latitude}),
|
point(longitude, latitude)
|
) as distance
|
from t_app_user where city_code = #{cityCode} and del_flag = 0 and status = 1
|
<if test="null != nearbyReferrer.name and '' != nearbyReferrer.name">
|
and `name` like CONCAT('%', #{nearbyReferrer.name}, '%')
|
</if>
|
) as aa order by aa.distance
|
</select>
|
|
<select id="getAppuserPage" resultType="com.ruoyi.account.api.model.AppUser">
|
SELECT ta.id, ta.`name`, ta.vip_id, ta.shop_id
|
FROM t_app_user ta
|
<where>
|
ta.del_flag = 0
|
<if test="null != appUser.name and '' != appUser.name">
|
and ta.`name` like CONCAT('%',#{appUser.name},'%')
|
</if>
|
<if test="null != appUser.phone and '' != appUser.phone">
|
and ta.phone like CONCAT('%',#{appUser.phone},'%')
|
</if>
|
<if test="null != appUser.status">
|
and ta.status = #{appUser.status}
|
</if>
|
<if test="null != appUser.vipId">
|
and ta.vip_id = #{appUser.vipId}
|
</if>
|
<if test="null != appUser.shopIds and appUser.shopIds.size() > 0">
|
and ta.shop_id in
|
<foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
|
#{shopId}
|
</foreach>
|
</if>
|
</where>
|
order by ta.is_danger desc
|
|
</select>
|
<select id="getAppuserPage1" resultType="com.ruoyi.account.api.model.AppUser">
|
SELECT ta.id, ta.`name`, ta.vip_id, ta.shop_id
|
FROM t_app_user ta
|
<where>
|
ta.del_flag = 0
|
<if test="null != appUser.name and '' != appUser.name">
|
and ta.`name` like CONCAT('%',#{appUser.name},'%')
|
</if>
|
<if test="null != appUser.phone and '' != appUser.phone">
|
and ta.phone like CONCAT('%',#{appUser.phone},'%')
|
</if>
|
<if test="null != appUser.status">
|
and ta.status = #{appUser.status}
|
</if>
|
<if test="null != appUser.vipId">
|
and ta.vip_id = #{appUser.vipId}
|
</if>
|
<if test="null != appUser.shopIds and appUser.shopIds.size() > 0">
|
and ta.shop_id in
|
<foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
|
#{shopId}
|
</foreach>
|
</if>
|
and ( ta.id
|
in
|
(
|
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
#{userId}
|
</foreach>
|
) or ta.shop_id = #{objectId} )
|
</where>
|
</select>
|
<select id="getUserStatistics" resultType="com.ruoyi.account.vo.UserStatistics">
|
SELECT
|
COUNT(*) AS totalUser,
|
SUM(CASE WHEN tau.user_type = 2 THEN 1 ELSE 0 END) AS shopUser,
|
SUM(CASE WHEN tau.vip_id <![CDATA[<]]> 4 THEN 1 ELSE 0 END) AS consumerUser,
|
SUM(CASE WHEN tau.vip_id = 1 THEN 1 ELSE 0 END) AS commonUser,
|
SUM(CASE WHEN tau.vip_id = 2 THEN 1 ELSE 0 END) AS goldUser,
|
SUM(CASE WHEN tau.vip_id = 3 THEN 1 ELSE 0 END) AS diamondUser,
|
SUM(CASE WHEN tau.vip_id <![CDATA[>]]> 3 THEN 1 ELSE 0 END) AS entrepreneurUser,
|
SUM(CASE WHEN tau.vip_id = 4 THEN 1 ELSE 0 END) AS proxyUser,
|
SUM(CASE WHEN tau.vip_id = 5 THEN 1 ELSE 0 END) AS agentUser,
|
SUM(CASE WHEN tau.vip_id = 6 THEN 1 ELSE 0 END) AS totalAgentUser,
|
SUM(CASE WHEN tau.vip_id = 7 THEN 1 ELSE 0 END) AS partnerUser
|
FROM
|
t_app_user tau
|
</select>
|
<select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail">
|
SELECT
|
SUM(tau.total_point) totalScore,
|
SUM(tau.shop_point) consumeScore,
|
SUM(tau.share_point) rebateScore,
|
SUM(tau.total_invite_point) inviteScore,
|
SUM(tau.total_register_point) registerScore,
|
SUM(tau.total_share_point+tau.total_sign_point+tau.total_hour_point) workScore,
|
SUM(tau.total_performance_point) achievementScore,
|
SUM(tau.total_distribution_amount) totalRebate,
|
SUM(tau.total_recharge_amount) totalRecharge,
|
SUM(tau.withdrawn_amount) totalWithdraw
|
FROM
|
t_app_user tau
|
<where>
|
<if test="null != userName and '' != userName">
|
and tau.id = #{userId}
|
</if>
|
</where>
|
</select>
|
</mapper>
|