From ada9d2e3f734582a0d9ae8c00a936d8c8ed669d7 Mon Sep 17 00:00:00 2001
From: huanghongfa <18228131219@163.com>
Date: 星期五, 15 一月 2021 13:51:44 +0800
Subject: [PATCH] 微心愿详情bug

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 108 insertions(+), 5 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
index ed13908..a99a4b8 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -14,13 +14,17 @@
 import com.panzhihua.service_community.model.dos.ComActActSignDO;
 import com.panzhihua.service_community.model.dos.ComActActivityDO;
 import com.panzhihua.service_community.service.ComActActivityService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -28,6 +32,7 @@
  * @author: huang.hongfa weixin hhf9596 qq 959656820
  * @create: 2020-12-07 14:35
  **/
+@Slf4j
 @Service
 public class ComActActivityServiceImpl extends ServiceImpl<ComActActivityDAO, ComActActivityDO> implements ComActActivityService {
     @Resource
@@ -84,10 +89,10 @@
         Page page = new Page<>();
         Long pageNum = comActActivityVO.getPageNum();
         Long pageSize = comActActivityVO.getPageSize();
-        if (ObjectUtils.isEmpty(pageNum)||0==pageNum) {
+        if (null==pageNum||0==pageNum) {
             pageNum = 1l;
         }
-        if (ObjectUtils.isEmpty(pageSize)||0==pageSize) {
+        if (null==pageSize||0==pageSize) {
             pageSize = 10l;
         }
         page.setSize(pageSize);
@@ -126,7 +131,7 @@
         ComActActivityDO comActActivityDO=new ComActActivityDO();
         comActActivityDO.setId(comActActivityVO.getId());
         comActActivityDO.setStatus(comActActivityVO.getStatus());
-        comActActivityDO.setCancelReason(comActActivityVO.getCancelRenson());
+        comActActivityDO.setCancelReason(comActActivityVO.getCancelReason());
         int update = comActActivityDAO.updateById(comActActivityDO);
         if (update>0) {
             return R.ok();
@@ -148,6 +153,7 @@
             ComActActSignDO comActActSignDO = comActActSignDAO.selectOne(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getActivityId, id).eq(ComActActSignDO::getUserId, userId));
             if (!ObjectUtils.isEmpty(comActActSignDO)) {
                 comActActivityVO.setIsSign(1);
+                comActActivityVO.setIsVolunteer(comActActSignDO.getIsVolunteer());
             }else {
 
             }
@@ -178,10 +184,10 @@
         Page page = new Page<>();
         Long pageNum = comActActivityVO.getPageNum();
         Long pageSize = comActActivityVO.getPageSize();
-        if (ObjectUtils.isEmpty(pageNum)||0==pageNum) {
+        if (null==pageNum||0==pageNum) {
             pageNum = 1l;
         }
-        if (ObjectUtils.isEmpty(pageSize)||0==pageSize) {
+        if (null==pageSize||0==pageSize) {
             pageSize = 10l;
         }
         page.setSize(pageSize);
@@ -218,5 +224,102 @@
         return R.fail();
     }
 
+    /**
+     * 用户参加的所有社区活动
+     *
+     * @param userId 用户id
+     * @return 活动列表
+     */
+    @Override
+    public R listActivity(Long userId) {
+        List<ComActActSignDO> comActActSignDOS = comActActSignDAO.selectList(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getUserId, userId));
+        if (ObjectUtils.isEmpty(comActActSignDOS)) {
+            return R.fail();
+        }
+        List<Long> longs = comActActSignDOS.stream().map(comActActSignDO -> comActActSignDO.getActivityId()).collect(Collectors.toList());
+        List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectBatchIds(longs);
+        List<ComActActivityVO>comActActivityVOS=new ArrayList<>();
+        comActActivityDOS.forEach(comActActivityDO -> {
+            ComActActivityVO comActActivityVO=new ComActActivityVO();
+            BeanUtils.copyProperties(comActActivityDO,comActActivityVO);
+            List<ComActActSignDO> collect = comActActSignDOS.stream().filter(comActActSignDO -> comActActSignDO.getActivityId().equals(comActActivityVO.getId())).limit(1).collect(Collectors.toList());
+            ComActActSignDO comActActSignDO = collect.get(0);
+            Integer isVolunteer = comActActSignDO.getIsVolunteer();
+            if (isVolunteer.intValue()==1) {
+                comActActivityVO.setType(1);
+            }else{
+                comActActivityVO.setType(2);
+            }
+            comActActivityVOS.add(comActActivityVO);
+        });
+        return R.ok(comActActivityVOS);
+    }
+
+    /**
+     * 查询志愿者参与的所有已经完成的活动
+     *
+     * @param phone 用户手机号
+     * @return 所有活动集合
+     */
+    @Override
+    public List<ComActActivityVO> listActivityByPhone(String phone) {
+        List<ComActActivityVO> comActActivityVOS=comActActivityDAO.listActivityByPhone(phone);
+        return comActActivityVOS;
+    }
+
+    /**
+     * 定时任务查询所有要取消的社区活动
+     *
+     * @return 社区活动集合
+     */
+    @Override
+    public R timedTaskActActivity() {
+        List<Long>longs=comActActivityDAO.selectTimedTaskActActivity();
+        if (ObjectUtils.isEmpty(longs)) {
+            return R.fail("没有需要取消的社区活动");
+        }
+        List<ComActActivityDO> comActActivityDOS = comActActivityDAO.selectBatchIds(longs);
+        List<ComActActivityVO>comActActivityVOS=new ArrayList<>();
+        if (!ObjectUtils.isEmpty(comActActivityDOS)) {
+            comActActivityDOS.forEach(comActActivityDO -> {
+                ComActActivityVO comActActivityVO=new ComActActivityVO();
+                BeanUtils.copyProperties(comActActivityDO,comActActivityVO);
+                List<ComActActSignDO> comActActSignDOS = comActActSignDAO.selectList(new QueryWrapper<ComActActSignDO>().lambda().eq(ComActActSignDO::getActivityId, comActActivityDO.getId()));
+                if (!ObjectUtils.isEmpty(comActActSignDOS)) {
+                    List<ActivitySignVO> activitySignVOList=new ArrayList<>();
+                    comActActSignDOS.forEach(comActActSignDO -> {
+                        ActivitySignVO activitySignVO=new ActivitySignVO();
+                        BeanUtils.copyProperties(comActActSignDO,activitySignVO);
+                        activitySignVOList.add(activitySignVO);
+                        comActActivityVO.setActivitySignVOList(activitySignVOList);
+                    });
+                }
+                comActActivityVOS.add(comActActivityVO);
+            });
+            int num=comActActivityDAO.updateIdBatch(longs);
+            log.info("定时任务--一共取消社区活动数量【{}】",num);
+        }
+        return R.ok(comActActivityVOS);
+    }
+
+    /**
+     * 定时任务刷新社区活动的各个状态 除取消外
+     *
+     * @return 更新结果
+     */
+    @Override
+    public R timedTaskActActivityAll() {
+//        修改发布状态 变为未开始
+        int num=comActActivityDAO.updateStatusToNotBegin();
+        log.info("定时任务--修改社区活动发布状态活动数量【{}】",num);
+//        修改报名状态 变为报名中
+        int num1=comActActivityDAO.updateStatusToBeginSign();
+        log.info("定时任务--修改社区活动报名状态活动数量【{}】",num1);
+//        修改进行状态 变为进行中或者已结束
+        int num2=comActActivityDAO.updateStatusToBeginActiveOrEnd();
+        log.info("定时任务--修改社区活动进行状态活动数量【{}】",num2);
+        return R.ok();
+    }
+
 
 }

--
Gitblit v1.7.1