package com.ruoyi.logistics.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.logistics.domain.BizWaybillCostDetails;
import com.ruoyi.logistics.domain.BizWaybillOrder;
import com.ruoyi.logistics.service.IBizWaybillOrderService;
import com.ruoyi.logistics.domain.dto.OrderStatisticsDto;
import com.ruoyi.logistics.domain.dto.DailyOrderStatisticsDto;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * PC-首页指标
 *
 * @author RuiJing
 * @date 2026-01-29
 */
@RestController
@RequestMapping("/index")
public class IndexController extends BaseController {

    @Autowired
    private IBizWaybillOrderService bizWaybillOrderService;

    /**
     * 获取订单数量汇总
     * 返回京东运单数量、顺丰运单数量、总运单量
     */

    @RequiresPermissions("system:order:list")
    @GetMapping("/getTotalOrdersByOrderType")
    public OrderStatisticsDto getTotalOrdersByOrderType() {
        return bizWaybillOrderService.getTotalOrdersByOrderType(new BizWaybillOrder(), new BizWaybillCostDetails());
    }

    /**
     * 获取近七日每日订单统计
     * 返回每日的京东订单数量、顺丰订单数量、总订单数量
     */
    @RequiresPermissions("system:order:list")
    @GetMapping("/getLast7DaysOrderStatistics")
    public List<DailyOrderStatisticsDto> getLast7DaysOrderStatistics() {
        return bizWaybillOrderService.getLast7DaysOrderStatistics(new BizWaybillOrder());
    }
}
