package cn.superdesk.uniorder.controller._common;

import cn.superdesk.uniorder.common.enums.scheduler.jd.ScheduleTaskAccountingStatusEnum;
import cn.superdesk.uniorder.common.enums.scheduler.jd.ScheduleTaskCheckStateEnum;
import cn.superdesk.uniorder.common.enums.scheduler.jd.ScheduleTaskProcessStateEnum;
import cn.superdesk.uniorder.common.enums.thirdpart.jd.SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.rest.response.ResponseResultOuterUtils;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.utils.AnDtoSortedListUtils;
import cn.superdesk.uniorder.dto.vo._common.EnumSelectIntegerStringVo;
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/6/8 7:39 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/6/8 7:39 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Api(value = "下拉列表-京东", tags = {"下拉列表-京东"})
@Slf4j
@RestController
@RequestMapping("/Scheduler/select/jd")
public class SchedulerJdSelectController extends BaseController {

    @ApiOperation(value = "供应商结算-京东对账-导入状态", notes = "v2.5")
    @RequestMapping(value = "/scheduleTaskProcessState", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectScheduleTaskProcessStateEnum() {

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

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

        List<Integer> orderList = Arrays.asList(
                ScheduleTaskProcessStateEnum.导入中.getKey(),
                ScheduleTaskProcessStateEnum.导入成功.getKey(),
                ScheduleTaskProcessStateEnum.导入失败.getKey()
        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

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

    @ApiOperation(value = "供应商结算-京东对账-对账状态", notes = "v2.5")
    @RequestMapping(value = "/scheduleTaskAccountingStatus", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectScheduleTaskAccountingStatusEnum() {

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

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

        List<Integer> orderList = Arrays.asList(
                ScheduleTaskAccountingStatusEnum.待对账.getKey(),
                ScheduleTaskAccountingStatusEnum.对账中.getKey(),
                ScheduleTaskAccountingStatusEnum.对账完成.getKey()
        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

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

    @ApiOperation(value = "供应商结算-京东对账-对账结果", notes = "v2.5")
    @RequestMapping(value = "/scheduleTaskCheckState", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectScheduleTaskCheckStateEnum() {

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

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

        List<Integer> orderList = Arrays.asList(
                ScheduleTaskCheckStateEnum.正常.getKey(),
                ScheduleTaskCheckStateEnum.异常.getKey(),
                ScheduleTaskCheckStateEnum.待对账.getKey()
        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

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

    @ApiOperation(value = "供应商结算-京东对账-对账类型", notes = "v2.5")
    @RequestMapping(value = "/sysQuartzScheduleTaskStatementOfAccountStatementOfAccountType", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectIntegerStringVo>> selectSysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum() {

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

        for (SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum value :
                SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum.values()) {

            selectVos.add(EnumSelectIntegerStringVo
                    .builder()
                    .key(value.getKey())
                    .desc(value.getDesc())
                    .build()
            );
        }

        List<Integer> orderList = Arrays.asList(
                SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum.客户结算.getKey(),
                SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum.供应商结算.getKey(),
                SysQuartzScheduleTaskStatementOfAccountStatementOfAccountTypeEnum.京东账单.getKey()
        );
        AnDtoSortedListUtils.sortEnumSelectIntegerStringVo(orderList, selectVos);

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


}
