From d60e946afb25dc8bd295a14e27a4ccf2df382283 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 20 十二月 2024 18:13:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 1083 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 549 insertions(+), 534 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 06c8936..44a756b 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
@@ -34,10 +34,10 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 import com.ruoyi.account.vo.*;
 import com.ruoyi.common.core.web.controller.BaseController;
@@ -46,7 +46,7 @@
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author luodangjia
@@ -58,602 +58,617 @@
 public class AppUserController extends BaseController {
 
 
+    @Resource
+    private TokenService tokenService;
+    @Resource
+    private AppUserService appUserService;
+    @Resource
+    private StoreClient storeClient;
+    @Resource
+    private UserCouponService userCouponService;
 
-	@Resource
-	private TokenService tokenService;
-	@Resource
-	private AppUserService appUserService;
-	@Resource
-	private StoreClient storeClient;
-	@Resource
-	private UserCouponService userCouponService;
-
-	@Resource
-	private UserSignRecordService userSignRecordService;
-	@Resource
-	private VipSettingClient vipSettingClient;
-	@Resource
-	private UserPointService userPointService;
-	@Resource
-	private VipSettingService vipSettingService;
-	@Resource
-	private AppUserMapper appUserMapper;
+    @Resource
+    private UserSignRecordService userSignRecordService;
+    @Resource
+    private VipSettingClient vipSettingClient;
+    @Resource
+    private UserPointService userPointService;
+    @Resource
+    private VipSettingService vipSettingService;
+    @Resource
+    private AppUserMapper appUserMapper;
 
 
-	@ResponseBody
-	@PostMapping("/mobileLogin")
-	@ApiOperation(value = "手机号登录")
-	public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){
-		return appUserService.mobileLogin(mobileLogin);
-	}
+    @ResponseBody
+    @PostMapping("/mobileLogin")
+    @ApiOperation(value = "手机号登录")
+    public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin) {
+        return appUserService.mobileLogin(mobileLogin);
+    }
 
 
+    @ResponseBody
+    @PostMapping("/appletLogin")
+    @ApiOperation(value = "小程序一键登录")
+    public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin) {
+        return appUserService.appletLogin(appletLogin);
+    }
 
 
+    @ResponseBody
+    @PostMapping("/getAppUserById")
+    public AppUser getAppUserById(@RequestParam("id") Long id) {
+        return appUserService.getById(id);
+    }
+
+    @ResponseBody
+    @PostMapping("/editAppUserById")
+    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);
+
+    }
+
+    @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();
+        return R.ok(count);
+    }
+
+    @ResponseBody
+    @PostMapping("/getVipCount")
+    public R<Long> getVipCount(@RequestParam("userId") Long userId, @RequestParam("vipId") Integer vipId) {
+        Long count = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count();
+        return R.ok(count);
+    }
 
 
-	@ResponseBody
-	@PostMapping("/appletLogin")
-	@ApiOperation(value = "小程序一键登录")
-	public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin){
-		return appUserService.appletLogin(appletLogin);
-	}
-	
-	
-	@ResponseBody
-	@PostMapping("/getAppUserById")
-	public AppUser getAppUserById(@RequestParam("id") Long id){
-		return appUserService.getById(id);
-	}
-
-	@ResponseBody
-	@PostMapping("/editAppUserById")
-	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);
-
-	}
-
-	@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();
-		return R.ok(count);
-	}
-
-	@ResponseBody
-	@PostMapping("/getVipCount")
-	public R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ){
-		 Long count = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count();
-		return R.ok(count);
-	}
+    @ResponseBody
+    @PostMapping("/getSMSCode")
+    @ApiOperation(value = "获取短信验证码")
+    public R getSMSCode(@RequestBody SMSCode smsCode) {
+        return appUserService.getSMSCode(smsCode);
+    }
 
 
-	
-	
-	@ResponseBody
-	@PostMapping("/getSMSCode")
-	@ApiOperation(value = "获取短信验证码")
-	public R getSMSCode(@RequestBody SMSCode smsCode){
-		return appUserService.getSMSCode(smsCode);
-	}
+    @ResponseBody
+    @PostMapping("/registerAccount")
+    @ApiOperation(value = "注册新账号")
+    public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount) {
+        return appUserService.registerAccount(registerAccount);
+    }
 
 
-
-	@ResponseBody
-	@PostMapping("/registerAccount")
-	@ApiOperation(value = "注册新账号")
-	public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount){
-		return appUserService.registerAccount(registerAccount);
-	}
+    @ResponseBody
+    @GetMapping("/getReferrer/{id}")
+    @ApiOperation(value = "获取推荐人信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long")
+    })
+    public R<String> getReferrer(@PathVariable("id") Long id) {
+        AppUser appUser = appUserService.getById(id);
+        String phone = appUser.getPhone();
+        phone = phone.substring(0, 3) + "****" + phone.substring(7);
+        return R.ok(appUser.getName() + "-" + phone);
+    }
 
 
-	@ResponseBody
-	@GetMapping("/getReferrer/{id}")
-	@ApiOperation(value = "获取推荐人信息")
-	@ApiImplicitParams({
-			@ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long")
-	})
-	public R<String> getReferrer(@PathVariable("id") Long id){
-		AppUser appUser = appUserService.getById(id);
-		String phone = appUser.getPhone();
-		phone = phone.substring(0, 3) + "****" + phone.substring(7);
-		return R.ok(appUser.getName() + "-" + phone);
-	}
+    @ResponseBody
+    @GetMapping("/getNearbyReferrer")
+    @ApiOperation(value = "获取附近推荐人列表")
+    public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) {
+        startPage();
+        List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer);
+        return getDataTable(list);
+    }
 
 
+    @ResponseBody
+    @PostMapping("/info")
+    @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"})
+    public R<AppUser> info() {
+        Long userId = tokenService.getLoginUserApplet().getUserid();
+        AppUser user = appUserService.getById(userId);
+        return R.ok(user);
+    }
 
-	@ResponseBody
-	@GetMapping("/getNearbyReferrer")
-	@ApiOperation(value = "获取附近推荐人列表")
-	public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer){
-		startPage();
-		List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer);
-		return getDataTable(list);
-	}
+    @Resource
+    private UserCancellationLogService userCancellationLogService;
+
+    @ResponseBody
+    @GetMapping("/unregis")
+    @ApiOperation(value = "注销", tags = {"小程序-个人中心首页-我的资料"})
+    public R unregis() {
+        Long userId = tokenService.getLoginUserApplet().getUserid();
+        AppUser user = appUserService.getById(userId);
+
+        //添加注销记录
+        UserCancellationLog userCancellationLog = new UserCancellationLog();
+        userCancellationLog.setAppUserId(user.getId());
+        userCancellationLog.setVipId(user.getVipId());
+        userCancellationLogService.save(userCancellationLog);
 
 
-	@ResponseBody
-	@PostMapping("/info")
-	@ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"})
-	public R<AppUser> info(){
-		Long userId = tokenService.getLoginUserApplet().getUserid();
-		AppUser user = appUserService.getById(userId);
-		return R.ok(user);
-	}
-   @Resource
-   private UserCancellationLogService userCancellationLogService;
-
-	@ResponseBody
-	@GetMapping("/unregis")
-	@ApiOperation(value = "注销", tags = {"小程序-个人中心首页-我的资料"})
-	public R unregis(){
-		Long userId = tokenService.getLoginUserApplet().getUserid();
-		AppUser user = appUserService.getById(userId);
-
-		//添加注销记录
-		UserCancellationLog userCancellationLog = new UserCancellationLog();
-		userCancellationLog.setAppUserId(user.getId());
-		userCancellationLog.setVipId(user.getVipId());
-		userCancellationLogService.save(userCancellationLog);
+        return R.ok();
+    }
 
 
-		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("/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();
+    @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("当前手机号未注册");
-		}
+        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();
-	}
-
+        appUserService.updateById(byId);
+        return R.ok();
+    }
 
 
     @GetMapping("/index")
-	@ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"})
-	public R<AppUser> index(){
+    @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"})
+    public R<AppUser> index() {
         System.err.println("=-====");
         Long userId = tokenService.getLoginUserApplet().getUserid();
-		//当前用户信息
-		AppUser user = appUserService.getById(userId);
-		//当前用户的推荐人信息
-		if (user.getInviteUserId()!=null){
-			AppUser inviteUser = appUserService.getById(user.getInviteUserId());
-			user.setInviteUserName(inviteUser.getName());
-		}
-		//当前绑定门店的店铺信息
-		if (user.getShopId()!=null){
-			R<Shop> storeById = storeClient.getStoreById(user.getShopId());
-			if (storeById.getData()!=null){
-				user.setShopName(storeById.getData().getName());
-			}
-		}
-		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();
-		user.setCount1(count1);
-		user.setCount2(count2);
-		user.setCount3(count3);
-		user.setCount4(count4);
-		user.setCount5(count5);
-		user.setCount6(count6);
-		user.setCount7(count7);
+        //当前用户信息
+        AppUser user = appUserService.getById(userId);
+        //当前用户的推荐人信息
+        if (user.getInviteUserId() != null) {
+            AppUser inviteUser = appUserService.getById(user.getInviteUserId());
+            user.setInviteUserName(inviteUser.getName());
+        }
+        //当前绑定门店的店铺信息
+        if (user.getShopId() != null) {
+            R<Shop> storeById = storeClient.getStoreById(user.getShopId());
+            if (storeById.getData() != null) {
+                user.setShopName(storeById.getData().getName());
+            }
+        }
+        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();
+        user.setCount1(count1);
+        user.setCount2(count2);
+        user.setCount3(count3);
+        user.setCount4(count4);
+        user.setCount5(count5);
+        user.setCount6(count6);
+        user.setCount7(count7);
 
         List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()).list();
-        if (!list.isEmpty()){
+        if (!list.isEmpty()) {
             user.setIsSign(1);
-        }else {
+        } else {
             user.setIsSign(0);
         }
-		return R.ok(user);
+        return R.ok(user);
 
 
-	}
+    }
 
-	@GetMapping("/index/change")
-	@ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"})
-	public R<AppUser> indexchange(String avatar,String name){
-		Long userId = tokenService.getLoginUserApplet().getUserid();
-		//当前用户信息
-		AppUser user = appUserService.getById(userId);
-		user.setName(name);
-		user.setAvatar(avatar);
-		appUserService.updateById(user);
-		return R.ok();
-	}
-	/**
-	 * 获取用户的祖籍列表
-	 */
-	@GetMapping("/getUserAncestorList")
-	public R<List<AppUser>> getUserAncestorList(Long id){
-		List<AppUser> list = appUserService.getUserAncestorList(id,null);
-		return R.ok(list);
-	}
+    @GetMapping("/index/change")
+    @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"})
+    public R<AppUser> indexchange(String avatar, String name) {
+        Long userId = tokenService.getLoginUserApplet().getUserid();
+        //当前用户信息
+        AppUser user = appUserService.getById(userId);
+        user.setName(name);
+        user.setAvatar(avatar);
+        appUserService.updateById(user);
+        return R.ok();
+    }
 
-	/**
-	 * 获取用户的直帮上级用户
-	 */
-	@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();
-	}
-	
-	
-	
-	
-	
-	/**
-	 * 根据用户名称模糊搜索用户列表
-	 * @param name
-	 * @return
-	 */
-	@PostMapping("/getAppUserByName")
-	public R<List<AppUser>> getAppUserByName(@RequestParam("name") String name){
-		List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
-				.like(AppUser::getName, name));
-		return R.ok(list);
-	}
-	
-	/**
-	 * 根据用户电话模糊搜索用户列表
-	 * @param phone
-	 * @return
-	 */
-	@PostMapping("/getAppUserByPhone")
-	public R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone){
-		List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
-				.like(AppUser::getPhone, phone));
-		return R.ok(list);
-	}
+    /**
+     * 获取用户的祖籍列表
+     */
+    @GetMapping("/getUserAncestorList")
+    public R<List<AppUser>> getUserAncestorList(Long id) {
+        List<AppUser> list = appUserService.getUserAncestorList(id, null);
+        return R.ok(list);
+    }
 
-	/**
-	 * 获取用户列表
-	 */
-	@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("/shop/getAppuserPage")
-	@ApiOperation(value = "用户列表", tags = {"门店后台"})
-	public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
-											@ApiParam("每一页数据大小") Integer pageSize,
-											AppUser appUser)
-	{
-		Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
-
-		List<Long> userIds = new ArrayList<>();
-		userIds.add(-1L);
-		//获取在该本店下单的用户ids
-		R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId);
-		for (Order datum : listR.getData()) {
-			userIds.add(datum.getAppUserId());
-		}
-		IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser,objectId,userIds);
-		return R.ok(appuserPage);
-	}
+    /**
+     * 获取用户的直帮上级用户
+     */
+    @ResponseBody
+    @PostMapping("/getSuperiorLeader")
+    @ApiOperation(value = "获取用户的直帮上级用户")
+    public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) {
+        AppUser superiorLeader = appUserService.getSuperiorLeader(id);
+        return R.ok(superiorLeader);
+    }
 
 
-
-	@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);
-	}
+    @ResponseBody
+    @PostMapping("/onlineRecord")
+    @ApiOperation(value = "10分钟定时任务调用,记录用户在线时长", tags = {"小程序-个人中心首页"})
+    public R onlineRecord() {
+        appUserService.onlineRecord();
+        return R.ok();
+    }
 
 
-	@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();
-	}
+    /**
+     * 根据用户名称模糊搜索用户列表
+     *
+     * @param name
+     * @return
+     */
+    @PostMapping("/getAppUserByName")
+    public R<List<AppUser>> getAppUserByName(@RequestParam("name") String name) {
+        List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
+                .like(AppUser::getName, name));
+        return R.ok(list);
+    }
 
-	@GetMapping("/select")
-	@ApiOperation(value = "用户列表-查询绑定人", tags = {"管理后台"})
-	public R<AppUser> select(String phone)
-	{
-		AppUser byId = appUserService.lambdaQuery().eq(AppUser::getPhone,phone).one();
-		if (byId==null){
-			return R.fail("搜索失败,手机号错误。");
-		}
-		return R.ok(byId);
-	}
+    /**
+     * 根据用户电话模糊搜索用户列表
+     *
+     * @param phone
+     * @return
+     */
+    @PostMapping("/getAppUserByPhone")
+    public R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone) {
+        List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
+                .like(AppUser::getPhone, phone));
+        return R.ok(list);
+    }
 
-	@GetMapping("/change/bind")
-	@ApiOperation(value = "用户列表-更换绑定人", tags = {"管理后台"})
-	public R<AppUser> select(Long id,Long inviteId)
-	{
-		AppUser byId = appUserService.getById(id);
-		byId.setInviteUserId(inviteId);
-		byId.setTopInviteId(getTop(inviteId));
-		appUserService.updateById(byId);
-		return R.ok();
-	}
-	@GetMapping("/change/shop")
-	@ApiOperation(value = "用户列表-更换门店", tags = {"管理后台"})
-	public R<AppUser> shop(Long id,Long shopId)
-	{
-		AppUser byId = appUserService.getById(id);
-		byId.setShopId(shopId);
-		appUserService.updateById(byId);
-		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("/shop/getAppuserPage")
+    @ApiOperation(value = "用户列表", tags = {"门店后台"})
+    public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
+                                                @ApiParam("每一页数据大小") Integer pageSize,
+                                                AppUser appUser) {
+        Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
+
+        List<Long> userIds = new ArrayList<>();
+        userIds.add(-1L);
+        //获取在该本店下单的用户ids
+        R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId);
+        for (Order datum : listR.getData()) {
+            userIds.add(datum.getAppUserId());
+        }
+        IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageNum, pageSize, appUser, objectId, userIds);
+        return R.ok(appuserPage);
+    }
 
 
-	public  Long getTop(Long inviteId){
-		AppUser byId = appUserService.getById(inviteId);
-		if (byId!=null){
-			return getTop(byId.getInviteUserId());
-		}else {
-			return inviteId;
-		}
-	}
+    @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();
+    }
+
+    @GetMapping("/select")
+    @ApiOperation(value = "用户列表-查询绑定人", tags = {"管理后台"})
+    public R<AppUser> select(String phone) {
+        AppUser byId = appUserService.lambdaQuery().eq(AppUser::getPhone, phone).one();
+        if (byId == null) {
+            return R.fail("搜索失败,手机号错误。");
+        }
+        return R.ok(byId);
+    }
+
+    @GetMapping("/change/bind")
+    @ApiOperation(value = "用户列表-更换绑定人", tags = {"管理后台"})
+    public R<AppUser> select(Long id, Long inviteId) {
+        AppUser byId = appUserService.getById(id);
+        byId.setInviteUserId(inviteId);
+        byId.setTopInviteId(getTop(inviteId));
+        appUserService.updateById(byId);
+        return R.ok();
+    }
+
+    @GetMapping("/change/shop")
+    @ApiOperation(value = "用户列表-更换门店", tags = {"管理后台"})
+    public R<AppUser> shop(Long id, Long shopId) {
+        AppUser byId = appUserService.getById(id);
+        byId.setShopId(shopId);
+        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);
-	}
-
-	@Resource
-	private UserChangeLogService userChangeLogService;
-	@GetMapping("/change/vip")
-	@ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"})
-	public R<Page<AppUser>> changevip(Long id,Integer vipId)
-	{
-		AppUser byId = appUserService.getById(id);
-
-		UserChangeLog userChangeLog = new UserChangeLog();
-		userChangeLog.setCreateTime(LocalDateTime.now());
-		userChangeLog.setAppUserId(byId.getId());
-		userChangeLog.setBeforeVipId(byId.getVipId());
-		userChangeLog.setAfterVipId(vipId);
-		if (userChangeLog.getBeforeVipId()>userChangeLog.getAfterVipId()) {
-			userChangeLog.setChangeType(0);
-		}else {
-			userChangeLog.setChangeType(1);
-		}
-		userChangeLogService.save(userChangeLog);
-		byId.setVipId(vipId);
-		appUserService.updateById(byId);
-		return R.ok();
-
-	}
-
-	@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("/orders")
-	@ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"})
-	public R<List<Order>> orders(Long id)
-	{
-		R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id);
-		return R.ok(listR.getData());
-
-	}
+    public Long getTop(Long inviteId) {
+        AppUser byId = appUserService.getById(inviteId);
+        if (byId != null) {
+            return getTop(byId.getInviteUserId());
+        } else {
+            return inviteId;
+        }
+    }
 
 
+    @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);
+    }
+
+    @Resource
+    private UserChangeLogService userChangeLogService;
+
+    @GetMapping("/change/vip")
+    @ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"})
+    public R<Page<AppUser>> changevip(Long id, Integer vipId) {
+        AppUser byId = appUserService.getById(id);
+
+        UserChangeLog userChangeLog = new UserChangeLog();
+        userChangeLog.setCreateTime(LocalDateTime.now());
+        userChangeLog.setAppUserId(byId.getId());
+        userChangeLog.setBeforeVipId(byId.getVipId());
+        userChangeLog.setAfterVipId(vipId);
+        if (userChangeLog.getBeforeVipId() > userChangeLog.getAfterVipId()) {
+            userChangeLog.setChangeType(0);
+        } else {
+            userChangeLog.setChangeType(1);
+        }
+        userChangeLogService.save(userChangeLog);
+        byId.setVipId(vipId);
+        appUserService.updateById(byId);
+        return R.ok();
+
+    }
+
+    @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("/orders")
+    @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"})
+    public R<List<Order>> orders(Long id) {
+        R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id);
+        return R.ok(listR.getData());
+
+    }
 
 
+    @GetMapping("/listByIds")
+    List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) {
+        List<AppUser> appUsers = appUserService.listByIds(ids);
+        return appUsers;
+    }
 
 
+    @PostMapping("/getAppUserByPhone1")
+    public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone) {
+        AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
+                .eq(AppUser::getPhone, phone));
+        return R.ok(appUser);
+    }
+
+    /**
+     * 用户统计
+     */
+    @GetMapping("/statistics")
+    @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"})
+    public R<UserStatistics> statistics() {
+        UserStatistics userStatistics = appUserMapper.getUserStatistics();
+        return R.ok(userStatistics);
+    }
+
+    /**
+     * 用户统计详情
+     */
+    @GetMapping("/statistics/detail")
+    @ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"})
+    public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) {
+        UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId);
+        return R.ok(userStatisticsDetail);
+    }
 
 
-	@GetMapping("/listByIds")
-	List<AppUser> listByIds(@RequestParam("ids") List<Long> ids){
-		List<AppUser> appUsers = appUserService.listByIds(ids);
-		return appUsers;
-	}
-	
-	
-	
-	@PostMapping("/getAppUserByPhone1")
-	public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone){
-		AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
-				.eq(AppUser::getPhone, phone));
-		return R.ok(appUser);
-	}
+    /**
+     * 分佣统计明细
+     */
+    @GetMapping("/commissionDetail")
+    @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计")
+    public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) {
+        List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList());
 
-	/**
-	 * 用户统计
-	 */
-	@GetMapping("/statistics")
-	@ApiOperation(value = "用户统计",tags = {"管理后台-首页统计-用户统计"})
-	public R<UserStatistics> statistics() {
-		UserStatistics userStatistics = appUserMapper.getUserStatistics();
-		return R.ok(userStatistics);
-	}
+        if (appUserList.isEmpty()) {
+            return R.ok(new CommissionDetail());
+        }
 
-	/**
-	 * 用户统计详情
-	 */
-	@GetMapping("/statistics/detail")
-	@ApiOperation(value = "用户统计详情",tags = {"管理后台-首页统计-用户统计详情"})
-	public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) {
-		UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId);
-		return R.ok(userStatisticsDetail);
-	}
+        BigDecimal totalCommission = BigDecimal.ZERO;
+        BigDecimal totalServiceFee = BigDecimal.ZERO;
+        BigDecimal totalUserCommission = BigDecimal.ZERO;
+        Map<Integer, BigDecimal> vipCommissions = new HashMap<>();
+
+        for (AppUser appUser : appUserList) {
+            totalCommission = totalCommission.add(Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO));
+            totalServiceFee = totalServiceFee.add(Optional.ofNullable(appUser.getShopServiceFee()).orElse(BigDecimal.ZERO));
+            totalUserCommission = totalUserCommission.add(Optional.ofNullable(appUser.getShopCommission()).orElse(BigDecimal.ZERO));
+
+            Integer vipId = appUser.getVipId();
+            if (vipId != null && vipId >= 1 && vipId <= 7) {
+                vipCommissions.merge(vipId, Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO), BigDecimal::add);
+            }
+        }
+
+        CommissionDetail commissionDetail = new CommissionDetail();
+        commissionDetail.setTotalCommission(totalCommission);
+        commissionDetail.setTotalServiceFee(totalServiceFee);
+        commissionDetail.setTotalUserCommission(totalUserCommission);
+
+        commissionDetail.setTotalNormalCommission(vipCommissions.getOrDefault(1, BigDecimal.ZERO));
+        commissionDetail.setTotalGoldCommission(vipCommissions.getOrDefault(2, BigDecimal.ZERO));
+        commissionDetail.setTotalDiamondCommission(vipCommissions.getOrDefault(3, BigDecimal.ZERO));
+        commissionDetail.setTotalAgentCommission(vipCommissions.getOrDefault(4, BigDecimal.ZERO));
+        commissionDetail.setTotalSuperAgentCommission(vipCommissions.getOrDefault(5, BigDecimal.ZERO));
+        commissionDetail.setTotalTopAgentCommission(vipCommissions.getOrDefault(6, BigDecimal.ZERO));
+        commissionDetail.setTotalPartnerCommission(vipCommissions.getOrDefault(7, BigDecimal.ZERO));
+
+        return R.ok(commissionDetail);
+    }
+
 
 }
 

--
Gitblit v1.7.1