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
 * 文件名: CpsOrderView
 * 创建者: JavaZou
 * 创建时间:2024/3/21 14:55
 */
@Getter
@Setter
@SearchBean(tables = "distribute_waiting_send_points dw left join order_don od on od.id = dw.order_id and dw.is_vip = false" +
		" left join vip_order_don vod on vod.id = dw.order_id and dw.is_vip = true" +
		" left join goods_don g on g.id = ifnull(od.goods_id,vod.goods_id)"
		, where = ":userId: and dw.send_status not in ('not_exist','close')"
		, groupBy = "g.id,g.title,date_format(ifnull(od.created_time,vod.created_time),'%Y-%m-%d')")
public class CpsOrderView {

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

	/**
	 * 平台名称
	 */
	@DbField("g.title")
	private String title;

	/**
	 * 当前日期订单金额
	 */
	@DbField("cast(sum(if(od.id is null,vod.money,if(od.is_dp and od.ori_money != 0,od.ori_money,od.money))/100) as decimal(10,2))")
	private BigDecimal distributeOrderMoney;

	/**
	 * 当前日期订单数
	 */
	@DbField("count(dw.order_id)")
	private Integer orders;

	/**
	 * 日期
	 */
	@DbField("date_format(ifnull(od.created_time,vod.created_time),'%Y-%m-%d')")
	private String date;
}
