package com.ruoyi.system.domain.flash;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

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

/** 独立闪送订单实体，不与餐饮订单或出租车订单共用状态。 */
@Data
@TableName("flash_delivery_order")
public class FlashDeliveryOrder {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String orderNo;
    /** 客户端请求幂等号，与 userId 共同建立唯一约束。 */
    private String clientRequestId;
    private Long userId;
    /** 创建订单时按收件手机号唯一匹配的普通用户；匹配后不再动态追溯。 */
    private Long receiverUserId;
    /** 抢单前为空，原子抢单成功后绑定且不允许骑手主动放弃。 */
    private Long riderId;
    private String serviceType;
    private String deliveryType;
    private String status;
    /** 用户申报的包裹类别和机车可载重量档。 */
    private String packageType;
    private Integer quantity;
    private BigDecimal totalWeightKg;
    private String specification;
    private String packageSize;
    /** NOW 为立即配送，SCHEDULED 为预约取件时段。 */
    private String deliveryMode;
    private Date scheduledPickupStartAt;
    private Date scheduledPickupEndAt;
    /** 交付 PIN 只允许订单用户和平台读取，骑手响应必须剔除。 */
    private Boolean pinRequired;
    private String deliveryPinCode;

    /** 取件联系人和完整地址快照。 */
    private String pickupName;
    private String pickupPhone;
    private String pickupAddress;
    private String pickupAddressDetail;
    private String pickupCity;
    private String pickupArea;
    private String pickupHandoffMethod;
    private BigDecimal pickupLongitude;
    private BigDecimal pickupLatitude;

    /** 收件联系人和完整地址快照。 */
    private String deliveryName;
    private String deliveryPhone;
    private String deliveryAddress;
    private String deliveryAddressDetail;
    private String deliveryCity;
    private String deliveryArea;
    private String deliveryHandoffMethod;
    private BigDecimal deliveryLongitude;
    private BigDecimal deliveryLatitude;

    /** 服务端计算的路线结果；distanceSource 标识地图路线或降级直线距离。 */
    private Integer distanceMeters;
    private String distanceSource;
    private Integer estimatedDurationSeconds;

    /** 下单时的金额和计价配置快照，后续后台调价不会修改这些字段。 */
    private Long amount;
    private String currency;
    private Long pricingId;
    private Integer pricingVersion;
    private String pricingStartTime;
    private String pricingEndTime;
    private BigDecimal startingDistance;
    private Long startingFare;
    private BigDecimal distance;
    private Long freight;
    private Long distanceFee;
    private Long baseDeliveryFee;
    private BigDecimal urgentRate;
    private Long minimumUrgentFee;
    private Long urgentFee;
    private Long tipAmount;
    private String userNote;
    /** 订单条件更新版本号，用于记录并发状态变化次数。 */
    private Integer version;

    /** 各履约节点的首次成功时间。 */
    private Date acceptedAt;
    private Date pickedUpAt;
    private Date deliveredAt;
    private Date completedAt;
    private Date cancelledAt;

    /** 取消审计信息，操作人类型可为 USER 或 ADMIN。 */
    private String cancelReason;
    private String cancelOperatorType;
    private Long cancelOperatorId;
    private Date createTime;
    private Date updateTime;
}
