From 179c4d64313c9b7572778da4aaaf6c6584fe457d Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期二, 20 五月 2025 23:48:08 +0800
Subject: [PATCH] 修改文件上传类型限制

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActEvaluateServiceImpl.java |  180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 175 insertions(+), 5 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 051e630..f88f293 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,11 +1,38 @@
 package com.panzhihua.service_community.service.impl;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.panzhihua.service_community.dao.ComActActEvaluateDAO;
-import com.panzhihua.service_community.model.dos.ComActActEvaluateDO;
-import com.panzhihua.service_community.service.ComActActEvaluateService;
-import lombok.extern.slf4j.Slf4j;
+import static java.util.Objects.isNull;
+import static java.util.Objects.nonNull;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.ComActActEvaluateVO;
+import com.panzhihua.common.model.vos.community.MyActivityEvaluateVO;
+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;
+
+import lombok.extern.slf4j.Slf4j;
+
 /**
  * title: ComActActEvaluateServiceImpl  社区》活动》活动评价表服务实现类
  * projectName 成都呐喊信息技术有限公司-智慧社区项目
@@ -18,4 +45,147 @@
 @Service
 public class ComActActEvaluateServiceImpl extends ServiceImpl<ComActActEvaluateDAO, ComActActEvaluateDO> implements ComActActEvaluateService {
 
+    @Resource
+    private ComActActivityDAO comActActivityDAO;
+    @Resource
+    private ComActActSignDAO comActActSignDAO;
+    @Resource
+    private ComActActRegistDAO comActActRegistDAO;
+    /**
+     * 社区活动评价
+     *
+     * @param comActActEvaluateVO 社区评价VO
+     * @return 评价结果
+     */
+    @Override
+    public R activityEvaluate(ComActActEvaluateVO comActActEvaluateVO) {
+        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("活动不存在");
+        }
+        ComActActSignDO comActActSignDO = comActActSignDAO
+                .selectOne(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getActivityId, activityId)
+                        .eq(ComActActSignDO::getUserId, userId).eq(ComActActSignDO::getStatus, 1));
+        if (isNull(comActActSignDO)) {
+            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));
+            int evaluateCount = this.baseMapper.selectCount(new QueryWrapper<ComActActEvaluateDO>().lambda()
+                    .eq(ComActActEvaluateDO::getUserId, userId).eq(ComActActEvaluateDO::getActivityId, activityId));
+            if (registCount <= evaluateCount) {
+                //未签到,不能评价
+                return R.fail("未签到,不能评价");
+            }
+        } else {
+            if (nowDate.before(beginAt)) {
+                return R.fail("活动还未开始,暂不支持评价");
+            }
+        }
+        ComActActEvaluateDO comActActEvaluateDO = new ComActActEvaluateDO();
+        BeanUtils.copyProperties(comActActEvaluateVO, comActActEvaluateDO);
+        comActActEvaluateDO.setSignIdentity(comActActSignDO.getSignIdentity());
+        int result = this.baseMapper.insert(comActActEvaluateDO);
+        if (result < 0) {
+            return R.fail("评论失败,请重试");
+        }
+        return R.ok();
+    }
+
+    /**
+     * 定时任务针对活动结束后7天还未评价的用户默认好评
+     */
+    @Override
+    public R timedTaskActivityDefaultPraise() {
+        //获取还未默认好评的活动
+        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)));
+        //获取报名记录
+        if (!ObjectUtils.isEmpty(comActActivityDOS)) {
+            List<Long> activityIds = comActActivityDOS.stream().map(ComActActivityDO::getId).collect(Collectors.toList());
+            List<ComActActSignDO> comActActSignDOS = comActActSignDAO.selectNeedEvaluateSignRecords(activityIds);
+            //批量插入好评
+            if (!ObjectUtils.isEmpty(comActActSignDOS)) {
+                List<ComActActEvaluateDO> comActActEvaluateDOList = comActActSignDOS.stream().map(comActActSignDO -> {
+                    ComActActEvaluateDO comActActEvaluateDO = new ComActActEvaluateDO();
+                    comActActEvaluateDO.setActivityId(comActActSignDO.getActivityId());
+                    comActActEvaluateDO.setSignIdentity(comActActSignDO.getSignIdentity());
+                    comActActEvaluateDO.setUserId(comActActSignDO.getUserId());
+                    comActActEvaluateDO.setCreateAt(new Date());
+                    comActActEvaluateDO.setStarLevel(5);
+                    comActActEvaluateDO.setEvaluateContent("系统默认好评!");
+                    return comActActEvaluateDO;
+                }).collect(Collectors.toList());
+                boolean result = this.saveBatch(comActActEvaluateDOList);
+                if (!result) {
+                    return R.fail("批量插入评价失败");
+                }
+                ComActActivityDO comActActivityDO = new ComActActivityDO();
+                comActActivityDO.setIsDefaultPraise(1);
+                int updateResult = comActActivityDAO.update(comActActivityDO, new UpdateWrapper<ComActActivityDO>()
+                        .lambda().in(ComActActivityDO::getId, activityIds));
+                if (updateResult < 0) {
+                    return R.fail("修改是否已默认评价状态失败");
+                }
+            }
+        }
+        return R.ok();
+    }
+
+    /**
+     * 用户评价列表
+     *
+     * @param userId 用户id
+     * @return 当前用户对所有活动的评价列表
+     */
+    @Override
+    public R listEvaluate(Long userId) {
+        List<ComActActEvaluateDO> comActActEvaluateDOList = this.baseMapper.selectList(new QueryWrapper<ComActActEvaluateDO>()
+                .lambda().eq(ComActActEvaluateDO::getUserId, userId));
+        List<ComActActEvaluateVO> comActActEvaluateVOS = new ArrayList<>();
+        if (!ObjectUtils.isEmpty(comActActEvaluateDOList)) {
+            comActActEvaluateDOList.forEach(comActActEvaluateDO -> {
+                ComActActEvaluateVO comActActEvaluateVO = new ComActActEvaluateVO();
+                BeanUtils.copyProperties(comActActEvaluateDO, comActActEvaluateVO);
+                comActActEvaluateVOS.add(comActActEvaluateVO);
+            });
+        }
+        return R.ok(comActActEvaluateVOS);
+    }
+
+    /**
+     * 我的评价
+     * @param userId
+     * @param activityId
+     * @return
+     */
+    @Override
+    public R listMyActivityEvaluate(Long userId, Long activityId) {
+        ComActActivityDO comActActivityDO = comActActivityDAO.selectById(activityId);
+        if (isNull(comActActivityDO)) {
+            return R.fail("活动不存在");
+        }
+        List<ComActActEvaluateVO> comActActEvaluateVOS = this.baseMapper.selectEvaluateList(activityId, userId);
+        int regCount = comActActRegistDAO.selectCount(new QueryWrapper<ComActActRegistDO>()
+                .lambda().eq(ComActActRegistDO::getActivityId, activityId).eq(ComActActRegistDO::getUserId, userId));
+
+        MyActivityEvaluateVO evaluateVO = new MyActivityEvaluateVO();
+        evaluateVO.setMyEvaluateList(comActActEvaluateVOS);
+        boolean needDisplay = regCount > comActActEvaluateVOS.size() &&
+                new Date().before(DateUtils.addDays(comActActivityDO.getEndAt(), 3));
+        evaluateVO.setIsDisplay(needDisplay ? 1 : 0);
+        return R.ok(evaluateVO);
+    }
 }

--
Gitblit v1.7.1