package vip.xiaonuo.sale.controller;


import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.sale.entity.SaleCost;
import vip.xiaonuo.sale.entity.SaleTarget;
import vip.xiaonuo.sale.entity.vo.SaleTargetDetailVo;
import vip.xiaonuo.sale.entity.vo.SaleTargetVo;
import vip.xiaonuo.sale.param.SaleCostParam;
import vip.xiaonuo.sale.param.SaleCustomerParam;
import vip.xiaonuo.sale.param.SaleDetailPageParam;
import vip.xiaonuo.sale.param.SaleParam;
import vip.xiaonuo.sale.service.ISaleTargetService;

import java.util.List;

/**
 * <p>
 * 销售指标 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-13
 */
@RestController
@Api(tags = "销售指标")
@ApiSupport(author = "wang", order = 1)
@Validated
public class SaleTargetController {

    @Autowired
    private ISaleTargetService targetService;

    @PostMapping("/sale-target/getList")
    @ApiOperationSupport(order = 1)
    @ApiOperation("销售指标ka")
    public CommonResult<JSONArray> getList(@RequestBody SaleParam saleParam) {
        return CommonResult.data(targetService.getTarget(saleParam));
    }

    @PostMapping("/sale-target/getTargetScreen")
    @ApiOperationSupport(order = 2)
    @ApiOperation("大屏销售指标")
    public CommonResult<SaleTargetVo> getTargetScreen(@RequestBody SaleParam saleParam) {
        return CommonResult.data(targetService.getTargetScreen(saleParam));
    }

    @PostMapping("/sale-target/getCompleteDetail")
    @ApiOperationSupport(order = 3)
    @ApiOperation("大屏销售计划完成率详情")
    public CommonResult<List<SaleTargetDetailVo>> getCompleteDetail(@RequestBody SaleParam saleParam) {
        return CommonResult.data(targetService.getCompleteDetail(saleParam));
    }

    @PostMapping("/sale-target/getVisitNumDetail")
    @ApiOperationSupport(order = 4)
    @ApiOperation("大屏客户拜访次数详情")
    public CommonResult<List<SaleTargetDetailVo>> getVisitNumDetail(@RequestBody SaleParam saleParam) {
        return CommonResult.data(targetService.getVisitNumDetail(saleParam));
    }

    @PostMapping("/sale-target/getSaleMoneyDetail")
    @ApiOperationSupport(order = 5)
    @ApiOperation("大屏销售合同金额详情")
    public CommonResult<List<SaleTargetDetailVo>> getSaleMoneyDetail(@RequestBody SaleParam saleParam) {
        return CommonResult.data(targetService.getSaleMoneyDetail(saleParam));
    }

    @PostMapping("/sale-target/listTop")
    @ApiOperationSupport(order = 6)
    @ApiOperation("大屏客户拜访top10，包含全部")
    public CommonResult<Page<SaleTarget>> listTop(@RequestBody SaleDetailPageParam customerParam) {
        return CommonResult.data(targetService.listTop(customerParam));
    }
}


