From 1f09f6daaf73bc83cceb4ae22b862b7b365635cf Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 03 四月 2025 19:59:17 +0800 Subject: [PATCH] 修改反馈文档bug --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java | 114 ++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 73 insertions(+), 41 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..7d435f6 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 @@ -5,16 +5,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.web.page.PageInfo; 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 +49,12 @@ private SysUserClient sysUserClient; @Resource private ShopService shopService; + @Resource + private ShopGiveawayTemporaryMapper shopGiveawayTemporaryMapper; + + @Resource + private ShopPointCopyMapper shopPointCopyMapper; + @@ -51,44 +63,41 @@ 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(); + shopPointStatistics.setTotalPoint(0); + shopPointStatistics.setSubShopCommissionPoint(0); + shopPointStatistics.setShopPoint(0); + shopPointStatistics.setShopCommissionPoint(0); + IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint); + shopPointIPage.getRecords().forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection())); shopPointStatistics.setShopPointIPage(shopPointIPage); + + IPage<ShopPoint> page1 = new PageInfo<>(0, 100000); + IPage<ShopPoint> shopPointIPage1 = this.baseMapper.queryShpointPage(page1, shopPoint); + List<ShopPoint> shopPointList = shopPointIPage1.getRecords(); + shopPointList.forEach(s->s.setVariablePoint(s.getVariablePoint() * s.getChangeDirection())); + 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; + } + }); + }); - 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); - shopPointStatistics.setShopCommissionPoint(shopCommissionPoint); - shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint); LocalDateTime startTime = shopPoint.getStartTime(); LocalDateTime endTime = shopPoint.getEndTime(); if(null != startTime){ @@ -112,7 +121,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")) @@ -126,19 +135,30 @@ brokenLine.put("data", data); shopPointStatistics.setBrokenLine(brokenLine); } + + Integer shopPoint1 = shopPointStatistics.getShopPoint(); + Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint(); + Integer subShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint(); + shopPointStatistics.setTotalPoint(shopPoint1 + shopCommissionPoint + subShopCommissionPoint); 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 +184,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")) @@ -181,4 +201,16 @@ return shopPointStatistics; } } + + + /** + * 获取门店积分流水 + * @param page + * @param shopPoint + * @return + */ + @Override + public IPage<ShopPoint> getShopPointPage(IPage<ShopPoint> page, ShopPoint shopPoint) { + return this.baseMapper.queryShpointPage(page, shopPoint); + } } -- Gitblit v1.7.1