| | |
| | | import com.ruoyi.sales.dto.StatisticsTableDto; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | |
| | | @Autowired |
| | | private ShippingInfoMapper shippingInfoMapper; |
| | | |
| | | public AjaxResult total() { |
| | | List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(null); |
| | | if(CollectionUtils.isEmpty(salesLedgers)) return AjaxResult.success(salesLedgers); |
| | |
| | | map.put("shipRate", "0%"); |
| | | if(CollectionUtils.isEmpty(salesLedgerProducts)) return AjaxResult.success(map); |
| | | // 发货数量 |
| | | long count = salesLedgerProducts.stream() |
| | | .filter(salesLedgerProduct -> salesLedgerProduct.getApproveStatus().equals(2)) |
| | | .count(); |
| | | long count = shippingInfoMapper.selectCount(new LambdaQueryWrapper<ShippingInfo>() |
| | | .in(ShippingInfo::getSalesLedgerProductId, salesLedgerProducts.stream().map(SalesLedgerProduct::getId).collect(Collectors.toList())) |
| | | .eq(ShippingInfo::getStatus,"已发货")); |
| | | map.put("shipRate", String.format("%.2f", count * 100.0 / salesLedgerProducts.size()) + "%"); |
| | | return AjaxResult.success(map); |
| | | } |