luodangjia
2024-12-16 a8d2cb07f6440dc54dc4005b0b06d5a47cb1517d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?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>
</mapper>