package com.yuchen.saas.payment.api.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.nest.springwrap.core.log.exception.ServiceException;

/**
 * 钱包枚举
 */
@Data
public class WalletBillEnum {

    /**
     * 钱包类型枚举类
     */
    @Getter
    @AllArgsConstructor
    public enum WalletStateEnum {

        NORMAL("1", "正常"),
        DISABLE("2", "禁用"),
        ;

        private final String code;
        private final String desc;

    }

    /**
     * 钱包类型枚举类
     */
    @Getter
    @AllArgsConstructor
    public enum WalletBillTypeEnum {

        INCOME("1", "收入"),
        EXPEND("2", "支出"),
        ;

        private final String code;
        private final String desc;

        public static WalletBillTypeEnum getEnum(String code) {
            if (StrUtil.isNotBlank(code)) {
                for (WalletBillTypeEnum e : WalletBillTypeEnum.values()) {
                    if (e.getCode().equals(code)) {
                        return e;
                    }
                }
            }
            throw new ServiceException(SaasPaymentErrorEnums.ENUMS_NOT_EXIST_ERROR.getMessage());
        }

        public static String getEnumDesc(String code) {
            if (StrUtil.isNotBlank(code)) {
                for (WalletBillTypeEnum e : WalletBillTypeEnum.values()) {
                    if (e.getCode().equals(code)) {
                        return e.getDesc();
                    }
                }
            }
            return null;
        }

    }

    // 账单来源类型（1：微信支付充值,2：后台支付充值，3：智慧充电缴费，4：智慧停车缴费...）
    // 1：钱包充值，2：充值退款，3：消费扣款， 4：消费退款， 5：钱包扣款，
    @Getter
    @AllArgsConstructor
    public enum WalletBillSourceTypeEnum {

        WECHAT_PAY("1", "微信支付充值", "1", "钱包充值"),
        BACK_PAY("2", "后台支付充值", "1","钱包充值"),
        CHARGE_EXPEND("3", "智慧充电缴费", "3","消费扣款"),
        PARK_EXPEND("4", "智慧停车缴费", "3","消费扣款"),
        WALLET_REFUND("5", "钱包退款", "2","充值退款"),
        WALLET_CHARGE_FREEZE_REFUND("6", "钱包充电费冻结", "0", "其他"),
        WALLET_CHARGE_THAW_REFUND("7", "钱包充电费解冻", "0", "其他"),
        MONTHLY_CARD_EXPEND("8", "月卡充值缴费", "3", "消费扣款"),
        TIME_FREE_EXPEND("9", "错时卡充值缴费", "3", "消费扣款"),
        OCCUPY_FEE_EXPEND("10", "占位费缴费", "3", "消费扣款"),
        PROPERTY_FEE_EXPEND("11", "物业缴费", "3", "消费扣款"),
        PROPERTY_PREPAYMENT_FEE_EXPEND("12", "物业预存款缴费", "3", "消费扣款"),
        DECORATION_DEPOSIT_FEE_EXPEND("13", "装修押金充值", "3", "消费扣款"),
        PARK_REFUND("21", "智慧停车退款", "4", "消费退款"),
        MONTHLY_CARD_REFUND("22", "月卡退卡退款", "4", "消费退款"),
        TIME_FREE_REFUND("23", "错时卡退卡退款", "4", "消费退款"),
        OCCUPY_FEE_REFUND("24", "占位费退款", "4", "消费退款"),
        CHARGE_PAY_REFUND("25", "充电费退款", "4", "消费退款"),
        PROPERTY_PAY_REFUND("26", "物业费退款", "4", "消费退款"),
        PROPERTY_PREPAYMENT_PAY_REFUND("27", "物业预存款退款", "4", "消费退款"),
        DECORATION_DEPOSIT_PAY_REFUND("28", "装修押金退款", "4", "消费退款"),
        BACK_DEDUCT_MONEY("31", "后台扣款", "5", "钱包扣款"),
        BACK_BOSS_LIMIT_DISTRIBUTION_MONEY("32", "主钱包额度分配", "5", "钱包扣款"),
        BACK_CHILD_LIMIT_DEDUCT_MONEY("33", "子钱包额度扣回", "5", "钱包扣款"),
        BACK_BOSS_LIMIT_DEDUCT_PAY("34", "主钱包额度扣回", "1","钱包充值"),
        BACK_CHILD_LIMIT_DISTRIBUTION_PAY("35", "子钱包额度分配", "1","钱包充值"),
        ;

        private final String code;
        private final String desc;
        private final String classify;
        private final String classifyName;


        public static String getEnumDesc(String code) {
            if (StrUtil.isNotBlank(code)) {
                for (WalletBillSourceTypeEnum e : WalletBillSourceTypeEnum.values()) {
                    if (e.getCode().equals(code)) {
                        return e.getDesc();
                    }
                }
            }
            return null;
        }

        public static String getClassifyDesc(String code) {
            if (StrUtil.isNotBlank(code)) {
                for (WalletBillSourceTypeEnum e : WalletBillSourceTypeEnum.values()) {
                    if (e.getCode().equals(code)) {
                        return e.getClassify();
                    }
                }
            }
            return null;
        }

    }



}
