Browse Source

积分分类统计

feature/syp_points
曲树通 5 years ago
parent
commit
7e903ec1c3
  1. 26
      esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsStatisticsListResultDTO.java
  2. 17
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java
  3. 13
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsRuleController.java
  4. 8
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java
  5. 4
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java
  6. 32
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java
  7. 25
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml

26
esua-epdc/epdc-module/epdc-points/epdc-points-client/src/main/java/com/elink/esua/epdc/dto/result/PointsStatisticsListResultDTO.java

@ -0,0 +1,26 @@
package com.elink.esua.epdc.dto.result;
import lombok.Data;
import java.io.Serializable;
@Data
public class PointsStatisticsListResultDTO implements Serializable {
private static final long serialVersionUID = 8249595537995735691L;
/**
* 总积分
*/
private int allPoints;
/**
* 剩余积分
*/
private int residuePoints;
/**
* 操作描述
*/
private String operationDesc;
}

17
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java

@ -28,6 +28,7 @@ import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO;
import com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO;
import com.elink.esua.epdc.excel.PointsLogsExcel;
import com.elink.esua.epdc.service.PointsLogsService;
import org.springframework.beans.factory.annotation.Autowired;
@ -121,4 +122,20 @@ public class PointsLogsController {
ValidatorUtils.validateEntity(formDto);
return pointsLogsService.confirmUserAdjustPoint(formDto);
}
/***
* 积分分类统计
* @param params
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO>>
* @author qushutong
* @date 2020/7/21 9:22
*/
@GetMapping("/point/listPagePoints")
public Result<PageData<PointsStatisticsListResultDTO>> listPagePoints(@RequestParam Map<String, Object> params) {
PageData<PointsStatisticsListResultDTO> list = pointsLogsService.listPagePoint(params);
return new Result<PageData<PointsStatisticsListResultDTO>>().ok(list);
}
}

13
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsRuleController.java

@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -101,4 +102,16 @@ public class PointsRuleController {
return pointsRuleService.getPointRule(ruleCode);
}
/***
* 规则列表
* @param
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.commons.tools.page.PageData<com.elink.esua.epdc.dto.PointsRuleDTO>>
* @author qushutong
* @date 2020/7/20 17:28
*/
@GetMapping("ruleList")
public Result<List<PointsRuleDTO>> getRuleList() {
List<PointsRuleDTO> list = pointsRuleService.list(new HashMap<>());
return new Result<List<PointsRuleDTO>>().ok(list);
}
}

8
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java

@ -20,12 +20,9 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingTopTenDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingUserDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.*;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO;
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO;
import com.elink.esua.epdc.entity.PointsLogsEntity;
import org.apache.ibatis.annotations.Mapper;
@ -128,4 +125,7 @@ public interface PointsLogsDao extends BaseDao<PointsLogsEntity> {
* @Date: 2020-05-13
*/
int selectCountPointsRanking(EpdcAppPointsRankingFormDTO formDto);
List<PointsStatisticsListResultDTO> selectPointsList(Map<String, Object> params);
}

4
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java

@ -29,6 +29,7 @@ import com.elink.esua.epdc.dto.form.PointsLogsFormDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO;
import com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO;
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO;
import com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO;
import com.elink.esua.epdc.entity.PointsLogsEntity;
import java.util.List;
@ -171,4 +172,7 @@ public interface PointsLogsService extends BaseService<PointsLogsEntity> {
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result confirmUserAdjustPoint(EpdcAdjustUserPointsDTO formDto);
PageData<PointsStatisticsListResultDTO> listPagePoint(Map<String, Object> params);
}

32
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java

@ -161,15 +161,15 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
@Override
@Transactional(rollbackFor = Exception.class)
public Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto) {
if(formDto.getOperatePoints()== NumConstant.ZERO){
if (formDto.getOperatePoints() == NumConstant.ZERO) {
return new Result().error("操作积分不能为0");
}
//根据动作编码获取动作信息
Result<BehaviorResultDto> behaviorCodeInfoByBehaviorCode = pointsBehaviorService.getBehaviorCodeInfoByBehaviorCode(formDto.getBehaviorCode());
if (!behaviorCodeInfoByBehaviorCode.success() || behaviorCodeInfoByBehaviorCode.getData()==null){
if (!behaviorCodeInfoByBehaviorCode.success() || behaviorCodeInfoByBehaviorCode.getData() == null) {
throw new RenException("获取动作编码信息异常或无此动作编码");
}
PointsLogsEntity pointsLogsEntity=new PointsLogsEntity();
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity();
pointsLogsEntity.setVolunteerId(formDto.getId());
pointsLogsEntity.setUserId(formDto.getUserId());
pointsLogsEntity.setNickname(formDto.getNickname());
@ -195,7 +195,7 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
pointsLogsEntity.setBehaviorCode(formDto.getBehaviorCode());
this.insert(pointsLogsEntity);
//给用户发送消息通知
this.issueSmsNotification(pointsLogsEntity,formDto);
this.issueSmsNotification(pointsLogsEntity, formDto);
return new Result();
}
@ -254,10 +254,10 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
@Override
public Result confirmUserAdjustPoint(EpdcAdjustUserPointsDTO formDto) {
if(formDto.getOperatePoints()== NumConstant.ZERO){
if (formDto.getOperatePoints() == NumConstant.ZERO) {
return new Result().error("操作积分不能为0");
}
PointsLogsEntity pointsLogsEntity=new PointsLogsEntity();
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity();
pointsLogsEntity.setUserId(formDto.getId());
pointsLogsEntity.setNickname(formDto.getNickname());
pointsLogsEntity.setFaceImg(formDto.getFaceImg());
@ -283,21 +283,23 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
return new Result();
}
/**
* 获取排好序的排行榜数据
*
* @param formDto
* @return java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRankingTopTenDTO>
* @Author zhangyong
* @Date 16:09 2020-05-13
**/
private List<EpdcAppPointsRankingTopTenDTO> sortListPointsRank(EpdcAppPointsRankingFormDTO formDto){
private List<EpdcAppPointsRankingTopTenDTO> sortListPointsRank(EpdcAppPointsRankingFormDTO formDto) {
List<EpdcAppPointsRankingTopTenDTO> listPointsRank = new ArrayList<>();
listPointsRank = baseDao.selectListPointsRanking(formDto);
int sortNumber = 1;
if (listPointsRank != null){
for (int i = 1; i < listPointsRank.size(); i++){
if (listPointsRank != null) {
for (int i = 1; i < listPointsRank.size(); i++) {
listPointsRank.get(0).setRank(NumConstant.ONE);
if(listPointsRank.get(i - NumConstant.ONE).getPoints().intValue() == listPointsRank.get(i).getPoints().intValue()){
if (listPointsRank.get(i - NumConstant.ONE).getPoints().intValue() == listPointsRank.get(i).getPoints().intValue()) {
listPointsRank.get(i).setRank(sortNumber);
} else {
sortNumber = sortNumber + NumConstant.ONE;
@ -310,12 +312,13 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
/**
* 查询积分排行接口0 周排行1 月排行如果没有当前登录用户的积分记录返回 处理(总排名+1) 过的排名信息
*
* @param formDto
* @return com.elink.esua.epdc.dto.result.EpdcAppPointsRankingUserDTO
* @Author zhangyong
* @Date 13:35 2020-05-13
**/
private EpdcAppPointsRankingUserDTO noPointsRecordIsUserRanking(EpdcAppPointsRankingFormDTO formDto){
private EpdcAppPointsRankingUserDTO noPointsRecordIsUserRanking(EpdcAppPointsRankingFormDTO formDto) {
EpdcAppPointsRankingUserDTO userRang = new EpdcAppPointsRankingUserDTO();
int pointCountRaning = baseDao.selectCountPointsRanking(formDto);
userRang.setUserId(formDto.getUserId());
@ -324,4 +327,11 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
userRang.setRank(pointCountRaning + NumConstant.ONE);
return userRang;
}
@Override
public PageData<PointsStatisticsListResultDTO> listPagePoint(Map<String, Object> params) {
IPage<PointsStatisticsListResultDTO> page = getPage(params);
List<PointsStatisticsListResultDTO> list = baseDao.selectPointsList(params);
return new PageData(list, page.getTotal());
}
}

25
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml

@ -180,4 +180,29 @@
) p GROUP BY p.points
) tab
</select>
<select id="selectPointsList" resultType="com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO">
SELECT
SUM(
IF( lg.OPERATION_TYPE = '1', lg.POINTS, 0 )
) allPoints,
SUM(
IF( lg.OPERATION_TYPE = '0', lg.POINTS, 0 )
) residuePoints,
lg.OPERATION_DESC
FROM
epdc_points_logs lg
WHERE
lg.DEL_FLAG = '0'
<if test="ruleCode!= null and ruleCode !=''">
and lg.RULE_CODE = #{ruleCode}
</if>
<if test="startTime!= null and startTime !=''">
and lg.OPERATION_TIME between #{startTime} AND #{endTime}
</if>
GROUP BY
lg.RULE_CODE
ORDER BY allPoints DESC
</select>
</mapper>

Loading…
Cancel
Save