| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | |
| | | import com.ruoyi.account.mapper.AppUserMapper; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.ObsUploadUtil; |
| | | import com.ruoyi.account.util.weChat.EnvVersion; |
| | | import com.ruoyi.account.util.weChat.WeChatUtil; |
| | | import com.ruoyi.account.vo.*; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.ShopBalanceStatementClient; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.StoreClient; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | @Api(tags = {"登录注册-小程序"}) |
| | | @RestController |
| | | @RequestMapping("/app-user") |
| | | @Slf4j |
| | | public class AppUserController extends BaseController { |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | @Resource |
| | | private UserCouponService userCouponService; |
| | | |
| | |
| | | private VipSettingClient vipSettingClient; |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private AppUserMapper appUserMapper; |
| | | @Resource |
| | |
| | | private UserCancellationLogService userCancellationLogService; |
| | | @Resource |
| | | private BalanceChangeRecordService balanceChangeRecordService; |
| | | @Resource |
| | | private UserChangeLogService userChangeLogService; |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @Resource |
| | | private IAppUserGiveawayTemporaryService appUserGiveawayTemporaryService; |
| | | |
| | | @Value("${file.upload.location}") |
| | | private String filePath; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | |
| | | @PostMapping("/getAppUserById") |
| | | public AppUser getAppUserById(@RequestParam("id") Long id) { |
| | | System.out.println("根据id获取用户:"+id); |
| | | return appUserService.getById(id); |
| | | } |
| | | |
| | | @PostMapping("/getBaseUserById") |
| | | public R<Map<String, Object>> getBaseUserById(@RequestParam("id") Long id) { |
| | | AppUser appUser = appUserService.getById(id); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", appUser.getId()); |
| | | map.put("name", appUser.getName()); |
| | | map.put("phone", appUser.getPhone()); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/editAppUserById") |
| | |
| | | @PostMapping("/getCouponCount") |
| | | public R<Long> getCouponCount(@RequestParam("userId") Long userId, @RequestParam("couponId") Integer couponId) { |
| | | LambdaQueryChainWrapper<UserCoupon> chainWrapper = userCouponService.lambdaQuery().eq(UserCoupon::getCouponId, couponId); |
| | | if(null != userId && -1 == userId){ |
| | | if(null != userId && -1 != userId){ |
| | | chainWrapper.eq(UserCoupon::getAppUserId, userId); |
| | | } |
| | | Long count = chainWrapper.count(); |
| | |
| | | public R<AppUser> info() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser user = appUserService.getById(userId); |
| | | if(StringUtils.isEmpty(user.getQrCode())){ |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName); |
| | | user.setQrCode(getwxacodeunlimit); |
| | | appUserService.updateById(user); |
| | | } |
| | | return R.ok(user); |
| | | } |
| | | |
| | |
| | | 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()); |
| | | |
| | | |
| | | //当前用户的推荐人信息(指导老师) |
| | | List<AppUser> allSuperiors = getAllSuperiors(userId); |
| | | //当前绑定门店的店铺信息 |
| | | for (AppUser allSuperior : allSuperiors) { |
| | | List<Shop> shopList = shopClient.getShopByUserId(allSuperior.getId()).getData(); |
| | | if (!CollectionUtils.isEmpty(shopList)){ |
| | | user.setShopName(shopList.get(0).getName()); |
| | | user.setShopCover(shopList.get(0).getHomePicture()); |
| | | user.setShopAddress(shopList.get(0).getAddress()); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (user.getShopName() == null){ |
| | | user.setShopName(""); |
| | | } |
| | | if (user.getShopCover() == null){ |
| | | user.setShopCover(""); |
| | | } |
| | | if (user.getShopAddress() == null){ |
| | | user.setShopAddress(""); |
| | | } |
| | | |
| | | //指导老师 |
| | | allSuperiors.stream() |
| | | .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3) |
| | | .findFirst() |
| | | .ifPresent(superiors -> { |
| | | user.setTeacher(superiors.getName()); |
| | | user.setTeacherPhone(superiors.getPhone()); |
| | | }); |
| | | |
| | | if (user.getTeacher() == null){ |
| | | user.setTeacher(""); |
| | | } |
| | | if (user.getTeacherPhone() == null){ |
| | | user.setTeacherPhone(""); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //获取绑定上级 |
| | | if (user.getInviteUserId() != null) { |
| | | AppUser byId = appUserService.getById(user.getInviteUserId()); |
| | | user.setTopUser(byId); |
| | | }else { |
| | | AppUser topUser = new AppUser(); |
| | | user.setTopUser(topUser); |
| | | } |
| | | //获取绑定下级列表 |
| | | List<AppUser> list = appUserService.lambdaQuery() |
| | |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .list(); |
| | | |
| | | Long vip1Count1 =0L; |
| | | Long vip1Count2 =0L; |
| | | Long vip1Count3 =0L; |
| | | Long vip1Count4 =0L; |
| | | Long vip1Count5 =0L; |
| | | Long vip1Count6 =0L; |
| | | Long vip1Count7 =0L; |
| | | for (AppUser appUser : list) { |
| | | if (appUser.getVipId() == 1){ |
| | | vip1Count1++; |
| | | } |
| | | if (appUser.getVipId() == 2){ |
| | | vip1Count2++; |
| | | } |
| | | if (appUser.getVipId() == 3){ |
| | | vip1Count3++; |
| | | } |
| | | if (appUser.getVipId() == 4){ |
| | | vip1Count4++; |
| | | } |
| | | if (appUser.getVipId() == 5){ |
| | | vip1Count5++; |
| | | } |
| | | if (appUser.getVipId() == 6){ |
| | | vip1Count6++; |
| | | } |
| | | if (appUser.getVipId() == 7){ |
| | | vip1Count7++; |
| | | } |
| | | |
| | | Long count1 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 1) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count1 += count1; |
| | | |
| | | Long count2 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 2) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count2 += count2; |
| | | Long count3 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 3) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count3 += count3; |
| | | Long count4 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 4) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count4 += count4; |
| | | Long count5 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 5) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count5 += count5; |
| | | Long count6 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 6) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count6 += count6; |
| | | Long count7 = appUserService.lambdaQuery() |
| | | .eq(AppUser::getVipId, 7) |
| | | .eq(AppUser::getInviteUserId, appUser.getId()) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .ne(AppUser::getStatus, 3) |
| | | .count(); |
| | | vip1Count7 += count7; |
| | | appUser.setCount1(count1); |
| | | appUser.setCount2(count2); |
| | | appUser.setCount3(count3); |
| | |
| | | appUser.setCount7(count7); |
| | | } |
| | | user.setBottomUsers(list); |
| | | |
| | | user.setCount1(vip1Count1); |
| | | user.setCount2(vip1Count2); |
| | | user.setCount3(vip1Count3); |
| | | user.setCount4(vip1Count4); |
| | | user.setCount5(vip1Count5); |
| | | user.setCount6(vip1Count6); |
| | | user.setCount7(vip1Count7); |
| | | return R.ok(user); |
| | | } |
| | | |
| | |
| | | @GetMapping("/change") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> change(@ApiParam("换绑用户手机号") String phone) { |
| | | |
| | | Long userId1 = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser byId = appUserService.getById(userId1); |
| | | |
| | | |
| | | |
| | | // List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | // .eq(AppUser::getInviteUserId, userId1) |
| | | // .eq(AppUser::getPhone, phone)); |
| | | // if (!CollectionUtils.isEmpty(appUserList)){ |
| | | // return R.fail("绑定关系已存在!"); |
| | | // } |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.lambdaQuery().eq(AppUser::getPhone, phone).one(); |
| | | AppUser user = appUserService.lambdaQuery() |
| | | .eq(AppUser::getPhone, phone) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .eq(AppUser::getStatus, 1) |
| | | .one(); |
| | | |
| | | |
| | | // 获取当前用户的所有下级 |
| | | List<AppUser> allSubordinates = getAllSubordinates(byId.getId()); |
| | | long count = allSubordinates.stream().filter(appUser -> appUser.getId().equals(user.getId())).count(); |
| | | if (count > 0) { |
| | | return R.fail("绑定关系已存在!"); |
| | | } |
| | | |
| | | if (user == null) { |
| | | return R.fail("当前手机号未注册"); |
| | | } |
| | | |
| | | Long userId = user.getId(); |
| | | if (userId.equals(byId.getId())) { |
| | | return R.fail("不能选择自己为绑定人。"); |
| | | } |
| | | |
| | | byId.setInviteUserId(user.getId()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | |
| | | 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(StringUtils.isEmpty(user.getQrCode())){ |
| | | //获取微信推广二维码 |
| | | String fileName = UUID.randomUUID() + ".jpg"; |
| | | String getwxacodeunlimit = weChatUtil.getwxacodeunlimit("pages/start/start", "id=" + user.getId(), EnvVersion.RELEASE, filePath + fileName); |
| | | user.setQrCode(getwxacodeunlimit); |
| | | appUserService.updateById(user); |
| | | } |
| | | //当前绑定门店的店铺信息 |
| | | if (user.getShopId() != null) { |
| | | R<Shop> storeById = shopClient.getShopById(user.getShopId()); |
| | | if (storeById.getData() != null) { |
| | | Shop shop = storeById.getData(); |
| | | user.setShopName(shop.getName()); |
| | | } |
| | | |
| | | //指导老师 |
| | | List<AppUser> allSuperiors = getAllSuperiors(userId); |
| | | allSuperiors.stream() |
| | | .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3) |
| | | .findFirst() |
| | | .ifPresent(superiors -> { |
| | | user.setTeacher(superiors.getName()); |
| | | }); |
| | | |
| | | Shop shop1 = shopClient.getServiceProvider(userId).getData(); |
| | | if(null != shop1){ |
| | | user.setShopName(shop1.getName()); |
| | | user.setShopId(shop1.getId()); |
| | | } |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .ne(AppUser::getStatus, 3) |
| | | .eq(AppUser::getDelFlag, 0)); |
| | | |
| | | ArrayList<Long> userIds = new ArrayList<>(); |
| | | userIds.add(userId); |
| | | getUserAncestorList(user,userIds,new ArrayList<>(),appUserList); |
| | | // Long count1 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count2 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count3 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count4 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count5 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count6 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count7 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).or().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<AppUser> allSubordinates = getAllSubordinates(userId); |
| | | // 统计下级中每种会员类型的人数 |
| | | Map<Integer, Long> countMap = allSubordinates.stream() |
| | | .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting())); |
| | | countMap.forEach((vipId, count) -> { |
| | | switch (vipId) { |
| | | case 1: |
| | | Long count1 = user.getCount1() == null ? 0 : user.getCount1(); |
| | | user.setCount1(count1 + count); |
| | | break; |
| | | case 2: |
| | | Long count2 = user.getCount2() == null ? 0 : user.getCount2(); |
| | | user.setCount2(count2 + count); |
| | | break; |
| | | case 3: |
| | | Long count3 = user.getCount3() == null ? 0 : user.getCount3(); |
| | | user.setCount3(count3 + count); |
| | | break; |
| | | case 4: |
| | | Long count4 = user.getCount4() == null ? 0 : user.getCount4(); |
| | | user.setCount4(count4 + count); |
| | | break; |
| | | case 5: |
| | | Long count5 = user.getCount5() == null ? 0 : user.getCount5(); |
| | | user.setCount5(count5 + count); |
| | | break; |
| | | case 6: |
| | | Long count6 = user.getCount6() == null ? 0 : user.getCount6(); |
| | | user.setCount6(count6 + count); |
| | | break; |
| | | case 7: |
| | | Long count7 = user.getCount7() == null ? 0 : user.getCount7(); |
| | | user.setCount7(count7 + count); |
| | | break; |
| | | } |
| | | }); |
| | | List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()) |
| | | .eq(UserSignRecord::getAppUserId,userId).list(); |
| | | if (!list.isEmpty()) { |
| | |
| | | } else { |
| | | user.setIsSign(0); |
| | | } |
| | | |
| | | List<AppUserGiveawayTemporary> temporaryList = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>() |
| | | .eq(AppUserGiveawayTemporary::getAppUserId, userId)); |
| | | |
| | | user.setLavePoint(temporaryList.stream().mapToInt(AppUserGiveawayTemporary::getTotalPoint).sum() + user.getTotalPoint()); |
| | | return R.ok(user); |
| | | } |
| | | public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { |
| | | children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(children)){ |
| | | user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); |
| | | user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); |
| | | user.setCount3((user.getCount3() == null ? 0L : user.getCount3()) + children.stream().filter(e->e.getVipId() == 3).count()); |
| | | user.setCount4((user.getCount4() == null ? 0L : user.getCount4()) + children.stream().filter(e->e.getVipId() == 4).count()); |
| | | user.setCount5((user.getCount5() == null ? 0L : user.getCount5()) + children.stream().filter(e->e.getVipId() == 5).count()); |
| | | user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); |
| | | user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); |
| | | List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | getUserAncestorList(user,userIdList, children,list); |
| | | |
| | | |
| | | public List<AppUser> getAllSuperiors(Long userId) { |
| | | List<AppUser> allSuperiors = new ArrayList<>(); |
| | | |
| | | // 获取当前用户的直接上级 |
| | | AppUser currentUser = appUserService.getById(userId); |
| | | if (currentUser != null && currentUser.getInviteUserId() != null) { |
| | | AppUser superior = appUserService.getById(currentUser.getInviteUserId()); |
| | | if (superior != null) { |
| | | allSuperiors.add(superior); // 添加直接上级 |
| | | allSuperiors.addAll(getAllSuperiors(superior.getId())); // 递归添加上级的上级 |
| | | } |
| | | } |
| | | |
| | | return allSuperiors; |
| | | } |
| | | |
| | | |
| | | |
| | | // 递归获取指定用户的所有下级 |
| | | public List<AppUser> getAllSubordinates(Long userId) { |
| | | List<AppUser> allSubordinates = new ArrayList<>(); |
| | | |
| | | List<AppUser> directChildren = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | |
| | | for (AppUser child : directChildren) { |
| | | allSubordinates.add(child); // 添加直接下级 |
| | | allSubordinates.addAll(getAllSubordinates(child.getId())); // 递归添加间接下级 |
| | | } |
| | | return allSubordinates; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/index/change") |
| | | @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) |
| | |
| | | .like(AppUser::getName, name)); |
| | | return R.ok(list); |
| | | } |
| | | /** |
| | | * 根据用户名称模糊搜索用户列表,不过滤状态 |
| | | */ |
| | | @GetMapping("/getAppUserByNameNoFilter") |
| | | public R<List<AppUser>> getAppUserByNameNoFilter(@RequestParam("name") String name) { |
| | | List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .like(AppUser::getName, name)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据用户电话模糊搜索用户列表 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更具用户电话模糊查询用户列表,不过滤状态 |
| | | */ |
| | | @GetMapping("/getAppUserByPhoneNoFilter") |
| | | public R<List<AppUser>> getAppUserByPhoneNoFilter(@RequestParam("phone") String phone) { |
| | | List<AppUser> list = appUserService.getAppUserByPhoneNoFilter(phone); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getUserPointsPage") |
| | | @ApiOperation(value = "用户列表", tags = {"管理后台"}) |
| | | public R<IPage<AppUser>> getUserPointsPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userId).getData(); |
| | | |
| | | QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>(); |
| | | if (data.getRoleType() == 2) { |
| | | Integer shopId = data.getObjectId(); |
| | | List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); |
| | | List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); |
| | | queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds) |
| | | .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName()); |
| | | } |
| | | queryWrapper.eq("del_flag", 0); |
| | | queryWrapper.ne("status", 3); |
| | | |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | Page<AppUser> objectPage = Page.of(pageNum, pageSize); |
| | | objectPage.setRecords(appUserList); |
| | | return R.ok(objectPage); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @GetMapping("/getAppuserPage") |
| | | @ApiOperation(value = "用户列表", tags = {"管理后台"}) |
| | | public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser){ |
| | | |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | appUser.setExcludeStatus(3); |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | | if (byId1!=null) { |
| | | record.setInviteUserName(byId1.getName()); |
| | | } |
| | | } |
| | | if (record.getShopId()!=null){ |
| | | R<Shop> shopById = shopClient.getShopById(record.getShopId()); |
| | | if (shopById.getData()!=null){ |
| | | record.setShopName(shopById.getData().getName()); |
| | | } |
| | | } |
| | | record.setTotalPoint(record.getUserTotalPoint()); |
| | | } |
| | | return R.ok(appuserPage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户积分列表 |
| | | */ |
| | | @GetMapping("/getUserPotPage") |
| | | public R<IPage<AppUser>> getUserPotPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | |
| | | record.setShopName(shopById.getData().getName()); |
| | | } |
| | | } |
| | | record.setTotalPoint(record.getUserTotalPoint()); |
| | | } |
| | | return R.ok(appuserPage); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/shop/getAppuserPage") |
| | | @ApiOperation(value = "用户列表", tags = {"门店后台"}) |
| | |
| | | DangerInfoDto dangerInfoDto = new DangerInfoDto(); |
| | | BeanUtils.copyProperties(data, dangerInfoDto); |
| | | List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getAppUserId,id).eq(UserPoint::getType, 1).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); |
| | | List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getAppUserId,id).eq(UserPoint::getType, 9).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); |
| | | List<UserPoint> list2 = userPointService.lambdaQuery().eq(UserPoint::getAppUserId,id).eq(UserPoint::getType, 2).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); |
| | | List<UserPoint> list3 = userPointService.lambdaQuery().eq(UserPoint::getAppUserId,id).eq(UserPoint::getType, 8).ge(UserPoint::getCreateTime, now.minusDays(data.getKeepBuyDay())).list(); |
| | | Integer userKeepBuyPoint = 0; |
| | | for (UserPoint userPoint : list1) { |
| | |
| | | userChangeLog.setChangeType(0); |
| | | userChangeLogService.save(userChangeLog); |
| | | appUser.setVipId(appUser.getVipId() - 1); |
| | | appUser.setIsDanger(0); |
| | | //检查是否达标,不达标继续标红 |
| | | VipSetting vipSetting = vipSettingClient.getVipSetting(appUser.getVipId()).getData(); |
| | | //消费积分 |
| | | List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) <= create_time")); |
| | | int sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); |
| | | if(sum < vipSetting.getKeepBuyPoint()){ |
| | | appUser.setIsDanger(1); |
| | | } |
| | | //返佣积分 |
| | | list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) <= create_time")); |
| | | sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); |
| | | if(sum < vipSetting.getKeepSharePoint()){ |
| | | appUser.setIsDanger(1); |
| | | } |
| | | //门店业绩 |
| | | list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) <= create_time")); |
| | | sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); |
| | | if(sum < vipSetting.getKeepShopPoint()){ |
| | | appUser.setIsDanger(1); |
| | | } |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | } |
| | |
| | | AppUser byId = appUserService.getById(id); |
| | | byId.setStatus(status); |
| | | appUserService.updateById(byId); |
| | | if (status == 2){ |
| | | loginout(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private void loginout(Long userId) { |
| | | // 获取所有符合模式的缓存键 |
| | | Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); |
| | | if (CollectionUtils.isEmpty(keys)) { |
| | | return; // 如果没有匹配的键,直接返回 |
| | | } |
| | | |
| | | // 遍历所有键并删除与指定用户ID相关的登录信息 |
| | | for (String key : keys) { |
| | | LoginUser user = redisService.getCacheObject(key); |
| | | if (user != null && userId.equals(user.getUserid())) { |
| | | redisService.deleteObject(key); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/select") |
| | |
| | | if (userId.equals(inviteId)) { |
| | | return R.fail("不能选择自己为绑定人。"); |
| | | } |
| | | |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, id) |
| | | .eq(AppUser::getId, inviteId)); |
| | | if (!CollectionUtils.isEmpty(appUserList)){ |
| | | return R.fail("绑定关系已存在!"); |
| | | } |
| | | |
| | | byId.setInviteUserId(inviteId); |
| | | byId.setTopInviteId(getTop(inviteId)); |
| | | appUserService.updateById(byId); |
| | |
| | | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | | public R<AppUser> detail(Long id,Integer shopId) { |
| | | |
| | | public R<AppUser> detail(Long id, Integer shopId) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | 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()); |
| | | } |
| | | Shop shop1 = shopClient.getServiceProvider(id).getData(); |
| | | if(null != shop1){ |
| | | byId.setShopName(shop1.getName()); |
| | | } |
| | | R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); |
| | | if (shopByUserId.getData() != null) { |
| | |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list); |
| | | //消费总金额 |
| | | R<List<Order>> orderR = remoteOrderGoodsClient.byShopIdAndUserId(id,shopId); |
| | | if(null == shopId || 1 == sysUser.getRoleType()){ |
| | | shopId = -1; |
| | | } |
| | | if(null == shopId && 2 == sysUser.getRoleType()){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | R<List<Order>> orderR = remoteOrderGoodsClient.byUserId(id, shopId); |
| | | List<Order> orderList = orderR.getData(); |
| | | if (!CollectionUtils.isEmpty(orderList)){ |
| | | BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | @Resource |
| | | private UserChangeLogService userChangeLogService; |
| | | /** |
| | | * 获取指定用户的下级用户 |
| | | */ |
| | | @GetMapping("/bottom/list") |
| | | @ApiOperation(value = "用户列表-下级用户", tags = {"管理后台"}) |
| | | public R<Page<AppUser>> bottom(Integer pageNum, Integer pageSize, Long userId){ |
| | | Page<AppUser> page = appUserService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/change/vip") |
| | | @ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"}) |
| | |
| | | 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)); |
| | | Page<AppUser> page = appUserService.lambdaQuery() |
| | | .eq(AppUser::getInviteUserId, id) |
| | | .eq(AppUser::getDelFlag, 0) |
| | | .eq(AppUser::getStatus, 1) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/orders") |
| | | @ApiOperation(value = "用户列表-订单列表", tags = {"管理后台"}) |
| | | public R<List<Order>> orders(Long id) { |
| | | public R<JSONObject> orders(Long id,Integer pageNum, Integer pageSize) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = sysUser.getObjectId(); |
| | | Integer shopId = -1; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id,shopId); |
| | | return R.ok(listR.getData()); |
| | | |
| | | List<Order> data = listR.getData(); |
| | | Integer total = data.size(); |
| | | // 手动分页 |
| | | if (data != null && data.size() > 0) { |
| | | if (pageNum == null || pageNum == 0) { |
| | | pageNum = 1; |
| | | } |
| | | if (pageSize == null || pageSize == 0) { |
| | | pageSize = 10; |
| | | } |
| | | data = data.stream() |
| | | .skip((pageNum - 1) * pageSize) |
| | | .limit(pageSize) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("records", data); |
| | | jsonObject.put("total", total); |
| | | jsonObject.put("size", pageSize); |
| | | jsonObject.put("current", pageNum); |
| | | return R.ok(jsonObject); |
| | | } |
| | | |
| | | |
| | |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) |
| | | public R<UserStatistics> statistics() { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userId).getData(); |
| | | |
| | | QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>(); |
| | | if (data.getRoleType() == 2) { |
| | | Integer shopId = data.getObjectId(); |
| | | List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); |
| | | List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); |
| | | queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中 |
| | | } |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId); |
| | | queryWrapper.eq("del_flag", 0); |
| | | queryWrapper.ne("status", 3); |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | |
| | | Map<Integer, Long> vipIdCountMap = appUserList.stream() |
| | | .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting())); |
| | | |
| | | UserStatistics userStatistics = new UserStatistics(); |
| | | userStatistics.setTotalUser(appUserList.size()); |
| | | userStatistics.setConsumerUser(vipIdCountMap.getOrDefault(0, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(1, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(2, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(3, 0L).intValue()); |
| | | userStatistics.setCommonUser(vipIdCountMap.getOrDefault(1, 0L).intValue()); |
| | | userStatistics.setGoldUser(vipIdCountMap.getOrDefault(2, 0L).intValue()); |
| | | userStatistics.setDiamondUser(vipIdCountMap.getOrDefault(3, 0L).intValue()); |
| | | userStatistics.setEntrepreneurUser(vipIdCountMap.getOrDefault(4, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(5, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(6, 0L).intValue() + |
| | | vipIdCountMap.getOrDefault(7, 0L).intValue()); |
| | | userStatistics.setProxyUser(vipIdCountMap.getOrDefault(4, 0L).intValue()); |
| | | userStatistics.setAgentUser(vipIdCountMap.getOrDefault(5, 0L).intValue()); |
| | | userStatistics.setTotalAgentUser(vipIdCountMap.getOrDefault(6, 0L).intValue()); |
| | | userStatistics.setPartnerUser(vipIdCountMap.getOrDefault(7, 0L).intValue()); |
| | | |
| | | long shopUserCount = appUserList.stream() |
| | | .filter(appUser -> appUser.getUserType() == 2) |
| | | .count(); |
| | | userStatistics.setShopUser((int) shopUserCount); |
| | | |
| | | return R.ok(userStatistics); |
| | | } |
| | | |
| | |
| | | if (cd.getStartTime().isAfter(cd.getEndTime())) { |
| | | return R.fail("开始时间不能大于结束时间"); |
| | | } |
| | | |
| | | |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>(); |
| | | getDatesBetween(cd.getStartTime(), cd.getEndTime()).forEach(date -> { |
| | | for (int i = 1; i < 8; i++){ |
| | | List<BalanceChangeRecord> list = balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() |
| | | LambdaQueryWrapper<BalanceChangeRecord> queryWrapper = new LambdaQueryWrapper<BalanceChangeRecord>() |
| | | .between(BalanceChangeRecord::getCreateTime, date, date.plusDays(1)) |
| | | .eq(BalanceChangeRecord::getChangeType,4) |
| | | .eq(BalanceChangeRecord::getVipId, i)); |
| | | .eq(BalanceChangeRecord::getChangeType, 4) |
| | | .eq(BalanceChangeRecord::getVipId, i); |
| | | if(sysUser.getRoleType() == 2){ |
| | | Integer objectId = sysUser.getObjectId(); |
| | | List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 1)); |
| | | List<Long> appUserIds = list.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | Set<Long> data = orderClient.getAppUserByShoppingShop(objectId).getData(); |
| | | if(null != data){ |
| | | appUserIds.addAll(data); |
| | | } |
| | | if(appUserIds.size() == 0){ |
| | | appUserIds.add(-1L); |
| | | } |
| | | queryWrapper.in(BalanceChangeRecord::getAppUserId, appUserIds); |
| | | } |
| | | List<BalanceChangeRecord> list = balanceChangeRecordService.list(queryWrapper); |
| | | BigDecimal reduce = list.stream().map(BalanceChangeRecord::getChangeAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | String dateKey = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | |
| | | } |
| | | |
| | | for (int i = 1; i < 4; i++){ |
| | | R<List<ShopBalanceStatement>> r = shopBalanceStatementClient.getShopBalanceStatementList2(i, date); |
| | | Integer objectId = 0; |
| | | if(sysUser.getRoleType() == 2){ |
| | | objectId = sysUser.getObjectId(); |
| | | } |
| | | R<List<ShopBalanceStatement>> r = shopBalanceStatementClient.getShopBalanceStatementList2(i, objectId, date); |
| | | if (!CollectionUtils.isEmpty(r.getData())){ |
| | | List<ShopBalanceStatement> list = r.getData(); |
| | | BigDecimal reduce = list.stream().map(ShopBalanceStatement::getVariableAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | } |
| | | } |
| | | }); |
| | | Integer objectId = 0; |
| | | if(sysUser.getRoleType() == 2){ |
| | | objectId = sysUser.getObjectId(); |
| | | } |
| | | |
| | | R<Map<String, BigDecimal>> shopStatistics = shopClient.getShopStatistics(objectId); |
| | | Map<String, BigDecimal> data = shopStatistics.getData(); |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | if (data != null){ |
| | | totalServiceFee = data.get("serverGiveawayMoney"); |
| | | totalUserCommission = data.get("giveawayMoney"); |
| | | } |
| | | |
| | | BigDecimal totalCommission = BigDecimal.ZERO; |
| | | BigDecimal totalNormalCommission = BigDecimal.ZERO; |
| | |
| | | |
| | | BigDecimal totalPartnerCommission = BigDecimal.ZERO; |
| | | |
| | | List<AppUser> allAppUserList = appUserService.list(); |
| | | for (AppUser appUser : allAppUserList) { |
| | | BigDecimal totalDistributionAmount = appUser.getTotalDistributionAmount(); |
| | | totalCommission = totalCommission.add(totalDistributionAmount); |
| | | if (appUser.getVipId() == 1){ |
| | | totalNormalCommission = totalNormalCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 2){ |
| | | totalGoldCommission = totalGoldCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 3){ |
| | | totalDiamondCommission = totalDiamondCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 4){ |
| | | totalAgentCommission = totalAgentCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 5){ |
| | | totalSuperAgentCommission = totalSuperAgentCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 6){ |
| | | totalTopAgentCommission = totalTopAgentCommission.add(totalDistributionAmount); |
| | | } |
| | | if (appUser.getVipId() == 7){ |
| | | totalPartnerCommission = totalPartnerCommission.add(totalDistributionAmount); |
| | | } |
| | | Set<String> keySet = dailyVipCommissions.keySet(); |
| | | List<CommissionDate> commissionDateList = new ArrayList<>(); |
| | | for (String key : keySet) { |
| | | CommissionDate commissionDate = new CommissionDate(); |
| | | commissionDate.setDate(key); |
| | | Map<Integer, BigDecimal> dailyCommissions = dailyVipCommissions.get(key); |
| | | commissionDate.setNormalCommission(dailyCommissions.getOrDefault(1, BigDecimal.ZERO)); |
| | | totalNormalCommission = totalNormalCommission.add(dailyCommissions.getOrDefault(1, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setGoldCommission(dailyCommissions.getOrDefault(2, BigDecimal.ZERO)); |
| | | totalGoldCommission = totalGoldCommission.add(dailyCommissions.getOrDefault(2, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setDiamondCommission(dailyCommissions.getOrDefault(3, BigDecimal.ZERO)); |
| | | totalDiamondCommission = totalDiamondCommission.add(dailyCommissions.getOrDefault(3, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setAgentCommission(dailyCommissions.getOrDefault(4, BigDecimal.ZERO)); |
| | | totalAgentCommission = totalAgentCommission.add(dailyCommissions.getOrDefault(4, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setSuperAgentCommission(dailyCommissions.getOrDefault(5, BigDecimal.ZERO)); |
| | | totalSuperAgentCommission = totalSuperAgentCommission.add(dailyCommissions.getOrDefault(5, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setTopAgentCommission(dailyCommissions.getOrDefault(6, BigDecimal.ZERO)); |
| | | totalTopAgentCommission = totalTopAgentCommission.add(dailyCommissions.getOrDefault(6, BigDecimal.ZERO)); |
| | | |
| | | commissionDate.setPartnerCommission(dailyCommissions.getOrDefault(7, BigDecimal.ZERO)); |
| | | totalPartnerCommission = totalPartnerCommission.add(dailyCommissions.getOrDefault(7, BigDecimal.ZERO)); |
| | | |
| | | // 用户分销总金额 |
| | | BigDecimal add = commissionDate.getNormalCommission().add(commissionDate.getGoldCommission()).add(commissionDate.getDiamondCommission()).add(commissionDate.getAgentCommission()) |
| | | .add(commissionDate.getSuperAgentCommission()).add(commissionDate.getTopAgentCommission()).add(commissionDate.getPartnerCommission()); |
| | | commissionDate.setTotalCommission(add); |
| | | |
| | | commissionDate.setServiceChargeCommission(dailyCommissions.getOrDefault(10, BigDecimal.ZERO)); |
| | | commissionDate.setAssociatedUserCommission(dailyCommissions.getOrDefault(8, BigDecimal.ZERO)); |
| | | commissionDate.setBindLowerLevelStoresCommission(dailyCommissions.getOrDefault(9, BigDecimal.ZERO)); |
| | | commissionDateList.add(commissionDate); |
| | | } |
| | | |
| | | R<Map<String, BigDecimal>> shopStatistics = shopClient.getShopStatistics(); |
| | | Map<String, BigDecimal> data = shopStatistics.getData(); |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | if (data != null){ |
| | | totalServiceFee = data.get("serverGiveawayMoney"); |
| | | totalUserCommission = data.get("lowerLevelGiveawayMoney"); |
| | | } |
| | | |
| | | |
| | | CommissionDetail commissionDetail = new CommissionDetail(); |
| | | commissionDetail.setTotalCommission(totalCommission); |
| | | commissionDetail.setTotalServiceFee(totalServiceFee); |
| | | commissionDetail.setTotalUserCommission(totalUserCommission); |
| | | |
| | | commissionDetail.setTotalNormalCommission(totalNormalCommission); |
| | | commissionDetail.setTotalGoldCommission(totalGoldCommission); |
| | | commissionDetail.setTotalDiamondCommission(totalDiamondCommission); |
| | |
| | | commissionDetail.setTotalSuperAgentCommission(totalSuperAgentCommission); |
| | | commissionDetail.setTotalTopAgentCommission(totalTopAgentCommission); |
| | | commissionDetail.setTotalPartnerCommission(totalPartnerCommission); |
| | | |
| | | |
| | | List<CommissionDate> commissionDateList = dailyVipCommissions.entrySet().stream() |
| | | .map(entry -> { |
| | | CommissionDate commissionDate = new CommissionDate(); |
| | | commissionDate.setDate(entry.getKey()); |
| | | Map<Integer, BigDecimal> dailyCommissions = entry.getValue(); |
| | | commissionDate.setNormalCommission(dailyCommissions.getOrDefault(1, BigDecimal.ZERO)); |
| | | commissionDate.setGoldCommission(dailyCommissions.getOrDefault(2, BigDecimal.ZERO)); |
| | | commissionDate.setDiamondCommission(dailyCommissions.getOrDefault(3, BigDecimal.ZERO)); |
| | | commissionDate.setAgentCommission(dailyCommissions.getOrDefault(4, BigDecimal.ZERO)); |
| | | commissionDate.setSuperAgentCommission(dailyCommissions.getOrDefault(5, BigDecimal.ZERO)); |
| | | commissionDate.setTopAgentCommission(dailyCommissions.getOrDefault(6, BigDecimal.ZERO)); |
| | | commissionDate.setPartnerCommission(dailyCommissions.getOrDefault(7, BigDecimal.ZERO)); |
| | | BigDecimal add = commissionDate.getNormalCommission().add(commissionDate.getGoldCommission()).add(commissionDate.getDiamondCommission()).add(commissionDate.getAgentCommission()) |
| | | .add(commissionDate.getSuperAgentCommission()).add(commissionDate.getTopAgentCommission()).add(commissionDate.getPartnerCommission()); |
| | | commissionDate.setTotalCommission(add); |
| | | |
| | | commissionDate.setServiceChargeCommission(dailyCommissions.getOrDefault(10, BigDecimal.ZERO)); |
| | | commissionDate.setAssociatedUserCommission(dailyCommissions.getOrDefault(8, BigDecimal.ZERO)); |
| | | commissionDate.setBindLowerLevelStoresCommission(dailyCommissions.getOrDefault(9, BigDecimal.ZERO)); |
| | | return commissionDate; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | totalCommission = totalNormalCommission.add(totalGoldCommission).add(totalDiamondCommission).add(totalAgentCommission) |
| | | .add(totalSuperAgentCommission).add(totalTopAgentCommission).add(totalPartnerCommission); |
| | | commissionDetail.setTotalCommission(totalCommission); |
| | | commissionDetail.setCommissionDateList(commissionDateList); |
| | | |
| | | return R.ok(commissionDetail); |
| | |
| | | public void vipUpgrade(@RequestParam("appUserId") Long appUserId){ |
| | | appUserService.vipUpgrade(appUserId); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/vipConsumption") |
| | | public void vipConsumption(@RequestParam("appUserId") Long appUserId){ |
| | | appUserService.vipConsumption(appUserId); |
| | | } |
| | | |
| | | /** |
| | | * 检查会员降级 |
| | | * @param appUserId |
| | | */ |
| | | @PostMapping("/app-user/vipDemotion") |
| | | @PostMapping("/vipDemotion") |
| | | public void vipDemotion(@RequestParam("appUserId") Long appUserId){ |
| | | appUserService.vipDemotion(appUserId); |
| | | } |
| | |
| | | .set(AppUser::getUserType,1)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |