package com.sheep.gamegroup.model.entity;

import com.kfzs.duanduan.utils.NumberFormatUtils;
import com.sheep.gamegroup.util.TimeUtil;

import java.util.Locale;

/**
 * Created by realicing on 2018/9/4.
 * realicing@sina.com
 * <p>
 * "name": "tesat",
 * "icon": "http:\/\/staticcdn.kuaifazs.com\/upload\/static\/201807\/12\/0a\/35\/HOib9G.png",
 * "online_time": 1531382193,
 * "deadline": 1533023768,
 * "gift_ratio": 0,
 * "consume_amount": 0,
 * "Log": {
 * "Id": 450,
 * "Type": 1,
 * "Amount": 50,
 * "CreateTime": 1536022825,
 * "UserId": 63096,
 * "GameId": "",
 * "ConsumptionAmount": 0,
 * "SurplusAmount": 0
 * }
 */
public class VoucherUseLog {
    private String name;

    private String icon;

    private int online_time;

    private int deadline;

    private int gift_ratio;

    private int consume_amount;

    private VoucherRecord Log;

    public void setName(String name) {
        this.name = name;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public int getOnline_time() {
        return online_time;
    }

    public void setOnline_time(int online_time) {
        this.online_time = online_time;
    }

    public int getDeadline() {
        return deadline;
    }

    public void setDeadline(int deadline) {
        this.deadline = deadline;
    }

    public int getGift_ratio() {
        return gift_ratio;
    }

    public void setGift_ratio(int gift_ratio) {
        this.gift_ratio = gift_ratio;
    }

    public int getConsume_amount() {
        return consume_amount;
    }

    public void setConsume_amount(int consume_amount) {
        this.consume_amount = consume_amount;
    }

    public VoucherRecord getLog() {
        return Log;
    }

    public void setLog(VoucherRecord log) {
        Log = log;
    }

    public String getName() {
        return name;
    }

    public String getIcon() {
        return icon;
    }




    @Override
    public boolean equals(Object obj) {
        try {
            return obj instanceof VoucherUseLog && ((VoucherUseLog) obj).getLog().getId() == getLog().getId();
        } catch (Exception e) {
            return true;
        }
    }





    /**
     * 福利内容
     *
     * @return
     */
    public String getGiftRatioText() {
        return String.format(Locale.CHINA, "充值%s元", this.Log != null ? NumberFormatUtils.retainMost2(this.Log.getConsumptionAmount()): "");
    }

    /**
     * 剩余金额
     *
     * @return
     */
    public String getSurplusText() {
        return String.format(Locale.CHINA, "剩余<font color='#7AD5F6'>%s</font>元", this.Log != null ? NumberFormatUtils.retainMost2(this.Log.getSurplusAmount()) : "0");
    }

    public String getDateText() {
        return this.Log != null ? TimeUtil.TimeStamp2Date(this.Log.getCreateTime(), "yyyy/MM/dd") : "";
    }

    /**
     * -金额
     *
     * @return
     */
    public String getConsumptionAmountText() {
        return String.format(Locale.CHINA, "-%s", this.Log != null ? NumberFormatUtils.retainMost2(this.Log.getAmount()) : "0");
    }
}
