package com.jeesharp.business.modules.mall.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

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

/**
 * 小程序商城提交订单入参：配送方式为快递时须传收货地址；到店自提时须选自提点，地址可选（用于联系人信息）。
 *
 * @author jeesharp
 * @since 2026-05-15
 */
@Data
@Schema(description = "商城提交订单请求")
public class MallOrderSubmitDTO {

    /**
     * 配送方式：{@link com.jeesharp.business.modules.mall.enums.MallDeliveryTypeEnum}，缺省为 DELIVERY。
     */
    @Schema(description = "配送方式：DELIVERY-快递 PICKUP-到店自提，缺省 DELIVERY")
    private String deliveryType;

    /**
     * 会员收货地址主键；快递配送时必填；自提时选填（不填则取货联系人使用自提点信息）。
     */
    @Schema(description = "会员收货地址主键（mall_member_address.id）；快递必填，自提选填")
    private String addressId;

    @Schema(description = "自提点主键（mall_pickup_point.id）；到店自提时必填")
    private String pickupPointId;

    @Schema(description = "期望到店自提时间（可选）")
    private Date pickupTime;

    @Schema(description = "买家留言")
    private String buyerRemark;

    @Schema(description = "会员优惠券主键（app_member_coupon.id，兼容单券），选填")
    private String memberCouponId;

    @Schema(description = "平台券 app_member_coupon.id")
    private String platformMemberCouponId;

    @Schema(description = "各商户券")
    private List<MallMerchantCouponDTO> merchantCoupons;

    @Schema(description = "运费金额（客户端传入将被忽略；服务端按运费模板与地址重算）")
    private BigDecimal freightAmount;

    @NotEmpty(message = "商品列表不能为空")
    @Valid
    @Schema(description = "下单商品行", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<MallOrderSubmitLineDTO> items;

    @Schema(description = "分享人会员ID（归因快照，选填）")
    private String shareMemberId;

    @Schema(description = "分享归因 JSON 快照（shareToken、activityId、bindTime、scope 等，选填）")
    private String shareAttributionJson;
}
