<?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.account.mapper.UserPointMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.UserPoint">
|
<id column="id" property="id" />
|
<result column="type" property="type" />
|
<result column="historical_point" property="historicalPoint" />
|
<result column="variable_point" property="variablePoint" />
|
<result column="create_time" property="createTime" />
|
<result column="app_user_id" property="appUserId" />
|
<result column="object_id" property="objectId" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, type, historical_point, variable_point, create_time, app_user_id, object_id
|
</sql>
|
|
<sql id="userPointList">
|
SELECT
|
tau.`name` userName,
|
tau.phone,
|
tup.type,
|
tup.create_time,
|
tup.variable_point,
|
tup.historical_point,
|
tup.balance
|
FROM
|
t_user_point tup
|
LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id
|
<where>
|
tup.type not in (8, 9, 14) and tau.status != 3 and tau.del_flag = 0
|
<if test="userPoint.userName != null and userPoint.userName != ''">
|
AND tau.`name` LIKE concat('%',#{userPoint.userName},'%')
|
</if>
|
<if test="userPoint.phone != null and userPoint.phone != ''">
|
AND tau.phone LIKE concat('%',#{userPoint.phone},'%')
|
</if>
|
<if test="userPoint.type != null and userPoint.type != ''">
|
AND tup.type = #{userPoint.type}
|
</if>
|
<if test="userPoint.startTime != null and userPoint.endTime != null">
|
AND tup.create_time BETWEEN #{userPoint.startTime} AND #{userPoint.endTime}
|
</if>
|
</where>
|
order by tup.create_time desc
|
</sql>
|
|
<select id="queryUserPointPage" resultType="com.ruoyi.account.api.model.UserPoint">
|
<include refid="userPointList"/>
|
</select>
|
<select id="selectUserPoint" resultType="com.ruoyi.account.api.model.UserPoint">
|
<include refid="userPointList"/>
|
</select>
|
|
|
|
<select id="getUserPointDetail" resultType="com.ruoyi.account.vo.UserPointDetailVO">
|
|
select
|
type,
|
historical_point as historicalPoint,
|
balance,
|
variable_point as variablePoint,
|
DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime,
|
object_id as objectId
|
from t_user_point where app_user_id = #{userId}
|
<if test="null != startTime and null != endTime">
|
and create_time between #{startTime} and #{endTime}
|
</if>
|
<if test="null != type">
|
and type = #{type}
|
</if>
|
|
order by create_time desc
|
</select>
|
<select id="getUserPontDetailPageList" resultType="com.ruoyi.account.vo.UserPointDetailVO">
|
select
|
type,
|
variable_point,
|
DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime,
|
object_id as objectId,
|
CASE
|
WHEN type = 17 THEN extention -- 当 type=17 时取 extention
|
ELSE CAST(object_id AS CHAR) -- 否则取 object_id 的字符串形式
|
END AS objectIdStr,
|
|
CASE WHEN (balance - historical_point) > 0 THEN 1 ELSE 2 END AS flag
|
from t_user_point where app_user_id = #{userId}
|
<if test="types != null and types.size>0">
|
AND type IN
|
<foreach collection="types" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
</if>
|
<if test="objectIdStr != null and objectIdStr != ''">
|
and (
|
(type = 17 AND extention LIKE CONCAT('%', #{objectIdStr}, '%'))
|
OR
|
(type != 17 AND CAST(object_id AS CHAR) LIKE CONCAT('%', #{objectIdStr}, '%'))
|
)
|
</if>
|
</select>
|
<select id="selectRechargeAndUse" resultType="java.lang.Integer">
|
select
|
sum(tp.variable_point) as chargeTotalPoint
|
from
|
t_user_point tp
|
left join t_app_user tu on tp.app_user_id = tu.id
|
where
|
tp.type =#{type}
|
<if test="null != name and '' != name">
|
AND tu.`name` LIKE concat('%',#{name},'%')
|
</if>
|
<if test="null != phone and '' != phone">
|
AND tu.`phone` LIKE concat('%',#{phone},'%')
|
</if>
|
|
<if test="null != beginTime and null != endTime">
|
and tp.create_time between #{beginTime} and #{endTime}
|
</if>
|
|
</select>
|
<select id="getUserPointStatisticsPageList" resultType="com.ruoyi.account.vo.UserPointStatisticsPageVO">
|
select
|
tu.name,
|
tu.phone,
|
tp.type,
|
tp.variable_point,
|
tp.object_id,
|
tp.create_time,
|
CASE
|
WHEN tp.type = 17 THEN tp.extention -- 当 type=17 时取 extention
|
ELSE CAST(tp.object_id AS CHAR) -- 否则取 object_id 的字符串形式
|
END AS objectIdStr
|
from
|
t_user_point tp
|
left join t_app_user tu on tp.app_user_id = tu.id
|
where
|
1=1
|
<if test="types != null and types.size>0">
|
AND type IN
|
<foreach collection="types" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
</if>
|
<if test="null != name and '' != name">
|
AND tu.`name` LIKE concat('%',#{name},'%')
|
</if>
|
<if test="null != phone and '' != phone">
|
AND tu.`phone` LIKE concat('%',#{phone},'%')
|
</if>
|
|
<if test="null != beginTime and null != endTime">
|
and tp.create_time between #{beginTime} and #{endTime}
|
</if>
|
order by create_time desc
|
</select>
|
<select id="userPointExcel" resultType="com.ruoyi.account.vo.UserPointExcel">
|
select
|
tu.name,
|
tu.phone,
|
tp.type,
|
tp.variable_point,
|
tp.object_id,
|
CASE
|
WHEN tp.type = 17 THEN tp.extention -- 当 type=17 时取 extention
|
ELSE CAST(tp.object_id AS CHAR) -- 否则取 object_id 的字符串形式
|
END AS objectIdStr,
|
tp.create_time
|
from
|
t_user_point tp
|
left join t_app_user tu on tp.app_user_id = tu.id
|
where
|
1=1
|
<if test="types != null and types.size>0">
|
AND type IN
|
<foreach collection="types" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
</if>
|
<if test="null != name and '' != name">
|
AND tu.`name` LIKE concat('%',#{name},'%')
|
</if>
|
<if test="null != phone and '' != phone">
|
AND tu.`phone` LIKE concat('%',#{phone},'%')
|
</if>
|
|
<if test="null != beginTime and null != endTime">
|
and tp.create_time between #{beginTime} and #{endTime}
|
</if>
|
order by create_time desc
|
</select>
|
</mapper>
|