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 * from distribute_waiting_send_points where :sharedId: :time:) dw left join order_don od on od.id = dw.order_id and dw.is_vip = false and od.status not in ('close','noPayment')" +
		" left join vip_order_don vod on vod.id = dw.order_id and dw.is_vip = true and vod.status not in ('close','noPayment')" +
		" left join goods_don g on g.id = ifnull(od.goods_id,vod.goods_id)"
)
public class UserDistributeOrdersDetailView {

	@DbField("select nickname from user where id = dw.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.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 money;

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

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

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

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

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

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