package com.cyksj.model.excel;

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
 *文件名: ExcelOrderDonData
 *创建者: JavaZou
 *创建时间:2022/12/29 10:25
 */
@Getter
@Setter
@SearchBean(tables = "order_don o left join goods_don_sku sku on o.sku_id = sku.id " +
		"left join goods_don g on g.id = sku.goods_id " +
		"left join user u on o.user_id = u.id " +
		"left join groups_relation gr on gr.id = o.relation_id " +
		"left join channel_popularize cp on o.popularize_id = cp.id " +
		"left join channel c on c.id = cp.channel_id "
)
public class ExcelOrderDonData {

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

	@DbField("c.id")
	@ExcelIgnore
	private Long channelId;

	@DbField("o.relation_id")
	@ExcelIgnore
	private Long relationId;

	@DbField("o.transaction_id")
	@ExcelIgnore
	private String transactionId;

	@DbField("g.type")
	@ExcelIgnore
	private Integer goodsDonType;

	@DbField("o.order_no")
	@ExcelProperty("订单号")
	private String orderNo;

	@DbField("c.name")
	@ExcelProperty("渠道")
	private String channel;

	@DbField("g.title")
	@ExcelProperty("商品")
	private String title;

	@DbIgnore
	@ExcelProperty("优惠券")
	private String couponName;

	@DbField("o.coupon_money")
	@ExcelProperty("减免金额")
	private BigDecimal couponMoney;

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

	@DbField("o.money")
	@ExcelProperty("金额")
	private BigDecimal money;

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

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

	@DbField("case when u.login_phone != '' then 'phone' when u.email != '' then 'email' when u.open_id != '' then 'wechat' else 'wechat' end")
	@ExcelIgnore
	private String register;

	@DbField("case when u.login_phone != '' then concat('手机号',login_phone) when u.email != '' then concat('邮箱',email) when u.open_id != '' then '微信授权' else '微信授权' end")
	@ExcelProperty("注册方式")
	private String registerStr;

	@DbField("gr.account")
	@ExcelProperty("账号")
	private String account;

	@DbIgnore
	@ExcelProperty("售前")
	private String beforeServiceName;

	@DbIgnore
	@ExcelProperty("售后")
	private String afterServiceName;

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

	@ExcelProperty("状态")
	private String statusStr;

	@DbField("o.created_time")
	@ExcelProperty("创建时间")
	private Date createdTime;

	@DbField("o.type")
	@ExcelIgnore
	private OrderDon.Type type;

	@DbField("o.source")
	@ExcelIgnore
	private OrderDon.Source source;

	@ExcelProperty("支付方式")
	private String typeStr;

	@ExcelProperty("收货地址")
	@DbIgnore
	private String transportStr;

	@ExcelProperty("收货人")
	@DbIgnore
	private String receiver;

	@ExcelProperty("手机号")
	@DbIgnore
	private String phone;

	@ExcelProperty("物流公司")
	@DbIgnore
	private String codeCn;

	@ExcelProperty("物流单号")
	@DbIgnore
	private String trackingNumber;

	@DbField("o.order_type")
	@ExcelIgnore
	private Integer orderType;

	@DbField("o.num")
	@ExcelIgnore
	private Integer num;

	@DbField("o.coupon_user_id")
	@ExcelIgnore
	private Long couponUserId;

	@DbField("cp.id")
	@ExcelIgnore
	private Long popularizeId;
}
