package com.slodon.b2b2c.vo.member;

import com.slodon.b2b2c.core.i18n.Language;
import com.slodon.b2b2c.enums.WebSiteConstant;
import com.slodon.b2b2c.member.pojo.MemberEnquiry;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * @author cyan
 */
@Data
public class MemberEnquiryVO implements Serializable {

    private static final long serialVersionUID = -8426680439937326616L;
    private Long id;

    private String name;

    private String email;

    private String phoneCode;

    private String phone;

    private Integer quantity;

    private String company;

    private String message;

    private String ip;

    private Date createTime;

    private String pageUrl;

    private String itemType;

    private String itemTypeStr;

    private String itemName;

    private Long itemId;

    private Long storeId;

    public MemberEnquiryVO(MemberEnquiry memberEnquiry,String webSite) {
        id = memberEnquiry.getId();
        name = memberEnquiry.getName();
        email = memberEnquiry.getEmail();
        phoneCode = memberEnquiry.getPhoneCode();
        phone = memberEnquiry.getPhone();
        quantity = memberEnquiry.getQuantity();
        company = memberEnquiry.getCompany();
        message = memberEnquiry.getMessage();
        ip = memberEnquiry.getIp();
        createTime = memberEnquiry.getCreateTime();
        pageUrl = memberEnquiry.getPageUrl();
        itemType = memberEnquiry.getItemType();
        itemTypeStr = memberEnquiry.getItemType();
        if(!WebSiteConstant.MEMBER_OVERSEA.equals(webSite)){
            itemTypeStr = getEnquiryTypeText(memberEnquiry.getItemType());
        }
        itemId = memberEnquiry.getItemId();
        itemName = memberEnquiry.getItemName();
        storeId = memberEnquiry.getStoreId();
    }

    /**
     * @param itemType
     * @return
     */
    public static String getEnquiryTypeText(String itemType) {
        String value = "";
        if (StringUtils.isEmpty(itemType)) {
            return null;
        }
        switch (itemType) {
            case "MALL":
                value = "平台端";
                break;
            case "SHOP":
                value = "商户端";
                break;
            case "GOODS":
                value = "商品";
                break;
            default:
                break;
        }
        return value;
    }
}
