package com.cf.imes.module.system.controller.admin.funds.purchase.vo;


import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.module.system.validation.products.DurationUnitValid;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "管理后台 - 组织购买记录明细 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PurchaseRecordPageReqVO extends PageParam {


    @Schema(description = "组织ID")
    private Long organId;


    @Schema(description = "产品名称")
    private String productName;


    @Schema(description = "购买时长")
    private Integer purchaseDuration;

    @Schema(description = "购买时长单位")
    @DurationUnitValid
    private Integer purchaseDurationUnit;

    @Schema(description = "赠送时长")
    private Integer giftDuration;

    @Schema(description = "赠送时长单位")
    @DurationUnitValid
    private Integer giftDurationUnit;


    @Schema(description = "购买时间", example = "[2022-07-01 01:01:01 ,2022-07-01 01:01:01]")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime[] createTime;


    @Schema(description = "操作人")
    private String creator;

    @Schema(description = "订单号")
    @Size(max = 20, message = "{purchase.record.page.id.size}")
    private String id;

    @Schema(description = "有效时间", example = "[2022-07-01 01:01:01 ,2022-07-01 01:01:01]")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate[] endTime;

    @Schema(hidden = true)
    private LocalDateTime[] endTimeSection;

    @Schema(description = "产品金额")
    @DecimalMin(value = "0.01", message = "{purchase.record.page.productPrice.min}")
    @DecimalMax(value = "100000", message = "{purchase.record.page.productPrice.max}")
    @Digits(integer = 6, fraction = 2, message = "{purchase.record.page.productPrice.format}")
    private BigDecimal productPrice;
}
