101captain
2022-01-17 a024be265347c2ee974771f0dc85a1b7dab06bf6
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java
@@ -2,6 +2,8 @@
import static java.util.stream.Collectors.toList;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
@@ -11,6 +13,8 @@
import javax.annotation.Resource;
import com.panzhihua.common.model.vos.community.ComActActivityTypeVO;
import com.panzhihua.common.model.vos.user.SysTemplateConfigVO;
import com.panzhihua.service_community.dao.ComActActEvaluateDAO;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.*;
@@ -277,8 +281,8 @@
                        });
                    }
                    comActActivityVO1.setComActActPrizeVOList(comActActPrizeVOList);
                    Integer participantMax = comActActivityVO1.getParticipantMax();
                    if (participantMax.intValue() == 0) {
                    Integer volunteerMax = comActActivityVO1.getVolunteerMax();
                    if (volunteerMax.intValue() != 0) {
                        comActActivityVO1.setType(1);
                    } else {
                        comActActivityVO1.setType(2);
@@ -361,6 +365,23 @@
        comActActivityVO.setComActActEvaluateVOList(comActActEvaluatePage.getRecords());
        //活动评价总数
        comActActivityVO.setEvaluateAmount(comActActEvaluatePage.getTotal());
        List<ComActActEvaluateDO> comActActEvaluateList = comActActEvaluateDAO
                .selectList(new QueryWrapper<ComActActEvaluateDO>().lambda().eq(ComActActEvaluateDO::getActivityId, id));
        if (comActActEvaluateList != null && comActActEvaluateList.size() > 0) {
            BigDecimal starNum = BigDecimal.ZERO;
            //总星级
            for (ComActActEvaluateDO evaluate:comActActEvaluateList) {
                starNum = starNum.add(BigDecimal.valueOf(evaluate.getStarLevel()==null?0:evaluate.getStarLevel()));
            }
            //评分星级(如果无评分默认5分)=总星级/总评价人数
            if(starNum.compareTo(BigDecimal.ZERO) == 0){
                comActActivityVO.setEvaluateLevel(BigDecimal.valueOf(5));
            }else{
                comActActivityVO.setEvaluateLevel(starNum.divide(BigDecimal.valueOf(comActActEvaluateList.size()),2, RoundingMode.HALF_UP));
            }
        }else{
            comActActivityVO.setEvaluateLevel(BigDecimal.valueOf(5));
        }
        //当前用户对活动的评分
        ComActActEvaluateVO userActEvaluateVO = comActActEvaluateDAO.getEvaluateListByUserId(id,userId);
        if(userActEvaluateVO != null){
@@ -380,6 +401,7 @@
        //活动报名名单
        ActivitySignVO activitySignVO = new ActivitySignVO();
        activitySignVO.setActivityId(activityId);
        activitySignVO.setStatus(1);
        R r = comActActivityService.listActivitySigns(activitySignVO);
        if (R.isOk(r)) {
            List<ActivitySignVO> activitySignVOS =
@@ -1386,8 +1408,9 @@
     * @return 活动列表
     */
    @PostMapping("listactivity")
    public R listActivity(@RequestParam("userId") Long userId) {
        return comActActivityService.listActivity(userId);
    public R listActivity(@RequestParam("userId") Long userId,
                          @RequestParam(value = "status", required = false) Integer status) {
        return comActActivityService.listActivity(userId, status);
    }
    /**
@@ -1493,8 +1516,8 @@
     * @return 社区集合 按照创建顺序倒序排列
     */
    @PostMapping("listcommunityall")
    public R listCommunityAll() {
        return comActService.listCommunityAll();
    public R listCommunityAll(@RequestParam("areaCode") String areaCode) {
        return comActService.listCommunityAll(areaCode);
    }
    /**
@@ -2218,10 +2241,11 @@
                String openid = map.get("openid");
                try {
                    WxXCXTempSend util = new WxXCXTempSend();
                    R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(eldersAuthFeedbackAddDTO.getAreaCode(),5);
                    String accessToken = util.getAppAccessToken();
                    WxUtil.sendSubscribeRZSH(openid, accessToken, "高龄认证",
                        DateUtils.format(eldersAuthDO.getCreateAt(), DateUtils.ymdhms_format),
                        eldersAuthFeedbackAddDTO.getFeedBack());
                        eldersAuthFeedbackAddDTO.getFeedBack(),sysTemplateConfigVO.getData().getTemplateId());
                } catch (Exception e) {
                    log.error("推送审核状态订阅消息失败,失败原因:" + e.getMessage());
                }
@@ -2285,6 +2309,16 @@
    @GetMapping("/eventgrid/community/list")
    public R getCommunityLists() {
        return comActService.getCommunityLists();
    }
    /**
     * 查询西区社区列表
     *
     * @return 社区列表
     */
    @GetMapping("/eventgrid/community/westList")
    public R getWestCommunityLists(String areaCode) {
        return comActService.getWestCommunityLists(areaCode);
    }
    /**
@@ -2477,4 +2511,36 @@
    public R listRegistRecord(@RequestParam("id")  Long id, @RequestParam("userId") Long userId) {
        return comActActivityService.listRegistRecord(id, userId);
    }
    /**
     * 获取活动类型(目前只有志愿者活动需要获取)
     * @param communityId
     * @param type
     * @return
     */
    @GetMapping("activity/type/list")
    public R listActivityType(@RequestParam("communityId") Long communityId, @RequestParam("type") Integer type) {
        return comActActivityService.listActivityType(communityId, type);
    }
    /**
     * 添加活动类型
     * @param comActActivityTypeVO
     * @return
     */
    @PostMapping("activity/type/add")
    public R addActivityType(@RequestBody ComActActivityTypeVO comActActivityTypeVO) {
        return comActActivityService.addActivityType(comActActivityTypeVO);
    }
    /**
     * 我的评价
     * @param userId
     * @param activityId 活动id
     * @return
     */
    @GetMapping("activity/my-evaluate")
    public R listMyActivityEvaluate(@RequestParam("userId") Long userId, @RequestParam("activityId") Long activityId) {
        return comActActEvaluateService.listMyActivityEvaluate(userId, activityId);
    }
}