无关风月
9 天以前 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
<?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.ShopBalanceStatementMapper">
 
    <sql id="shopBalanceStatementList">
        SELECT
        tsbs.*,
        ts.`name` shopName,
        ts.shop_manager shopManagerName,
        ts.phone
        FROM
        t_shop_balance_statement tsbs
        INNER JOIN t_shop ts ON ts.id = tsbs.shop_id
        <where>
            tsbs.type != 4 and ts.del_flag = 0
            <if test="bs.shopName != null and bs.shopName != ''">
                AND ts.`name` like concat('%', #{bs.shopName}, '%')
            </if>
            <if test="bs.shopManagerName != null and bs.shopManagerName != ''">
                AND ts.shop_manager like concat('%', #{bs.shopManagerName}, '%')
            </if>
            <if test="bs.phone != null and bs.phone != ''">
                AND ts.phone like concat('%', #{bs.phone}, '%')
            </if>
            <if test="bs.type != null">
                AND tsbs.type = #{bs.type}
            </if>
            <if test="bs.startTime != null and bs.endTime != null">
                AND tsbs.create_time BETWEEN #{bs.startTime} AND #{bs.endTime}
            </if>
        </where>
    </sql>
 
    <select id="queryShopBalanceStatementPage" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement">
        <include refid="shopBalanceStatementList"/>
    </select>
    <select id="selectShopBalanceStatementList" resultType="com.ruoyi.other.api.domain.ShopBalanceStatement">
        <include refid="shopBalanceStatementList"/>
    </select>
 
 
    <select id="getShopBalanceStatementList" resultType="com.ruoyi.other.vo.ShopBalanceStatementVO">
        select
        type,
        historical_balance as historicalBalance,
        variable_amount as variableAmount,
        balance,
        DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime
        from t_shop_balance_statement where shop_id = #{shopId}
        <if test="null != startTime and null != endTime">
            and create_time between #{startTime} and #{endTime}
        </if>
        <if test="null != type">
            and type = #{type}
        </if>
        order by createTime desc
    </select>
 
    <select id="getShopBalanceStatementPageList" resultType="com.ruoyi.other.vo.ShopBalanceStatementVO">
        select
            type,
            variable_amount,
            DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime,
            historical_balance,
            balance,
            CASE WHEN (balance - historical_balance) > 0 THEN 1 ELSE 0 END AS flag,
        object_id
        from
            t_shop_balance_statement
        where
            shop_id = #{shopId}
        <if test="objectId != null ">
            AND object_id = #{objectId}
        </if>
        <if test="types != null and types.size>0">
            AND type IN
            <foreach collection="types" item="type" open="(" separator="," close=")">
                #{type}
            </foreach>
        </if>
 
 
    </select>
</mapper>