package com.ruoyi.cai.enums;

import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
import com.ruoyi.cai.enums.account.AccountTypeEnum;
import lombok.Getter;


/**
 * 类型 1-充值 2-礼物 3-守护 4-通话
 * <p>created on 2023/12/29 20:39</p>
 * @author duet
 */
@Getter
public enum ConsumeLogType {
    RECHARGE(1),
    GIFT(2),
    GUARD(3),
    VIDEO(4),
    ;

    private final Integer code;

    ConsumeLogType(Integer code) {
        this.code = code;
    }

    public static ConsumeLogType getByCode(Integer code){
        ConsumeLogType[] values = ConsumeLogType.values();
        for (ConsumeLogType value : values) {
            if(value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }

    public static AccountChangeCodeEnum getTargetChange(ConsumeLogType type){
        if(type == RECHARGE){ // 充值
            return AccountChangeCodeEnum.RECHARGE;
        }else if(type == GIFT){
            return AccountChangeCodeEnum.GIFT_INCOME;
        }else if(type == GUARD){
            return AccountChangeCodeEnum.GUARD_INCOME;
        }else if(type == VIDEO){
            return AccountChangeCodeEnum.VIDEO_INCOME;
        }
        return null;
    }

    public static AccountChangeCodeEnum getSourceChange(ConsumeLogType type, AccountTypeEnum typeEnum){
        if(type == GIFT){
            if(typeEnum == AccountTypeEnum.COIN){
                return AccountChangeCodeEnum.GIFT_COIN_OUT;
            }else{
                return AccountChangeCodeEnum.GIFT_INCOME_COIN_OUT;
            }
        }else if(type == GUARD){
            if(typeEnum == AccountTypeEnum.COIN){
                return AccountChangeCodeEnum.GUARD_COIN_OUT;
            }else{
                return AccountChangeCodeEnum.GUARD_INCOME_COIN_OUT;
            }
        }else if(type == VIDEO){
            if(typeEnum == AccountTypeEnum.COIN){
                return AccountChangeCodeEnum.VIDEO_COIN_OUT;
            }else{
                return AccountChangeCodeEnum.VIDEO_INCOME_COIN_OUT;
            }
        }
        return null;
    }

    public static AccountChangeCodeEnum getOneInviteChange(ConsumeLogType type){
        if(type == GIFT){
            return AccountChangeCodeEnum.GIFT_INVITE;
        }else if(type == GUARD){
            return AccountChangeCodeEnum.GUARD_INVITE;
        }else if(type == VIDEO){
            return AccountChangeCodeEnum.VIDEO_INVITE;
        }else if(type == RECHARGE){ // 充值
            return AccountChangeCodeEnum.RECHARGE_INVITE;
        }
        return null;
    }


    public static AccountChangeCodeEnum getUnionChange(ConsumeLogType type){
        if(type == GIFT){
            return AccountChangeCodeEnum.UNION_INVITE;
        }else if(type == GUARD){
            return AccountChangeCodeEnum.UNION_INVITE;
        }else if(type == VIDEO){
            return AccountChangeCodeEnum.UNION_INVITE;
        }
        return null;
    }

}
