package com.cyksj.model.excel;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cyksj.model.entity.GoodsDon;
import com.cyksj.model.entity.GroupsRelation;
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.util.Date;

/**
 * 项目名: yhlxj11111111
 * 文件名: ExcelRechargeAccountData
 * 创建者: JavaZou
 * 创建时间:2025/10/9 15:23
 */
@Getter
@Setter
@ExcelIgnoreUnannotated
@SearchBean(tables = "groups_relation gr left join groups_trips gt on gt.id = gr.groups_id" +
		" left join goods_don_sku gdk on gdk.id = gt.sku_id " +
		" left join goods_don g on g.id = gdk.goods_id" +
		" left join user u on u.id = gr.user_id",
		where = ":errorInfo:")
public class ExcelRechargeAccountData {

	@DbField("select order_no from order_don o where o.user_id = gr.user_id and o.relation_id = gr.id and o.status not in ('noPayment','close','refund') order by o.id desc limit 1")
	@ExcelProperty("订单号")
	private String orderNo;

	@DbField("gr.id")
	private Long relationId;

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

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

	@DbField("gr.status")
	private GroupsRelation.Status status;

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

	@DbField("gr.password")
	@ExcelProperty("密码")
	private String password;

	/**
	 * 联系方式
	 */
	@DbField("gr.contact")
	@ExcelProperty("联系方式")
	private String contact;

	/**
	 * 备用验证码
	 */
	@DbField("gr.bp_verify_code")
	@ExcelProperty("备用验证码")
	private String bpVerifyCode;

	@DbField("g.id")
	private Long goodsId;

	@DbField("g.title")
	@ExcelProperty("平台")
	private String title;

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

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

	/**
	 * 代充剩余次数
	 */
	@DbField("gr.recharge_remain_num")
	@ExcelProperty("代充剩余次数")
	private Integer rechargeRemainNum;

	@DbField("gr.submit_time")
	@ExcelProperty("提交时间")
	private Date submitTime;

	@DbField("gr.send_time")
	@ExcelProperty("发货时间")
	private Date sendTime;

	@DbField("gr.expiry_time")
	@ExcelProperty("到期时间")
	private Date expiryTime;

	@DbField("gr.recharge_status")
	private GroupsRelation.RechargeStatus rechargeStatus;

	@DbIgnore
	@ExcelProperty("状态")
	private String rechargeStatusStr;

	@DbField("gr.recharge_error_info")
	@ExcelProperty("失败原因")
	private String rechargeErrorInfo;

	/**
	 * 代充备注
	 */
	@DbField("gr.recharge_remark")
	@ExcelProperty("备注")
	private String rechargeRemark;

	@DbField("gr.operator")
	@ExcelProperty("操作人")
	private String operator;

	/***
	 * 代充次数
	 */
	@DbField("gr.recharge_num")
	private Integer rechargeNum;

	/**
	 * 代充任务id
	 */
	@DbField("gr.gpt_task_id")
	private String gptTaskId;

	/**
	 * 代充token
	 */
	@DbField("gr.gpt_token")
	private String gptToken;

	/**
	 * 家庭组邀请链接
	 */
	@DbField("gr.invite_link")
	private String inviteLink;

	/**
	 * 座位数
	 */
	@DbField("gdk.num")
	private Integer skuNUm;

	@DbField("g.special_type")
	private GoodsDon.SpecialType specialType;

	public String getRechargeStatusStr() {
		return this.rechargeStatus.getDesc();
	}

	public String getRechargeErrorInfo() {
		if (this.rechargeStatus == GroupsRelation.RechargeStatus.recharge_error) {
			return rechargeErrorInfo;
		}
		return null;
	}
}
