package com.cyksj.model.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ejlchina.searcher.bean.DbIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

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

/**
 * 项目名: yhlxj2
 * 文件名: VipOrderDon
 * 创建者: JavaZou
 * 创建时间:2025/5/13 10:38
 */
@Getter
@Setter
public class VipOrderDon extends BaseEntity{

	private Long goodsId;

	/**
	 * cps后台推广id
	 */
	private Long cpsPopularizeId;

	/** 订单号 */
	private String orderNo ;

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

	/**
	 * 微信订单号
	 */
	private String transactionId;


	/** 用户id */
	private Long userId ;

	/**
	 * openId
	 */
	private String openId;

	/**
	 * 续费月数
	 */
	private Integer num;

	/** 金额 */
	private BigDecimal money;

	/**
	 * 抵扣金额
	 */
	private BigDecimal deductMoney;

	/**
	 * 实际可抵扣金额（超过）
	 */
	private BigDecimal actuallyDeductMoney;

	/**
	 * 超出抵扣会员可延长多少天
	 */
	private Integer extendsDays;

	/**
	 * 海外支付金额
	 */
	private BigDecimal abroadMoney;

	/**
	 * 手续费
	 */
	private BigDecimal abroadTransactionFee;

	/**
	 * 退款金额
	 */
	private BigDecimal refundMoney;

	/**
	 * 退款余额
	 */
	private BigDecimal refundBalance;

	/**
	 * 退款原因
	 */
	private String refundDesc;

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

	/**
	 * 支付类型
	 */
	private Type type;

	/**
	 * 订单类型 1普通订单、2续费订单
	 * 默认值为1
	 */
	private Integer orderType;

	/**
	 * 是否是分销订单
	 */
	private Boolean isDistribute;

	/**
	 * 是否是固定推广者分销
	 */
	private Boolean isFixedDistribute;

	/**
	 * 支付时间
	 */
	private Date payTime;

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

	/**
	 * 渠道链接id
	 */
	private Long popularizeId;

	/**
	 * 是否是网页端支付 默认0移动端支付
	 */
	private Boolean isWebPay;

	/**
	 * 余额支付
	 */
	private BigDecimal balance;

	private String payTitle;

	/**
	 * 付款说明
	 */
	@TableField(exist = false)
	@DbIgnore
	private String payDesc;

	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","支付宝"),
		BALANCE("balance", "余额支付"),
		PAYPAL("paypal","paypal支付"),
		STRIPE("stripe","stripe支付"),
		GALAXY_COIN("galaxy_coin","银河币支付"),
		;
		String type;
		String desc;

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