package user.company;

import com.alibaba.fastjson.JSONObject;
import common.Resp;
import config.Config;
import util.HttpUtil;
import util.Tools;
import util.ZxlSDKUtil;

public class RegisterCompany {
    String epName;
    String creditCode;
    int busiLicenseId;
    String representativeName;
    String contact;
    String mobile;
    String idcard;
    int cardType;
    int businessType;
    String platformPubKey;
    String platformSignData;

    public RegisterCompany() {
    }

    public RegisterCompany(String epName, String creditCode, int busiLicenseId, String representativeName, String contact, String mobile, String idcard, int cardType, int businessType) {
        this.epName = epName;
        this.creditCode = creditCode;
        this.busiLicenseId = busiLicenseId;
        this.representativeName = representativeName;
        this.contact = contact;
        this.mobile = mobile;
        this.idcard = idcard;
        this.cardType = cardType;
        this.businessType = businessType;
    }

    public String register() throws Exception {
        this.platformPubKey = Config.platformPubKey;
        this.platformSignData = ZxlSDKUtil.signByPriKey(Config.platformPrivateKey,
                Tools.getSignData(this.epName, this.creditCode, this.representativeName, this.contact, this.mobile, this.idcard));

        JSONObject params = Tools.getJson(this);
        Resp resp = HttpUtil.apiPostJsonX("https://open.zxchain.qq.com/api/v1/user/register/company_platform/down_grade",
                params, ZxlSDKUtil.generateApiSign());

        return resp.getData().get("userIdentification").toString();
    }

    public String getEpName() {
        return epName;
    }

    public void setEpName(String epName) {
        this.epName = epName;
    }

    public String getCreditCode() {
        return creditCode;
    }

    public void setCreditCode(String creditCode) {
        this.creditCode = creditCode;
    }

    public int getBusiLicenseId() {
        return busiLicenseId;
    }

    public void setBusiLicenseId(int busiLicenseId) {
        this.busiLicenseId = busiLicenseId;
    }

    public String getRepresentativeName() {
        return representativeName;
    }

    public void setRepresentativeName(String representativeName) {
        this.representativeName = representativeName;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public int getCardType() {
        return cardType;
    }

    public void setCardType(int cardType) {
        this.cardType = cardType;
    }

    public int getBusinessType() {
        return businessType;
    }

    public void setBusinessType(int businessType) {
        this.businessType = businessType;
    }

    public String getPlatformPubKey() {
        return platformPubKey;
    }

    public void setPlatformPubKey(String platformPubKey) {
        this.platformPubKey = platformPubKey;
    }

    public String getPlatformSignData() {
        return platformSignData;
    }

    public void setPlatformSignData(String platformSignData) {
        this.platformSignData = platformSignData;
    }
}

