package com.cool.store.vo.shop;

import com.cool.store.entity.ShopInfoDO;
import com.cool.store.entity.ShopStageInfoDO;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * @author zhangchenbiao
 * @FileName: MiniHomePageShopVO
 * @Description:
 * @date 2024-04-11 16:50
 */
@Data
public class MiniShopPageVO {

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

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

    @ApiModelProperty("店铺编码")
    private String shopCode;

    @ApiModelProperty("加盟合同签约完成标识，0-未完成，1-完成")
    private Boolean flag;

    public MiniShopPageVO(Long shopId, String shopName,String shopCode,Boolean flag) {
        this.shopId = shopId;
        this.shopName = shopName;
        this.shopCode = shopCode;
        this.flag = flag;
    }

    public static List<MiniShopPageVO> convertList(List<ShopInfoDO> shopInfoList, Map<Long, ShopStageInfoDO> stageMap ) {
        List<MiniShopPageVO> resultList = new ArrayList<>();
        for (ShopInfoDO shopInfo : shopInfoList) {
            ShopStageInfoDO stageInfoDO = stageMap.get(shopInfo.getId());
            Boolean flag = Boolean.FALSE;
            if (Objects.nonNull(stageInfoDO)) {
                if (ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_84.getShopSubStageStatus().equals(stageInfoDO.getShopSubStageStatus())) {
                    flag = Boolean.TRUE;
                }
            }
            resultList.add(new MiniShopPageVO(shopInfo.getId(), shopInfo.getShopName(),shopInfo.getShopCode(),flag));
        }
        return resultList;
    }

}
