package com.gxwebsoft.shop.entity;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.List;

import com.gxwebsoft.bszx.entity.BszxBm;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.*;

/**
 * 订单
 *
 * @author 科技小王子
 * @since 2025-01-11 10:45:12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopOrder对象", description = "订单")
public class ShopOrder implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "订单号")
    @TableId(value = "order_id", type = IdType.AUTO)
    private Integer orderId;

    @Schema(description = "订单编号")
    private String orderNo;

    @Schema(description = "订单类型，0商城订单 1预定订单/外卖 2会员卡")
    private Integer type;

    @Schema(description = "订单标题")
    private String title;

    @Schema(description = "快递/自提")
    private Integer deliveryType;

    @Schema(description = "下单渠道，0小程序预定 1俱乐部训练场 3活动订场")
    private Integer channel;

    @Schema(description = "微信支付订单号")
    private String transactionId;

    @Schema(description = "微信退款订单号")
    private String refundOrder;

    @Schema(description = "商户ID")
    private Long merchantId;

    @Schema(description = "商户名称")
    private String merchantName;

    @Schema(description = "商户编号")
    private String merchantCode;

    @Schema(description = "店铺ID")
    private Integer storeId;

    @Schema(description = "店铺名称")
    @TableField(exist = false)
    private String storeName;

    @Schema(description = "配送员ID")
    private Integer riderId;

    @Schema(description = "配送员名称")
    @TableField(exist = false)
    private String riderName;

    @Schema(description = "仓库ID")
    private Integer warehouseId;

    @Schema(description = "仓库名称")
    @TableField(exist = false)
    private String warehouseName;

    @Schema(description = "使用的优惠券id")
    private Integer couponId;

    @Schema(description = "使用的会员卡id")
    private String cardId;

    @Schema(description = "关联管理员id")
    private Integer adminId;

    @Schema(description = "核销管理员id")
    private Integer confirmId;

    @Schema(description = "IC卡号")
    private String icCard;

    @Schema(description = "收货人id")
    private Integer addressId;

    @Schema(description = "收货地址")
    private String address;

    private String addressLat;

    private String addressLng;

    @Schema(description = "买家备注")
    private String buyerRemarks;

    @Schema(description = "自提店铺id")
    private Integer selfTakeMerchantId;

    @Schema(description = "自提店铺")
    private String selfTakeMerchantName;

    @Schema(description = "配送开始时间")
    private String sendStartTime;

    @Schema(description = "配送结束时间")
    private String sendEndTime;

    @Schema(description = "送达拍照记录")
    private String sendEndImg;

    @Schema(description = "发货店铺id")
    private Integer expressMerchantId;

    @Schema(description = "发货店铺")
    private String expressMerchantName;

    @Schema(description = "订单总额")
    @NotNull(message = "订单总额不能为空")
    @DecimalMin(value = "0.01", message = "订单总额必须大于0")
    @Digits(integer = 10, fraction = 2, message = "订单总额格式不正确")
    private BigDecimal totalPrice;

    @Schema(description = "减少的金额，使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格")
    @DecimalMin(value = "0", message = "减少金额不能为负数")
    private BigDecimal reducePrice;

    @Schema(description = "实际付款")
    @DecimalMin(value = "0", message = "实际付款不能为负数")
    private BigDecimal payPrice;

    @Schema(description = "用于统计")
    private BigDecimal price;

    @Schema(description = "价钱，用于积分赠送")
    private BigDecimal money;

    @Schema(description = "退款金额")
    private BigDecimal refundMoney;

    @Schema(description = "教练价格")
    private BigDecimal coachPrice;

    @Schema(description = "购买数量")
    @Min(value = 1, message = "购买数量必须大于0")
    private Integer totalNum;

    @Schema(description = "教练id")
    private Integer coachId;

    @Schema(description = "来源ID，存商品ID")
    private Integer formId;

    @Schema(description = "支付的用户id")
    private Integer payUserId;

    @Schema(description = "支付方式：0余额支付，1微信支付，2支付宝支付，3银联支付，4现金支付，5POS机支付，6免费，7积分支付")
    private Integer payType;

    @Schema(description = "微信支付子类型：JSAPI小程序支付，NATIVE扫码支付")
    private String wechatPayType;

    @Schema(description = "代付支付方式：0余额支付，1微信支付，2支付宝支付，3银联支付，4现金支付，5POS机支付，6免费，7积分支付")
    private Integer friendPayType;

    @Schema(description = "0未付款，1已付款")
    private Boolean payStatus;

    @Schema(description = "0未使用，1已完成，2已取消，3取消中，4退款申请中，5退款被拒绝，6退款成功，7客户端申请退款")
    private Integer orderStatus;

    @Schema(description = "发货状态(10未发货 20已发货 30部分发货)")
    private Integer deliveryStatus;

    @Schema(description = "发货备注")
    private String deliveryNote;

    @Schema(description = "快递单号")
    private String expressNo;

    @Schema(description = "发货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deliveryTime;

    @Schema(description = "优惠类型：0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡，5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡")
    private Integer couponType;

    @Schema(description = "优惠说明")
    private String couponDesc;

    @Schema(description = "二维码地址，保存订单号，支付成功后才生成")
    private String qrcode;

    @Schema(description = "vip月卡年卡、ic月卡年卡回退次数")
    private Integer returnNum;

    @Schema(description = "vip充值回退金额")
    private BigDecimal returnMoney;

    @Schema(description = "预约详情开始时间数组")
    private String startTime;

    @Schema(description = "是否已开具发票：0未开发票，1已开发票，2不能开具发票")
    private Integer isInvoice;

    @Schema(description = "发票流水号")
    private String invoiceNo;

    @Schema(description = "支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime payTime;

    @Schema(description = "退款原因")
    @NotBlank(message = "退款原因不能为空")
    private String refundReason;

    @Schema(description = "退款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refundTime;

    @Schema(description = "申请退款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime refundApplyTime;

    @Schema(description = "取消时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime cancelTime;

    @Schema(description = "取消原因")
    private String cancelReason;

    @Schema(description = "过期时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expirationTime;

    @Schema(description = "评价状态 0未评价 1已评价")
    private Integer evaluateStatus;

    @Schema(description = "评价时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime evaluateTime;

    @Schema(description = "对账情况：0=未对账；1=已对账；3=已对账，金额对不上；4=未查询到该订单")
    private Integer checkBill;

    @Schema(description = "订单是否已结算(0未结算 1已结算)")
    private Integer isSettled;

    @Schema(description = "商户备注")
    private String merchantRemarks;

    @Schema(description = "系统版本号 0当前版本 value=其他版本")
    private Integer version;

    @Schema(description = "用户id")
    private Integer userId;

    @Schema(description = "头像")
    @TableField(exist = false)
    private String avatar;

    @Schema(description = "昵称")
    @TableField(exist = false)
    private String nickname;

    @Schema(description = "真实姓名")
    private String realName;

    @Schema(description = "手机号码")
    @TableField(exist = false)
    private String phone;

    @Schema(description = "手机号码(脱敏)")
    @TableField(exist = false)
    private String mobile;

    @Schema(description = "备注")
    @Size(max = 500, message = "备注长度不能超过500字符")
    private String comments;

    @Schema(description = "排序号")
    private Integer sortNumber;

    @Schema(description = "是否删除, 0否, 1是")
    @TableLogic
    private Integer deleted;

    @Schema(description = "租户id")
    @NotNull(message = "租户ID不能为空")
    private Integer tenantId;

    @Schema(description = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "自提码")
    private String selfTakeCode;

    @Schema(description = "是否已收到赠品")
    private Boolean hasTakeGift;

    @Schema(description = "accessToken")
    @TableField(exist = false)
    private String accessToken;

    @Schema(description = "openid")
    @TableField(exist = false)
    private String openid;

    @Schema(description = "订单商品")
    @TableField(exist = false)
    private List<ShopOrderGoods> orderGoods;

    @Schema(description = "报名信息")
    @TableField(exist = false)
    private BszxBm bm;

    @Schema(description = "快递id")
    @TableField(exist = false)
    private Integer expressId;

    @Schema(description = "发货人")
    @TableField(exist = false)
    private String sendName;

    @Schema(description = "发货人联系方式")
    @TableField(exist = false)
    private String sendPhone;

    @Schema(description = "发货地址")
    @TableField(exist = false)
    private String sendAddress;

    @TableField(exist = false)
    private ShopOrderDelivery shopOrderDelivery;
}
