| | |
| | | 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; |
| | |
| | | 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); |
| | | shopPointStatistics.setShopPointIPage(shopPointIPage); |
| | | |
| | | for (ShopPoint record : shopPointIPage.getRecords()) { |
| | | switch (record.getType()){ |
| | | case 1: |
| | | sPoint += record.getVariablePoint(); |
| | | |
| | | break; |
| | | case 2: |
| | | shopCommissionPoint += record.getVariablePoint(); |
| | | 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; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | break; |
| | | case 3: |
| | | subShopCommissionPoint += record.getVariablePoint(); |
| | | Integer point = shopPointStatistics.getShopPoint() == null ? 0 : shopPointStatistics.getShopPoint(); |
| | | Integer shopCommissionPoint = shopPointStatistics.getShopCommissionPoint() == null ? 0 : shopPointStatistics.getShopCommissionPoint(); |
| | | Integer setSubShopCommissionPoint = shopPointStatistics.getSubShopCommissionPoint() == null ? 0 : shopPointStatistics.getSubShopCommissionPoint(); |
| | | Integer totalPoint = point + shopCommissionPoint + setSubShopCommissionPoint; |
| | | shopPointStatistics.setTotalPoint(totalPoint); |
| | | |
| | | 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){ |
| | |
| | | return shopPointStatistics; |
| | | }else{ |
| | | Shop shop = shopService.getById(sysUser.getObjectId()); |
| | | sPoint += shop.getServerPoint(); |
| | | shopCommissionPoint += shop.getSharePoint(); |
| | | subShopCommissionPoint += shop.getLowerLevelSharePoint(); |
| | | Integer serverPoint = shop.getServerPoint(); |
| | | Integer sharePoint = shop.getSharePoint(); |
| | | Integer lowerLevelSharePoint = shop.getLowerLevelSharePoint(); |
| | | 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); |
| | | shopPointStatistics.setShopPointIPage(shopPointIPage); |