1
phpcjl
2024-12-20 d51a8cfa10c34d9c1e7d6b4726d31e75ecee5dc6
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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>
    <select id="selectShopList" resultType="com.ruoyi.other.api.domain.Shop">
        SELECT
            ts.id,
            ts.`name`,
            ts.business_date,
            ts.start_time,
            ts.end_time,
            ts.phone,
            ts.address,
            ts.`status`,
            ts.shop_manager
        FROM
            t_shop ts
        <where>
            ts.del_flag = 0
            <if test="shop.name != null and shop.name != ''">
                and ts.name like concat('%',#{shop.name},'%')
            </if>
            <if test="shop.shopManager != null and shop.shopManager != ''">
                and ts.shop_manager like concat('%',#{shop.shopManager},'%')
            </if>
            <if test="shop.phone != null and shop.phone != ''">
                and ts.phone like concat('%',#{shop.phone},'%')
            </if>
            <if test="shop.status != null and shop.status != ''">
                and ts.status = #{shop.status}
            </if>
        </where>
    </select>
    <select id="getShopStatistics" resultType="com.ruoyi.other.vo.ShopStatistics">
        SELECT
            SUM(ts.shop_all_point) totalPoint,
            SUM(ts.share_point) commissionPoint,
            SUM(ts.server_point) servicePoint,
            SUM(ts.lower_level_giveaway_money) bindCommissionPoint,
            SUM(ts.giveaway_all_money) totalCommissionMoney,
            SUM(ts.giveaway_money) commissionMoney,
            SUM(ts.lower_level_giveaway_money) bindCommissionMoney,
            SUM(ts.server_giveaway_money) serviceCommissionMoney,
            SUM(ts.order_number) totalOrder,
            SUM(ts.server_order_number) serviceOrder,
            SUM(ts.custom_order_number) goodsOrder,
            SUM(ts.can_withdraw_money) canWithdrawMoney,
            SUM(ts.withdraw_money) alreadyWithdrawMoney
        FROM
            t_shop ts
    </select>
</mapper>