无关风月
2025-07-23 7fd053651ac11db87fe4f6c57e65eed3b9a59452
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?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,
               score,
               detail_address,
               address,
               longitude,
               latitude
        FROM t_shop
        where del_flag = 0 and status = 1
        <if test="shop.name != null and shop.name != ''">
            and name like concat('%',#{shop.name},'%')
        </if>
    </select>
    <select id="selectShopDetail" resultType="com.ruoyi.other.vo.ShopDetailVO">
        SELECT
            ts.id,
            ts.details_picture,
            ts.certification,
            ts.`name`,
            ts.address,
            ts.detail_address,
            ts.business_time,
            ts.start_time,
            ts.end_time,
            ts.longitude,
            ts.latitude,
            ts.status,
            ts.phone,
            (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) totalPoint,
            SUM(ts.share_point) commissionPoint,
            SUM(ts.server_point) servicePoint,
            SUM(ts.lower_level_share_point) 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 where ts.del_flag = 0
            <if test="null != shopId">
                and ts.id = #{shopId}
            </if>
    </select>
 
    <select id="selectListByShopId" resultType="com.ruoyi.other.vo.GoodsVO">
        SELECT
            tg.id as goodsId,
            tg.`name` as goodsName,
            tg.purchase_limit as purchaseLimit,
            tg.detail,
            tg.detail_picture,
            tg.integral,
            tg.introduction,
            tg.selling_price as sellingPrice,
            tg.original_price as originalPrice,
            tg.sale_num as saleNum,
            tg.home_page_picture as homePagePicture,
            tg.sort,
            tg.status
        FROM t_goods tg
        where tg.del_flag = 0  and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId})
 
        ORDER BY ifnull(tg.sort, -1) DESC
    </select>
    <select id="getBalanceList" resultType="com.ruoyi.other.vo.ShopBalanceListVO">
        SELECT
        id,
        name,
        balance,
        can_withdraw_money AS canWithdrawMoney,
        withdraw_audit_money AS withdrawAuditMoney,
        withdraw_money AS withdrawMoney,
        (balance - can_withdraw_money) AS frozenMoney,
        (can_withdraw_money + withdraw_audit_money + withdraw_money + (balance - can_withdraw_money)) AS totalMoney
        FROM t_shop
        WHERE del_flag = 0
        <if test="name != null and name != ''">
            AND `name` LIKE CONCAT('%', #{name}, '%')
        </if>
    </select>
    <select id="shopBalanceExcel" resultType="com.ruoyi.other.vo.ShopBalanceExcel">
        select
            id,
            name,
            balance,
            can_withdraw_money AS canWithdrawMoney,
            withdraw_audit_money AS withdrawAuditMoney,
            withdraw_money AS withdrawMoney,
            (balance - can_withdraw_money) AS frozenMoney,
            (can_withdraw_money + withdraw_audit_money + withdraw_money + (balance - can_withdraw_money)) AS totalMoney
        FROM t_shop
        WHERE del_flag = 0
        <if test="name != null and name != ''">
            AND `name` LIKE CONCAT('%', #{name}, '%')
        </if>
    </select>
</mapper>