package com.cyksj.model.views;

import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.SearchBean;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;

/*
 *项目名: netflix
 *文件名: UserDistributeOrdersDetailView
 *创建者: JavaZou
 *创建时间:2023/5/15 11:50
 */
@Getter
@Setter
@SearchBean(tables = "(select o.id,o.user_id,o.goods_id,o.sku_id,o.money,o.refund_money,o.coupon_money,o.created_time,o.is_dp,o.ori_money from order_don o inner join (select user_id from user_distribute_shared where :sharedId:) us on us.user_id = o.user_id where o.is_fixed_distribute is true and o.status not in ('close','noPayment') :time:) od" +
		" left join goods_don g on g.id = od.goods_id" +
		" inner join distribute_waiting_send_points dp on dp.order_id = od.id")
public class UserDistributeOrdersDetailView {

	@DbField("select nickname from user where id = od.user_id limit 1")
	private String nickname;

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

	@DbField("g.title")
	private String title;

	@DbField("select spec_val from goods_don_sku where id = od.sku_id limit 1")
	private String specVal;

	@DbField("cast(if(od.is_dp and od.ori_money != 0,od.ori_money,od.money)/100 as decimal(10,2))")
	private BigDecimal money;

	@DbField("od.coupon_money")
	private BigDecimal couponMoney;

	@DbField("TRUNCATE(dp.points/1000,2)")
	private BigDecimal reMoney = BigDecimal.ZERO;

	@DbField("if(send_status = 'success',TRUNCATE(dp.refund_points/1000,2),0)")
	private BigDecimal rdMoney;

	/**
	 * 是否参与渠道分销规则
	 */
	@DbField("dp.is_rule")
	private Boolean isRule;

	@DbField("dp.send_status")
	private String sendStatus;

	@DbField("od.created_time")
	private Date createdTime;
}
