Pu Zhibing
2025-03-27 e7a4c604b4703caf135ec3d360106e7cf028cc89
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
@@ -7,8 +7,12 @@
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.api.domain.ShopGiveawayTemporary;
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.api.domain.ShopPointCopy;
import com.ruoyi.other.api.enums.PointChangeType;
import com.ruoyi.other.mapper.ShopGiveawayTemporaryMapper;
import com.ruoyi.other.mapper.ShopPointCopyMapper;
import com.ruoyi.other.mapper.ShopPointMapper;
import com.ruoyi.other.service.ShopPointService;
import com.ruoyi.other.service.ShopService;
@@ -44,6 +48,12 @@
    private SysUserClient sysUserClient;
    @Resource
    private ShopService shopService;
    @Resource
    private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper;
    @Resource
    private ShopPointCopyMapper shopPointCopyMapper;
@@ -56,6 +66,7 @@
            ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
            IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
            shopPointIPage.getRecords().forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection()));
            shopPointStatistics.setShopPointIPage(shopPointIPage);
@@ -78,11 +89,39 @@
                    }
                });
            });
            Integer point = shopPointStatistics.getShopPoint() == null ? 0 : shopPointStatistics.getShopPoint();
            Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint() == null ? 0 : shopPointStatistics.getShopCommissionPoint();
            Integer setSubShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint() == null ? 0 : shopPointStatistics.getSubShopCommissionPoint();
            List<ShopPointCopy> shopPointCopyList = shopPointCopyMapper.selectList(null);
            Map<Integer, List<ShopPointCopy>> shopPointByTypeMaps = shopPointCopyList.stream().collect(Collectors.groupingBy(ShopPointCopy::getType));
            shopPointByTypeMaps.forEach((type, shopPoints) -> {
                shopPoints.stream().map(ShopPointCopy::getVariablePoint).reduce(Integer::sum).ifPresent(sum -> {
                    switch (type) {
                        case 1:
                            shopPointStatistics.setShopPoint((null == shopPointStatistics.getShopPoint() ? 0 : shopPointStatistics.getShopPoint()) + sum);
                            break;
                        case 2:
                            shopPointStatistics.setShopCommissionPoint((null == shopPointStatistics.getShopCommissionPoint() ? 0 : shopPointStatistics.getShopCommissionPoint()) + sum);
                            break;
                        case 3:
                            shopPointStatistics.setSubShopCommissionPoint((null == shopPointStatistics.getSubShopCommissionPoint() ? 0 : shopPointStatistics.getSubShopCommissionPoint()) + sum);
                            break;
                        default:
                            break;
                    }
                });
            });
            List<ShopGiveawayTemporary> list1 = shopGiveawayTemporaryMapper.selectList(null);
            int serverPointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getServerPoint).sum();
            int sharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getSharePoint).sum();
            int lowerLevelSharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getLowerLevelSharePoint).sum();
            Integer point = shopPointStatistics.getShopPoint() == null ? 0 : shopPointStatistics.getShopPoint() + serverPointCopy;
            Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint() == null ? 0 : shopPointStatistics.getShopCommissionPoint() + sharePointCopy;
            Integer setSubShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint() == null ? 0 : shopPointStatistics.getSubShopCommissionPoint() + lowerLevelSharePointCopy;
            Integer totalPoint = point + shopCommissionPoint + setSubShopCommissionPoint;
            shopPointStatistics.setShopPoint(point);
            shopPointStatistics.setShopCommissionPoint(shopCommissionPoint);
            shopPointStatistics.setSubShopCommissionPoint(setSubShopCommissionPoint);
            shopPointStatistics.setTotalPoint(totalPoint);
@@ -126,9 +165,14 @@
            return shopPointStatistics;
        }else{
            Shop shop = shopService.getById(sysUser.getObjectId());
            Integer serverPoint = shop.getServerPoint();
            Integer sharePoint = shop.getSharePoint();
            Integer lowerLevelSharePoint = shop.getLowerLevelSharePoint();
            List<ShopGiveawayTemporary> list1 = shopGiveawayTemporaryMapper.selectList(new LambdaQueryWrapper<ShopGiveawayTemporary>().eq(ShopGiveawayTemporary::getShopId, shop.getId()));
            int serverPointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getServerPoint).sum();
            int sharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getSharePoint).sum();
            int lowerLevelSharePointCopy = list1.stream().mapToInt(ShopGiveawayTemporary::getLowerLevelSharePoint).sum();
            shopPoint.setShopId(shop.getId());
            Integer serverPoint = shop.getServerPoint() + serverPointCopy;
            Integer sharePoint = shop.getSharePoint() + sharePointCopy;
            Integer lowerLevelSharePoint = shop.getLowerLevelSharePoint() + lowerLevelSharePointCopy;
            ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
            shopPointStatistics.setTotalPoint(serverPoint + sharePoint + lowerLevelSharePoint);
            shopPointStatistics.setShopPoint(serverPoint);
@@ -136,6 +180,7 @@
            shopPointStatistics.setSubShopCommissionPoint(lowerLevelSharePoint);
            IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
            shopPointIPage.getRecords().forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection()));
            shopPointStatistics.setShopPointIPage(shopPointIPage);
            LocalDateTime startTime = shopPoint.getStartTime();