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
 * 文件名: UserDistributePosterOrderDetailView
 * 创建者: JavaZou
 * 创建时间:2024/8/22 10:32
 */
@Getter
@Setter
@SearchBean(tables = "(select id from user_distribute_poster_record :condition:) dp left join order_don_poster_relate opr on opr.record_id = dp.id" +
		" left join order_don od on od.id = opr.order_id and od.status not in ('close','noPayment') and od.relation_id != 0 and is_fixed_distribute is true :time:" +
		" left join distribute_waiting_send_points dsp on dsp.order_id = od.id and dsp.send_status in ('success','waiting')",
		groupBy = "dp.id")
public class UserDistributePosterOrderDetailView {

	@DbField("dp.id")
	private Long id;

	@DbField("count(if(dsp.id is NULL,NULL,1))")
	private Integer orders;

	@DbField("ifnull(cast(sum(if(dsp.id is NULL,0,money))/100 as decimal(11,2)),0)")
	private BigDecimal ordersMoney;

	@DbField("ifnull(cast(sum(if(dsp.send_status='waiting',dsp.points,0))/1000 as decimal(11,2)),0)")
	private BigDecimal wMoney;

	@DbField("ifnull(cast(sum(if(dsp.send_status='success',dsp.points,0))/1000 as decimal(11,2)),0)")
	private BigDecimal gotMoney;
}
