luofl
2025-02-20 e4eaabefaaa2ca95f809c47a11712c3bee56e1b5
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -15,6 +15,7 @@
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;
@@ -175,7 +176,7 @@
            user.setObjectId(shopId);
            user.setAppUserId(appUser.getId());
            String s = MD5Generator.generateMD5(phone.substring(5));
            user.setPassword(SecurityUtils.encryptPassword(s));
            user.setPassword(s);
            user.setCreateTime(new Date());
            Long userId = sysUserClient.saveShopUser(user).getData();
@@ -209,7 +210,7 @@
    @ApiOperation(value = "门店详情", tags = {"管理后台-门店管理"})
    public R<Shop> getDetailById(@RequestParam("id") Integer id){
        Shop shop = shopService.getById(id);
        if (shop.getPid()==0){
        if (null != shop.getPid() && shop.getPid()==0){
            shop.setPid(null);
        }
        return R.ok(shop);
@@ -503,7 +504,8 @@
            userShop.setRoleType(1);
            List<UserShop> data = userShopClient.getUserShop(userShop).getData();
            SysUser userData = sysUserClient.getSysUser(data.get(0).getUserId()).getData();
            userData.setPassword(userData.getPhonenumber().substring(5));
            String s = MD5Generator.generateMD5(userData.getPhonenumber().substring(5));
            userData.setPassword(s);
            sysUserClient.resetPassword(userData);
        }
        return R.ok();
@@ -687,14 +689,35 @@
    @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);
    }
    
@@ -822,17 +845,21 @@
    @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);
    }