Pu Zhibing
2025-04-22 fd7b8fb7c89832c28a838b0449bbb8a392433ee2
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
<?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,
               longitude,
               latitude
        FROM t_shop
        where del_flag = 0 and status = 1
    </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,
            ts.status,
            (select ROUND(AVG(score), 1) from t_shop_score where shop_id = ts.id) as score
        FROM
            t_shop ts
        WHERE ts.del_flag = 0 AND ts.id = #{shopId}
    </select>
    <select id="selectShopList" resultType="com.ruoyi.other.api.domain.Shop">
        SELECT
            ts.*
        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>
        order by ts.id desc
    </select>
    <select id="getShopStatistics" resultType="com.ruoyi.other.vo.ShopStatistics">
        SELECT
            SUM(ts.shop_all_point + tt.shop_all_point) totalPoint,
            SUM(ts.share_point + tt.share_point) commissionPoint,
            SUM(ts.server_point + tt.server_point) servicePoint,
            SUM(ts.lower_level_share_point + tt.lower_level_share_point) bindCommissionPoint,
            SUM(ts.giveaway_all_money + tt.giveaway_all_money) totalCommissionMoney,
            SUM(ts.giveaway_money + tt.giveaway_money) commissionMoney,
            SUM(ts.lower_level_giveaway_money + tt.lower_level_giveaway_money) bindCommissionMoney,
            SUM(ts.server_giveaway_money + tt.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
            left join (select
                            shop_id,
                            ifnull(sum(shop_all_point), 0) as shop_all_point,
                            ifnull(sum(lower_level_share_point), 0) as lower_level_share_point,
                            ifnull(sum(share_point), 0) as share_point,
                            ifnull(sum(server_point), 0) as server_point,
                            ifnull(sum(giveaway_all_money), 0) as giveaway_all_money,
                            ifnull(sum(giveaway_money), 0) as giveaway_money,
                            ifnull(sum(lower_level_giveaway_money), 0) as lower_level_giveaway_money,
                            ifnull(sum(server_giveaway_money), 0) as server_giveaway_money
                       from t_shop_giveaway_temporary group by shop_id) tt on (ts.id = tt.shop_id)
        where ts.del_flag = 0
            <if test="null != shopId">
                and ts.id = #{shopId}
            </if>
    </select>
</mapper>