From 1e3b97098151f2d0471de6e8103b6cdaa6b5099d Mon Sep 17 00:00:00 2001 From: puhanshu <a9236326> Date: 星期六, 18 九月 2021 09:15:59 +0800 Subject: [PATCH] Merge branch 'test' of http://gitlab.nhys.cdnhxx.com/root/zhihuishequ into auth --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java | 40 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 36 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java index 4b4c523..9aff4c0 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java @@ -1,5 +1,8 @@ package com.panzhihua.service_community.service.impl; +import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -19,9 +22,11 @@ import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComActActEvaluateVO; import com.panzhihua.service_community.dao.ComActActEvaluateDAO; +import com.panzhihua.service_community.dao.ComActActRegistDAO; import com.panzhihua.service_community.dao.ComActActSignDAO; import com.panzhihua.service_community.dao.ComActActivityDAO; import com.panzhihua.service_community.model.dos.ComActActEvaluateDO; +import com.panzhihua.service_community.model.dos.ComActActRegistDO; import com.panzhihua.service_community.model.dos.ComActActSignDO; import com.panzhihua.service_community.model.dos.ComActActivityDO; import com.panzhihua.service_community.service.ComActActEvaluateService; @@ -44,6 +49,8 @@ private ComActActivityDAO comActActivityDAO; @Resource private ComActActSignDAO comActActSignDAO; + @Resource + private ComActActRegistDAO comActActRegistDAO; /** * 社区活动评价 * @@ -52,9 +59,33 @@ */ @Override public R activityEvaluate(ComActActEvaluateVO comActActEvaluateVO) { - ComActActEvaluateDO currentUserEvaluateForThisActivity = this.baseMapper.selectOne(new QueryWrapper<ComActActEvaluateDO>().lambda() - .eq(ComActActEvaluateDO::getActivityId, comActActEvaluateVO.getActivityId()) - .eq(ComActActEvaluateDO::getUserId, comActActEvaluateVO.getUserId())); + Long activityId = comActActEvaluateVO.getActivityId(); + Long userId = comActActEvaluateVO.getUserId(); + if (isNull(activityId)) { + return R.fail("参数有误"); + } + ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId); + if (isNull(comActActivityDO)) { + return R.fail("活动不存在"); + } + Date beginAt = comActActivityDO.getBeginAt(); + Date nowDate = new Date(); + Integer isQrCode = comActActivityDO.getIsQrCode(); + if (nonNull(isQrCode) && isQrCode.equals(1)) { + //需要签到类型 + int registCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>() + .lambda().eq(ComActActRegistDO::getUserId, userId).eq(ComActActRegistDO::getActivityId, activityId)); + if (registCount <= 0) { + //未签到,不能评价 + return R.fail("未签到,不能评价"); + } + } else { + if (nowDate.before(beginAt)) { + return R.fail("活动还未开始,暂不支持评价"); + } + } + ComActActEvaluateDO currentUserEvaluateForThisActivity = this.baseMapper.selectOne(new QueryWrapper<ComActActEvaluateDO>() + .lambda().eq(ComActActEvaluateDO::getActivityId, activityId).eq(ComActActEvaluateDO::getUserId, userId)); if (Objects.nonNull(currentUserEvaluateForThisActivity)) { return R.fail("该用户已评论过了,请勿重复评论"); } @@ -76,7 +107,7 @@ List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectList(new QueryWrapper<ComActActivityDO>().lambda() .eq(ComActActivityDO::getStatus, 5) .eq(ComActActivityDO::getIsDefaultPraise, 0) - .le(ComActActivityDO::getEndAt, DateUtils.addDays(new Date(), 7))); + .le(ComActActivityDO::getEndAt, DateUtils.addDays(new Date(), -7))); //获取报名记录 if (!ObjectUtils.isEmpty(comActActivityDOS)) { List<Long> activityIds = comActActivityDOS.stream().map(ComActActivityDO::getId).collect(Collectors.toList()); @@ -90,6 +121,7 @@ comActActEvaluateDO.setUserId(comActActSignDO.getUserId()); comActActEvaluateDO.setCreateAt(new Date()); comActActEvaluateDO.setStarLevel(5); + comActActEvaluateDO.setEvaluateContent("系统默认好评!"); return comActActEvaluateDO; }).collect(Collectors.toList()); boolean result = this.saveBatch(comActActEvaluateDOList); -- Gitblit v1.7.1