InviteRewardDetailMapper.java
/**
* @author Administrator
*/
@Mapper
public interface InviteRewardDetailMapper extends SuperMapper<InviteRewardDetailEntity> {
/**
* 查询活动流水统计
* @param page
* @param inviteRewardSearchBo
* @return
*/
Page<RewardStatisticDto> listRewardStatistic(@Param("page") IPage page, @Param("searchBo") InviteRewardSearchDTO inviteRewardSearchBo);
}
InviteRewardDetailMapper.xml
<?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="cn.jmfen.sport.activitycenter.invite.mapper.InviteRewardDetailMapper">
<select id="listRewardStatistic" resultType="cn.jmfen.sport.activitycenter.invite.dto.RewardStatisticDto"
parameterType="cn.jmfen.sport.activitycenter.invite.bo.InviteRewardSearchBo">
SELECT
temp.from_uid as uid,
temp.from_nickname as nickname,
count(reward_type = 2 OR reward_type = 0 OR NULL) AS invite_num,
sum(if(temp.from_uid = temp.reward_uid,reward_num,0)) AS reward_amount
FROM
(
SELECT
b.uid as reward_uid,
a.from_uid,
a.from_nickname,
IF (b.create_time IS NULL,a.create_time,b.create_time) AS reward_time,
IF (b.reward_type IS NULL,0,b.reward_type) AS reward_type,
IF (b.reward_num IS NULL,0,b.reward_num) AS reward_num
FROM jmf_invite_attend_detail a
LEFT JOIN jmf_invite_reward_detail b ON a.id = b.aid
) AS temp
<where>
temp.reward_time between #{searchBo.startTime} and #{searchBo.endTime}
<if test="searchBo.user != null and searchBo.user!=''">
and temp.from_uid like concat('%',#{searchBo.user},'%') or temp.from_nickname like concat('%',#{searchBo.user},'%')
</if>
</where>
GROUP BY temp.from_uid ORDER BY invite_num DESC
</select>
</mapper>