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;

/*
 *项目名: yhlxj
 *文件名: YhShopUserDistributeOrdersStatisticsView
 *创建者: JavaZou
 *创建时间:2023/9/20 11:08
 */
@Getter
@Setter
@SearchBean(tables = "(select o.id,o.user_id,o.goods_id,o.money,o.refund_money,o.status from order_don o where :yhs_id: and o.status not in ('close','noPayment') :time:) od left join goods_don g on g.id = od.goods_id" +
		" inner join yh_shop_distribute_waiting_send_points dp on dp.order_id = od.id",
		groupBy = "od.goods_id,g.title")
public class YhShopUserDistributeOrdersStatisticsView {
	@DbField("g.title")
	private String title;

	@DbField("cast(sum(od.money)/100 as decimal(10,2))")
	private BigDecimal distributeOrderMoney;

	@DbField("count(od.id)")
	private Integer orders;

	@DbField("TRUNCATE(sum(if(dp.send_status != 'close',dp.money,0))/100,2)")
	private BigDecimal takeMoney;

	@DbField("count(if(od.status = 'refund',1,NULL))")
	private Integer refundOrders;

	@DbField("cast(sum(ifnull(od.refund_money,0))/100 as decimal(10,2))")
	private BigDecimal refundMoney;
}
