diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/MyTotalPointResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/MyTotalPointResultDTO.java index 81d70ffd3c..050416dd08 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/MyTotalPointResultDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/MyTotalPointResultDTO.java @@ -12,10 +12,6 @@ import java.io.Serializable; @Data public class MyTotalPointResultDTO implements Serializable { private static final long serialVersionUID = 15299506166024546L; - /** - * 德育积分moral_education;党建积分party_building;活跃积分active - */ - private String categoryCode; /** * 总积分 */ diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/CommonConstant.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/CommonConstant.java index 9f8a8786d9..50cccad0ec 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/CommonConstant.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/CommonConstant.java @@ -29,6 +29,10 @@ public interface CommonConstant extends Constant { * 活跃积分 */ String ACTIVE = "active"; + /** + * 活跃积分 + */ + String TOTAL = "total"; /** * 积分申请 */ diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java index 6166f4b592..5a393cc871 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java @@ -233,8 +233,10 @@ public class ResiPointController { } @PostMapping("total") - public Result> totalPoint(@LoginUser TokenDto tokenDto) { - return new Result>().ok(userPointTotalService.totalPoint(tokenDto)); + public Result totalPoint(@LoginUser TokenDto tokenDto, @RequestBody CommonPageUserFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + return new Result().ok(userPointTotalService.totalPoint(formDTO)); } /** diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointTotalService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointTotalService.java index 07bc0b77e1..43302c3948 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointTotalService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointTotalService.java @@ -18,7 +18,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.CommonPageUserFormDTO; import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; import com.epmet.dto.result.MyTotalPointResultDTO; @@ -75,10 +75,10 @@ public interface UserPointTotalService extends BaseService /** * 积分总分 * - * @Param tokenDto + * @Param formDTO * @Return {@link MyTotalPointResultDTO} * @Author zhaoqifeng * @Date 2022/6/14 15:46 */ - List totalPoint(TokenDto tokenDto); + MyTotalPointResultDTO totalPoint(CommonPageUserFormDTO formDTO); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointTotalServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointTotalServiceImpl.java index 4dbda58db2..66afc5150e 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointTotalServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointTotalServiceImpl.java @@ -24,11 +24,11 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; -import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.PointAditiveCalcDao; import com.epmet.dao.UserPointTotalDao; +import com.epmet.dto.form.CommonPageUserFormDTO; import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; import com.epmet.dto.result.*; @@ -215,28 +215,53 @@ public class UserPointTotalServiceImpl extends BaseServiceImpl totalPoint(TokenDto tokenDto) { - List list = new ArrayList(); - //活跃度积分 - MyTotalPointResultDTO active = new MyTotalPointResultDTO(); - active.setCategoryCode(CommonConstant.ACTIVE); - ResiPointDetailResultDTO activeTotal = baseDao.selectPointByCustomerUserId(tokenDto.getUserId(), tokenDto.getCustomerId()); - if (null != activeTotal) { - active.setTotal(activeTotal.getAccumulatedPoint()); - active.setUsable(activeTotal.getUsablePoint()); - active.setSpend(activeTotal.getAccumulatedPoint() - activeTotal.getUsablePoint()); + public MyTotalPointResultDTO totalPoint(CommonPageUserFormDTO formDTO) { + MyTotalPointResultDTO resultDTO = new MyTotalPointResultDTO(); + switch (formDTO.getCategoryCode()) { + case CommonConstant.MORAL_EDUCATION: + //德育积分 + resultDTO = getEducationTotal(formDTO); + break; + case CommonConstant.PARTY_BUILDING: + //党建积分 + resultDTO = getPartyTotal(formDTO); + break; + case CommonConstant.ACTIVE: + //活跃度积分 + resultDTO = getActiveTotal(formDTO); + break; + case CommonConstant.TOTAL: + MyTotalPointResultDTO education = getEducationTotal(formDTO); + MyTotalPointResultDTO party = getPartyTotal(formDTO); + MyTotalPointResultDTO active = getActiveTotal(formDTO); + resultDTO.setTotal(education.getTotal() + party.getTotal() + active.getTotal()); + resultDTO.setSpend(education.getSpend() + party.getSpend() + active.getSpend()); + resultDTO.setUsable(education.getUsable() + party.getUsable() + active.getUsable()); + break; + default: + break; } - list.add(active); + + return resultDTO; + } + + /** + * 德育积分 + * @Param formDTO + * @Return {@link MyTotalPointResultDTO} + * @Author zhaoqifeng + * @Date 2022/6/17 9:58 + */ + private MyTotalPointResultDTO getEducationTotal(CommonPageUserFormDTO formDTO) { + MyTotalPointResultDTO resultDTO = new MyTotalPointResultDTO(); //德育积分 - MyTotalPointResultDTO education = new MyTotalPointResultDTO(); - education.setCategoryCode(CommonConstant.MORAL_EDUCATION); //获取居民绑定的家庭 Result result = epmetUserOpenFeignClient.getHomeInfo(); if (!result.success() || null == result.getData()) { @@ -244,34 +269,58 @@ public class UserPointTotalServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PointAditiveCalcEntity::getCustomerId, tokenDto.getCustomerId()); + wrapper.eq(PointAditiveCalcEntity::getCustomerId, formDTO.getCustomerId()); wrapper.eq(PointAditiveCalcEntity::getSubjectId, result.getData().getHouseId()); wrapper.eq(PointAditiveCalcEntity::getCategoryCode, CommonConstant.MORAL_EDUCATION); PointAditiveCalcEntity entity = pointAditiveCalcDao.selectOne(wrapper); if (null != entity) { - education.setTotal(entity.getTotal()); - education.setSpend(entity.getSpend()); - education.setUsable(entity.getTotal() - entity.getSpend()); + resultDTO.setTotal(entity.getTotal()); + resultDTO.setSpend(entity.getSpend()); + resultDTO.setUsable(entity.getTotal() - entity.getSpend()); } } - list.add(education); + return resultDTO; + } - //党建积分 - MyTotalPointResultDTO party = new MyTotalPointResultDTO(); - party.setCategoryCode(CommonConstant.PARTY_BUILDING); + /** + * 党建积分 + * @Param formDTO + * @Return {@link MyTotalPointResultDTO} + * @Author zhaoqifeng + * @Date 2022/6/17 9:58 + */ + private MyTotalPointResultDTO getPartyTotal(CommonPageUserFormDTO formDTO) { + MyTotalPointResultDTO resultDTO = new MyTotalPointResultDTO(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PointAditiveCalcEntity::getCustomerId, tokenDto.getCustomerId()); - wrapper.eq(PointAditiveCalcEntity::getSubjectId, tokenDto.getUserId()); + wrapper.eq(PointAditiveCalcEntity::getCustomerId, formDTO.getCustomerId()); + wrapper.eq(PointAditiveCalcEntity::getSubjectId, formDTO.getUserId()); wrapper.eq(PointAditiveCalcEntity::getCategoryCode, CommonConstant.PARTY_BUILDING); PointAditiveCalcEntity entity = pointAditiveCalcDao.selectOne(wrapper); if (null != entity) { - party.setTotal(entity.getTotal()); - party.setSpend(entity.getSpend()); - party.setUsable(entity.getTotal() - entity.getSpend()); + resultDTO.setTotal(entity.getTotal()); + resultDTO.setSpend(entity.getSpend()); + resultDTO.setUsable(entity.getTotal() - entity.getSpend()); } - list.add(party); + return resultDTO; + } - return list; + /** + * 活跃积分 + * + * @Param formDTO + * @Return {@link MyTotalPointResultDTO} + * @Author zhaoqifeng + * @Date 2022/6/17 9:58 + */ + private MyTotalPointResultDTO getActiveTotal(CommonPageUserFormDTO formDTO) { + MyTotalPointResultDTO resultDTO = new MyTotalPointResultDTO(); + ResiPointDetailResultDTO activeTotal = baseDao.selectPointByCustomerUserId(formDTO.getUserId(), formDTO.getCustomerId()); + if (null != activeTotal) { + resultDTO.setTotal(activeTotal.getAccumulatedPoint()); + resultDTO.setUsable(activeTotal.getUsablePoint()); + resultDTO.setSpend(activeTotal.getAccumulatedPoint() - activeTotal.getUsablePoint()); + } + return resultDTO; } }