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 g on g.id = o.goods_id" +
		" left join goods_don_sku sku on sku.id = o.sku_id" +
		" :tb:",
		where = ":condition:"
)
public class ExcelOrderDonData {

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

	@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("o.goods_id")
	@ExcelIgnore
	private Long goodsId;

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

	@DbIgnore
	@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("o.user_id")
	@ExcelProperty("用户ID")
	private Long userId;

	@DbIgnore
	@ExcelProperty("用户名")
	private String nickname;

	@DbIgnore
	@ExcelIgnore
	private String register;

	@DbIgnore
	@ExcelProperty("注册方式")
	private String registerStr;

	@DbField("select gr.account from groups_relation gr where gr.id = o.relation_id and gr.user_id = o.user_id limit 1")
	@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 diffInfo;

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

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

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

	@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.coupon_user_id")
	@ExcelIgnore
	private Long couponUserId;

	@DbField("o.coupon_id")
	@ExcelIgnore
	private Long couponId;

	@DbField("o.popularize_id")
	@ExcelIgnore
	private Long popularizeId;

	public String getRegisterStr() {
		if ("phone".equals(register)) {
			return "手机号";
		}
		if ("email".equals(register)) {
			return "邮箱";
		}
		return "微信授权";
	}
}
