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;
import java.util.Date;

/*
 *项目名: yhlxj
 *文件名: YhShopBusinessTakeMoneyDetail
 *创建者: JavaZou
 *创建时间:2023/9/22 10:53
 */
@Getter
@Setter
@SearchBean(tables = "yh_shop_user_distribute_business_order_don_record ubr",
		where = ":time:"
		, groupBy = "ubr.shop_user_id,ubr.business_id")
public class YhShopBusinessTakeMoneyDetail {
	@DbField("ubr.shop_user_id")
	private Long userId;

	@DbIgnore
	private String nickname;

	@DbIgnore
	private Date createdTime;

	@DbField("ubr.business_id")
	private Long businessId;

	@DbIgnore
	private String businessName;

	@DbField("count(distinct ubr.user_id)")
	private Integer distributeNum;

	@DbField("count(if(ubr.order_type = 1 and ubr.status = 'success',1,NULL))")
	private Integer numOfFirstOrderThisMonth;

	@DbField("cast(sum(if(ubr.order_type = 1 and ubr.status = 'success',ubr.take_money,0))/100 as decimal(10,2))")
	private BigDecimal moneyOfFirstOrderThisMonth;

	@DbField("count(if(ubr.order_type = 2 and ubr.status = 'success',1,NULL))")
	private Integer numOfRenewOrderThisMonth;

	@DbField("cast(sum(if(ubr.order_type = 2 and ubr.status = 'success',ubr.take_money,0))/100 as decimal(10,2))")
	private BigDecimal moneyOfRenewOrderThisMonth;

	@DbField("cast(sum(if(ubr.status = 'success',ubr.take_money,0))/100 as decimal(10,2))")
	private BigDecimal takeMoney;

	@DbField("cast(sum(if(ubr.status = 'refund', ubr.take_money,0))/100 as decimal(10,2))")
	private BigDecimal refundMoney;

}

