package cn.superdesk.uniorder.controller._common;

import cn.superdesk.uniorder.common.enums.invoice.InvoiceInvoicedIsRedWriteOffEnum;
import cn.superdesk.uniorder.common.enums.invoice.common.PurchaserCompanyTypeEnum;
import cn.superdesk.uniorder.common.enums.invoice.customer.InvoiceApplyBecomeInvalidEnum;
import cn.superdesk.uniorder.common.enums.thirdpart.szhtxx.electronicInvoice.*;
import cn.superdesk.uniorder.common.enums.thirdpart.szhtxx.paperInvoice.SzhtxxPaperInvoiceReqfCodeEnum;
import cn.superdesk.uniorder.common.enums.thirdpart.szhtxx.paperInvoice.SzhtxxPaperInvoiceUsedEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.rest.response.ResponseResultOuterUtils;
import cn.superdesk.uniorder.dto.utils.AnDtoSortedListUtils;
import cn.superdesk.uniorder.dto.vo._common.EnumSelectIntegerStringVo;
import cn.superdesk.uniorder.dto.vo._common.EnumSelectStringStringStringVo;
import cn.superdesk.uniorder.dto.vo._common.EnumSelectStringStringVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/5/13 3:41 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/5/13 3:41 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Api(value = "第三方-下拉列表-深圳航天信息有限公司", tags = {"第三方-下拉列表-深圳航天信息有限公司"})
@Slf4j
@RestController
@RequestMapping("/thirdpart/szhtxx/electronicInvoice/select")
public class ThirdPartSzhtxxElectronicInvoiceSelectController {


    @ApiOperation(value = "开票类型", notes = "积分结算2.1")
    @RequestMapping(value = "/kplx", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxKplxEnum() {

        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxKplxEnum value : SzhtxxElectronicInvoiceFptxxKplxEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "交付标志", notes = "积分结算2.1")
    @RequestMapping(value = "/billSentSign", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxBillSentSignEnum() {

        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxBillSentSignEnum value : SzhtxxElectronicInvoiceFptxxBillSentSignEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "购货方企业类型", notes = "积分结算2.1")
    @RequestMapping(value = "/ghfqylx", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectStringStringVo>> selectPurchaserCompanyTypeEnum() {

        List<EnumSelectStringStringVo> selectVos = new ArrayList<>();

        for (PurchaserCompanyTypeEnum value : PurchaserCompanyTypeEnum.values()) {
            selectVos.add(EnumSelectStringStringVo
                    .builder()
                    .key(value.getPurchaserCompanyType())
                    .desc(value.getPurchaserCompanyTypeName())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "清单标志", notes = "积分结算2.1")
    @RequestMapping(value = "/qdBz", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxQdBzEnum() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxQdBzEnum value : SzhtxxElectronicInvoiceFptxxQdBzEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "是否红冲", notes = "积分结算2.1")
    @RequestMapping(value = "/isRedWriteOff", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectInvoiceInvoicedIsRedWriteOffEnum() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (InvoiceInvoicedIsRedWriteOffEnum value : InvoiceInvoicedIsRedWriteOffEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "报送状态", notes = "积分结算2.1")
    @RequestMapping(value = "/pushedOutStatus", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxPushedOutStatusEnum() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxPushedOutStatusEnum value : SzhtxxElectronicInvoiceFptxxPushedOutStatusEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        List<Integer> orderList = Arrays.asList(
                SzhtxxElectronicInvoiceFptxxPushedOutStatusEnum.未报送.getKey(),
                SzhtxxElectronicInvoiceFptxxPushedOutStatusEnum.已报送.getKey(),
                SzhtxxElectronicInvoiceFptxxPushedOutStatusEnum.报送失败.getKey()
        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "邮件状态", notes = "积分结算2.1")
    @RequestMapping(value = "/sentEmailStatus", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxSentEmailStatusEnum() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxSentEmailStatusEnum value : SzhtxxElectronicInvoiceFptxxSentEmailStatusEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }


    @ApiOperation(value = "作废标志", notes = "积分结算2.2")
    @RequestMapping(value = "/becomeInvalid", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectInvoiceApplyBecomeInvalidEnum() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (InvoiceApplyBecomeInvalidEnum value : InvoiceApplyBecomeInvalidEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        List<Integer> orderList = Arrays.asList(
                InvoiceApplyBecomeInvalidEnum.未作废.getKey(),
                InvoiceApplyBecomeInvalidEnum.已作废.getKey()

        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }


    /**************************************** 20220323 start ****************************************/


    @ApiOperation(value = "发票类型(20220323需求变更，接口变更)", notes = "积分结算2.1")
    @RequestMapping(value = "/invoiceType", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxInvoiceType() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxInvoiceTypeEnum value : SzhtxxElectronicInvoiceFptxxInvoiceTypeEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "开具理由(20220323需求变更，接口变更)", notes = "积分结算2.1")
    @RequestMapping(value = "/invReason", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxInvReason() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxInvReasonEnum value : SzhtxxElectronicInvoiceFptxxInvReasonEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "冲红原因(20220323需求变更，接口变更)", notes = "积分结算2.1")
    @RequestMapping(value = "/redReason", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxElectronicInvoiceFptxxRedReason() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxElectronicInvoiceFptxxRedReasonEnum value : SzhtxxElectronicInvoiceFptxxRedReasonEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    /**************************************** 20220323 start ****************************************/


    @ApiOperation(value = "申请方", notes = "积分结算2.1")
    @RequestMapping(value = "/reqfCode", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectStringStringStringVo>> selectSzhtxxPaperInvoiceReqfCode() {
        List<EnumSelectStringStringStringVo> selectVos = new ArrayList<>();

        for (SzhtxxPaperInvoiceReqfCodeEnum value : SzhtxxPaperInvoiceReqfCodeEnum.values()) {
            selectVos.add(EnumSelectStringStringStringVo
                    .builder()

                    .reqfCode(value.getReqfCode())
                    .reqfName(value.getReqfName())
                    .reqExplain(value.getReqExplain())

                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "是否使用", notes = "积分结算2.1")
    @RequestMapping(value = "/used", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSzhtxxPaperInvoiceUsed() {
        List<EnumSelectIntegerStringVo> selectVos = new ArrayList<>();

        for (SzhtxxPaperInvoiceUsedEnum value : SzhtxxPaperInvoiceUsedEnum.values()) {
            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }


}
