From 91d448f7f2e396f76b2fec0df8881b574d40baa1 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 17 十二月 2024 09:08:07 +0800
Subject: [PATCH] 合并代码

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java |   71 ++++++++++++++++++++++++++++++++++-
 1 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
index 43cc2f6..5b5b1f6 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
@@ -1,9 +1,18 @@
 package com.ruoyi.other.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.other.api.domain.RedPackegeSet;
+import com.ruoyi.other.service.RedPackegeSetService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * <p>
@@ -16,6 +25,64 @@
 @RestController
 @RequestMapping("/red-packege-set")
 public class RedPackegeSetController {
+    @Resource
+    private RedPackegeSetService redPackegeSetService;
+    //获取当前生效的红包设置
+    @ResponseBody
+    @GetMapping("/get")
+    public R<BigDecimal> get(){
+        LocalDateTime now = LocalDateTime.now();
+        RedPackegeSet one = redPackegeSetService.lambdaQuery().le(RedPackegeSet::getStartTime, now).ge(RedPackegeSet::getEndTime, now).one();
+        if (one!=null){
+            return R.ok(one.getPackegeAmount());
+        }else {
+            return R.ok(BigDecimal.ZERO);
+
+        }
+    }
+
+
+    /**
+     * 获取红包配置
+     */
+    @ApiOperation(value = "获取红包配置", tags = {"管理后台-活动管理-签到红包"})
+    @GetMapping("/getRedPackegeSet")
+    public R<RedPackegeSet> getRedPackegeSet(){
+        return R.ok(redPackegeSetService.getOne(null));
+    }
+
+
+    /**
+     * 添加红包配置
+     */
+    @ApiOperation(value = "添加红包配置", tags = {"管理后台-活动管理-签到红包"})
+    @PostMapping("/addRedPackegeSet")
+    @Transactional(rollbackFor = Exception.class)
+    public R<Void> addRedPackegeSet(@RequestBody List<RedPackegeSet> redPackegeSets){
+        for (RedPackegeSet redPackegeSet : redPackegeSets) {
+            RedPackegeSet one = redPackegeSetService.getOne(null);
+            if (one==null){
+                redPackegeSet.setId(1);
+                redPackegeSetService.save(redPackegeSet);
+            }else {
+                if (one.getId()==null){
+                    return R.fail("参数错误");
+                }
+                redPackegeSetService.updateById(redPackegeSet);
+            }
+        }
+        return R.ok();
+    }
+
+    /**
+     * 删除红包配置
+     */
+    @ApiOperation(value = "删除红包配置", tags = {"管理后台-活动管理-签到红包"})
+    @GetMapping("/delRedPackegeSet")
+    public R<Void> delRedPackegeSet(){
+        redPackegeSetService.removeById(1);
+        return R.ok();
+    }
 
 }
 

--
Gitblit v1.7.1