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;

/*
 *项目名: yhlxj
 *文件名: YhShopBusinessDistributesDataView
 *创建者: JavaZou
 *创建时间:2023/9/18 17:41
 */
@Getter
@Setter
@SearchBean(tables = "(select distinct business_id from yh_shop_user_distribute_business_rate) ur inner join yh_shop ys on ys.business_id = ur.business_id :time1:" +
		" left join yh_shop_user_distribute_shared us on us.shop_user_id = ys.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.yhs_id = ys.id  :time3:",
		groupBy = "ur.business_id")
public class YhShopBusinessDistributesDataView {
	@DbField("ur.business_id")
	private Long businessId;

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

	/**
	 * 渠道数量
	 */
	@DbField("count(distinct ys.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;
}
