From a8d2cb07f6440dc54dc4005b0b06d5a47cb1517d Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期一, 16 十二月 2024 13:34:03 +0800
Subject: [PATCH] 12.16

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java |  273 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 259 insertions(+), 14 deletions(-)

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 2a58d42..f06387c 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
@@ -1,31 +1,36 @@
 package com.ruoyi.account.controller;
 
 
-import com.ruoyi.account.api.model.AppUser;
-import com.ruoyi.account.api.model.UserCancellationLog;
-import com.ruoyi.account.api.model.UserCoupon;
-import com.ruoyi.account.service.AppUserService;
-import com.ruoyi.account.service.UserCancellationLogService;
-import com.ruoyi.account.service.UserCouponService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.account.api.model.*;
+import com.ruoyi.account.dto.DangerInfoDto;
+import com.ruoyi.account.service.*;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.bean.BeanUtils;
+import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
+import com.ruoyi.order.model.Order;
 import com.ruoyi.other.api.domain.Shop;
+import com.ruoyi.other.api.domain.VipSetting;
+import com.ruoyi.other.api.feignClient.ShopClient;
 import com.ruoyi.other.api.feignClient.StoreClient;
+import com.ruoyi.other.api.feignClient.VipSettingClient;
+import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.util.ArrayList;
 import java.util.List;
 
 import com.ruoyi.account.vo.*;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.page.TableDataInfo;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import org.springframework.web.bind.annotation.*;
 
 /**
@@ -52,6 +57,15 @@
 	@Resource
 	private UserCouponService userCouponService;
 
+	@Resource
+	private UserSignRecordService userSignRecordService;
+	@Resource
+	private VipSettingClient vipSettingClient;
+	@Resource
+	private UserPointService userPointService;
+	@Resource
+	private VipSettingService vipSettingService;
+
 
 	@ResponseBody
 	@PostMapping("/mobileLogin")
@@ -59,10 +73,6 @@
 	public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){
 		return appUserService.mobileLogin(mobileLogin);
 	}
-
-
-
-
 
 
 	@ResponseBody
@@ -84,6 +94,18 @@
 	public R<Void> editAppUserById(@RequestBody AppUser appUser) {
 		appUserService.updateById(appUser);
 		return R.ok();
+
+	}
+
+	@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);
 
 	}
 
@@ -152,6 +174,9 @@
 	public R<AppUser> info(){
 		Long userId = tokenService.getLoginUserApplet().getUserid();
 		AppUser user = appUserService.getById(userId);
+
+
+
 		return R.ok(user);
 	}
    @Resource
@@ -174,6 +199,67 @@
 		return R.ok();
 	}
 
+
+
+	@ResponseBody
+	@GetMapping("/recommend")
+	@ApiOperation(value = "推广中心", tags = {"小程序-推广中心"})
+	public R<AppUser> recommend(){
+		Long userId = tokenService.getLoginUserApplet().getUserid();
+		//获取绑定门店
+		AppUser user = appUserService.getById(userId);
+		if (user.getShopId()!=null){
+			R<Shop> storeById = storeClient.getStoreById(user.getShopId());
+			if (storeById.getData()!=null){
+				user.setShopName(storeById.getData().getName());
+				user.setShopCover(storeById.getData().getHomePicture());
+				user.setShopAddress(storeById.getData().getAddress());
+			}
+		}
+
+		//获取绑定上级
+		if (user.getInviteUserId()!=null) {
+			AppUser byId = appUserService.getById(user.getInviteUserId());
+			user.setTopUser(byId);
+		}
+		//获取绑定下级列表
+		List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, user.getInviteUserId()).list();
+		for (AppUser appUser : list) {
+			Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).count();
+			Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count();
+			Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count();
+			Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count();
+			Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count();
+			Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count();
+			Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count();
+			appUser.setCount1(count1);
+			appUser.setCount2(count2);
+			appUser.setCount3(count3);
+			appUser.setCount4(count4);
+			appUser.setCount5(count5);
+			appUser.setCount6(count6);
+			appUser.setCount7(count7);
+		}
+		user.setBottomUsers(list);
+
+		return R.ok(user);
+	}
+
+	@ResponseBody
+	@GetMapping("/change")
+	@ApiOperation(value = "推广中心", tags = {"小程序-推广中心"})
+	public R<AppUser> change(@ApiParam("换绑用户手机号") String phone){
+		Long userId1 = tokenService.getLoginUserApplet().getUserid();
+        AppUser byId = appUserService.getById(userId1);
+        //获取绑定门店
+		AppUser user = appUserService.lambdaQuery().eq(AppUser::getPhone,phone).one();
+		if (user==null){
+			return R.fail("当前手机号未注册");
+		}
+        byId.setInviteUserId(user.getId());
+		appUserService.updateById(byId);
+		return R.ok();
+	}
 
 
 
@@ -210,6 +296,13 @@
 		user.setCount5(count5);
 		user.setCount6(count6);
 		user.setCount7(count7);
+
+        List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()).list();
+        if (!list.isEmpty()){
+            user.setIsSign(1);
+        }else {
+            user.setIsSign(0);
+        }
 		return R.ok(user);
 
 
@@ -235,6 +328,158 @@
 		return R.ok(list);
 	}
 
+	/**
+	 * 获取用户的直帮上级用户
+	 */
+	@ResponseBody
+	@PostMapping("/getSuperiorLeader")
+	@ApiOperation(value = "获取用户的直帮上级用户")
+	public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) {
+		AppUser superiorLeader = appUserService.getSuperiorLeader(id);
+		return R.ok(superiorLeader);
+	}
+	
+	
+	
+	@ResponseBody
+	@PostMapping("/onlineRecord")
+	@ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"})
+	public R onlineRecord(){
+		appUserService.onlineRecord();
+		return R.ok();
+	}
+
+	/**
+	 * 获取用户列表
+	 */
+	@GetMapping("/getAppuserPage")
+	@ApiOperation(value = "用户列表", tags = {"管理后台"})
+	public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
+								  @ApiParam("每一页数据大小") Integer pageSize,
+								  AppUser appUser)
+	{
+		IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser);
+		return R.ok(appuserPage);
+	}
+
+	@GetMapping("/danger/info")
+	@ApiOperation(value = "用户列表-保级条件详情", tags = {"管理后台"})
+	public R<DangerInfoDto> dangerinfo(Long id)
+	{
+		AppUser byId = appUserService.getById(id);
+		LocalDate now = LocalDate.now();
+		R<VipSetting> vipSetting = vipSettingClient.getVipSetting(byId.getVipId());
+		VipSetting data = vipSetting.getData();
+		DangerInfoDto dangerInfoDto	= new DangerInfoDto();
+		BeanUtils.copyProperties(data,dangerInfoDto);
+		List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,1).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list();
+		List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getType,2).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list();
+		List<UserPoint> list3 = userPointService.lambdaQuery().eq(UserPoint::getType,5).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list();
+		Integer userKeepBuyPoint = 0;
+		for (UserPoint userPoint : list1) {
+			userKeepBuyPoint = userPoint.getVariablePoint()+userKeepBuyPoint;
+		}
+		Integer userKeepSharePoint = 0;
+		for (UserPoint userPoint : list2) {
+			userKeepSharePoint = userPoint.getVariablePoint()+userKeepSharePoint;
+		}
+		Integer userKeepShopPoint = 0;
+		for (UserPoint userPoint : list3) {
+			userKeepShopPoint = userPoint.getVariablePoint()+userKeepShopPoint;
+		}
+		dangerInfoDto.setUserKeepBuyPoint(userKeepBuyPoint);
+		dangerInfoDto.setUserKeepSharePoint(userKeepSharePoint);
+		dangerInfoDto.setUserKeepShopPoint(userKeepShopPoint);
+		return R.ok(dangerInfoDto);
+	}
+
+
+	@GetMapping("/danger/down")
+	@ApiOperation(value = "用户列表-保级条件降级", tags = {"管理后台"})
+	public R down(Long id)
+	{
+		AppUser byId = appUserService.getById(id);
+		byId.setVipId(byId.getVipId()-1);
+		appUserService.updateById(byId);
+		//执行降级标记代码
+		new Thread(new Runnable() {
+			@Override
+			public void run() {
+				{
+					vipSettingService.downUsers();
+				}
+			}
+		}
+		).start();
+		return R.ok();
+	}
+	@GetMapping("/frozen")
+	@ApiOperation(value = "用户列表-冻结解冻", tags = {"管理后台"})
+	public R frozen(Long id,@ApiParam("1=正常,2=冻结")Integer status)
+	{
+		AppUser byId = appUserService.getById(id);
+		byId.setStatus(status);
+		appUserService.updateById(byId);
+		return R.ok();
+	}
+	@Resource
+	private ShopClient shopClient;
+	@Resource
+	private RemoteOrderGoodsClient remoteOrderGoodsClient;
+
+	@GetMapping("/detail")
+	@ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
+	public R<AppUser> detail(Long id)
+	{
+		AppUser byId = appUserService.getById(id);
+		if (byId.getShopId()!=null) {
+			R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId())));
+			if (shopById.getData()!=null) {
+				byId.setShopName(shopById.getData().getName());
+			}
+		}
+		R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id);
+		if (shopByUserId.getData()!=null) {
+			List<String> shopName = new ArrayList<>();
+			for (Shop datum : shopByUserId.getData()) {
+				shopName.add(datum.getName());
+			}
+			byId.setShopNames(shopName);
+		}
+		//推广人
+		if (byId.getInviteUserId()!=null) {
+			AppUser byId1 = appUserService.getById(byId.getInviteUserId());
+			byId1.setInviteUserName(byId1.getInviteUserName());
+		}
+		//最后下单时间
+		R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id);
+		if (lastOrder.getData()!=null){
+			byId.setLastOrderTime(lastOrder.getData().getCreateTime());
+		}
+		return R.ok(byId);
+	}
+	@GetMapping("/bottom")
+	@ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"})
+	public R<Page<AppUser>> bottom(Long id,Integer pageNum,Integer pageSize)
+	{
+		//绑定下级
+		Page<AppUser> page = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).page(Page.of(pageNum, pageSize));
+		return R.ok(page);
+
+	}
+
+
+
+
+
+
+	@GetMapping("/getAppUserByPhone")
+	public R<AppUser> getAppUserByPhone(String phone){
+		AppUser appUser = appUserService.lambdaQuery().eq(AppUser::getPhone, phone).one();
+		return R.ok(appUser);
+	}
+
+
 
 
 }

--
Gitblit v1.7.1