Pu Zhibing
2024-10-16 c4664502dfdaffff555b532e65b51a57ac8b29c2
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
<?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.order.mapper.TVipOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.order.api.model.TVipOrder">
        <id column="id" property="id" />
        <result column="code" property="code" />
        <result column="app_user_id" property="appUserId" />
        <result column="type" property="type" />
        <result column="vip_id" property="vipId" />
        <result column="vip_type" property="vipType" />
        <result column="order_amount" property="orderAmount" />
        <result column="discount" property="discount" />
        <result column="discount_amount" property="discountAmount" />
        <result column="payment_amount" property="paymentAmount" />
        <result column="payment_status" property="paymentStatus" />
        <result column="payment_type" property="paymentType" />
        <result column="serial_number" property="serialNumber" />
        <result column="create_time" property="createTime" />
        <result column="del_flag" property="delFlag" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, code, app_user_id, `type`, vip_id, vip_type, order_amount, discount, discount_amount, payment_amount, payment_status, payment_type, serial_number, create_time, del_flag
    </sql>
    <select id="pageList" resultType="com.ruoyi.order.api.model.TVipOrder">
        select t1.* from
        t_vip_order t1
        where 1=1
        <if test="null != req.userIds and req.userIds.size()>0" >
            and t1.app_user_id in
            <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.vipType != null ">
            and t1.vip_type = #{req.vipType}
        </if>
        <if test="req.vipId != null ">
            and t1.vip_id = #{req.vipId}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and t1.create_time between #{startTime1} and #{startTime2}
        </if>
        and t1.payment_status = 2
        AND t1.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        order by t1.create_time desc
    </select>
    <select id="sixBefore" resultType="com.ruoyi.order.dto.SixVipDto">
        SELECT
        DATE_FORMAT(subquery.create_time, '%Y-%m') AS MONTH,
        COUNT(1) AS orderNum,
        SUM(subquery.payment_amount) AS paymentAmount,
        tp.`name`
        FROM (
        SELECT
        vip_id,
        create_time,
        payment_amount
        FROM
        t_vip_order
        <where>
            del_flag = 0 AND
            payment_status = 2
            <if test="sixBefore != null">
                AND create_time &gt; #{sixBefore}
            </if>
        </where>
        ) AS subquery
        LEFT JOIN `charging_pile_other`.`t_vip` tp on  subquery.vip_id = tp.id
        GROUP BY
        DATE_FORMAT(subquery.create_time, '%Y-%m'),
        tp.`name`
 
 
    </select>
    <select id="getSumAmout" resultType="java.math.BigDecimal">
        SELECT
            SUM(payment_amount) AS paymentAmount
        FROM
            t_vip_order
        WHERE
            del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} AND
            payment_status = 2 AND
            refund_amount IS NULL
            <if test="sixBefore != null">
                AND create_time &gt; #{sixBefore}
            </if>
    </select>
 
</mapper>