<?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.MerchantActivityMapper">
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.MerchantActivity">
|
<id column="id" property="id"/>
|
<result column="merchantId" property="merchantId"/>
|
<result column="companyType" property="companyType"/>
|
<result column="companyId" property="companyId"/>
|
<result column="activityType" property="activityType"/>
|
<result column="name" property="name"/>
|
<result column="orderType" property="orderType"/>
|
<result column="type" property="type"/>
|
<result column="orderAmountFull" property="orderAmountFull"/>
|
<result column="orderNumber" property="orderNumber"/>
|
<result column="effectiveDays" property="effectiveDays"/>
|
<result column="auditStatus" property="auditStatus"/>
|
<result column="auditNote" property="auditNote"/>
|
<result column="auditUserId" property="auditUserId"/>
|
<result column="auditTime" property="auditTime"/>
|
<result column="status" property="status"/>
|
<result column="state" property="state"/>
|
<result column="createTime" property="createTime"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, merchantId, companyType ,companyId, `name`, auditStatus, fullAmount, status, state,createTime
|
</sql>
|
|
|
<select id="list" resultType="map">
|
SELECT a.* ,b.name merchantName,
|
(SELECT IFNULL(COUNT(1),0) total FROM t_user_merchant_coupon WHERE state=1 AND merchantActivityId=a.id ) number
|
FROM t_merchant_activity a
|
LEFT JOIN t_merchant b ON a.merchantId = b.id
|
WHERE a.state = 1 AND a.auditStatus = 2 AND a.activityType=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="companyId!=null">
|
AND a.companyId=#{companyId}
|
</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="status!=null ">
|
AND a.status =#{status}
|
</if>
|
|
ORDER BY a.createTime DESC
|
</select>
|
|
|
<select id="getReceiveList" resultType="map">
|
SELECT * FROM(
|
SELECT
|
a.*,
|
b.nickName,
|
b.phone,
|
c.type
|
FROM
|
t_user_merchant_coupon a
|
LEFT JOIN t_user b ON ( a.userId = b.id AND a.userType = 1 )
|
LEFT JOIN t_merchant_coupon c ON a.merchantCouponId = c.id
|
WHERE
|
a.state = 1 AND a.userType = 1
|
<if test="merchantActivityId!=null">
|
AND a.merchantActivityId=#{merchantActivityId}
|
</if>
|
|
<if test="userName!=null and userName!=''">
|
AND b.nickName LIKE CONCAT('%',#{userName},'%')
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
AND b.phone LIKE CONCAT('%',#{phone},'%')
|
</if>
|
|
<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="status!=null">
|
AND a.status = #{status}
|
</if>
|
UNION ALL
|
SELECT
|
a.*,
|
b.`name` nickName,
|
b.phone,
|
c.type
|
FROM
|
t_user_merchant_coupon a
|
LEFT JOIN t_driver b ON ( a.userId = b.id AND a.userType = 2 )
|
LEFT JOIN t_merchant_coupon c ON a.merchantCouponId = c.id
|
WHERE
|
a.state = 1 AND a. userType = 2
|
<if test="merchantActivityId!=null">
|
AND a.merchantActivityId=#{merchantActivityId}
|
</if>
|
|
<if test="userName!=null and userName!=''">
|
AND b.name LIKE CONCAT('%',#{userName},'%')
|
</if>
|
|
<if test="phone!=null and phone!=''">
|
AND b.phone LIKE CONCAT('%',#{phone},'%')
|
</if>
|
|
<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="status!=null">
|
AND a.status = #{status}
|
</if>
|
) tt ORDER BY tt.createTime DESC
|
</select>
|
|
<select id="activityExamineList" resultType="map">
|
SELECT a.* ,b.name merchantName,
|
(SELECT IFNULL(COUNT(1),0) total FROM t_user_merchant_coupon WHERE state=1 AND merchantActivityId=a.id ) number
|
FROM t_merchant_activity a
|
LEFT JOIN t_merchant b ON a.merchantId = b.id
|
|
WHERE a.state = 1 AND a.activityType = 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="companyId!=null">
|
AND a.companyId NOT IN (#{companyId})
|
</if>
|
|
<if test="auditStatus!=null ">
|
AND a.auditStatus =#{auditStatus}
|
</if>
|
ORDER BY a.createTime DESC
|
</select>
|
|
<select id="getMerchantActivityGiveList" resultType="map">
|
SELECT a.* ,b.name merchantName,
|
(SELECT IFNULL(COUNT(1),0) total FROM t_user_merchant_coupon WHERE state=1 AND merchantActivityId=a.id ) number
|
FROM t_merchant_activity a
|
LEFT JOIN t_merchant b ON a.merchantId = b.id
|
WHERE a.state = 1 AND a.activityType=2
|
|
<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="status!=null ">
|
AND a.status =#{status}
|
</if>
|
|
<if test="companyId!=null">
|
AND a.companyId =#{companyId}
|
</if>
|
ORDER BY a.createTime DESC
|
</select>
|
|
<!--获取用户信息-->
|
<select id="getUserList" resultType="map">
|
SELECT
|
*
|
FROM
|
(SELECT ci.`name` AS companyName,
|
ui.id,
|
ui.insertTime,
|
ui.nickName,
|
ui.phone ,
|
1 as type,
|
ui.flag
|
FROM
|
t_user AS ui
|
LEFT JOIN ( SELECT * FROM t_company WHERE flag != 3 ) AS ci ON ci.id = ui.companyId
|
LEFT JOIN ( SELECT COUNT( id ) AS num, userId FROM t_order_taxi WHERE FIND_IN_SET( state, '8,9' ) GROUP BY
|
userId ) AS ot ON ot.userId = ui.id
|
LEFT JOIN ( SELECT sum( money ) AS num, userId FROM t_pub_transaction_details WHERE userType = 1 AND type = 1
|
AND state = 2 GROUP BY userId ) AS td ON td.userId = ui.id
|
) AS o
|
WHERE
|
o.flag != 3
|
<if test="phone != null and phone != ''">
|
and o.phone LIKE CONCAT('%',#{phone},'%')
|
</if>
|
<if test="nickName != null and nickName != ''">
|
and o.nickName LIKE CONCAT('%',#{nickName},'%')
|
</if>
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
AND o.insertTime >= CONCAT(#{startTime},' 00:00:00')
|
AND o.insertTime <= CONCAT(#{endTime},' 23:59:59')
|
</if>
|
order by o.id desc
|
</select>
|
|
<select id="getDriverList" resultType="map">
|
SELECT
|
a.id,
|
a.insertTime,
|
a.`name` nickName,
|
a.phone,
|
2 as type,
|
b.`name` companyName ,
|
a.flag
|
FROM
|
t_driver a
|
LEFT JOIN t_company b ON a.companyId = b.id
|
WHERE
|
a.flag != 3
|
<if test="phone != null and phone != ''">
|
and a.phone LIKE CONCAT('%',#{phone},'%')
|
</if>
|
<if test="nickName != null and nickName != ''">
|
and a.name LIKE CONCAT('%',#{nickName},'%')
|
</if>
|
<if test="companyName != null and companyName != ''">
|
and b.`name` LIKE CONCAT('%',#{companyName},'%')
|
</if>
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
AND a.insertTime >= CONCAT(#{startTime},' 00:00:00')
|
AND a.insertTime <= CONCAT(#{endTime},' 23:59:59')
|
</if>
|
order by a.id desc
|
</select>
|
</mapper>
|