From 640ff18d2d7f4be02ddb7f8f75e899f05545eb98 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 05 二月 2024 11:56:52 +0800
Subject: [PATCH] 更新bug修改

---
 cloud-server-activity/src/main/java/com/dsh/activity/controller/IntroduceRewardsController.java |   70 +++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/IntroduceRewardsController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/IntroduceRewardsController.java
index 8bb9b84..d7573c9 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/IntroduceRewardsController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/IntroduceRewardsController.java
@@ -40,27 +40,32 @@
 
     /**
      * 获取介绍有礼-参与用户记录表
+     *
      * @return
      */
     @RequestMapping("/base/introduceUser/listAllUser")
-    public List<IntroduceUser> listAllUser(@RequestBody IntroduceUserQuery query){
+    public List<IntroduceUser> listAllUser(@RequestBody IntroduceUserQuery query) {
         return introduceUserService.listAll(query);
     }
+
     /**
      * 通过id获取介绍有礼
+     *
      * @return
      */
     @RequestMapping("/base/introduce/getInfoById")
-    public IntroduceRewards getInfoById(@RequestBody Integer id){
+    public IntroduceRewards getInfoById(@RequestBody Integer id) {
         return idrService.getById(id);
 
     }
+
     /**
      * 获取介绍有礼记录表
+     *
      * @return
      */
     @RequestMapping("/base/introduce/listAll")
-    public List<IntroduceVO> listAll(@RequestBody IntroduceQuery query){
+    public List<IntroduceVO> listAll(@RequestBody IntroduceQuery query) {
         Date date = new Date();
         List<IntroduceVO> introduceVOS = idrService.listAll(query);
         for (IntroduceVO introduceVO : introduceVOS) {
@@ -77,16 +82,36 @@
         }
         return introduceVOS;
     }
+
     /**
      * 增加/修改介绍有礼记录
+     *
      * @return
      */
     @RequestMapping("/base/introduce/addIntroduce")
-    public Object addIntroduce(@RequestBody IntroduceRewards  introduceRewards){
+    public Object addIntroduce(@RequestBody IntroduceRewards introduceRewards) {
 
-        if (introduceRewards.getId()!=null){
+
+        if (introduceRewards.getId() != null) {
+            IntroduceRewards byId = idrService.getById(introduceRewards.getId());
+            // 判断当前活动有没有开始 如果开始了不能编辑赠送课时数 不能编辑活动开始时间
+            Date endTime = byId.getEndTime();
+            Date startTime = byId.getStartTime();
+            Date local = new Date();
+            if (startTime.before(local) && endTime.after(local)) {
+                // 证明当前活动已开始
+                // 判断有没有修改开始时间
+                if (!introduceRewards.getStartTime().equals(byId.getStartTime())) {
+                    // 表示不能修改开始时间
+                    return 5002;
+                }
+                if (!introduceRewards.getGiveClass().equals(byId.getGiveClass())) {
+                    // 表示不能修改赠送课时数
+                    return 5001;
+                }
+            }
             return idrService.updateById(introduceRewards);
-        }else {
+        } else {
             introduceRewards.setInsertTime(new Date());
             return idrService.save(introduceRewards);
         }
@@ -94,44 +119,43 @@
 
     /**
      * 上/下架介绍有礼 type = 1上架 type=2下架
+     *
      * @return
      */
     @RequestMapping("/base/introduce/changeState")
-    public Object changeState(@RequestBody IntroduceChangeStateDTO dto){
+    public Object changeState(@RequestBody IntroduceChangeStateDTO dto) {
         return idrService.changeState(dto);
     }
 
     @PostMapping("/base/introduce/useOfRewards")
-    public List<PurchaseRecordVo> queryAppUsersofIntroduce(@RequestBody IntrduceOfUserRequest request){
+    public List<PurchaseRecordVo> queryAppUsersofIntroduce(@RequestBody IntrduceOfUserRequest request) {
         List<PurchaseRecordVo> recordVos = new ArrayList<>();
         List<IntroduceRewards> list = idrService.list(new QueryWrapper<IntroduceRewards>()
-                .ge("startTime",request.getStartTime())
-                .lt("endTime",request.getEndTime()));
-        if (request.getUserIds().size() > 0 && list.size() > 0){
+                .ge("startTime", request.getStartTime())
+                .lt("endTime", request.getEndTime()));
+        if (request.getUserIds().size() > 0 && list.size() > 0) {
             IntroduceRewards introduceRewards = list.get(0);
-            request.getUserIds().forEach( userId -> {
+            request.getUserIds().forEach(userId -> {
                 PurchaseRecordVo recordVo = new PurchaseRecordVo();
-                recordVo.setPurchaseAmount("+"+introduceRewards.getGiveClass());
+                recordVo.setPurchaseAmount("+" + introduceRewards.getGiveClass());
                 recordVo.setPurchaseType("介绍有礼");
                 recordVos.add(recordVo);
-            } );
+            });
         }
         return recordVos;
     }
 
     @PostMapping("/base/introduce/getGiftList")
     @ResponseBody
-    public IntroduceRewards getGiftList(@RequestBody String cityCode){
+    public List<IntroduceRewards> getGiftList(@RequestBody String cityCode) {
         List<IntroduceRewards> list = idrService.list(new LambdaQueryWrapper<IntroduceRewards>()
-                .eq(IntroduceRewards::getCityCode,cityCode)
-                .le(IntroduceRewards::getStartTime,new Date())
-                .ge(IntroduceRewards::getEndTime,new Date())
+                .eq(IntroduceRewards::getCityCode, cityCode)
+                .le(IntroduceRewards::getStartTime, new Date())
+                .ge(IntroduceRewards::getEndTime, new Date())
+                .eq(IntroduceRewards::getState, 1)
                 .orderByDesc(IntroduceRewards::getInsertTime)
-                .last("LIMIT 1"));
-        if (list.size()>0){
-            return list.get(0);
-        }
-        return null;
+        );
+        return list;
     }
 
 }

--
Gitblit v1.7.1