From e7a4c604b4703caf135ec3d360106e7cf028cc89 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 27 三月 2025 00:45:08 +0800 Subject: [PATCH] 修改统计bug和部分功能修改 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java | 120 ++++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 81 insertions(+), 39 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java index 18b4501..9971d47 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java @@ -7,14 +7,19 @@ 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; import com.ruoyi.other.vo.ShopPointStatistics; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; +import io.swagger.models.auth.In; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -43,6 +48,12 @@ private SysUserClient sysUserClient; @Resource private ShopService shopService; + @Resource + private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper; + + @Resource + private ShopPointCopyMapper shopPointCopyMapper; + @@ -51,44 +62,69 @@ public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) { Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); - Integer sPoint = 0; - Integer shopCommissionPoint = 0; - Integer subShopCommissionPoint = 0; - Integer serverCommissionPoint = 0; if (sysUser.getRoleType()==1){ - if (StringUtils.isNotEmpty(shopPoint.getShopName())){ - } - if (StringUtils.isNotEmpty(shopPoint.getShopLeaderName())){ - - } 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); - for (ShopPoint record : shopPointIPage.getRecords()) { - switch (record.getType()){ - case 1: - sPoint += record.getVariablePoint(); - break; - case 2: - shopCommissionPoint += record.getVariablePoint(); - - break; - case 3: - subShopCommissionPoint += record.getVariablePoint(); - - break; - case 4: - serverCommissionPoint+= record.getVariablePoint(); - break; - } - } - shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint+serverCommissionPoint); - shopPointStatistics.setShopPoint(sPoint); + List<ShopPoint> shopPointList = list(); + Map<Integer, List<ShopPoint>> shopPointByTypeMap = shopPointList.stream().collect(Collectors.groupingBy(ShopPoint::getType)); + shopPointByTypeMap.forEach((type, shopPoints) -> { + shopPoints.stream().map(ShopPoint::getVariablePoint).reduce(Integer::sum).ifPresent(sum -> { + switch (type) { + case 1: + shopPointStatistics.setShopPoint(sum); + break; + case 2: + shopPointStatistics.setShopCommissionPoint(sum); + break; + case 3: + shopPointStatistics.setSubShopCommissionPoint(sum); + break; + default: + break; + } + }); + }); + + 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(subShopCommissionPoint); + shopPointStatistics.setSubShopCommissionPoint(setSubShopCommissionPoint); + shopPointStatistics.setTotalPoint(totalPoint); + + LocalDateTime startTime = shopPoint.getStartTime(); LocalDateTime endTime = shopPoint.getEndTime(); if(null != startTime){ @@ -112,7 +148,7 @@ //服务积分 List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) - .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList()); + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 1).collect(Collectors.toList()); map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum()); //绑定下级门店返佣积分 List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) @@ -129,16 +165,22 @@ return shopPointStatistics; }else{ Shop shop = shopService.getById(sysUser.getObjectId()); - sPoint += shop.getServerPoint(); - shopCommissionPoint += shop.getSharePoint(); - subShopCommissionPoint += 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(sPoint + shopCommissionPoint + subShopCommissionPoint); - shopPointStatistics.setShopPoint(sPoint); - shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); - shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); + shopPointStatistics.setTotalPoint(serverPoint + sharePoint + lowerLevelSharePoint); + shopPointStatistics.setShopPoint(serverPoint); + shopPointStatistics.setShopCommissionPoint(sharePoint); + 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(); @@ -164,7 +206,7 @@ //服务积分 List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) - .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList()); + .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 1).collect(Collectors.toList()); map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum()); //绑定下级门店返佣积分 List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) -- Gitblit v1.7.1