puzhibing
2024-12-09 609d91e1e62b1e8932b34b15b09baf02e7f09a93
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
<?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.other.mapper.ShopMapper">
 
    <select id="selectNearbyShopList" resultType="com.ruoyi.other.vo.NearbyShopVO">
        SELECT id,
               home_picture,
               name,
               address,
               (
                   6371 * acos(
                           cos(
                                   radians(#{latitude})) * cos(
                                   radians(latitude)) * cos(
                                   radians(longitude) - radians(#{longitude})) + sin(
                                                                                         radians(#{latitude})) * sin(
                                                                                         radians(latitude))
                          )) AS distance
        FROM t_shop
        where del_flag = 0
          and status = 1
        ORDER BY distance
    </select>
    <select id="selectShopDetail" resultType="com.ruoyi.other.vo.ShopDetailVO">
        SELECT
            ts.id,
            ts.details_picture,
            ts.certification,
            ts.`name`,
            ts.address,
            ts.business_date,
            ts.start_time,
            ts.end_time,
            ts.longitude,
            ts.latitude,
            AVG( tss.score ) score
        FROM
            t_shop ts
                LEFT JOIN t_shop_score tss ON ts.id = tss.shop_id
        WHERE
            ts.del_flag = 0
          AND ts.`status` = 1
          AND ts.id = #{id}
        GROUP BY
            ts.id,
            ts.details_picture,
            ts.certification,
            ts.`name`,
            ts.address,
            ts.business_date,
            ts.start_time,
            ts.end_time,
            ts.longitude,
            ts.latitude
    </select>
</mapper>