package com.cool.store.vo;

import cn.hutool.core.date.DateUtil;
import com.cool.store.dto.partner.PrivateSeaLineDTO;
import com.cool.store.entity.HyPartnerInterviewPlanDO;
import com.cool.store.utils.CoolDateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.time.DateUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author suzhuhong
 * @Date 2023/5/30 21:38
 * @Version 1.0
 */
@Data
@ApiModel
public class PrivateSeaLineListVo {


    @ApiModelProperty("线索ID")
    private Long lineId;

    @ApiModelProperty("加盟商用户ID")
    private String partnerId;

    @ApiModelProperty("流程阶段:1意向申请审核;2预约面试时间;3加盟资格面试;4分配选址开发经理;5商圈点位评估;6上传店铺租赁信息;7完善加盟签约信息;8支付加盟费用;9签订加盟合同")
    private String workflowStage;

    @ApiModelProperty("流程子状态")
    private String workflowStatus;

    @ApiModelProperty("加盟商用户名称")
    private String partnerUserName;

    @ApiModelProperty("加盟商用户手机号")
    private String partnerUserPhone;

    @ApiModelProperty("截止时间")
    private String deadline;

    @ApiModelProperty("招商经理")
    private String investmentManager;

    @ApiModelProperty("招商经理")
    private String investmentManagerName;

    @ApiModelProperty("开发经理")
    private String developmentManager;

    @ApiModelProperty("开发经理")
    private String developmentManagerName;

    @ApiModelProperty("意向开店区域")
    private String wantShopArea;

    @ApiModelProperty("意向开店区域名称")
    private String wantShopAreaName;

    @ApiModelProperty("0不接受调剂、1全国调剂、2省内调剂、3市内调剂")
    private Integer acceptAdjustType;

    @ApiModelProperty("更新时间")
    private String updateTime;

    @ApiModelProperty("门店编码")
    private String storeCode;

    @ApiModelProperty("门店名称")
    private String storeName;

    @ApiModelProperty("线索状态")
    private Integer lineStatus;

    @ApiModelProperty("推荐加盟商ID")
    private String recommendPartnerId;

    @ApiModelProperty("推荐加盟商名称")
    private String recommendPartnerName;

    private String recommendPartnerMobile;

    private Long interviewPlanId;

    private Date startTime;

    private String investmentManagerMobile;


    public static List<PrivateSeaLineListVo> convertList(List<PrivateSeaLineDTO> list, Map<String, String> finalDevManagerMap, Map<String, String> wantShopAreaNameMap,Map<Long, HyPartnerInterviewPlanDO> hyPartnerInterviewPlanDOMap){
        List<PrivateSeaLineListVo> resultList = new ArrayList<>();
        for (PrivateSeaLineDTO x : list) {
            PrivateSeaLineListVo privateSeaLineListVo = new PrivateSeaLineListVo();
            privateSeaLineListVo.setLineId(x.getLineId());
            privateSeaLineListVo.setLineStatus(x.getLineStatus());
            privateSeaLineListVo.setPartnerId(x.getPartnerId());
            privateSeaLineListVo.setWorkflowStatus(x.getWorkflowStatus());
            String deadLine = DateUtil.format(x.getDeadline(), CoolDateUtils.DATE_FORMAT_SEC_2);
            privateSeaLineListVo.setDeadline(deadLine);
            privateSeaLineListVo.setPartnerUserPhone(x.getPartnerUserPhone());
            privateSeaLineListVo.setPartnerUserName(x.getPartnerUserName());
            privateSeaLineListVo.setAcceptAdjustType(x.getAcceptAdjustType());
            privateSeaLineListVo.setInvestmentManagerName(x.getInvestmentManager());
            privateSeaLineListVo.setDevelopmentManager(x.getDevelopmentManager());
            privateSeaLineListVo.setInvestmentManagerName(x.getInvestmentManagerName());
            privateSeaLineListVo.setStoreCode(x.getStoreCode());
            privateSeaLineListVo.setInvestmentManagerMobile(x.getInvestmentManagerMobile());
            privateSeaLineListVo.setStoreName(x.getStoreName());
            String updateTime = DateUtil.format(x.getUpdateTime(), CoolDateUtils.DATE_FORMAT_SEC_2);
            privateSeaLineListVo.setUpdateTime(updateTime);
            privateSeaLineListVo.setRecommendPartnerId(x.getRecommendPartnerId());
            privateSeaLineListVo.setRecommendPartnerMobile(x.getRecommendPartnerId());
            privateSeaLineListVo.setWantShopArea(x.getWantShopArea());
            privateSeaLineListVo.setWantShopAreaName(wantShopAreaNameMap.get(x.getWantShopArea()));
            privateSeaLineListVo.setInvestmentManager(x.getInvestmentManager());
            privateSeaLineListVo.setRecommendPartnerName(x.getRecommendPartnerName());
            privateSeaLineListVo.setRecommendPartnerMobile(x.getRecommendPartnerMobile());
            privateSeaLineListVo.setWorkflowStage(x.getWorkflowStage());
            privateSeaLineListVo.setWantShopArea(x.getWantShopArea());
            privateSeaLineListVo.setWorkflowStage(x.getWorkflowStage());
            privateSeaLineListVo.setStartTime(hyPartnerInterviewPlanDOMap.getOrDefault(x.getLineId(),new HyPartnerInterviewPlanDO()).getStartTime());
            privateSeaLineListVo.setInterviewPlanId(hyPartnerInterviewPlanDOMap.getOrDefault(x.getLineId(),new HyPartnerInterviewPlanDO()).getId());
            privateSeaLineListVo.setDevelopmentManagerName(finalDevManagerMap.get(x.getDevelopmentManager()));
            resultList.add(privateSeaLineListVo);
        }
        return resultList;
    }

}
