package com.bonus.canteen.core.account.v3.app.dto;

import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.common.page.PageDTO;
import com.bonus.canteen.core.pay.common.constants.PayStateEnum;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class AppTradeDetailListDTO extends PageDTO {
    @ApiModelProperty("人员id")
    private @NotNull(
            message = "{acc_single_null_custid_exception}"
    ) Long custId;
    @ApiModelProperty("开始时间")
    private LocalDateTime startDateTime;
    @ApiModelProperty("结束时间")
    private LocalDateTime endDateTime;
    @ApiModelProperty("充值状态 1-充值成功 2-充值失败 3-充值超时")
    private Integer rechargeState;
    @ApiModelProperty(
            value = "充值交易类型",
            hidden = true
    )
    private List<Integer> tradeTypeList;
    @ApiModelProperty(
            value = "支付状态集合 充值超时(1,2) 充值成功(3) 充值失败(4,5) ",
            hidden = true
    )
    private List<Integer> payStateList;

    public List<Integer> convertPayStateList() {
        if (ObjectUtil.isNull(this.getRechargeState())) {
            return Lists.newArrayList();
        } else {
            List<Integer> result = new ArrayList();
            switch (this.getRechargeState()) {
                case 1:
                    result = Collections.singletonList(PayStateEnum.PAY_SUCC.getKey());
                    break;
                case 2:
                    result = Arrays.asList(PayStateEnum.PAY_FAIL.getKey(), PayStateEnum.PAY_CLOSE.getKey());
                    break;
                case 3:
                    result = Arrays.asList(PayStateEnum.UN_PAY.getKey(), PayStateEnum.PAY_INPROCESS.getKey());
            }

            return (List) result;
        }
    }

    public Long getCustId() {
        return this.custId;
    }

    public LocalDateTime getStartDateTime() {
        return this.startDateTime;
    }

    public LocalDateTime getEndDateTime() {
        return this.endDateTime;
    }

    public Integer getRechargeState() {
        return this.rechargeState;
    }

    public List<Integer> getTradeTypeList() {
        return this.tradeTypeList;
    }

    public List<Integer> getPayStateList() {
        return this.payStateList;
    }

    public void setCustId(final Long custId) {
        this.custId = custId;
    }

    public void setStartDateTime(final LocalDateTime startDateTime) {
        this.startDateTime = startDateTime;
    }

    public void setEndDateTime(final LocalDateTime endDateTime) {
        this.endDateTime = endDateTime;
    }

    public void setRechargeState(final Integer rechargeState) {
        this.rechargeState = rechargeState;
    }

    public void setTradeTypeList(final List<Integer> tradeTypeList) {
        this.tradeTypeList = tradeTypeList;
    }

    public void setPayStateList(final List<Integer> payStateList) {
        this.payStateList = payStateList;
    }
}
