| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | 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.util.ObsUploadUtil; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | |
| | | 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 io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | @ResponseBody |
| | | @GetMapping("/getNearbyReferrer") |
| | | @ApiOperation(value = "获取附近推荐人列表") |
| | | public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) { |
| | | startPage(); |
| | | List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer); |
| | | return getDataTable(list); |
| | | public R<PageInfo<NearbyReferrerVo>> getNearbyReferrer(NearbyReferrer nearbyReferrer) { |
| | | return R.ok(appUserService.getNearbyReferrer(nearbyReferrer)); |
| | | } |
| | | |
| | | |
| | |
| | | public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, 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(); |
| | | } |
| | | 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 (byId.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(byId.getInviteUserId()); |
| | | byId.setInviteUserName(byId1.getName()); |
| | | AppUser appUser = appUserService.getById(byId.getInviteUserId()); |
| | | if(null != appUser){ |
| | | byId.setInviteUserName(appUser.getName()); |
| | | } |
| | | } |
| | | //最后下单时间 |
| | | R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id); |
| | |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) |
| | | public R<UserStatistics> statistics() { |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | Set<Long> userIdT = null; |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId); |
| | | UserStatistics userStatistics1 = appUserMapper.getUserStatistics(shopId, userIdT); |
| | | userStatistics.setShopUser(userStatistics1.getShopUser()); |
| | | return R.ok(userStatistics); |
| | | } |
| | | |
| | |
| | | @GetMapping("/statistics/detail") |
| | | @ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"}) |
| | | public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userIds = null; |
| | | if(null != userId){ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | if(null == userId){ |
| | | userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | }else{ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | } |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds); |
| | | return R.ok(userStatisticsDetail); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/commissionDetail") |
| | | @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") |
| | | public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) { |
| | | List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList()); |
| | | |
| | | public R<CommissionDetail> commissionDetail() { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0); |
| | | if(sysUser.getRoleType() == 2){ |
| | | queryWrapper.eq(AppUser::getShopId, sysUser.getObjectId()); |
| | | } |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | if (appUserList.isEmpty()) { |
| | | return R.ok(new CommissionDetail()); |
| | | } |
| | | |
| | | BigDecimal totalCommission = BigDecimal.ZERO; |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>(); |
| | | |
| | | for (AppUser appUser : appUserList) { |
| | | BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO); |
| | | totalCommission = totalCommission.add(distributionAmount); |
| | |
| | | } |
| | | } |
| | | List<Shop> data = shopClient.getAllShop().getData(); |
| | | if(sysUser.getRoleType() == 2){ |
| | | data = Arrays.asList(shopClient.getShopById(sysUser.getObjectId()).getData()); |
| | | } |
| | | for (Shop shop : data) { |
| | | totalServiceFee = totalServiceFee.add(shop.getServerGiveawayMoney()); |
| | | totalUserCommission = totalUserCommission.add(shop.getGiveawayMoney()); |
| | |
| | | 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(); |
| | | // commissionDate.setAssociatedUserCommission(); |
| | | // commissionDate.setBindLowerLevelStoresCommission(); |
| | | return commissionDate; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | commissionDetail.setCommissionDateList(commissionDateList); |
| | | |
| | | return R.ok(commissionDetail); |
| | | } |
| | | |
| | |
| | | public void demotionDetection(){ |
| | | appUserService.demotionDetection(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清空绑定门店的用户门店数据 |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | @PostMapping("/clearBindShop") |
| | | public R clearBindShop(@RequestParam("shopId") Integer shopId){ |
| | | appUserService.update(new LambdaUpdateWrapper<AppUser>().eq(AppUser::getShopId, shopId).set(AppUser::getShopId, null)); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |