From 3669a1434209e399d46341504bd241dbf51ac291 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期五, 10 十二月 2021 10:29:10 +0800
Subject: [PATCH] 修改活动bug

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 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 90c6dfb..25ab5a4 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
@@ -115,6 +115,9 @@
      */
     @Override
     public R addActivity(ComActActivityVO comActActivityVO) {
+        if (comActActivityVO.getHaveIntegralReward().intValue() == 2) {
+            comActActivityVO.setRewardWay(null);
+        }
         ComActActivityDO comActActivityDO = new ComActActivityDO();
         BeanUtils.copyProperties(comActActivityVO, comActActivityDO);
         Integer status = comActActivityVO.getStatus();
@@ -199,6 +202,9 @@
                     log.error("消息推送失败,失败原因:" + e.getMessage());
                 }
             }
+        }
+        if (comActActivityVO.getHaveIntegralReward().intValue() == 2) {
+            comActActivityVO.setRewardWay(null);
         }
         BeanUtils.copyProperties(comActActivityVO, comActActivityDO);
 
@@ -545,6 +551,10 @@
                 num = comActActSignDAO.insert(comActActSignDO);
             }
         } else {
+            Integer canCancel = actActivityDO.getCanCancel();
+            if (nonNull(canCancel) && canCancel.equals(2)) {
+                return R.fail("该活动暂不支持取消");
+            }
             if (isNull(signactivityVO.getReason())) {
                 return R.fail("缺少取消原因");
             }
@@ -554,6 +564,15 @@
             comActActSignDO.setStatus(0);
             comActActSignDO.setReason(signactivityVO.getReason());
             num = comActActSignDAO.updateById(comActActSignDO);
+            if (num > 0) {
+                AddComActIntegralUserDTO addComActIntegralUserDTO = new AddComActIntegralUserDTO();
+                addComActIntegralUserDTO.setUserId(userId);
+                addComActIntegralUserDTO.setIntegralType(9);
+                addComActIntegralUserDTO.setActivityType(1);
+                addComActIntegralUserDTO.setCommunityId(actActivityDO.getCommunityId());
+                addComActIntegralUserDTO.setServiceId(activityId);
+                comActIntegralUserTradeService.addIntegralTradeAdmin(addComActIntegralUserDTO);
+            }
         }
         if (num > 0) {
             return R.ok(isVolunteer);
@@ -610,7 +629,8 @@
                 }
                 comActActivityVO.setSingDate(createAt);
                 comActActivityVO.setTimes(activitySignVO.getTimes());
-                comActActivityVO.setAward(activitySignVO.getAward());
+                Integer totalAward = comActActRegistDAO.selectTotalAwardWithRegist(activitySignVO.getActivityId(), userId);
+                comActActivityVO.setAward(totalAward);
                 comActActivityVOS.add(comActActivityVO);
             });
         }
@@ -894,6 +914,8 @@
 //        if (stringRedisTemplate.hasKey(activitySignInKey)) {
 //            return R.fail("你已签到,如要再次签到请三十分钟后尝试!");
 //        }
+            Integer haveIntegralReward = comActActivityDO.getHaveIntegralReward();
+            boolean isHave = nonNull(haveIntegralReward) && haveIntegralReward.equals(1);
             ComActActRegistDO comActActRegistDO = new ComActActRegistDO();
             comActActRegistDO.setActivityId(activityId);
             comActActRegistDO.setType(1);
@@ -901,11 +923,11 @@
             comActActRegistDO.setIsVolunteer(comActActRegistVO.getIsVolunteer());
             comActActRegistDO.setCreateAt(nowDate);
             comActActRegistDO.setCodeId(comActActRegistVO.getCodeId());
-            comActActRegistDO.setAward(comActActivityDO.getRewardIntegral());
+            comActActRegistDO.setAward(isHave ? comActActivityDO.getRewardIntegral() : 0);
             comActActRegistDO.setPosition(comActActRegistVO.getPosition());
             comActActRegistDO.setTimes(signAllCount+1);
             int result = comActActRegistDAO.insert(comActActRegistDO);
-            if (result > 0) {
+            if (isHave && result > 0) {
                 AddComActIntegralUserDTO addComActIntegralUserDTO=new AddComActIntegralUserDTO();
                 addComActIntegralUserDTO.setUserId(userId);
                 addComActIntegralUserDTO.setIntegralType(8);

--
Gitblit v1.7.1