From d7b3c61e01aadf99ce6a1d8ebf18c4e6dd81cc2b Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 12 十二月 2024 18:05:34 +0800
Subject: [PATCH] 12.12
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java | 42 ++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java | 105 +++++++++++++++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java | 25 ++++
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java | 10 ++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java | 2
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipGood.java | 4
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java | 6 +
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java | 4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java | 25 +++++
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 13 ++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/VipSetDto.java | 23 ++++
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java | 3
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java | 2
13 files changed, 258 insertions(+), 6 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
index 5c0a263..38531a4 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
@@ -59,6 +59,12 @@
}
@Override
+ public R<List<AppUser>> getTopUsers() {
+ log.error("获取用户列表失败:{}", cause.getMessage());
+ throw new RuntimeException("获取用户列表失败");
+ }
+
+ @Override
public R<Long> getVipCount(Long userId, Integer vipId) {
log.error("获取直推会员数失败:{}", cause.getMessage());
throw new RuntimeException("获取直推会员数失败");
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
index dea7127..43819bb 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
@@ -49,7 +49,8 @@
@GetMapping("/appletLogin/getSuperiorLeader")
R<AppUser> getSuperiorLeader(@RequestParam("id") Long id);
-
+ @GetMapping("/app-user/getTopUsers")
+ R<List<AppUser>> getTopUsers();
@PostMapping("/app-user/getVipCount")
R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId );
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java
index 2fb7181..8d8d2bc 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java
@@ -77,6 +77,10 @@
@ApiModelProperty(value = "对象id")
@TableField("object_id")
private String objectId;
+ @TableField(exist = false)
+ private String authName;
+ @TableField(exist = false)
+ private String authPhone;
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipGood.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipGood.java
index 1f6ec5a..07ba62c 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipGood.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipGood.java
@@ -34,8 +34,8 @@
private Integer vipId;
@ApiModelProperty(value = "指定购买后升级商品的json快照")
- @TableField("good_json")
- private String goodJson;
+ @TableField("good_id")
+ private Integer goodId;
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
index 688cbd4..799df1d 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/VipSetting.java
@@ -10,6 +10,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
+import java.util.List;
/**
* <p>
@@ -135,5 +136,14 @@
@TableField("vip_level_up_proxy_role")
private Integer vipLevelUpProxyRole;
+ @ApiModelProperty(value = "指定会员升级商品")
+ @TableField("good_ids")
+ private String goodIds;
+
+
+ @ApiModelProperty("指定商品列表")
+ @TableField(exist = false)
+ private List<Goods> goodsList;
+
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
index d344763..8039b75 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -22,6 +22,7 @@
import javax.annotation.Resource;
import java.time.LocalDate;
+import java.util.ArrayList;
import java.util.List;
import com.ruoyi.account.vo.*;
@@ -92,6 +93,18 @@
}
@ResponseBody
+ @PostMapping("/getTopUsers")
+ public R<List<AppUser>> getTopUsers(@RequestBody AppUser appUser) {
+ List<Integer> vipIds = new ArrayList<>();
+ vipIds.add(5);
+ vipIds.add(6);
+ vipIds.add(7);
+ List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list();
+ return R.ok(list);
+
+ }
+
+ @ResponseBody
@PostMapping("/getCouponCount")
public R<Long> getCouponCount(@RequestParam("userId")Long userId, @RequestParam("couponId") Integer couponId ){
Long count = userCouponService.lambdaQuery().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getCouponId, couponId).count();
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
index 8b1b86b..5df2096 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -102,7 +102,7 @@
@ResponseBody
@PostMapping("/getGoodsByIds")
public R<List<Goods>> getGoodsByIds(@RequestParam("ids") String [] ids){
- List<Goods> goods = goodsService.lambdaQuery().in(Goods::getId, ids).eq(Goods::getStatus, 0).list();
+ List<Goods> goods = goodsService.lambdaQuery().in(Goods::getId, ids).list();
return R.ok(goods);
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
index 067517f..887c1c1 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
@@ -3,11 +3,15 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.other.api.domain.Share;
+import com.ruoyi.other.api.domain.Shop;
+import com.ruoyi.other.api.feignClient.ShopClient;
import com.ruoyi.other.enums.ShareAddType;
import com.ruoyi.other.enums.ShareAuditStatus;
import com.ruoyi.other.service.ShareService;
@@ -37,6 +41,10 @@
private ShareService shareService;
@Resource
private TokenService tokenService;
+ @Resource
+ private AppUserClient appUserClient;
+ @Resource
+ private ShopClient shopClient;
/**
* 分享列表
@@ -169,8 +177,21 @@
@ApiOperation(value = "列表", tags = {"后台-分享管理-审核"})
@GetMapping("/manage/auth/list")
- public R<Page<Share>> authmanagelist(String name,Integer addType,@RequestParam Integer PageNum,Integer pageSize){
- Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus,1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageSize, pageSize));
+ public R<Page<Share>> authmanagelist(String name,Integer addType,@RequestParam Integer pageNum,Integer pageSize){
+ Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus,1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize));
+ for (Share record : page.getRecords()) {
+ if (record.getAddType()==2) {
+ AppUser appUserById = appUserClient.getAppUserById(Long.valueOf(record.getObjectId()));
+ record.setAuthName(appUserById.getName());
+ record.setAuthPhone(appUserById.getPhone());
+ }
+ if (record.getAddType()==3) {
+ R<Shop> shopById = shopClient.getShopById(Integer.valueOf(record.getObjectId()));
+ if (shopById.getData()!=null){
+ record.setAuthName(shopById.getData().getName());
+ }
+ }
+ }
return R.ok(page);
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
index 733f887..b7762db 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
@@ -4,7 +4,13 @@
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.other.api.domain.BaseSetting;
+import com.ruoyi.other.api.domain.Goods;
+import com.ruoyi.other.api.domain.VipGood;
import com.ruoyi.other.api.domain.VipSetting;
+import com.ruoyi.other.api.feignClient.GoodsClient;
+import com.ruoyi.other.dto.VipSetDto;
+import com.ruoyi.other.service.BaseSettingService;
import com.ruoyi.other.service.VipGoodService;
import com.ruoyi.other.service.VipSettingService;
import io.swagger.annotations.ApiOperation;
@@ -13,6 +19,8 @@
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -35,6 +43,13 @@
private TokenService tokenService;
@Resource
private VipGoodService vipGoodService;
+ @Resource
+ private BaseSettingService baseSettingService;
+ @Resource
+ private GoodsClient goodsClient;
+
+ @Resource
+ private VipGoodService getVipGoodService;
@GetMapping("/info")
@ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页", "小程序-会员中心"})
@@ -95,6 +110,96 @@
public R<VipSetting> getVipSettingById(@ApiParam(value = "会员id") @RequestParam("id") Integer id) {
return R.ok(vipSettingService.getById(id));
}
+
+ @GetMapping("/manage/info")
+ @ApiOperation(value = "查询", tags = {"后台-会员设置"})
+ public R<VipSetDto> managesetinfo() {
+ VipSetDto vipSetDto = new VipSetDto();
+ VipSetting byId1 = vipSettingService.getById(1);
+ vipSetDto.setLevel1Name(byId1.getVipName());
+ VipSetting byId2 = vipSettingService.getById(2);
+ vipSetDto.setLevel2Name(byId2.getVipName());
+ VipSetting byId3 = vipSettingService.getById(3);
+ vipSetDto.setLevel3Name(byId3.getVipName());
+ VipSetting byId4 = vipSettingService.getById(4);
+ vipSetDto.setLevel4Name(byId4.getVipName());
+ VipSetting byId5 = vipSettingService.getById(5);
+ vipSetDto.setLevel5Name(byId5.getVipName());
+ VipSetting byId6 = vipSettingService.getById(6);
+ vipSetDto.setLevel6Name(byId6.getVipName());
+ VipSetting byId7 = vipSettingService.getById(7);
+ vipSetDto.setLevel7Name(byId7.getVipName());
+
+ BaseSetting base1 = baseSettingService.getById(1);
+ vipSetDto.setPartPoint(new BigDecimal(base1.getContent()));
+ BaseSetting base2 = baseSettingService.getById(2);
+ vipSetDto.setBottomPartPoint(new BigDecimal(base2.getContent()));
+ return R.ok(vipSetDto);
+ }
+
+
+ @PostMapping("/manage/set")
+ @ApiOperation(value = "设置", tags = {"后台-会员设置"})
+ public R<List<VipSetting>> manageset(@RequestBody VipSetDto vipSetDto) {
+ List<VipSetting> vipSettingList = new ArrayList<>();
+ VipSetting byId1 = vipSettingService.getById(1);
+ byId1.setVipName(vipSetDto.getLevel1Name());
+ vipSettingList.add(byId1);
+ VipSetting byId2 = vipSettingService.getById(2);
+ byId2.setVipName(vipSetDto.getLevel2Name());
+ vipSettingList.add(byId2);
+ VipSetting byId3 = vipSettingService.getById(3);
+ byId3.setVipName(vipSetDto.getLevel3Name());
+ vipSettingList.add(byId3);
+ VipSetting byId4 = vipSettingService.getById(4);
+ byId4.setVipName(vipSetDto.getLevel4Name());
+ vipSettingList.add(byId4);
+ VipSetting byId5 = vipSettingService.getById(5);
+ byId5.setVipName(vipSetDto.getLevel5Name());
+ vipSettingList.add(byId5);
+ VipSetting byId6 = vipSettingService.getById(6);
+ byId6.setVipName(vipSetDto.getLevel6Name());
+ vipSettingList.add(byId6);
+ VipSetting byId7 = vipSettingService.getById(7);
+ byId7.setVipName(vipSetDto.getLevel7Name());
+ vipSettingList.add(byId7);
+ vipSettingService.updateBatchById(vipSettingList);
+
+ BaseSetting base1 = baseSettingService.getById(1);
+ base1.setContent(String.valueOf(vipSetDto.getPartPoint()));
+ baseSettingService.updateById(base1);
+ BaseSetting base2 = baseSettingService.getById(2);
+ base2.setContent(String.valueOf(vipSetDto.getBottomPartPoint()));
+ baseSettingService.updateById(base2);
+ BaseSetting base3 = baseSettingService.getById(3);
+ base3.setContent(vipSetDto.getVipInfo());
+ baseSettingService.updateById(base3);
+
+ return R.ok();
+ }
+ @PostMapping("/manage/level/set")
+ @ApiOperation(value = "设置", tags = {"后台-会员等级设置"})
+ public R<Void> managelevelset(@RequestBody List<VipSetting> vipSettingList) {
+ vipSettingService.updateBatchById(vipSettingList);
+ return R.ok();
+ }
+
+ @GetMapping("/manage/level/info")
+ @ApiOperation(value = "查询", tags = {"后台-会员等级设置"})
+ public R<List<VipSetting>> managelevelinfo() {
+ List<VipSetting> list = vipSettingService.list();
+ for (VipSetting vipSetting : list) {
+ if (vipSetting.getGoodIds()!=null){
+ String[] split = vipSetting.getGoodIds().split(",");
+ R<List<Goods>> goodsById = goodsClient.getGoodsById(split);
+ if (goodsById.getData()!=null){
+ vipSetting.setGoodsList(goodsById.getData());
+ }
+ }
+ }
+ return R.ok(list);
+ }
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/VipSetDto.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/VipSetDto.java
new file mode 100644
index 0000000..169182f
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/VipSetDto.java
@@ -0,0 +1,23 @@
+package com.ruoyi.other.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class VipSetDto {
+ private String level1Name;
+ private String level2Name;
+ private String level3Name;
+ private String level4Name;
+ private String level5Name;
+ private String level6Name;
+ private String level7Name;
+ @ApiModelProperty("合伙人积分设置一")
+ private BigDecimal partPoint;
+ @ApiModelProperty("合伙人积分设置二")
+ private BigDecimal bottomPartPoint;
+ @ApiModelProperty("会员说明设置")
+ private String vipInfo;
+}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
index e576300..2302088 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
@@ -14,4 +14,6 @@
public interface VipSettingService extends IService<VipSetting> {
VipSetting getVipSettingByUserId(Long userId);
+
+ void downUsers();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
index be94a0c..dd8c839 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.other.mapper.VipSettingMapper;
import com.ruoyi.other.api.domain.VipSetting;
@@ -10,6 +11,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.util.List;
/**
* <p>
@@ -32,4 +34,27 @@
}
return this.getById(appUser.getVipId());
}
+
+ @Override
+ public void downUsers() {
+ //查出可能需要降级的人员
+ R<List<AppUser>> topUsers = appUserClient.getTopUsers();
+ //循环判断是否要展示
+ if (topUsers.getData()!=null && topUsers.getData().size()>0){
+ for (AppUser appUser : topUsers.getData()){
+ if (appUser.getVipId()==5){
+ VipSetting vipSetting = this.baseMapper.selectById(5);
+ if (vipSetting.getKeepBuyPoint()!=null){
+ //如果消费不为空,查找对应天数的消费积分
+
+ //如果消费积分小于保级积分,设置用户降级标志并将降级信息
+ }
+
+ }
+ }
+ }
+
+ //然后设置降级提示
+
+ }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java
new file mode 100644
index 0000000..6a67a19
--- /dev/null
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java
@@ -0,0 +1,42 @@
+package com.ruoyi.other.task;
+
+
+import com.ruoyi.other.service.VipSettingService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 定时任务工具类
+ */
+@Component
+public class TaskUtil {
+
+ @Resource
+ private VipSettingService vipSettingService;
+
+
+ /**
+ * 每天的凌晨执行的任务
+ */
+ @Scheduled(cron = "0 0 0 * * *")
+ public void taskDay(){
+ try {
+
+
+ vipSettingService.downUsers();
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+
+
+}
--
Gitblit v1.7.1