package com.cool.store.request;

import com.cool.store.entity.LineInfoDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.enums.point.ShopStageEnum;
import com.cool.store.enums.point.ShopStatusEnum;
import com.cool.store.utils.NumberConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @Author: WangShuo
 * @Date: 2025/01/08/下午2:20
 * @Version 1.0
 * @注释:
 */
@Data
public class AddBranchShopRequest {
    @NotNull
    private Long lineId;
    @ApiModelProperty("门店名称")
    private String shopName;
    @ApiModelProperty("意向开店区域")
    @NotNull
    private Long wantShopAreaId;

    @NotNull
    @Min(1)
    @ApiModelProperty(" 加盟模式//'1-社会加盟模式/加盟部加盟店 2-强加盟模式/加盟公司加盟店 3-加盟公司自有店',4-强加盟")
    private Integer joinMode;
    @NotBlank
    @ApiModelProperty("'加盟品牌1,\"正新鸡排\"，2,\"正新三明治\"，3,\"正烧记\"4,\"大鼓米线\"5,\"串小妹\"6,\"茂掌柜\"'")
    private String franchiseBrand;
    @ApiModelProperty("督导")
    private String investmentManagerUserId;
    @NotNull
    @ApiModelProperty("所属大区")
    private Long regionId;

    @NotNull
    @ApiModelProperty("所属管理区域id")
    private Long managerRegionId;

    public ShopInfoDO toDO(AddBranchShopRequest request, LineInfoDO lineInfo) {
        ShopInfoDO shopInfoDO = new ShopInfoDO();
        shopInfoDO.setLineId(request.getLineId());
        shopInfoDO.setShopName(StringUtils.isNotBlank(request.getShopName())?request.getShopName():"店铺" + NumberConverter.convertArabicToChinese(lineInfo.getWantShopNum()+1));
        shopInfoDO.setRegionId(request.getRegionId());
        shopInfoDO.setShopName(request.getShopName());
        shopInfoDO.setWantShopAreaId(request.getWantShopAreaId());
        shopInfoDO.setJoinMode(request.getJoinMode());
        shopInfoDO.setInvestmentManager(request.getInvestmentManagerUserId());
        shopInfoDO.setDevelopmentManager(request.getInvestmentManagerUserId());
        shopInfoDO.setSupervisorUserId(request.getInvestmentManagerUserId());
        shopInfoDO.setCreateTime(new Date());
        shopInfoDO.setShopStatus(ShopStatusEnum.ING.getCode());
        shopInfoDO.setShopStage(ShopStageEnum.SHOP_STAGE_1.getShopStage());
        shopInfoDO.setPartnerId(lineInfo.getPartnerId());
        shopInfoDO.setFranchiseBrand(request.getFranchiseBrand());
        shopInfoDO.setManagerRegionId(request.getManagerRegionId());
        return shopInfoDO;
    }
}
