package com.cyksj.model.excel;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
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;

/**
 * 项目名: yhlxj2
 * 文件名: ExcelInvoiceData
 * 创建者: JavaZou
 * 创建时间:2025/4/3 17:57
 */
@Getter
@Setter
@SearchBean(tables = "user_invoice_apply_record uar inner join user_invoice_order_relate uor on uor.record_id = uar.id" +
		" left join order_don o on o.id = uor.order_id and uor.type = 1" +
		" left join upgrade_order_don uod on uod.id = uor.order_id and uor.type = 2"
		, groupBy = "uar.id,uar.user_id,uar.money,uar.zfb_payment,uar.head,uar.tax_no,uar.bank,uar.bank_no,uar.email,uar.status,uar.invoice_img,uar.created_time,uar.update_time")
@ExcelIgnoreUnannotated
public class ExcelInvoiceData {

	@DbField("group_concat(o.order_no)")
	@ExcelProperty("开票订单")
	private String orderNoStr;

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

	@DbField("uar.user_id")
	private Long userId;

	@DbField("uar.money/100")
	@ExcelProperty("开票金额（元）")
	private BigDecimal money;

	/**
	 * 支付宝支付主体
	 */
	@DbField("uar.zfb_payment")
	@ExcelProperty("支付主体")
	private String zfbPayment;

	/**
	 * 发票头部信息
	 */
	@DbField("uar.head")
	@ExcelProperty("抬头")
	private String head;

	/**
	 * 税号
	 */
	@DbField("uar.tax_no")
	@ExcelProperty("税号")
	private String taxNo;

	@DbField("uar.email")
	@ExcelProperty("联系邮箱")
	private String email;

	/**
	 * 银行
	 */
	@DbField("uar.bank")
	@ExcelProperty("开户银行")
	private String bank;

	/**
	 * 银行
	 */
	@DbField("uar.bank_no")
	@ExcelProperty("银行账号")
	private String bankNo;

	/**
	 * 0待开票 1已上传 2已发送
	 */
	@DbField("uar.status")
	private Integer status;

	/**
	 * 0待开票 1已上传 2已发送
	 */
	@DbIgnore
	@ExcelProperty("状态")
	private String statusStr;

	@DbField("uar.file_name")
	@ExcelProperty("发票")
	private String fileName;

	/**
	 * 发票
	 */
	@DbField("uar.invoice_img")
	private String invoiceImg;

	@DbField("uar.created_time")
	private Date createdTime;

	@DbField("uar.update_time")
	@ExcelProperty("更新时间")
	private Date updateTime;

	public String getStatusStr() {
		return status == 0 ? "待开票" : status == 1 ? "已上传" : "已发送";
	}
}
