| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserCancellationLog; |
| | | import com.ruoyi.account.api.model.UserCoupon; |
| | |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageCurr, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | R<SysUser> sysUserR = sysUserClient.getSysUser(userid); |
| | | SysUser sysUser = sysUserR.getData(); |
| | | |
| | | List<Long> userIds = new ArrayList<>(); |
| | | userIds.add(-1L); |
| | | //获取在该本店下单的用户ids |
| | | Integer objectId = sysUser.getObjectId(); |
| | | R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId); |
| | | for (Order datum : listR.getData()) { |
| | | userIds.add(datum.getAppUserId()); |
| | |
| | | @ApiOperation(value = "用户列表-更换绑定人", tags = {"管理后台"}) |
| | | public R<AppUser> select(Long id, Long inviteId) { |
| | | AppUser byId = appUserService.getById(id); |
| | | Long userId = byId.getId(); |
| | | if (userId.equals(inviteId)) { |
| | | return R.fail("不能选择自己为绑定人。"); |
| | | } |
| | | byId.setInviteUserId(inviteId); |
| | | byId.setTopInviteId(getTop(inviteId)); |
| | | appUserService.updateById(byId); |
| | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | | public R<AppUser> detail(Long id) { |
| | | |
| | | 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()))); |
| | |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list); |
| | | //消费总金额 |
| | | R<List<Order>> orderR = remoteOrderGoodsClient.byShopId(sysUser.getObjectId()); |
| | | List<Order> orderList = orderR.getData(); |
| | | if (!CollectionUtils.isEmpty(orderList)){ |
| | | BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | byId.setShopAmount(paymentAmount); |
| | | }else { |
| | | byId.setShopAmount(BigDecimal.ZERO); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listByIds") |
| | | List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) { |
| | | @PostMapping("/listByIds") |
| | | public List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) { |
| | | if(ids.size() == 0){ |
| | | return new ArrayList<>(); |
| | | } |
| | |
| | | .eq(AppUser::getPhone, phone)); |
| | | return R.ok(appUser); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置指定用户的下级用户绑定门店 |
| | | */ |
| | | @PostMapping("/setLowerUserShop") |
| | | public R<Void> setLowerUserShop(@RequestParam("userId") Long userId,@RequestParam("shopId") Integer shopId) { |
| | | appUserService.update(new LambdaUpdateWrapper<AppUser>() |
| | | .set(AppUser::getShopId,shopId) |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户统计 |
| | |
| | | */ |
| | | @GetMapping("/commissionDetail") |
| | | @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") |
| | | public R<CommissionDetail> commissionDetail() { |
| | | public R<CommissionDetail> commissionDetail(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime, |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) { |
| | | 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()); |
| | | } |
| | | queryWrapper.ge(null != startTime, AppUser::getCreateTime, startTime); |
| | | queryWrapper.le(null != endTime, AppUser::getCreateTime, endTime); |
| | | queryWrapper.orderByAsc(AppUser::getCreateTime); |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | if (appUserList.isEmpty()) { |
| | | return R.ok(new CommissionDetail()); |
| | |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>(); |
| | | for (AppUser appUser : appUserList) { |
| | | BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO); |
| | | totalCommission = totalCommission.add(distributionAmount); |