package com.cyksj.model.views;

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

import java.math.BigDecimal;

/*
 *项目名: netflix
 *文件名: StatisticsGoodsDataView
 *创建者: JavaZou
 *创建时间:2023/2/14 11:31
 */
@Getter
@Setter
@SearchBean(tables = "goods_don gd left join goods_don_sku gdk on gdk.goods_id = gd.id" +
		" left join order_don od on od.sku_id = gdk.id",
		where = "od.status not in ('close','noPayment') and :time:",
		groupBy = "gd.id,gdk.id")
public class StatisticsGoodsDataView {

	@DbField("gd.id")
	private Long goodsId;

	/**
	 * 商品名称
	 */
	@DbField("gd.title")
	private String goodsTitle;

	/**
	 * 规格id
	 */
	@DbField("gdk.id")
	private Long skuId;

	/**
	 * 规格名称
	 */
	@DbField("any_value(gdk.spec_val)")
	private String specVal;

	/**
	 * 用户数
	 */
	@DbField("count(distinct od.user_id)")
	private Integer numOfUser;

	/**
	 * 订单数
	 */
	@DbField("count(od.id)")
	private Integer numOfOrder;

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