package cn.superdesk.uniorder.controller.operationCenter.accounting;

import cn.superdesk.uniorder.common.enums.accounting.order.ImportAccountingOrderExcelEnum;
import cn.superdesk.uniorder.common.enums.common.CommonAccountingStateEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.param.operationCenter.order.OperationCenterOrderParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.accounting.UnifiedAccountingOrderInfoVo;
import cn.superdesk.uniorder.dubbo.consumer.operationCenter.accounting.UnifiedAccountingDubboService;
import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author : zx
 * @Create : 2023/4/27 15:40
 * Description : 运营商结算-对账数据-订单管理 主要用途是为了对账
 * 商品维度  流水维度
 */
@Slf4j
@RestController
@RequestMapping("/operationCenter/accounting")
@RequiredArgsConstructor
public class UnifiedAccountingController extends BaseController {
    private final UnifiedAccountingDubboService unifiedAccountingDubboService;
    /**
     * 运营商结算-订单管理-商品维度
     */
    @ApiOperation(value = "运营中心-运营商结算订单管理-商品维度", notes = "")
    @PostMapping("/list")
    @ResponseBody
    public R<List<UnifiedAccountingOrderInfoVo>> getOrderGoodsList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算订单管理-商品维度,param:{}", JSON.toJSONString(param));

        return unifiedAccountingDubboService.getOrderGoodsList(param);


    }
    /**
     * 运营商结算-订单管理-流水维度---//未对账的也通过这个接口查询
     */
    @ApiOperation(value = "运营中心-运营商结算-订单管理-流水维度", notes = "")
    @PostMapping("/listWater")
    @ResponseBody
    public R<List<UnifiedAccountingOrderInfoVo>> getOrderCreditList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-订单管理-流水维度,param:{}", JSON.toJSONString(param));

        return unifiedAccountingDubboService.getOrderCreditList(param);


    }

    /**
     * 运营商结算-订单管理-流水维度--未对账
     */
    @ApiOperation(value = "运营中心-运营商结算-订单管理-流水维度", notes = "")
    @PostMapping("/Unreconciled")
    @ResponseBody
    public R<List<UnifiedAccountingOrderInfoVo>> getUnreconciledList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-订单管理-流水维度,param:{}", JSON.toJSONString(param));
        param.setAccountingStatus(CommonAccountingStateEnum.未对账.getKey().toString());
        return unifiedAccountingDubboService.getOrderCreditList(param);


    }


    /**
     * ##################每个导出的都写一个接口=进入口不同###都调用 相同底层####
     */

    /**
     * 运营商结算-商品维度-导出列表
     */
    @ApiOperation(value = "运营中心-运营商结算-商品维度-导出列表", notes = "")
    @PostMapping("/exportExcel/goodsList")
    @ResponseBody
    public R<String> importExcelOrderList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-商品维度-导出列表,param:{}", JSON.toJSONString(param));
        param.setImportAccountingOrderExcelEnum(ImportAccountingOrderExcelEnum.商品维度导出列表);
        return unifiedAccountingDubboService.importExcelOrderList(param,getToken());


    }
    /**
     * 运营商结算-商品维度-导出列表含协议成本
     */
    @ApiOperation(value = "运营中心-运营商结算-商品维度-导出列表含协议成本", notes = "")
    @PostMapping("/exportExcel/negotiatingCost")
    @ResponseBody
    public R<String> importExcelNegotiatingCostList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-商品维度-导出列表含协议成本,param:{}", JSON.toJSONString(param));
        param.setImportAccountingOrderExcelEnum(ImportAccountingOrderExcelEnum.商品维度导出列表含协议成本);
        return unifiedAccountingDubboService.importExcelOrderList(param,getToken());


    }
    /**
     * 运营商结算-商品维度-导出列表含供应商成本
     */
    @ApiOperation(value = "运营中心-运营商结算-商品维度-导出列表含供应商成本", notes = "")
    @PostMapping("/exportExcel/SupplierCosts")
    @ResponseBody
    public R<String> importExcelSupplierCostsOrderList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-商品维度-导出列表含供应商成本,param:{}", JSON.toJSONString(param));
        param.setImportAccountingOrderExcelEnum(ImportAccountingOrderExcelEnum.商品维度导出列表含供应商成本);
        return unifiedAccountingDubboService.importExcelOrderList(param,getToken());


    }
    /**
     * 运营商结算-流水维度-导出列表
     */
    @ApiOperation(value = "运营中心-运营商结算-流水维度-导出列表", notes = "")
    @PostMapping("/exportExcel/creditList")
    @ResponseBody
    public R<String> importExcelCreditList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-流水维度-导出列表,param:{}", JSON.toJSONString(param));
        param.setImportAccountingOrderExcelEnum(ImportAccountingOrderExcelEnum.流水维度导出列表);
        return unifiedAccountingDubboService.importExcelOrderList(param,getToken());


    }

    /**
     * 运营商结算-未对账订单-导出列表
     */
    @ApiOperation(value = "运营中心-运营商结算-未对账订单-导出列表", notes = "")
    @PostMapping("/exportExcel/AccountingCredit")
    @ResponseBody
    public R<String> importExcelNoAccountingCreditList(@RequestBody @Validated OperationCenterOrderParam param) {
        log.info("运营中心-运营商结算-未对账订单-导出列表,param:{}", JSON.toJSONString(param));
        param.setImportAccountingOrderExcelEnum(ImportAccountingOrderExcelEnum.未对账订单导出列表);
        return unifiedAccountingDubboService.importExcelOrderList(param,getToken());


    }

}
