package com.cool.store.vo.point;

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

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

@Data
public class PointPageVO {

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

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

    @ApiModelProperty("铺位编号")
    private String pointCode;

    @ApiModelProperty("所属大区")
    private Long regionId;

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

    @ApiModelProperty("铺位状态 1.采集中、2.已评估、3.待审核、5.已审核、6.已签约、7.已失效")
    private Integer pointStatus;

    @ApiModelProperty("铺位得分")
    private Integer pointScore;

    @ApiModelProperty("铺位面积")
    private String pointArea;

    @ApiModelProperty("拓展专员")
    private String developmentManagerUsername;

    @ApiModelProperty("拓展时间")
    private Date developmentTime;

    @ApiModelProperty("选择状态0.未选择, 1.已被选择")
    private Integer selectStatus;

    @ApiModelProperty("铺位地址")
    private String address;

    @ApiModelProperty("创建时间")
    private Date createTime;

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



    public static List<PointPageVO> convertVO(List<PointInfoDO> pointList, Map<String, String> usernameMap, Map<Long, String> regionNameMap) {
        if(CollectionUtils.isEmpty(pointList)){
            return Lists.newArrayList();
        }
        List<PointPageVO> resultList = new ArrayList<>();
        for (PointInfoDO pointInfo : pointList) {
            PointPageVO pointPageVO = new PointPageVO();
            pointPageVO.setPointId(pointInfo.getId());
            pointPageVO.setPointName(pointInfo.getPointName());
            pointPageVO.setPointCode(pointInfo.getPointCode());
            pointPageVO.setRegionId(pointInfo.getRegionId());
            pointPageVO.setRegionNodeName(regionNameMap.get(pointInfo.getRegionId()));
            pointPageVO.setPointStatus(pointInfo.getPointStatus());
            if(PointStatusEnum.POINT_STATUS_4.getCode().equals(pointInfo.getPointStatus())){
                pointPageVO.setPointStatus(PointStatusEnum.POINT_STATUS_3.getCode());
            }
            pointPageVO.setPointScore(pointInfo.getPointScore());
            pointPageVO.setPointArea(pointInfo.getPointArea());
            pointPageVO.setDevelopmentManagerUsername(usernameMap.get(pointInfo.getDevelopmentManager()));
            pointPageVO.setDevelopmentTime(pointInfo.getDevelopmentTime());
            pointPageVO.setSelectStatus(pointInfo.getSelectStatus());
            pointPageVO.setAddress(pointInfo.getAddress());
            pointPageVO.setCreateTime(pointInfo.getCreateTime());
            pointPageVO.setUpdateTime(pointInfo.getUpdateTime());
            resultList.add(pointPageVO);
        }
        return resultList;
    }

}