package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

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

/*
 *项目名: netflix
 *文件名: UserDistributePopularizeView
 *创建者: JavaZou
 *创建时间:2023/5/15 17:38
 */
@Getter
@Setter
@SearchBean(tables = "(select id,name,remark,code,created_time,goods_id,sku_id,other_url from user_distribute_popularize where deleted is true :userId:) dp left join order_don od on od.cps_popularize_id = dp.id" +
		" and od.status not in ('close','noPayment') and od.relation_id != 0 and is_fixed_distribute is true :time:" +
		" left join distribute_waiting_send_points dsp on dsp.order_id = od.id and dsp.send_status in ('success','waiting')",
		groupBy = "dp.id,dp.name,dp.code,dp.remark,dp.created_time,dp.goods_id")
public class UserDistributePopularizeView {
	@DbField("dp.id")
	private Long id;

	@DbField("dp.name")
	private String name;

	@DbField("dp.code")
	@JsonIgnore
	private String code;

	@DbField("dp.goods_id")
	private Long goodsId;

	@DbField("dp.sku_id")
	private Long skuId;

	@DbIgnore
	private String specVal;

	@DbIgnore
	private String title;

	@DbIgnore
	private String logo;

	/**
	 * 最低价格
	 */
	@DbIgnore
	private BigDecimal price;

	/**
	 * 分销比例
	 */
	@DbIgnore
	private Integer rate = 0;

	@DbIgnore
	private Integer clickNum = 0;

	@DbIgnore
	private String popularizeLink;

	/**
	 * 推广链接二维码
	 */
	@DbIgnore
	private String urlCode;

	@DbField("count(if(dsp.id is NULL,NULL,1))")
	private Integer orders;

	@DbField("ifnull(cast(sum(if(dsp.id is NULL,0,money))/100 as decimal(11,2)),0)")
	private BigDecimal ordersMoney;

	@DbField("ifnull(cast(sum(if(dsp.send_status='waiting',dsp.points,0))/1000 as decimal(11,2)),0)")
	private BigDecimal wMoney;

	@DbField("ifnull(cast(sum(if(dsp.send_status='success',dsp.points,0))/1000 as decimal(11,2)),0)")
	private BigDecimal gotMoney;

	@DbField("dp.remark")
	private String remark;

	@DbField("dp.created_time")
	private Date createdTime;

	/**
	 * 其他网址标识
	 * cc 独立网址
	 */
	@DbField("dp.other_url")
	private String otherUrl;

	/**
	 * 优惠码
	 */
	@DbIgnore
	private String couponCode;

	@DbIgnore
	private DistributePosterGoodsDetailView posterInfo;
}
