package com.cool.store.request;

import com.cool.store.entity.LicenseTransactDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@Data
public class SubmitLicenseRequest {

    @ApiModelProperty("主键id")
    private Long id;

    private Long shopId;

    @ApiModelProperty("营业执照拍照上传")
    private String licenseUrl;

    @ApiModelProperty("营业执照名称")
    private String licenseName;

    @ApiModelProperty("营业执照类型 0.个体工商户 1.有限责任公司 2.独资企业 3.自然人经营")
    private Integer licenseType;

    @ApiModelProperty("营业执照上的法人")
    private String licenseLegalPerson;

    @ApiModelProperty("统一社会信用代码")
    private String socialCreditCode;

    @ApiModelProperty("发证日期")
    private Date issueTime;

    @ApiModelProperty("营业执照经营场所")
    private String licenseAddress;

    @ApiModelProperty("有效期类型 0：长期有效（不用传validity） 1：效期内")
    private Integer validityType;

    @ApiModelProperty("有效期")
    private Date validity;


    @ApiModelProperty("法人双手持身份证正面+营业执照")
    private String idCardAndLicense1;

    @ApiModelProperty("法人双手持身份证反面+营业执照")
    private String idCardAndLicense2;

    @ApiModelProperty("食品经营许可证图片上传")
    private String foodLicenseUrl;

    @ApiModelProperty("经营者")
    private String operator;

    @ApiModelProperty("食品经营许可证上的法人")
    private String foodLicenseLegalPerson;

    @ApiModelProperty("食营经营场所")
    private String businessPremises;

    @ApiModelProperty("主体业态")
    private String mainBusiness;

    @ApiModelProperty("经营项目")
    private String businessProject;

    @ApiModelProperty("许可证编号")
    private String foodLicenseCode;

    @ApiModelProperty("许可证开始时间")
    private Date foodLicenseStartTime;

    @ApiModelProperty("许可证截止时间")
    private Date foodLicenseEndTime;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("备注图片")
    private String remarkUrl;

    @ApiModelProperty("0:保存 1：提交到待审核 2:未通过 3:已通过 ")
    private Integer submitStatus;


    public LicenseTransactDO toLicenseTransactDO() {
        LicenseTransactDO licenseTransactDO = new LicenseTransactDO();
        licenseTransactDO.setLicenseType(this.licenseType);
        licenseTransactDO.setLicenseLegalPerson(this.licenseLegalPerson);
        licenseTransactDO.setLicenseAddress(this.licenseAddress);
        licenseTransactDO.setIssueTime(this.issueTime);
        licenseTransactDO.setMainBusiness(this.mainBusiness);
        licenseTransactDO.setOperator(this.operator);
        licenseTransactDO.setFoodLicenseLegalPerson(this.foodLicenseLegalPerson);
        licenseTransactDO.setBusinessProject(this.businessProject);
        licenseTransactDO.setFoodLicenseRemark(this.remark);
        licenseTransactDO.setRemarkUrl(this.remarkUrl);
        licenseTransactDO.setShopId(this.shopId);
        licenseTransactDO.setBusinessLicense(this.licenseName);
        licenseTransactDO.setCreditCode(this.socialCreditCode);
        licenseTransactDO.setCreditUrl(this.licenseUrl);
        if (this.validityType == 0){
            licenseTransactDO.setValidity(null);
        }else if (this.validityType == 1){
            licenseTransactDO.setValidity(this.validity);
        }
        licenseTransactDO.setIdCardPositiveCreditUrl(this.idCardAndLicense1);
        licenseTransactDO.setIdCardNegativeCreditUrl(this.idCardAndLicense2);
        licenseTransactDO.setFoodBusinessLicenseCode(this.foodLicenseCode);
        licenseTransactDO.setFoodLicenseAddress(this.businessPremises);
        licenseTransactDO.setFoodBusinessStartTime(this.foodLicenseStartTime);
        licenseTransactDO.setFoodBusinessEndTime(this.foodLicenseEndTime);
        licenseTransactDO.setFoodBusinessLicenseUrl(this.foodLicenseUrl);
        licenseTransactDO.setSubmitStatus(this.submitStatus);
        return licenseTransactDO;
    }
}
