package com.microservices.zone.member.domain.vo;

import com.microservices.zone.member.domain.points.ZonePointsTransaction;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 积分流水输入对象（合并事件+流水，同时兼容原 ZonePointsEventInputVo 的 API 入参）
 *
 * @author otto
 */
@Data
@ApiModel("积分流水输入对象")
public class ZonePointsTransactionInputVo {
    @ApiModelProperty(value = "事件ID")
    private String eventId;

    @ApiModelProperty(value = "专区ID（API 入参，不存入流水表）")
    private Long zoneId;

    @ApiModelProperty(value = "用户ID（API 入参，不存入流水表）")
    private Long userId;

    @ApiModelProperty(value = "事件类型")
    private String eventType;

    @ApiModelProperty(value = "积分账户ID", required = true)
    @NotNull
    private Long accountId;

    @ApiModelProperty(value = "类型：add增/reduce减/freezed冻结/unfreezed解冻", required = true)
    @NotNull
    private String transactionType;

    @ApiModelProperty(value = "积分数量（正数）", required = true)
    @NotNull
    private Integer points;

    @ApiModelProperty(value = "变动后可用积分")
    private Integer availableAfter;

    @ApiModelProperty(value = "变动后冻结积分")
    private Integer frozenAfter;

    @ApiModelProperty(value = "操作人ID")
    private Long operatorId;

    @ApiModelProperty(value = "变动原因")
    private String reason;

    @ApiModelProperty(value = "回复内容")
    private String replyContent;

    @ApiModelProperty(value = "来源ID")
    private Long sourceId;

    @ApiModelProperty(value = "来源数据")
    private String sourceData;

    @ApiModelProperty(value = "主题")
    private String subject;

    @ApiModelProperty(value = "主题描述")
    private String subjectDesc;

    public ZonePointsTransaction toZonePointsTransaction() {
        ZonePointsTransaction zonePointsTransaction = new ZonePointsTransaction();
        zonePointsTransaction.setEventId(eventId);
        zonePointsTransaction.setEventType(eventType);
        zonePointsTransaction.setAccountId(accountId);
        zonePointsTransaction.setTransactionType(transactionType);
        zonePointsTransaction.setPoints(points);
        zonePointsTransaction.setAvailableAfter(availableAfter);
        zonePointsTransaction.setFrozenAfter(frozenAfter);
        zonePointsTransaction.setOperatorId(operatorId);
        zonePointsTransaction.setReason(reason);
        zonePointsTransaction.setReplyContent(replyContent);
        zonePointsTransaction.setSourceId(sourceId);
        zonePointsTransaction.setSourceData(sourceData);
        zonePointsTransaction.setSubject(subject);
        zonePointsTransaction.setSubjectDesc(subjectDesc);
        return zonePointsTransaction;
    }
}