yanghb
2023-04-14 cd8e73d4dad311de76fc9a7db3b74e8c88afe78e
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
<?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.stylefeng.guns.modular.system.dao.MerchantCouponMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.MerchantCoupon">
        <id column="id" property="id"/>
        <result column="merchantId" property="merchantId"/>
        <result column="type" property="type"/>
        <result column="name" property="name"/>
        <result column="content" property="content"/>
        <result column="fullAmount" property="fullAmount"/>
        <result column="discount" property="discount"/>
        <result column="state" property="state"/>
        <result column="createTime" property="createTime"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, merchantId, `type`, `name`, content, fullAmount, discount, state,createTime
    </sql>
 
 
    <select id="list" resultType="map">
        SELECT a.* ,b.name merchantName,
        CONCAT('满',fullAmount,'减',discount,'券') AS discountName
        FROM t_merchant_coupon a
        LEFT JOIN t_merchant b ON a.merchantId=b.id
        WHERE a.state =1
        <if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
            AND a.createTime &gt;= CONCAT(#{startTime},' 00:00:00')
            AND a.createTime &lt;= CONCAT(#{endTime},' 23:59:59')
        </if>
 
        <if test="type!=null">
            AND a.type = #{type}
        </if>
 
        <if test="merchantName!=null and merchantName!=''">
            AND b.name LIKE CONCAT('%',#{merchantName},'%')
        </if>
 
        <if test="name!=null and name!=''">
            AND a.`name` LIKE CONCAT('%',#{name},'%')
        </if>
        ORDER BY a.createTime DESC
    </select>
 
    <!--获取商家列表-->
    <select id="getMerchantList" resultType="map">
        SELECT * FROM t_merchant WHERE  auditStatus = 2 AND `state` =1
    </select>
 
    <select id="getCouponList" resultType="map">
        SELECT a.* ,b.name merchantName,
        CONCAT('满',fullAmount,'减',discount,'券') AS discountName
        FROM t_merchant_coupon a
        LEFT JOIN t_merchant b ON a.merchantId=b.id
        WHERE a.state =1
        <if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
            AND a.createTime &gt;= CONCAT(#{startTime},' 00:00:00')
            AND a.createTime &lt;= CONCAT(#{endTime},' 23:59:59')
        </if>
 
        <if test="type!=null">
            AND a.type = #{type}
        </if>
 
        <if test="asList!=null and asList.size>0">
            AND a.merchantId IN
            <foreach collection="asList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
 
        <if test="merchantName!=null and merchantName!=''">
            AND b.name LIKE CONCAT('%',#{merchantName},'%')
        </if>
 
        <if test="name!=null and name!=''">
            AND a.`name` LIKE CONCAT('%',#{name},'%')
        </if>
        ORDER BY a.createTime DESC
    </select>
</mapper>