package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/*
 *项目名: netflix
 *文件名: BusinessDistributesDataView
 *创建者: JavaZou
 *创建时间:2023/4/27 16:19
 */
@Getter
@Setter
@SearchBean(tables = "(select distinct business_id from user_distribute_business_rate) ur inner join user_distribute ud on ud.business_id = ur.business_id and ud.deleted is true :time1:" +
		" left join user_distribute_shared us on us.shared_id = ud.user_id :time2:" +
		" left join order_don od on od.user_id = us.user_id and od.status not in ('close','refund','noPayment') and od.is_fixed_distribute = 1 :time3:",
		groupBy = "ud.business_id")
public class BusinessDistributesDataView {
	@DbField("ud.business_id")
	private Long businessId;

	/**
	 * 商务名
	 */
	@DbIgnore
	private String businessName;

	/**
	 * 渠道数量
	 */
	@DbField("count(distinct ud.id)")
	private Integer numOfDistributor;

	/**
	 * 分销单数
	 */
	@DbField("count(od.id)")
	private Integer numOfDistributeOrders;

	/**
	 * 分销金额
	 */
	@DbField("ifnull(sum(od.money),0)")
	private BigDecimal distributeOrdersMoney;

	/**
	 * 拉新用户
	 */
	@DbField("count(distinct us.id)")
	private Integer numOfNewUser;
}
