package com.gingersoft.supply_chain.mvp.bean;

import com.gingersoft.supply_chain.R;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import lombok.Data;

/**
 * @author 宇航.
 * User: admin
 * Date: 2020/11/19
 * Time: 18:01
 * Use: 供應商信息
 */
@Data
public class SupplierInfoBean implements Serializable {
    private static final long serialVersionUID = 9167054021101810555L;

    private int id;
    private String supplierNo;
    private String contactInformation;
    private String supplierName;
    private String address;
    private String remarks;
    private String contacts;
    private String createDate;
    private int restaurantId;
    private int brandId;
    private int uid;
    private int countryId;
    private long createTime;
    private long updateTime;
    private Integer deletes;
    /**
     * 最低採購
     */
    private double minimumAmount;
    /**
     * 運費
     */
    private double shipping;


    private List<SupplierContacts> supplierContacts;

    public SupplierInfoBean(String supplierName, String address, String contactInformation, String contacts, String createDate) {
        this.contactInformation = contactInformation;
        this.supplierName = supplierName;
        this.address = address;
        this.contacts = contacts;
        this.createDate = createDate;
    }

    public SupplierInfoBean() {
    }

    public static SupplierInfoBean generateSupplierByFood(PurchaseFoodBean purchaseFoodBean) {
        SupplierInfoBean supplierInfoBean = new SupplierInfoBean();
        supplierInfoBean.setShipping(purchaseFoodBean.getShipping());
        supplierInfoBean.setSupplierName(purchaseFoodBean.getSupplierName());
        supplierInfoBean.setMinimumAmount(purchaseFoodBean.getMinimumAmount());
        supplierInfoBean.setAddress(purchaseFoodBean.getAddress());
        supplierInfoBean.setId(purchaseFoodBean.getSupplierId());
        return supplierInfoBean;
    }

    @Data
    public static class SupplierContacts implements Serializable {
        private static final long serialVersionUID = -4586838211196656718L;
        private int id;
        private int supplierId;
        private String configText;
        //是否默認
        private boolean isDefault;

        private long createTime;
        private long updateTime;
        /**
         * 聯繫方式
         * 1、郵箱
         * 2、Whatsapp
         * 3、ehat
         * 4、line
         * 5、Kakao
         * 6、Talk
         * 7、SMS
         * 8、efax
         */
        private int type;
        public final static int Email = 1;
        //接收軟件
        public final static int Whatsapp = 2;
        public final static int WeChat = 3;
        public final static int Line = 4;
        public final static int Kakao_Talk = 5;
        public final static int SMS = 6;
        public final static int Efax = 7;

        public static String getContractTitleByType(int type) {
            switch (type) {
                case Email:
                    return "Email";
                case Whatsapp:
                    return "WhatsApp";
                case WeChat:
                    return "WeChat";
                case Line:
                    return "Line";
                case Kakao_Talk:
                    return "Kakao Talk";
                case SMS:
                    return "SMS";
                case Efax:
                    return "Efax";
                default:
                    return "";
            }
        }

        public static @Resource
        int getContractPicByType(int type) {
            switch (type) {
                case Email:
                    return R.drawable.ic_email;
                case Whatsapp:
                    return R.drawable.ic_whatsapp;
                case WeChat:
                    return R.drawable.ic_wechat;
                case Line:
                    return R.drawable.ic_line;
                case Kakao_Talk:
                    return R.drawable.ic_talk;
                case SMS:
                    return R.drawable.ic_sms;
                case Efax:
                    return R.drawable.img_small_default;
                default:
                    return R.drawable.img_small_default;
            }
        }

        public SupplierContacts() {
        }

        public SupplierContacts(String configText, int type, boolean isDefault) {
            this.configText = configText;
            this.type = type;
            this.isDefault = isDefault;
        }
    }
}
