package com.tzy.common.dto.group;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.github.dozermapper.core.Mapping;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class PublicGoodsDTO implements Serializable {

	private static final long serializableUID = 1L;
	/** 卡密id,cgg表 */
	private Long id;
	/**
	 * 状态  0 未中卡, 100 待审核,2审核通过 3审核驳回 1 中卡
	 */
	private Long status;
	//卡编
	private String num;
	private String ids;
	//上传图片地址
	private String img;
	//中奖数量
	private Integer copies;
	//中卡卡编
	private String realNumJson;
	private Integer topSort;
	@Mapping("userOrderId")
	private Integer orderId;
	//订单id修改值
	private Long updateOrderId;
	private String orderNo;
	private String userAvatar;
	private String userNickname;
	private Long userId;
	private Integer giveFlag;
	/** 备注 */
	private String remark;
	/**id集合*/
	private List<Long> idList;
	/**状态集合*/
	private List<Long> statusList;
	/** 组团信息id */
	private Long groupInfoId;
	/** 开卡状态 */
	private Integer lockStatus;

	public List<Long> getIdList() {
		if(idList!=null){
			return idList;
		}
		if(StringUtils.isEmpty(this.ids)){
			return null;
		}
		String[] ids = this.ids.split(",");
		List<Long> idList = Arrays.stream(ids).map(id -> Long.valueOf(id)).collect(Collectors.toList());
		return idList;
	}
}