package cn.pluss.platform.entity;

import cn.pluss.platform.config.mybatis.SqlConditionExtra;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;

/**
 * <p>
 * 按日统计商户的账单
 * </p>
 *
 * @author Djh
 * @since 2021-03-11
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_pluss_merchant_bill_statistics")
public class MerchantBillStatistics implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    /**
     * 用户id
     */
    @TableField("userId")
    private Integer userId;


    /**
     * 开始日期
     */
    @TableField("startDate")
    private LocalDate startDate;

    @TableField(value = "lastStartDate", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private LocalDate lastStartDate;

    @TableField(value = "lastEndDate", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private LocalDate lastEndDate;

    /**
     * 开始时间的查询开始时间
     */
    @TableField(exist = false, condition = "startDate &gt;= #{%s}")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDateStart;

    /**
     * 开始时间的查询截止时间
     */
    @TableField(exist = false, condition = "startDate &lt; #{%s}")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDateEnd;

    /**
     * 截止日期, 包含
     */
    @TableField("endDate")
    private LocalDate endDate;

    /**
     * 截止时间的查询开始时间
     */
    @TableField(exist = false, condition = "endDate &gt;= #{%s}")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDateStart;

    /**
     * 截止时间的查询截止时间
     */
    @TableField(exist = false, condition = "endDate &lt; #{%s}")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDateEnd;


    /**
     * 账单类型，1：日；2：周；3：月；4：年
     */
    @TableField("type")
    private Integer type;


    /**
     * 金额总计
     */
    @TableField("amount")
    private BigDecimal amount;


    /**
     * 笔数
     */
    @TableField("count")
    private Integer count;


    /**
     * 备注
     */
    @TableField("remark")
    private String remark;


    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 创建时间 开始时间
     */
    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.GT)
    private Date createTimeStart;

    /**
     * 创建时间 截止时间
     */
    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.LT)
    private Date createTimeEnd;

    /**
     * 更新时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 更新时间 开始时间
     */
    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.GT)
    private Date updateTimeStart;

    /**
     * 更新时间 截止时间
     */
    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.LT)
    private Date updateTimeEnd;

}