package com.yuchen.saas.park.api.dto.property;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkunion.park.service.common.utils.AmtUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 固定金额分摊
 */
@Data
@ApiModel
public class PropertyShareFeeSaveDto {


    @ApiModelProperty
    private Long id;

    /**
     * 园区id
     */
    @NotNull(message = "园区不能为空")
    @ApiModelProperty
    private Long parkId;

    /**
     * 收费标准
     */
    @NotNull(message = "收费标准不能为空")
    @ApiModelProperty
    private Long feeId;

    /**
     * 分摊方式;1-按户分摊，2-按建筑面积
     * ShareTypeEnum
     */
    @NotNull(message = "分摊方式不能为空")
    @ApiModelProperty
    private int shareType;

    /**
     * 分摊总金额;单位：分
     */
    @JsonIgnore
    private long totalAmtFen;
    public long getTotalAmtFen() {
        return AmtUtil.yuanToFen(this.totalAmt);
    }

    /**
     * 分摊总金额;单位元
     */
    @NotNull(message = "分摊总金额不能为空")
    @ApiModelProperty
    private BigDecimal totalAmt;

    /**
     * 费用开始时间
     */
    @NotNull(message = "费用日期不能为空")
    @ApiModelProperty
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    private Date startDate;

    /**
     * 费用结束时间
     */
    @NotNull(message = "费用日期不能为空")
    @ApiModelProperty
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    private Date endDate;

    /**
     * 备注
     */
    @ApiModelProperty
    private String remark;

    /**
     * 房源id; 逗号分隔拼接
     */
    @ApiModelProperty
    private String strHouseIds;

    @JsonIgnore
    private long shareAmtFen;

    /**
     * 分摊合计金额; 单位：元
     */
    public BigDecimal getTotalShareAmt() {
        return AmtUtil.fenToYuan(shareAmtFen);
    }

}
