package com.cool.store.request;

import com.cool.store.entity.ShopAuditInfoDO;
import com.cool.store.enums.AuditResultTypeEnum;
import com.cool.store.enums.AuditStatusEnum;
import com.cool.store.enums.AuditTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * @Auther: WangShuo
 * @Date: 2024/04/22/下午3:52
 * @Version 1.0
 * @注释:
 */
@Data
public class OpeningOperationPlanAuditRequest {

    @ApiModelProperty("店铺id")
    private Long shopId;

    @ApiModelProperty("审核结果状态：0.待审核 1. 通过 2. 拒绝")
    private Integer resultType;

    @ApiModelProperty("通过原因")
    private String passReason;

    @ApiModelProperty("拒绝原因")
    private String rejectReason;

    public ShopAuditInfoDO toShopAuditInfoDO() {
        ShopAuditInfoDO shopAuditInfoDO = new ShopAuditInfoDO();
        shopAuditInfoDO.setShopId(this.shopId);
        shopAuditInfoDO.setAuditType(AuditTypeEnum.OPENING_OPERATION_PLAN.getCode());
        if (this.resultType.equals(AuditStatusEnum.PASS.getCode())) {
            shopAuditInfoDO.setResultType(AuditResultTypeEnum.PASS.getCode());
            shopAuditInfoDO.setPassReason(this.passReason);
        }else {
            shopAuditInfoDO.setResultType(AuditResultTypeEnum.REJECT.getCode());
            shopAuditInfoDO.setRejectReason(this.rejectReason);
        }

        shopAuditInfoDO.setCreateTime(new Date());
        return shopAuditInfoDO;
    }
}
