From 1121a81f275bc5834ff8f6cedd2c5ee23e16ce19 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 31 七月 2025 17:48:58 +0800
Subject: [PATCH] 用户NickName问题

---
 framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java |  116 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 77 insertions(+), 39 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java
index b32929a..825ffd3 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java
@@ -14,6 +14,7 @@
 import cn.lili.modules.lmk.domain.vo.ActivityVO;
 import cn.lili.modules.lmk.mapper.ActivityMapper;
 import cn.lili.modules.lmk.service.ActivityAuditRecordService;
+import cn.lili.modules.lmk.service.ActivityReportService;
 import cn.lili.modules.lmk.service.ActivityService;
 import cn.lili.modules.lmk.service.LmkFileService;
 import cn.lili.modules.member.entity.vo.MemberVO;
@@ -25,14 +26,17 @@
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
 @Service
 @RequiredArgsConstructor
+@Transactional
 public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements ActivityService {
 
     private final LmkFileService lmkFileService;
@@ -40,6 +44,8 @@
     private final COSUtil cOSUtil;
 
     private final ActivityAuditRecordService activityAuditRecordService;
+
+    private final ActivityReportService activityReportService;
 
 
     @Override
@@ -55,6 +61,7 @@
         entity.setPublish(false);
         //璁剧疆鐢宠浜篿d
         entity.setMemberId(UserContext.getCurrentUserId());
+        entity.setStoreId(UserContext.getCurrentUser().getStoreId());
         baseMapper.insert(entity);
         mangerSaveOrUpdate(isManager,entity);
         return Result.ok("娣诲姞鎴愬姛");
@@ -88,9 +95,9 @@
         //娣诲姞瀹℃牳璁板綍
         if (isManager){
             //鐩存帴閫氳繃
-            activityAuditRecordForm = ActivityAuditRecordForm.getEntityByManagerBuildForm(entity.getId());
+            activityAuditRecordForm = ActivityAuditRecordForm.getFormByManager(entity.getId());
         }else {
-            activityAuditRecordForm = ActivityAuditRecordForm.getEntityByBuyerBuildForm(entity.getId());
+            activityAuditRecordForm = ActivityAuditRecordForm.getFormByBuyer(entity.getId());
         }
         activityAuditRecordService.addOrUpdateAuditActivity(activityAuditRecordForm);
     }
@@ -98,15 +105,35 @@
     public Result remove(List<String> ids) {
         //鍒ゆ柇娲诲姩id鏄惁宸茬粡瀛樺湪鎶ュ悕浜哄憳
         for(String id : ids){
-            if(haveApplicationMembers(id)){
-                return Result.error("璇ユ椿鍔ㄦ棤娉曞垹闄わ紝宸插瓨鍦ㄦ姤鍚嶄汉鍛�");
-            }
-        }
-        //鏈粡杩噐eturn鍒欏垹闄�
-        for (String id : ids){
-            delActivityAndInformation(id);
+            canDeleteActivity(id);
+
         }
 
+        return Result.ok("鍒犻櫎鎴愬姛");
+    }
+    /**
+     * 鍒ゆ柇鏄惁鑳藉垹闄ゆ椿鍔� 骞跺垹闄ゆ椿鍔ㄧ浉鍏充俊鎭�
+     * @param id
+     * @return
+     */
+    public Result canDeleteActivity(String id){
+        Activity activity = baseMapper.selectById(id);
+
+        //娲诲姩鏄惁鍙戝竷
+        if (activity.getPublish()){
+            return Result.error("瀛樺湪娲诲姩宸插彂甯冨垹闄ゅ墠璇蜂笅鏋惰娲诲姩锛�");
+        }
+        //妫�鏌ユ姤鍚嶄汉鍛樺墠鍒ゆ柇娲诲姩鏄惁缁撴潫浜� 缁撴潫浜嗗氨鍏佽鍒犻櫎
+        Date currentDate = new Date();
+        if (currentDate.before(activity.getEndTime())){
+            //娲诲姩鏈粨鏉� 涓旀姤鍚嶄汉鍛樼殑鎯呭喌
+            if(haveApplicationMembers(activity.getId())){
+                //todo 鎶ュ悕浜哄憳瀛樺湪 浣嗘槸闇�瑕佸垹闄ょ殑鎯呭喌棰勭暀
+//                return Result.error("娲诲姩鏈粨鏉熶笖宸叉湁鎶ュ悕浜哄憳锛屾棤娉曞垹闄わ紒");
+            }
+
+        }
+        delActivityAndInformation(activity);
         return Result.ok("鍒犻櫎鎴愬姛");
     }
     //鍒ゆ柇娲诲姩鏄惁瀛樺湪鎶ュ悕浜哄憳
@@ -115,26 +142,26 @@
         activityMembersQuery.setId(id);
         return (long) activityMembersPage(activityMembersQuery).get("total") > 0;
     }
+    //鍒ゆ柇浜掑姩鏄惁鍙戝竷
+
     //鍒犻櫎娲诲姩鍚屾椂鍒犻櫎娲诲姩鐨勭浉鍏充俊鎭�
-    public void delActivityAndInformation(String id){
-        ActivityVO vo = baseMapper.getById(id);
-        if (StringUtils.isNotEmpty(vo.getCover())){
-            lmkFileService.deleteObject(vo.getCover());
+    public void delActivityAndInformation(Activity activity){
+        if (StringUtils.isNotEmpty(activity.getCover())){
+            lmkFileService.deleteObject(activity.getCover());
         }
-        baseMapper.deleteById(id);
+        baseMapper.deleteById(activity.getId());
         //鍒犻櫎瀹℃牳璁板綍
-        activityAuditRecordService.delActivityAuditById(id);
+        activityAuditRecordService.delActivityAuditById(activity.getId());
+        //鍒犻櫎娲诲姩鎶ュ悕浜哄憳
+        activityReportService.delByActivityId(activity.getId());
     }
+
+
+
     @Override
     public Result removeById(String id) {
         //鍏堝垽鏂椿鍔ㄦ槸鍚︽湁鎶ュ悕浜哄憳
-
-        if(haveApplicationMembers(id)){
-            return Result.error("璇ユ椿鍔ㄦ棤娉曞垹闄わ紝宸插瓨鍦ㄦ姤鍚嶄汉鍛�");
-        }
-        //鍒犻櫎锛屽悓鏃跺垽鏂瀵硅薄鐨勫皝闈㈡槸鍚﹀瓨鍦� 锛屽瓨鍦ㄥ垯鍦ㄤ簯鏈嶅姟鍣ㄥ垹闄�
-        delActivityAndInformation(id);
-        return Result.ok("鍒犻櫎鎴愬姛");
+        return canDeleteActivity(id);
     }
 
     @Override
@@ -152,18 +179,24 @@
 
     @Override
     public Result getMyApplyActivityPage(ActivityQuery query){
-        System.out.println(query);
 
         //浼犲叆褰撳墠璇锋眰鐢ㄦ埛鐨刬d
-        query.setMemberId(UserContext.getCurrentUserId());
+        String storeId = UserContext.getCurrentUser().getStoreId();
+        if (storeId == null){
+            query.setMemberId(UserContext.getCurrentUserId());
+        }else {
+            query.setStoreId(storeId);
+        }
+
         //鏇村叿鐢ㄦ埛id鑾峰緱娲诲姩
         IPage<ActivityVO> page = PageUtil.getPage(query, ActivityVO.class);
-        baseMapper.getPage(page, query);
+        baseMapper.storeGetPage(page, query);
         for (ActivityVO vo : page.getRecords()) {
             if (!ActivityCoverTypeEnum.TEXT.getType().equals(vo.getCoverType())){
                 vo.setUrl(cOSUtil.getPreviewUrl(vo.getCover()));
             }
         }
+
         return Result.ok().data(page.getRecords()).total(page.getTotal());
     }
 
@@ -215,31 +248,36 @@
 
     @Override
     public Result activityChangeStatus(ActivityForm form) {
+        //鍒ゆ柇娲诲姩
         Activity entity = baseMapper.selectById(form.getId());
+
         entity.setPublish(form.getPublish());
+
         if (!form.getPublish()){
-            //涓嬫灦鍒ゆ柇鏄惁鏈変汉鍛樻姤鍚嶏紝鏈夋姤鍚嶇殑璇濈姝㈡彁閱掓棤娉曚笅鏋�
+            //涓嬫灦鍒ゆ柇鏄惁鏈変汉鍛樻姤鍚嶏紝鏈夋姤鍚嶄笖娲诲姩鏈粨鏉熺殑璇濈姝㈡彁閱掓棤娉曚笅鏋�
             ActivityMembersQuery activityMembersQuery = new ActivityMembersQuery();
             activityMembersQuery.setId(form.getId());
-            if((long)activityMembersPage(activityMembersQuery).get("total") > 0){
-                return Result.error("璇ユ椿鍔ㄦ棤娉曚笅鏋讹紝宸插瓨鍦ㄦ姤鍚嶄汉鍛�");
+            Date currentTime = new Date();
+
+            if (currentTime.before(entity.getEndTime())){
+                if(haveApplicationMembers(form.getId())){
+//                    return Result.error("璇ユ椿鍔ㄦ棤娉曚笅鏋讹紝宸插瓨鍦ㄦ姤鍚嶄汉鍛�");
+                    //todo 鎶ュ悕浜哄憳瀛樺湪 浣嗘槸闇�瑕佷笅鏋剁殑鎯呭喌棰勭暀
+
+                }
+
+
             }
-            return Result.ok();
+
         }else {
             //鍒ゆ柇璇ユ椿鍔ㄦ槸鍚﹀鏍搁�氳繃
-           if(activityAuditRecordService.getActivityActivityIsAudit(form.getId())){
-               baseMapper.updateById(entity);
-               return Result.ok();
-           }else {
+           if(!activityAuditRecordService.getActivityActivityIsAudit(form.getId())){
                return Result.error("娲诲姩鏈�氳繃瀹℃牳");
+
            }
-
-
-
         }
-
-
-
+        baseMapper.updateById(entity);
+        return Result.ok();
     }
 
     @Override

--
Gitblit v1.8.0