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


import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dto.param.operationCenter.base.OperationCenterParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.base.OperationCenterVo;
import cn.superdesk.uniorder.dto.vo.sys.SysSelectVo;
import cn.superdesk.uniorder.dubbo.consumer.operationCenter.base.OperationCenterBaseDubboService;
import cn.superdesk.uniorder.dubbo.consumer.organisation.SysOrganizationDubboConsumerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author : zx
 * @Create : 2023/3/28 10:46
 * Description : 主要是为了给前端提供检索映射-运营中心1.0 数据同步
 */
@Slf4j
@RestController
@RequestMapping("/operationCenter/base")
@RequiredArgsConstructor
public class OperationCenterBaseController {

    private final OperationCenterBaseDubboService operationCenterBaseDubboService;

    /**
     *业务平台
     */
    @PostMapping("/platform")
    @ResponseBody
    public R<List<OperationCenterVo>> getPlatformCode() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> platformCode = operationCenterBaseDubboService.getPlatformCode();
        result.setData(platformCode);
        return result;
    }
    /**
     *订单类型
     */
    @PostMapping("/orderType")
    @ResponseBody
    public R<List<OperationCenterVo>> getOrderType() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> orderTypeCode = operationCenterBaseDubboService.getOrderType();
        result.setData(orderTypeCode);
        return result;
    }

    /**
     *业务类型
     */
    @PostMapping("/orderBizType")
    @ResponseBody
    public R<List<OperationCenterVo>> getOrderBizType() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> orderBizTypeCode = operationCenterBaseDubboService.getOrderBizType();
        result.setData(orderBizTypeCode);
        return result;
    }

    /**
     *支付状态
     */
    @PostMapping("/orderPayStatus")
    @ResponseBody
    public R<List<OperationCenterVo>> getOrderPayStatus() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> orderPayStatus = operationCenterBaseDubboService.getOrderPayStatus();
        result.setData(orderPayStatus);
        return result;
    }
    /**
     *平台支付方式
     */
    @PostMapping("/payMethod/{customerId}")
    @ResponseBody
    public R<List<OperationCenterVo>> paymentMethod(@PathVariable("customerId") Long customerId ) {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> paymentMethod = operationCenterBaseDubboService.getPaymentByCustomerId(customerId);
        result.setData(paymentMethod);
        return result;
    }
    /**
     *交易状态
     */
    @PostMapping("/transactionStatus")
    @ResponseBody
    public R<List<OperationCenterVo>> getTransactionStatus() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> transactionStatus = operationCenterBaseDubboService.getTransactionStatus();
        result.setData(transactionStatus);
        return result;
    }
    /**
     *售后状态 OpCenterPlatformAftersaleStatusEnum
     */
    @PostMapping("/afterSaleStatus")
    @ResponseBody
    public R<List<OperationCenterVo>> getAfterSaleStatus() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> afterSaleStatus = operationCenterBaseDubboService.getAfterSaleStatus();
        result.setData(afterSaleStatus);
        return result;
    }
    /**
     *售后类型  OpCenterPlatformAftersaleTypeEnum
     */
    @PostMapping("/afterSaleType")
    @ResponseBody
    public R<List<OperationCenterVo>> getAfterSaleType() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> afterSaleType = operationCenterBaseDubboService.getAfterSaleType();
        result.setData(afterSaleType);
        return result;
    }
    /**
     * 项目下拉列表
     */
    @PostMapping("/selectOrgList")
    @ResponseBody
    public R<List<SysSelectVo>> selectOrgList(@RequestBody OperationCenterParam param) {
        if (StringUtils.isBlank(param.getCustomerId())) {
            return new R<>("500", "客户id必传！", false);
        }
        return operationCenterBaseDubboService.selectOrgList(param);
    }
    /**
     * 商品类型
     */
    @PostMapping("/goodType")
    @ResponseBody
    public R<List<OperationCenterVo>> getOrderGoodType() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> orderGoodType = operationCenterBaseDubboService.getOrderGoodType();
        result.setData(orderGoodType);
        return result;
    }

    /**
     * 对账状态：
     */
    @PostMapping("/accountingState")
    @ResponseBody
    public R<List<OperationCenterVo>> getAccountingState() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> accountingState = operationCenterBaseDubboService.getAccountingState();
        result.setData(accountingState);
        return result;
    }

    /**
     * 账单状态：
     */
    @PostMapping("/opAccountingStatus")
    @ResponseBody
    public R<List<OperationCenterVo>> opAccountingStatus(@RequestBody OperationCenterParam param) {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> accountingState = operationCenterBaseDubboService.opAccountingStatus(param.getType());
        result.setData(accountingState);
        return result;
    }

    /**
     * 是否参与结算
     */
    @PostMapping("/isSettlement")
    @ResponseBody
    public R<List<OperationCenterVo>> getIsSettlement() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> isSettlement = operationCenterBaseDubboService.getIsSettlement();
        result.setData(isSettlement);
        return result;
    }

    /**
     * 邮件状态
     */
    @PostMapping("/getEmailStatus")
    @ResponseBody
    public R<List<OperationCenterVo>> getEmailStatus() {
        R<List<OperationCenterVo>> result = new R<>();
        List<OperationCenterVo> orderGoodType = operationCenterBaseDubboService.emailStatus();
        result.setData(orderGoodType);
        return result;
    }
}
