package com.datarecovery.master.data.api.bean;


import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.datarecovery.master.BR;
import com.datarecovery.master.R;
import com.datarecovery.master.module.member.MemberType;
import com.google.gson.annotations.SerializedName;

import java.util.Objects;

public class MemberGoodsBean extends BaseObservable {
    @SerializedName("id")
    private int id;
    @SerializedName("name")
    private String name;
    @SerializedName("auths")
    private String auths;
    @SerializedName("amount")
    private int amount;
    @SerializedName("originalAmount")
    private int originalAmount;
    @SerializedName("sort")
    private int sort;
    @SerializedName("description")
    private String description;

    @SerializedName("popular")
    private boolean popular;

    private boolean isSelect;

    private String[] scenesArray;

    @Bindable
    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
        notifyPropertyChanged(BR.select);
    }

    public void setScenesArray(String[] scenesArray) {
        this.scenesArray = scenesArray;
    }


    public String[] getScenesArray() {
        return scenesArray;
    }

    public boolean isPopular() {
        return popular;
    }

    public int getSort() {
        return sort;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getAuths() {
        return auths;
    }

    public int getAmount() {
        return amount;
    }

    public float getRMBAmount() {
        return (float) (amount / 100.0);
    }

    public float getOriginalAmount() {
        return originalAmount / 100f;
    }


    public String getDescription() {
        return description;
    }


    public int getUnlimitedImg() {
        if (Objects.equals(auths, MemberType.APP_IMAGE_CLEAN)) {
            return R.drawable.bg_member_clear_unlimited;
        } else {
            return R.drawable.bg_member_recover_unlimited;
        }
    }

    public int getValidityPeriod() {
        if (!Objects.equals(auths, MemberType.APP_IMAGE_CLEAN) || popular) {
            return R.drawable.bg_member_permanent;
        } else {
            return R.drawable.bg_member_one_aging;
        }
    }


    public String getCopywriting() {
        if (Objects.equals(auths, MemberType.APP_SUPER_RECOVER)) {
            return "解锁全部恢复功能 (微信消息、微信好友、图片、视频、文件、音频)";
        } else if (Objects.equals(auths, MemberType.APP_IMAGE_CLEAN)) {
            if (popular) {
                return "该服务可永久无上限清除相册、微信、QQ图片清除";
            } else {
                return "该服务在一年内可以无上限清除相册、微信、QQ图片清除";
            }
        } else if (Objects.equals(auths, MemberType.APP_WX_MESSAGE_RECOVER)) {
            return "恢复、查看、导出微信消息单项服务";
        } else if (Objects.equals(auths, MemberType.APP_WX_FRIEND_RECOVER)) {
            return "恢复、查看、导出微信好友单项服务";
        } else if (Objects.equals(auths, MemberType.APP_IMAGE_RECOVER)) {
            return "全力恢复图片数据";
        } else if (Objects.equals(auths, MemberType.APP_FILE_RECOVER)) {
            return "恢复文件单项数据";
        } else if (Objects.equals(auths, MemberType.APP_VIDEO_RECOVER)) {
            return "恢复视频单项数据";
        } else if (Objects.equals(auths, MemberType.APP_AUDIO_RECOVER)) {
            return "恢复音频单项数据";
        }
        return "";
    }
}
