gongzuming
2024-09-19 a768dc3daa04d35fedfbe75c0a59b9b2545b85c4
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
<?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.mzl.flower.mapper.point.CustomerPointDetailMapper">
    <select id="queryPage" resultType="com.mzl.flower.dto.response.point.CustomerPointDetailVO">
        select * from t_customer_point_detail t where t.deleted= 0
        <if test="dto.userId != null and dto.userId != ''">
            and t.userId = #{dto.userId}
        </if>
        <if test="dto.customerId != null and dto.customerId != ''">
            and t.customerId = #{dto.customerId}
        </if>
        <if test="dto.changeType != null and dto.changeType != ''">
            and t.changeType = #{dto.changeType}
        </if>
        <if test="dto.type != null and dto.type != ''">
            and t.type = #{dto.type}
        </if>
        order by t.c desc
    </select>
    <select id="tongjiExpiredPoint" resultType="com.mzl.flower.dto.response.point.ExpiredPointDTO"
            parameterType="java.time.LocalDate">
        SELECT
            p.user_id,
            p.customer_id,
            SUM(CASE WHEN p.change_type = 'add' THEN point ELSE 0 END) AS addPoint,
            SUM(CASE WHEN p.change_type = 'reduce' THEN point ELSE 0 END) AS reducePoint
        FROM
            t_customer_point_detail p
        WHERE p.deleted= 0
        <if test="lastYear!=null ">
            <![CDATA[
               and p.record_date <= #{lastYear}
            ]]>
        </if>
        <if test="userId!=null and userId!=''">
            and p.user_id = #{userId}
        </if>
        GROUP BY
        p.user_id,
        p.customer_id
    </select>
 
</mapper>