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 lombok.Data;
import org.hibernate.validator.constraints.Range;

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

/**
 * 押金保存对象
 */
@Data
public class PropertyDepositSaveDto {

    /**
     * 主键id
     */
    private Long id;
    /**
     * 是否退款; 0-否（交押金），1-是
     */
    @NotNull(message = "是否退款标识不能为空")
    @Range(min = 0, max = 1, message = "退款标识参数不正确")
    private Integer isRefund;
    /**
     * 园区id
     */
    @NotNull(message = "园区不能为空")
    private Long parkId;
    /**
     * 客户
     */
    @NotNull(message = "客户不为空")
    private Long customerId;
    /**
     * 收费标准
     */
    @NotNull(message = "收费标准不能为空")
    private Long feeId;
    /**
     * 押金金额
     */
    @JsonIgnore
    private Long depositAmtFen;
    public Long getDepositAmtFen() {
        return AmtUtil.yuanToFenObj(this.depositAmt);
    }

    @NotNull(message = "押金金额不能为空")
    @Positive(message = "金额必须大于")
    private BigDecimal depositAmt;

    /**
     * 退款金额
     */
    @NotNull(message = "押金金额不能为空", groups = {RefundThird.class, RefundBank.class})
    private BigDecimal refundAmt;

    @JsonIgnore
    private Long refundAmtFen;
    public Long getRefundAmtFen() {
        return AmtUtil.yuanToFenObj(this.refundAmt);
    }
    /**
     * 收费开始时间
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @NotNull(message = "收费开始时间不能为空", groups = {Unpaid.class, Cash.class, Third.class, Bank.class})
    private Date startDate;
    /**
     * 收费结束时间
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @NotNull(message = "收费结束时间不能为空", groups = {Unpaid.class, Cash.class, Third.class, Bank.class})
    private Date endDate;
    /**
     * 收费状态 0-未收，1-已收
     * YesOrNoEnum
     */
//    @NotNull(message = "收费状态不能为空", groups = {Pay.class})
    private Integer chargeType;

    /**
     * 收费方式; 1-现金，2-第三方转账，3-银行卡转账，4-在线支付
     */
//    @NotNull(message = "收费方式不能为空", groups = {Pay.class,Cash.class, Third.class, Bank.class})
    @Min(value = 1,message = "收费方式参数不正确")
    private Integer payType;
    /**
     * 退款方式;1-在线原路退回，2-第三方转账，3-银行卡转账
     */
//    @NotNull(message = "退款方式不能为空", groups = {Refund.class})
    @Min(value = 1,message = "退款方式参数不正确")
    private Integer refundType;
    /**
     * 付款时间
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "付款时间不能为空", groups = {Cash.class, Third.class, Bank.class})
    private Date payTime;
    /**
     * 退款时间
     */
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "退款时间不能为空", groups = {RefundThird.class, RefundBank.class})
    private Date refundTime;
    /**
     * 付款人员
     */
    @NotNull(message = "付款人员不能为空", groups = {Cash.class, Third.class, Bank.class})
    private String payUser;
    /**
     * 收费人员
     */
    @NotNull(message = "收费人员不能为空", groups = {Cash.class})
    private String receiveUser;
    /**
     * 第三方类型; 1-微信，2-支付宝
     */
    @NotNull(message = "第三方不能为空", groups = {Third.class, RefundThird.class})
    private Integer thirdPartyType;
    /**
     * 付款银行
     */
    @NotNull(message = "付款银行不能为空", groups = {Bank.class, RefundBank.class})
    private String payBank;
    /**
     * 付款账户
     */
    @NotNull(message = "付款账户不能为空", groups = {Third.class, Bank.class, RefundThird.class, RefundBank.class})
    private String payAccount;
    /**
     * 收款银行
     */
    @NotNull(message = "收款银行不能为空", groups = {Bank.class, RefundThird.class})
    private String receiveBank;
    /**
     * 收款账户
     */
    @NotNull(message = "收款账户不能为空", groups = {Third.class, Bank.class, RefundThird.class, RefundBank.class})
    private String receiveAccount;
    /**
     * 交易单号
     */
    @NotNull(message = "交易单号不能为空", groups = {Third.class, Bank.class, RefundThird.class, RefundBank.class})
    private String transactionNum;
    /**
     * 交易截图
     */
    @NotNull(message = "交易截图不能为空", groups = {Cash.class, Third.class, Bank.class, RefundThird.class, RefundBank.class})
    private String filePath;
    /**
     * 备注
     */
    private String remark;
    /**
     * 房源ids
     */
    private List<Long> houseIdList;

//    public interface Pay {} // 交押金
//    public interface Refund {} // 退款
    public interface Unpaid {} // 收费状态-未收
    public interface Cash {} // 现金
    public interface Third {} // 第三方
    public interface Bank {} // 银行卡
    public interface RefundRoad {} // 原路退回
    public interface RefundThird {} // 第三方退回
    public interface RefundBank {} // 银行卡退回

}
