package cn.ysk.cashier.mybatis.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * 积分兑换记录
 *
 * @author Tankaikai tankaikai@aliyun.com
 * @since 2.0 2024-10-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_points_exchange_record")
public class TbPointsExchangeRecord {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 订单编号
     */
    private String orderNo;
    /**
     * 店铺id
     */
    private Long shopId;
    /**
     * 积分商品id
     */
    private Long pointsGoodsId;
    /**
     * 积分商品名称
     */
    private String pointsGoodsName;
    /**
     * 商品图片URL
     */
    private String goodsImageUrl;
    /**
     * 领取方式 self-自取 post-邮寄
     */
    private String pickupMethod;
    /**
     * 会员id
     */
    private Long memberId;
    /**
     * 会员名称
     */
    private String memberName;
    /**
     * 手机号码
     */
    private String mobile;
    /**
     * 会员头像
     */
    private String avatarUrl;
    /**
     * 消耗积分
     */
    private Integer spendPoints;
    /**
     * 额外支付
     */
    private BigDecimal extraPaymentAmount;
    /**
     * 兑换券券码
     */
    private String couponCode;
    /**
     * 支付平台订单号
     */
    private String payOrderId;
    /**
     * 渠道订单号(微信/支付宝订单号)
     */
    private String channelTradeNo;
    /**
     * 支付方式 积分支付/积分+微信/积分+支付宝
     */
    private String payMethod;
    /**
     * 支付类型 POINTS-积分 WECHAT-微信 ALIPAY-支付宝 UNIONPAY-银联云闪付
     */
    private String payType;
    /**
     * 状态 unpaid-待支付 waiting-待自取 done-已完成 cancel-已取消
     */
    private String status;
    /**
     * 取消/退款原因
     */
    private String cancelOrRefundReason;
    /**
     * 取消/退款时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date cancelOrRefundTime;
    /**
     * 实际支付时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date payTime;
    /**
     * 创建时间（下单时间）
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 更新时间（核销时间）
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @TableField(value = "count(*)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Long count;

    @TableField(value = "sum(extra_payment_amount)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private BigDecimal totalAmount;

    /**
     * 用户ip
     */
    @JsonIgnore
    @TableField(exist = false)
    private String ip;

    /**
     * 微信openId/支付完userId
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(exist = false)
    private String openId;

    /**
     * 拉起支付所需信息
     */
    @TableField(exist = false)
    private String payInfo;
}