| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.config.exception.ValidationException; |
| | | import com.mzl.flower.constant.Constants; |
| | | import com.mzl.flower.dto.request.flower.FlowerQueryDTO; |
| | | import com.mzl.flower.dto.response.flower.FlowerListDTO; |
| | | import com.mzl.flower.dto.response.statistics.FlowerStatisticsDTO; |
| | | import com.mzl.flower.dto.response.statistics.SaleStatisticsDTO; |
| | | import com.mzl.flower.entity.payment.Order; |
| | | import com.mzl.flower.entity.supplier.Supplier; |
| | | import com.mzl.flower.mapper.flower.FlowerMapper; |
| | | import com.mzl.flower.mapper.payment.*; |
| | | import com.mzl.flower.mapper.supplier.SupplierMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.utils.UUIDGenerator; |
| | | import io.micrometer.core.instrument.util.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private OrderItemMapper orderItemMapper; |
| | | |
| | | @Autowired |
| | | private FlowerMapper flowerMapper; |
| | | |
| | | @Autowired |
| | | private SupplierMapper supplierMapper; |
| | | |
| | | public SaleStatisticsDTO getSaleStatistics(String date){ |
| | | if(StringUtils.isEmpty(date)){ |
| | |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | public FlowerStatisticsDTO getFlowerStatistics(){ |
| | | FlowerStatisticsDTO dto = new FlowerStatisticsDTO(); |
| | | |
| | | Page page = new Page(1, 1); |
| | | FlowerQueryDTO q = new FlowerQueryDTO(); |
| | | flowerMapper.selectFlowerList(page, q); |
| | | dto.setFlowerCount((int)page.getTotal()); |
| | | |
| | | Integer sc = supplierMapper.selectCount(new QueryWrapper<Supplier>() |
| | | .eq("is_enabled", 1) |
| | | .eq("status", "P") |
| | | .eq("deleted", 0)); |
| | | dto.setSupplierCount(sc); |
| | | |
| | | Integer oc = orderMapper.selectCount(new QueryWrapper<Order>() |
| | | .eq("deleted", 0) |
| | | .isNotNull("payment_time") |
| | | .isNull("cancel_time") |
| | | .isNull("refund_time")); |
| | | dto.setOrderCount(oc); |
| | | |
| | | return dto; |
| | | } |
| | | } |