|
|
@ -21,20 +21,32 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.BizPointUserTotalDetailDao; |
|
|
|
import com.epmet.dto.BizPointUserTotalDetailDTO; |
|
|
|
import com.epmet.dto.form.GroupPointFormDTO; |
|
|
|
import com.epmet.dto.result.PointRankingResultDTO; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.entity.BizPointUserTotalDetailEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.resi.group.dto.group.ResiGroupDTO; |
|
|
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
|
|
|
import com.epmet.service.BizPointUserTotalDetailService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 按业务类型积分总计 |
|
|
@ -45,6 +57,10 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class BizPointUserTotalDetailServiceImpl extends BaseServiceImpl<BizPointUserTotalDetailDao, BizPointUserTotalDetailEntity> implements BizPointUserTotalDetailService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private ResiGroupOpenFeignClient resiGroupOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<BizPointUserTotalDetailDTO> page(Map<String, Object> params) { |
|
|
@ -113,7 +129,8 @@ public class BizPointUserTotalDetailServiceImpl extends BaseServiceImpl<BizPoint |
|
|
|
QueryWrapper<BizPointUserTotalDetailEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("BIZ_TYPE", type) |
|
|
|
.eq("OBJECT_ID", objectId) |
|
|
|
.eq("USER_ID", userId); |
|
|
|
.eq("USER_ID", userId) |
|
|
|
.eq("DEL_FLAG", NumConstant.ZERO_STR); |
|
|
|
BizPointUserTotalDetailEntity entity = baseDao.selectOne(wrapper); |
|
|
|
return ConvertUtils.sourceToTarget(entity, BizPointUserTotalDetailDTO.class); |
|
|
|
} |
|
|
@ -130,8 +147,10 @@ public class BizPointUserTotalDetailServiceImpl extends BaseServiceImpl<BizPoint |
|
|
|
@Override |
|
|
|
public Integer getTotalByObject(String type, String objectId) { |
|
|
|
QueryWrapper<BizPointUserTotalDetailEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.select("sum(TOTAL_POINT) as TOTAL_POINT").eq("BIZ_TYPE", type) |
|
|
|
.eq("OBJECT_ID", objectId); |
|
|
|
wrapper.select("IFNULL(SUM(TOTAL_POINT), 0) as TOTAL_POINT") |
|
|
|
.eq("BIZ_TYPE", type) |
|
|
|
.eq("OBJECT_ID", objectId) |
|
|
|
.eq("DEL_FLAG", NumConstant.ZERO_STR); |
|
|
|
BizPointUserTotalDetailEntity entity = baseDao.selectOne(wrapper); |
|
|
|
if (null == entity) { |
|
|
|
return NumConstant.ZERO; |
|
|
@ -139,4 +158,78 @@ public class BizPointUserTotalDetailServiceImpl extends BaseServiceImpl<BizPoint |
|
|
|
return entity.getTotalPoint(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 小组积分贡献榜 |
|
|
|
* |
|
|
|
* @param tokenDto |
|
|
|
* @param formDTO |
|
|
|
* @return java.util.List<com.epmet.dto.result.PointRankingResultDTO> |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2021/4/21 14:06 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<PointRankingResultDTO> pointRanking(TokenDto tokenDto, GroupPointFormDTO formDTO) { |
|
|
|
List<PointRankingResultDTO> list = new ArrayList<>(); |
|
|
|
QueryWrapper<BizPointUserTotalDetailEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("BIZ_TYPE", "group") |
|
|
|
.eq("OBJECT_ID", formDTO.getGroupId()) |
|
|
|
.eq("DEL_FLAG", NumConstant.ZERO_STR) |
|
|
|
.orderByDesc("TOTAL_POINT"); |
|
|
|
List<BizPointUserTotalDetailEntity> userTotalList = baseDao.selectList(wrapper); |
|
|
|
int i = 1; |
|
|
|
list = userTotalList.stream().map(item -> { |
|
|
|
PointRankingResultDTO dto = new PointRankingResultDTO(); |
|
|
|
dto.setUserId(item.getUserId()); |
|
|
|
dto.setPoint(item.getTotalPoint().toString()); |
|
|
|
if (tokenDto.getUserId().equals(item.getUserId())) { |
|
|
|
dto.setIsMine(NumConstant.ONE_STR); |
|
|
|
} else { |
|
|
|
dto.setIsMine(NumConstant.ZERO_STR); |
|
|
|
} |
|
|
|
return dto; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
for (PointRankingResultDTO dto : list) { |
|
|
|
dto.setRanking(String.valueOf(i)); |
|
|
|
i++; |
|
|
|
} |
|
|
|
|
|
|
|
//获取小组信息
|
|
|
|
Result<ResiGroupDTO> group = resiGroupOpenFeignClient.getGroupDetail(formDTO.getGroupId()); |
|
|
|
if (!group.success() || null == group.getData()) { |
|
|
|
throw new RenException(group.getCode(), group.getMsg()); |
|
|
|
} |
|
|
|
//获取用户信息
|
|
|
|
List<String> userIds = userTotalList.stream().map(BizPointUserTotalDetailEntity :: getUserId).collect(Collectors.toList()); |
|
|
|
Result<List<UserBaseInfoResultDTO>> userInfoListResult = epmetUserOpenFeignClient.queryUserBaseInfo(userIds); |
|
|
|
if (!userInfoListResult.success() || null == userInfoListResult.getData()) { |
|
|
|
throw new RenException(userInfoListResult.getCode(), userInfoListResult.getMsg()); |
|
|
|
} |
|
|
|
list.forEach(item -> userInfoListResult.getData().stream().filter(baseInfo -> item.getUserId().equals(baseInfo.getUserId())).forEach( |
|
|
|
user -> { |
|
|
|
//楼院小组显示昵称,支部小组显示姓名
|
|
|
|
if (("ordinary").equals(group.getData().getGroupType())) { |
|
|
|
item.setName(user.getNickname()); |
|
|
|
} else { |
|
|
|
item.setName(user.getName()); |
|
|
|
} |
|
|
|
item.setHeadPhoto(user.getHeadImgUrl()); |
|
|
|
} |
|
|
|
)); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取今日增量 |
|
|
|
* |
|
|
|
* @param type |
|
|
|
* @param objectId |
|
|
|
* @return java.lang.Integer |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2021/4/21 16:41 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer getIncrease(String type, String objectId) { |
|
|
|
return baseDao.selectIncrease(type, objectId); |
|
|
|
} |
|
|
|
|
|
|
|
} |