package cn.com.ctop.common.module.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 规则计划清洗数据
 * @author jeecg-boot
 * @date   2020-11-16
 * @version V1.0
 */
@Data
@TableName("ctop_rule_data_plan")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
public class RuleDataPlan {

	@TableId
	private Long id;
	private Long accountId;
	private String accountName;
	private Long planId;
	private String planName;
	private String externalUrl;
	private String downloadUrl;
	private BigDecimal cost;
	private Long convertNum;
	private Long convertId;
	private String deepConvertTarget;
	private BigDecimal convertCost;
	private BigDecimal nextDayOpenRate;
	private BigDecimal nextDayOpenCost;
	private Long nextDayOpen;
	private String pricing;
	private BigDecimal budget;
	private Integer status;
	private BigDecimal cpaBid;
	private BigDecimal deepCpabid;
	private Date createTime;
	private Date updateTime;

	public RuleDataPlan() {
	}

	public RuleDataPlan(JSONObject data, Long accountId) {
		Long nextDayOpen = data.getLong("attribution_next_day_open_cnt");
		if (null != nextDayOpen) {
			this.nextDayOpen = nextDayOpen;
		}
		Long convert = data.getLong("convert");
		if (null != convert) {
			this.convertNum = convert;
		}
		BigDecimal nextDayOpenCost = data.getBigDecimal("attribution_next_day_open_cost");
		if (null != nextDayOpenCost) {
			this.nextDayOpenCost = nextDayOpenCost;
		}

		BigDecimal nextDayOpenRate = data.getBigDecimal("attribution_next_day_open_rate");
		if (null != nextDayOpenRate) {
			this.nextDayOpenRate = nextDayOpenRate;
		}
		this.accountId = accountId;
		BigDecimal cost = data.getBigDecimal("cost");
		if (null != cost) {
			this.cost = cost;
		}
		BigDecimal convertCost = data.getBigDecimal("convert_cost");
		if (null != convertCost) {
			this.convertCost = convertCost;
		}
		String adName = data.getString("ad_name");
		if (null != adName) {
			this.planName = adName;
		}
		Long adId = data.getLong("ad_id");
		this.id = adId;
		this.planId = adId;
		this.createTime = new Date();
		this.updateTime = new Date();
	}




}
