You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
7.5 KiB
195 lines
7.5 KiB
<?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.epmet.dao.UserPointActionLogDao">
|
|
|
|
<resultMap type="com.epmet.entity.UserPointActionLogEntity" id="userPointActionLogMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="userId" column="USER_ID"/>
|
|
<result property="customerId" column="CUSTOMER_ID"/>
|
|
<result property="actionFlag" column="ACTION_FLAG"/>
|
|
<result property="eventId" column="EVENT_ID"/>
|
|
<result property="sourceId" column="SOURCE_ID" />
|
|
<result property="eventStatement" column="EVENT_STATEMENT"/>
|
|
<result property="eventName" column="EVENT_NAME"/>
|
|
<result property="point" column="POINT"/>
|
|
<result property="operatorAgencyId" column="OPERATOR_AGENCY_ID"/>
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
</resultMap>
|
|
|
|
<!-- 查询用户积分明细,按照时间倒叙 传参:用户Id -->
|
|
<select id="selectPointActionLogList" resultType="com.epmet.dto.result.ResiPointLogPeriodResultDTO">
|
|
SELECT
|
|
EVENT_NAME AS TITLE,
|
|
IFNULL(EVENT_STATEMENT,'') AS REMARK,
|
|
CASE ACTION_FLAG WHEN 'plus' THEN concat('+',POINT) ELSE POINT END AS point,
|
|
DATE_FORMAT(CREATED_TIME,'%Y-%m-%d') AS DATE,
|
|
DATE_FORMAT(CREATED_TIME,'%H:%i') AS TIME
|
|
FROM
|
|
USER_POINT_ACTION_LOG
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND
|
|
USER_ID = #{userId}
|
|
AND
|
|
CUSTOMER_ID = #{customerId}
|
|
ORDER BY
|
|
CREATED_TIME DESC
|
|
</select>
|
|
|
|
<select id="selectPageResiPoin" parameterType="com.epmet.dto.form.IcResiPointPageFormDTO" resultType="com.epmet.dto.result.ResiPointPageResDTO">
|
|
SELECT
|
|
ID,
|
|
EVENT_NAME AS title,
|
|
CASE ACTION_FLAG WHEN 'plus' THEN concat('+',POINT) ELSE POINT END AS point,
|
|
CREATED_TIME as dateTime
|
|
FROM
|
|
USER_POINT_ACTION_LOG
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
<foreach item="epmetUserId" collection="epmetUserIdList" open="AND (" separator="or" close=")" index="">
|
|
USER_ID = #{epmetUserId}
|
|
</foreach>
|
|
ORDER BY
|
|
CREATED_TIME DESC
|
|
</select>
|
|
<!-- 查询指定用户在某条规则下所得的积分总和 -->
|
|
<select id="selectSumByEvent" resultType="integer">
|
|
SELECT
|
|
SUM( POINT )
|
|
FROM
|
|
USER_POINT_ACTION_LOG
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND USER_ID = #{userId}
|
|
AND EVENT_ID = #{eventId}
|
|
<if test='null != customerId and "" != customerId'>
|
|
AND CUSTOMER_ID = #{customerId}
|
|
</if>
|
|
<if test='null != sourceId and "" != sourceId'>
|
|
AND SOURCE_ID = #{sourceId}
|
|
</if>
|
|
<if test="null != dateCheck">
|
|
AND CREATED_TIME <![CDATA[ >= ]]> #{dateCheck}
|
|
</if>
|
|
<if test="null != right">
|
|
AND CREATED_TIME <![CDATA[ < ]]> #{right}
|
|
</if>
|
|
</select>
|
|
<select id="selectIncrease" resultType="java.lang.Integer">
|
|
SELECT IFNULL(SUM(POINT), 0)
|
|
FROM USER_POINT_ACTION_LOG
|
|
WHERE
|
|
BIZ_TYPE = #{type}
|
|
AND OBJECT_ID = #{objectId}
|
|
AND DATE_FORMAT(CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
|
</select>
|
|
|
|
|
|
<!-- 未完成:无上限的、一次性任务未完成的、非一次性任务完成数量< 积分上限次数的 -->
|
|
<!-- 已完成:有上线并且完成的、一次性任务完成的 -->
|
|
<select id="queryMyPointTaskList" parameterType="map" resultType="com.epmet.dto.result.MyPointTaskResultDTO">
|
|
select
|
|
temp.*
|
|
from (
|
|
SELECT
|
|
pr.RULE_NAME AS ruleName,
|
|
pr.RULE_DESC AS ruleDesc,
|
|
(
|
|
CASE
|
|
WHEN pr.OPERATE_TYPE = 'plus' THEN
|
|
CONCAT( '积分+', pr.POINT )
|
|
WHEN pr.OPERATE_TYPE = 'minus' THEN
|
|
CONCAT( '积分-', pr.POINT )
|
|
else '未知'
|
|
END
|
|
) AS pointDesc,
|
|
'' AS finishTotalDesc,
|
|
'' AS finishFlag,
|
|
pr.LINK_PAGE AS linkPage,
|
|
pr.EVENT_CODE AS eventCode,
|
|
pr.OPERATE_TYPE AS operateType,
|
|
pr.UP_LIMIT AS upLimit,
|
|
pr.POINT AS point,
|
|
(
|
|
SELECT
|
|
count( 1 )
|
|
FROM
|
|
user_point_action_log u
|
|
WHERE
|
|
u.USER_ID = #{userId}
|
|
AND u.EVENT_ID = pr.EVENT_CODE
|
|
AND u.DEL_FLAG = '0'
|
|
AND u.CUSTOMER_ID = #{customerId}
|
|
AND DATE_FORMAT( u.CREATED_TIME, '%Y%m%d' ) =#{dateId}
|
|
) AS finishedCount,
|
|
(case when pr.UP_LIMIT='0' then '0'
|
|
else CEIL(pr.UP_LIMIT/pr.point)
|
|
end
|
|
)as upLimitCount,
|
|
pr.sort,
|
|
pr.DISPOSABLE as disposable
|
|
FROM
|
|
point_rule pr
|
|
WHERE
|
|
pr.DEL_FLAG = '0'
|
|
AND pr.CUSTOMER_ID = #{customerId}
|
|
AND pr.ENABLED_FLAG = '1'
|
|
)temp
|
|
where 1=1
|
|
<if test='null != type and "unfinished" == type'>
|
|
AND (
|
|
temp.upLimit='0'
|
|
or ( temp.upLimit !='0' and temp.DISPOSABLE = '0' AND temp.finishedCount < upLimitCount )
|
|
OR ( temp.upLimit !='0' and temp.DISPOSABLE = '1' AND temp.finishedCount = 0 )
|
|
)
|
|
</if>
|
|
<if test='null != type and "finished" == type'>
|
|
and (
|
|
( temp.upLimit !='0' and temp.DISPOSABLE='0' and temp.finishedCount=temp.upLimitCount and temp.finishedCount !=0)
|
|
or(temp.DISPOSABLE='1'and temp.finishedCount=1)
|
|
)
|
|
</if>
|
|
ORDER BY temp.sort ASC
|
|
</select>
|
|
<select id="getPagePartyPoint" resultType="com.epmet.dto.result.PartyPointResultDTO">
|
|
SELECT
|
|
OBJECT_ID AS actId,
|
|
EVENT_NAME AS title,
|
|
CASE
|
|
ACTION_FLAG
|
|
WHEN 'plus' THEN
|
|
concat( '+', POINT ) ELSE POINT
|
|
END AS point,
|
|
DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) AS date,
|
|
DATE_FORMAT( CREATED_TIME, '%H:%i' ) AS time
|
|
FROM
|
|
USER_POINT_ACTION_LOG
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND BIZ_TYPE = 'party_building'
|
|
AND USER_ID = #{userId}
|
|
AND CUSTOMER_ID = #{customerId}
|
|
<if test='null != type and "" != type'>
|
|
AND SOURCE_TYPE = #{type}
|
|
</if>
|
|
<if test='"1" == dateType'>
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y') = #{startDate}
|
|
</if>
|
|
<if test='"2" == dateType'>
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y%m') = #{startDate}
|
|
</if>
|
|
<if test='"3" == dateType'>
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y%m') >= #{startDate}
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y%m') <= #{endDate}
|
|
</if>
|
|
ORDER BY
|
|
CREATED_TIME DESC
|
|
</select>
|
|
|
|
</mapper>
|