package com.cyksj.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cyksj.model.entity.OrderDon;
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
 *文件名: ExcelServiceMonthStatisticsData
 *创建者: JavaZou
 *创建时间:2023/7/11 10:37
 */
@Getter
@Setter
@SearchBean(tables = "real_goods_order_handle rh left join order_don od on od.id = rh.order_id" +
		" left join goods_don_sku gdk on gdk.id = od.sku_id" +
		" left join goods_don gd on gd.id = gdk.goods_id" +
		" left join user u on u.id = od.user_id")
public class ExcelServiceMonthStatisticsData {

	@DbField("gd.title")
	@ExcelProperty("商品名称")
	private String goodsName;

	@DbField("gdk.id")
	@ExcelIgnore
	private Long skuId;

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

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

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

	@DbField("u.id")
	@ExcelProperty("用户ID")
	private Long userId;

	@DbField("od.status")
	@ExcelIgnore
	private OrderDon.Status status;

	/**
	 * 订单标注来源
	 * 用于客服标注订单来源
	 */
	@DbField("rh.label_source")
	@ExcelIgnore
	private String labelSource;

	@DbIgnore
	@ExcelProperty("订单来源")
	private String labelSourceStr;

	@DbField("od.created_time")
	@ExcelProperty("日期")
	private Date createdTime;

	@DbField("rh.before_service_name")
	@ExcelIgnore
	private String beforeServiceName;

	@DbField("rh.after_service_name")
	@ExcelIgnore
	private String afterServiceName;

	@DbField("rh.created_time")
	@ExcelIgnore
	private Date recordCreatedTime;

	public String getLabelSourceStr() {
		if (StrUtil.isEmpty(labelSource)) {
			return null;
		}
		OrderDon.LabelSource labelSource = OrderDon.LabelSource.valueOf(this.labelSource);
		return labelSource.getDesc();
	}
}
