package com.cyksj.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ejlchina.searcher.bean.DbIgnore;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

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

/**
 * 项目名: yhlxj
 * 文件名: GoodsWholesaleOrderDon
 * 创建者: JavaZou
 * 创建时间:2024/8/26 12:22
 */
@Getter
@Setter
public class GoodsWholesaleOrderDon extends BaseEntity{
	private Long userId;

	private String orderNo;

	/**
	 * 批发id
	 */
	private Long pid;

	private Long goodsId;

	private Long skuId;

	private Type type;

	private BigDecimal money;

	private BigDecimal balance;

	private Integer num;

	private String source;

	private Status status;

	private Date payTime;

	private String shopId;

	private String outRefundNo;

	/**
	 * 是否网页支付
	 */
	private Boolean isWebPay;

	private String transactionId;

	/**
	 * 买家id
	 */
	private String buyerId;

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

	private BigDecimal refundMoney;

	@DbIgnore
	@TableField(exist = false)
	@JsonIgnore
	private Boolean isRecordDiffer = false;

	public enum Status {
		/**
		 * 订单状态
		 */
		close("已关闭"),
		noPayment("待付款"),
		hasPayment("已付款"),
		complete("已完成"),
		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","支付宝"),
		EX_CODE("exchange_code","兑换码"),
		LOTTERY("lottery","抽奖"),
		EQUIPMENT("equipment", "实物设备分销"),
		PAY_EQUIPMENT("pay_equipment", "自购设备"),
		BALANCE("balance", "余额支付"),
		PAYPAL("paypal","paypal支付"),
		STRIPE("stripe","stripe支付")
		;
		String type;
		String desc;

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