From a0333e5234fae97ce785858e2152e390d85ca270 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 20 一月 2025 11:10:01 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java |   52 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
index 2ea18aa..56cd613 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -84,9 +84,8 @@
     private TAppUserService appUserService;
     @Resource
     private TAppUserTagService appUserTagService;
-    @Autowired
+    @Resource
     private OrderClient orderClient;
-
     @Resource
     private TAppUserVipDetailService tAppUserVipDetailService;
     @Resource
@@ -835,6 +834,51 @@
         }
         return R.ok();
     }
+    
+    
+    
+    @PostMapping(value = "/user/give/vip1")
+    public R giveVip1(@RequestBody GiveVipDto  giveVipDto) {
+        String[] split = giveVipDto.getUserIds().split(",");
+        for (String s : split) {
+            TAppUser nowUser = appUserService.getById(s);
+            int plusDay = 0;
+            if (giveVipDto.getType() == 1) {
+                plusDay = 1;
+            } else if (giveVipDto.getType() == 2) {
+                plusDay = 3;
+            } else if (giveVipDto.getType() == 3) {
+                plusDay = 12;
+            }
+            BigDecimal bigDecimal = new BigDecimal("0");
+            TVip info = vipClient.getInfo1(giveVipDto.getVipId()).getData();
+            switch (giveVipDto.getType()){
+                case 1:
+                    bigDecimal = bigDecimal.add(info.getMonthlyCard()==null?new BigDecimal(0):info.getMonthlyCard());
+                    break;
+                case 2:
+                    bigDecimal = bigDecimal.add(info.getSeasonCard()==null?new BigDecimal(0):info.getSeasonCard());
+                    break;
+                case 3:
+                    bigDecimal = bigDecimal.add(info.getAnnualCard()==null?new BigDecimal(0):info.getAnnualCard());
+                    break;
+            }
+            //增加vipDetail
+            giveVipUtil.sendVip(nowUser, giveVipDto.getVipId(),plusDay,giveVipDto.getType());
+            appUserService.updateById(nowUser);
+            // 新增后台赠送记录
+            TGrantVip tGrantVip = new TGrantVip();
+            tGrantVip.setCode(OrderCodeUtil.getOrderCode("ZS"));
+            tGrantVip.setAppUserId(nowUser.getId());
+            tGrantVip.setVipId(giveVipDto.getVipId());
+            tGrantVip.setOrderAmount(bigDecimal);
+            tGrantVip.setCreateTime(LocalDateTime.now());
+            tGrantVip.setAppUserId(nowUser.getId());
+            orderClient.managementGiveVip(tGrantVip);
+        }
+        return R.ok();
+    }
+    
 
     @ApiOperation(value = "已赠送列表", tags = {"小程序-个人中心-邀请好友"})
     @PostMapping(value = "/user/invite/page")
@@ -967,14 +1011,10 @@
     public R sign() {
         LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet();
         Long userId = loginUserApplet.getUserId();
-
         TAppUser byId = appUserService.getById(userId);
-
-
         if (signService.lambdaQuery().eq(TAppUserSign::getSignDay, LocalDate.now()).eq(TAppUserSign::getAppUserId, userId).count()>0){
             return R.fail("今日已签到");
         }
-
         //判断当前生效的vipDetail
         TAppUserVipDetail one = tAppUserVipDetailService.lambdaQuery().le(TAppUserVipDetail::getStartTime, LocalDateTime.now()).ge(TAppUserVipDetail::getEndTime, LocalDateTime.now()).eq(TAppUserVipDetail::getAppUserId, userId).last("limit 1").one();
         boolean doubleVip = false;

--
Gitblit v1.7.1