package com.cyksj.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;

/**
 * 项目名: yhlxj
 * 文件名: GoodsWholesaleUserDeposit
 * 创建者: JavaZou
 * 创建时间:2024/8/21 15:52
 */
@Getter
@Setter
@SearchBean(tables = "goods_wholesale_user_deposit gwud")
public class GoodsWholesaleUserDeposit extends BaseEntity {
	private Long userId;

	private BigDecimal money;

	private Type type;

	/**
	 * 支付状态
	 */
	private Status status;

	/**
	 * 累积批发
	 */
	@TableField(exist = false)
	@DbIgnore
	private Integer total;

	/**
	 * 操作人
	 */
	private String operator;

	/**
	 * 商户id
	 */
	private String shopId;

	private String orderNo;

	private String refundOutNo;

	private String transactionId;

	private Boolean isWebPay;

	/**
	 * 批发数达标
	 */
	private Boolean isGoal;

	private Date payTime;

	private String buyerId;

	@DbIgnore
	@TableField(exist = false)
	private Boolean isDeposit;

	@DbField("select nickname from user where id = gwud.user_id limit 1")
	@TableField(exist = false)
	private String nickname;

	public enum Status {
		/**
		 * 订单状态
		 */
		noPayment("待付款"),
		hasPayment("已付款"),
		refund("已退款"),
		;

		private String desc;

		Status(String desc) {
			this.desc = desc;
		}

		public String getDesc() {
			return desc;
		}
	}


	@Getter
	@AllArgsConstructor
	public enum Type {
		WeChat("wechat", "微信"),
		ALI_PAY("zfb", "支付宝"),
		PAYPAL("paypal", "paypal支付"),
		STRIPE("stripe", "stripe支付");
		String type;
		String desc;

		public static GoodsWholesaleUserDeposit.Type getType(String type) {
			return Arrays.stream(GoodsWholesaleUserDeposit.Type.values()).filter(tp -> tp.getType().equals(type)).findFirst().orElse(ALI_PAY);
		}
	}
}
