日照智慧社区接口服务
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.

62 lines
2.3 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.UserPointTotalDao">
<resultMap type="com.epmet.entity.UserPointTotalEntity" id="userPointTotalMap">
<result property="id" column="ID"/>
<result property="userId" column="USER_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="usedPoint" column="USED_POINT"/>
<result property="usablePoint" column="USABLE_POINT"/>
<result property="totalPoint" column="TOTAL_POINT"/>
<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="selectPointByUserId" resultType="com.epmet.dto.result.ResiPointDetailResultDTO">
SELECT
USABLE_POINT AS usablePoint,
TOTAL_POINT AS accumulatedPoint
FROM
USER_POINT_TOTAL
WHERE
DEL_FLAG = '0'
AND
USER_ID = #{userId}
</select>
<!-- 查询客户下的用户积分排行,分页 传参:customerId -->
<select id="selectUserPointRank" resultType="com.epmet.dto.result.ResiPointRankResultDTO">
SELECT
IF ( @point > point.total_point, @rank := @rank + 1, @rank := @rank + 0 ) AS rank,
point.user_id,
point.customer_id,
point.total_point,
@point := point.total_point
FROM
( SELECT * FROM user_point_total ORDER BY total_point DESC ) point,
( SELECT @point := NULL, @rank := 1 ) a
</select>
<!-- 根据userId查找是否存在数据 -->
<select id="selectIfExisted" resultType="com.epmet.entity.UserPointTotalEntity">
SELECT
ID,
USED_POINT,
USABLE_POINT,
TOTAL_POINT
FROM
user_point_total
WHERE
del_flag = '0'
AND
user_id = #{userId}
</select>
</mapper>