package com.cool.store.request.license;

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

import java.util.Date;
import java.util.Objects;

/**
 * @Author suzhuhong
 * @Date 2024/10/9 16:01
 * @Version 1.0
 */
@Data
public class BusinessLicenseRequest {

    @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 businessLicenseRemark;

    @ApiModelProperty("0:保存 1：提交到待审核")
    private Integer submitStatus;

    public LicenseTransactDO toLicenseTransactDO(LicenseTransactDO licenseTransactDO) {
        if (Objects.isNull(licenseTransactDO)){
            licenseTransactDO = new LicenseTransactDO();
        }
        licenseTransactDO.setId(licenseTransactDO.getId());
        licenseTransactDO.setLicenseType(this.licenseType);
        licenseTransactDO.setLicenseLegalPerson(this.licenseLegalPerson);
        licenseTransactDO.setLicenseAddress(this.licenseAddress);
        licenseTransactDO.setIssueTime(this.issueTime);
        licenseTransactDO.setBusinessLicenseRemark(this.businessLicenseRemark);
        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);
        }
        return licenseTransactDO;
    }


}
