package com.lframework.xingyun.sc.controller.chart;

import com.lframework.starter.web.controller.DefaultBaseController;
import com.lframework.starter.web.resp.InvokeResult;
import com.lframework.starter.web.resp.InvokeResultBuilder;
import com.lframework.xingyun.sc.dto.chart.OrderProportionDto;
import com.lframework.xingyun.sc.service.chart.HomeChartService;
import com.lframework.xingyun.sc.vo.chart.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品库存
 *
 * @author zmj
 */
@Api(tags = "分析页数据")
@Validated
@RestController
@RequestMapping("/stock/chart")
public class HomeChartController extends DefaultBaseController {

  @Autowired
  private HomeChartService homeChartService;


  @GetMapping("/statisticsTodaysOrderData")
  @ApiOperation(value = "今日-销售与采购情况")
  public InvokeResult<OrderTodaysDataVo> statisticsTodaysOrderData() {

    OrderTodaysDataVo orderDataVo=homeChartService.statisticsTodaysOrderData();

    return InvokeResultBuilder.success(orderDataVo);

  }

  @GetMapping("/statisticsMonthOrderData")
  @ApiOperation(value = "本月-销售与采购情况")
  public InvokeResult<OrderMonthDataVo> statisticsMonthOrderData() {

    OrderMonthDataVo orderDataVo=homeChartService.statisticsMonthOrderData();

    return InvokeResultBuilder.success(orderDataVo);

  }


  @GetMapping("/orderMonthContrast")
  @ApiOperation(value = "每月-订单趋势分析")
  public InvokeResult<OrderMonthContrastVo> orderMonthContrast() {

    OrderMonthContrastVo orderContrastVo=homeChartService.orderMonthContrast();

    return InvokeResultBuilder.success(orderContrastVo);

  }

  @GetMapping("/orderTodaysContrast")
  @ApiOperation(value = "每日-订单趋势分析")
  public InvokeResult<OrderTodaysContrastVo> orderTodaysContrast() {

    OrderTodaysContrastVo orderContrastVo=homeChartService.orderTodaysContrast();

    return InvokeResultBuilder.success(orderContrastVo);

  }

  @PostMapping("/orderProportion")
  @ApiOperation(value = "订单占比")
  public InvokeResult<OrderProportionVo> orderProportion(@RequestBody OrderProportionDto orderProportionDto) {

    OrderProportionVo orderProportionVo=homeChartService.orderProportion(orderProportionDto);

    return InvokeResultBuilder.success(orderProportionVo);

  }

  @GetMapping("/productProductStockProportion")
  @ApiOperation(value = "商品库存占比")
  public InvokeResult<List<ProductStockProportionVo>> productProductStockProportion() {

    List<ProductStockProportionVo> list=homeChartService.productProductStockProportion();

    return InvokeResultBuilder.success(list);

  }

  @GetMapping("/saleSalerWeekRank")
  @ApiOperation(value = "销售人员排名-本周")
  public InvokeResult<List<SaleSalerRankVo>> saleSalerWeekRank() {

    List<SaleSalerRankVo> list=homeChartService.saleSalerWeekRank();

    return InvokeResultBuilder.success(list);

  }

  @GetMapping("/saleSalerMonthRank")
  @ApiOperation(value = "销售人员排名-本月")
  public InvokeResult<List<SaleSalerRankVo>> saleSalerMonthRank() {

    List<SaleSalerRankVo> list=homeChartService.saleSalerMonthRank();

    return InvokeResultBuilder.success(list);

  }

  @GetMapping("/saleOrderGrossMargin")
  @ApiOperation(value = "最近12个月-销售毛利分析")
  public InvokeResult<SaleOrderGrossMarginVo> saleOrderGrossMargin() {

    SaleOrderGrossMarginVo saleOrderGrossMarginVo=homeChartService.saleOrderGrossMargin();

    return InvokeResultBuilder.success(saleOrderGrossMarginVo);

  }

  @GetMapping("/saleOrderLastYearProfit")
  @ApiOperation(value = "去年-销售毛利分析")
  public InvokeResult<SaleOrderLastYearProfitVo> saleOrderLastYearProfit() {

    SaleOrderLastYearProfitVo saleOrderLastYearProfitVo=homeChartService.saleOrderLastYearProfit();

    return InvokeResultBuilder.success(saleOrderLastYearProfitVo);

  }

  @GetMapping("/saleOrderCurrentYearAmount")
  @ApiOperation(value = "年度累计销售额，销售数量，销售成本，毛利率")
  public InvokeResult<SaleOrderCurrentYearAmountVo> saleOrderCurrentYearAmount() {

    SaleOrderCurrentYearAmountVo saleOrderCurrentYearAmountVo=homeChartService.saleOrderCurrentYearAmount();

    return InvokeResultBuilder.success(saleOrderCurrentYearAmountVo);

  }



}
