<?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 >= CONCAT(#{startTime},' 00:00:00')
|
AND a.createTime <= 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 >= CONCAT(#{startTime},' 00:00:00')
|
AND a.createTime <= 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>
|