package com.cyksj.model.excel;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cyksj.model.entity.RealGoodsInterestUser;
import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

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

/*
 *项目名: netflix
 *文件名: ExcelRealGoodsUserInterestData
 *创建者: JavaZou
 *创建时间:2022/11/25 15:41
 */
@Getter
@Setter
@SearchBean(tables = "real_goods_interest_user ru " +
		" left join goods_don_sku gdk on gdk.id = ru.sku_id" +
		" left join user u on u.id = ru.user_id" +
		" left join goods_don gd on gd.id = gdk.goods_id" +
		" left join order_don_transport ot on ot.order_id = ru.order_id",
		where = "ru.order_created_time < DATE_ADD(CURRENT_TIMESTAMP,interval -1 day)")
public class ExcelRealGoodsUserInterestData {

	@DbField("ru.id")
	@ExcelIgnore
	private Long id;

	@DbField("ru.user_id")
	@ExcelProperty("用户ID")
	private Long userId;

	@DbField("ru.goods_id")
	@ExcelIgnore
	private Long goodsId;

	@DbField("ru.sku_id")
	@ExcelIgnore
	private Long skuId;

	@DbField("ru.order_id")
	@ExcelIgnore
	private Long orderId;

	@DbField("u.nickname")
	@ExcelProperty("用户名称")
	private String nickname;

	@DbField("ru.order_created_time")
	@ExcelProperty("创建时间")
	private Date orderCreatedTime;

	@DbField("ru.pay_time")
	@ExcelProperty("购买时间")
	private Date payTime;

	@DbField("gd.title")
	@ExcelProperty("意向商品")
	private String goodsTitle;

	@DbField("gdk.spec_val")
	@ExcelProperty("规格")
	private String specVal;

	@DbField("cast(gdk.price/100 as decimal(10,0))")
	@ExcelProperty("金额")
	private BigDecimal money;

	@DbField("ot.receiver")
	@ExcelProperty("姓名")
	private String receiver;

	@DbField("ot.phone")
	@ExcelProperty("手机号")
	private String phone;

	@DbField("concat(ot.province,ot.city,ot.district,ot.address)")
	@ExcelProperty("地址")
	private String address;

	@DbField("ru.interest_status")
	@ExcelIgnore
	private RealGoodsInterestUser.Status interestStatus;

	@DbIgnore
	@ExcelProperty("意向")
	private String cnInterestStatus;

	public String getCnInterestStatus() {
		return interestStatus.getDesc();
	}
}
