package com.cool.store.vo.shop;

import com.cool.store.entity.PointInfoDO;
import com.cool.store.entity.ShopInfoDO;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.*;

/**
 * @author zhangchenbiao
 * @FileName: PointToDoVO
 * @Description:
 * @date 2024-04-22 14:56
 */
@Data
public class RentInfoToDoVO {

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

    @ApiModelProperty("加盟商名称")
    private String lineUsername;

    @ApiModelProperty("电话号码")
    private String lineMobile;

    @ApiModelProperty("铺位id")
    private Long pointId;

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

    @ApiModelProperty("店铺名称")
    private String pointName;

    @ApiModelProperty("详细地址")
    private String address;

    @ApiModelProperty("所属大区")
    private String regionNodeName;

    @ApiModelProperty("提交时间")
    private Date submitTime;

    @ApiModelProperty("阶段")
    private Integer shopSubStageStatus;

    public static List<RentInfoToDoVO> convert(List<RentInfoToDoVO> list, Map<Long, ShopInfoDO> shopPointMap, Map<Long, PointInfoDO> pointMap, Map<Long, String> regionNameMap, Map<Long, Date> rentContractSubmitTimeMap){
        if(CollectionUtils.isEmpty(list)){
            return Lists.newArrayList();
        }
        List<RentInfoToDoVO> resultList = new ArrayList<>();
        for (RentInfoToDoVO rent : list) {
            ShopInfoDO shopInfo = shopPointMap.get(rent.getShopId());
            if(Objects.isNull(shopInfo)){
                continue;
            }
            PointInfoDO pointInfo = pointMap.get(shopInfo.getPointId());
            if(Objects.nonNull(pointInfo)){
                rent.setPointName(pointInfo.getPointName());
                rent.setAddress(pointInfo.getAddress());
            }
            rent.setPointId(shopInfo.getPointId());
            rent.setRegionNodeName(regionNameMap.get(shopInfo.getRegionId()));
            rent.setSubmitTime(rentContractSubmitTimeMap.get(rent.getShopId()));
            resultList.add(rent);
        }
        return resultList;
    }

}
