package com.czg.market.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import java.io.Serial;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 套餐推广订单 实体类。
 *
 * @author gyj
 * @since 2025-12-18
 */
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table("pp_package_order")
public class PpPackageOrder implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 自增主键
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 店铺 Id
     */
    private Long shopId;

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

    /**
     * 套餐 Id
     */
    private Long packageId;

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

    /**
     * 分享人数
     */
    private Integer shareNum;

    /**
     * 最终支付金额
     */
    private BigDecimal finalPrice;

    /**
     * 订单状态：ing进行中, wait_verify 待核销，finish 已核销，refunding 退款中，refund 已退款，cancel 已取消，timeout 超时
     * {@link com.czg.constants.PpPackageConstants.OrderStatus}
     */
    private String status;

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

    /**
     * 支付订单 Id
     */
    private Long payOrderId;

    /**
     * 核销码
     */
    private String verifyCode;

    /**
     * 核销时间
     */
    private LocalDateTime verifyTime;

    /**
     * 取消时间
     */
    private LocalDateTime cancelTime;

    /**
     * 取消原因
     */
    private String cancelReason;

    /**
     * 创建时间
     */
    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(onInsertValue = "now()", onUpdateValue = "now()")
    private LocalDateTime updateTime;

    /**
     * 过期时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireTime;

    /**
     * 申请退款原因
     */
    private String refundReason;

}
