InviteRewardDetailMapper.java

    1. /**
    2. * @author Administrator
    3. */
    4. @Mapper
    5. public interface InviteRewardDetailMapper extends SuperMapper<InviteRewardDetailEntity> {
    6. /**
    7. * 查询活动流水统计
    8. * @param page
    9. * @param inviteRewardSearchBo
    10. * @return
    11. */
    12. Page<RewardStatisticDto> listRewardStatistic(@Param("page") IPage page, @Param("searchBo") InviteRewardSearchDTO inviteRewardSearchBo);
    13. }

    InviteRewardDetailMapper.xml

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    3. <mapper namespace="cn.jmfen.sport.activitycenter.invite.mapper.InviteRewardDetailMapper">
    4. <select id="listRewardStatistic" resultType="cn.jmfen.sport.activitycenter.invite.dto.RewardStatisticDto"
    5. parameterType="cn.jmfen.sport.activitycenter.invite.bo.InviteRewardSearchBo">
    6. SELECT
    7. temp.from_uid as uid,
    8. temp.from_nickname as nickname,
    9. count(reward_type = 2 OR reward_type = 0 OR NULL) AS invite_num,
    10. sum(if(temp.from_uid = temp.reward_uid,reward_num,0)) AS reward_amount
    11. FROM
    12. (
    13. SELECT
    14. b.uid as reward_uid,
    15. a.from_uid,
    16. a.from_nickname,
    17. IF (b.create_time IS NULL,a.create_time,b.create_time) AS reward_time,
    18. IF (b.reward_type IS NULL,0,b.reward_type) AS reward_type,
    19. IF (b.reward_num IS NULL,0,b.reward_num) AS reward_num
    20. FROM jmf_invite_attend_detail a
    21. LEFT JOIN jmf_invite_reward_detail b ON a.id = b.aid
    22. ) AS temp
    23. <where>
    24. temp.reward_time between #{searchBo.startTime} and #{searchBo.endTime}
    25. <if test="searchBo.user != null and searchBo.user!=''">
    26. and temp.from_uid like concat('%',#{searchBo.user},'%') or temp.from_nickname like concat('%',#{searchBo.user},'%')
    27. </if>
    28. </where>
    29. GROUP BY temp.from_uid ORDER BY invite_num DESC
    30. </select>
    31. </mapper>