| | |
| | | import com.ruoyi.common.security.utils.MD5Generator; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.vo.OrderSaleNum; |
| | | import com.ruoyi.order.vo.VerifiableShopVo; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | |
| | | @ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"}) |
| | | public R<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) { |
| | | ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId); |
| | | if(null == shopId){ |
| | | shopId = 0; |
| | | List<Integer> shopIds; |
| | | |
| | | shopIds = shopService.list(new LambdaQueryWrapper<Shop>() |
| | | .eq(Shop::getDelFlag, 0) |
| | | .eq(shopId !=null,Shop::getId, shopId)) |
| | | .stream() |
| | | .map(Shop::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | if (CollectionUtils.isEmpty(shopIds)){ |
| | | shopStatistics.setTotalOrder(0); |
| | | shopStatistics.setServiceOrder(0); |
| | | shopStatistics.setGoodsOrder(0); |
| | | }else { |
| | | OrderSaleNum serviceOrderSaleNum = new OrderSaleNum(); |
| | | serviceOrderSaleNum.setShopIds(shopIds); |
| | | serviceOrderSaleNum.setType(1); |
| | | Integer serviceOrder = orderClient.getShopSaleNumByShopIds(serviceOrderSaleNum).getData(); |
| | | |
| | | OrderSaleNum goodsOrderSaleNum = new OrderSaleNum(); |
| | | goodsOrderSaleNum.setShopIds(shopIds); |
| | | goodsOrderSaleNum.setType(2); |
| | | Integer goodsOrder = orderClient.getShopSaleNumByShopIds(goodsOrderSaleNum).getData(); |
| | | |
| | | shopStatistics.setTotalOrder(serviceOrder + goodsOrder); |
| | | shopStatistics.setServiceOrder(serviceOrder); |
| | | shopStatistics.setGoodsOrder(goodsOrder); |
| | | } |
| | | Integer serviceOrder = orderClient.getShopSaleNum(shopId, 1).getData(); |
| | | Integer goodsOrder = orderClient.getShopSaleNum(shopId, 2).getData(); |
| | | shopStatistics.setTotalOrder(serviceOrder + goodsOrder); |
| | | shopStatistics.setServiceOrder(serviceOrder); |
| | | shopStatistics.setGoodsOrder(goodsOrder); |
| | | return R.ok(shopStatistics); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @GetMapping("/getShopStatistics") |
| | | public R<Map<String, BigDecimal> > getShopStatistics(){ |
| | | List<Shop> shopList = shopService.list(); |
| | | public R<Map<String, BigDecimal> > getShopStatistics(@RequestParam("shopId") Integer shopId){ |
| | | LambdaQueryWrapper<Shop> queryWrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1); |
| | | if(null != shopId && 0 != shopId){ |
| | | queryWrapper.eq(Shop::getId, shopId); |
| | | } |
| | | List<Shop> shopList = shopService.list(queryWrapper); |
| | | BigDecimal serverGiveawayMoney = BigDecimal.ZERO; |
| | | BigDecimal lowerLevelGiveawayMoney = BigDecimal.ZERO; |
| | | BigDecimal giveawayMoney = BigDecimal.ZERO; |
| | | for (Shop shop : shopList) { |
| | | serverGiveawayMoney = serverGiveawayMoney.add(shop.getServerGiveawayMoney()); |
| | | lowerLevelGiveawayMoney = lowerLevelGiveawayMoney.add(shop.getLowerLevelGiveawayMoney()); |
| | | giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney()); |
| | | } |
| | | Map<String, BigDecimal> map = new HashMap<>(); |
| | | map.put("serverGiveawayMoney", serverGiveawayMoney); |
| | | map.put("lowerLevelGiveawayMoney", lowerLevelGiveawayMoney); |
| | | map.put("giveawayMoney", giveawayMoney); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | | * 获取指定用户的服务商 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @GetMapping("/getServiceProvider") |
| | | public R<Shop> getServiceProvider(Long userId){ |
| | | //向上找获取第一个开店的门店 |
| | | List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | AppUser appUser = appUserClient.getAppUserById(userId); |
| | | //上级集合,防止循环关联 |
| | | Set<Long> pid = new HashSet<>(); |
| | | Shop shop = getSuperiorStore(appUser, list, 1, 1, pid); |
| | | return R.ok(shop); |
| | | } |
| | | |
| | | |
| | | |
| | | public Shop getSuperiorStore(AppUser appUser, List<Shop> list, Integer hierarchy, Integer num, Set<Long> pid){ |
| | | if(null == appUser.getInviteUserId()){ |
| | | return null; |
| | | } |
| | | if(pid.contains(appUser.getInviteUserId())){ |
| | | return null; |
| | | } |
| | | AppUser appUser1 = appUserClient.getAppUserById(appUser.getInviteUserId()); |
| | | if(null != appUser1){ |
| | | Optional<Shop> first = list.stream().filter(shop -> shop.getAppUserId().equals(appUser1.getId())).findFirst(); |
| | | if(first.isPresent()){ |
| | | if(hierarchy.equals(num)){ |
| | | return first.get(); |
| | | } |
| | | num++; |
| | | } |
| | | } |
| | | return getSuperiorStore(appUser1, list, hierarchy, num, pid); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取指定用户的高级服务商 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getSuperiorServiceProvider") |
| | | public R<Shop> getSuperiorServiceProvider(Long userId){ |
| | | //向上找获取第一个开店的门店 |
| | | List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | AppUser appUser = appUserClient.getAppUserById(userId); |
| | | //上级集合,防止循环关联 |
| | | Set<Long> pid = new HashSet<>(); |
| | | Shop shop = getSuperiorStore(appUser, list, 2, 1, pid); |
| | | return R.ok(shop); |
| | | } |
| | | |
| | | } |
| | | |