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

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

import javax.validation.constraints.NotNull;

/**
 * 积分账户输入对象
 *
 * @author otto
 */
@Data
@ApiModel("积分账户输入对象")
public class ZonePointsAccountInputVo {
    @ApiModelProperty(value = "用户ID", required = true)
    @NotNull
    private Long userId;

    @ApiModelProperty(value = "专区ID", required = true)
    @NotNull
    private Long zoneId;

    @ApiModelProperty(value = "累计积分")
    private Integer totalPoints;

    @ApiModelProperty(value = "累计获取积分")
    private Integer totalEarnedPoints;

    @ApiModelProperty(value = "累计消费积分")
    private Integer totalConsumedPoints;

    @ApiModelProperty(value = "可用积分")
    private Integer availablePoints;

    @ApiModelProperty(value = "冻结积分")
    private Integer frozenPoints;

    public ZonePointsAccount toZonePointsAccount() {
        ZonePointsAccount zonePointsAccount = new ZonePointsAccount();
        zonePointsAccount.setUserId(userId);
        zonePointsAccount.setZoneId(zoneId);
        zonePointsAccount.setTotalPoints(totalPoints != null ? totalPoints : 0);
        zonePointsAccount.setTotalEarnedPoints(totalEarnedPoints != null ? totalEarnedPoints : 0);
        zonePointsAccount.setTotalConsumedPoints(totalConsumedPoints != null ? totalConsumedPoints : 0);
        zonePointsAccount.setAvailablePoints(availablePoints != null ? availablePoints : 0);
        zonePointsAccount.setFrozenPoints(frozenPoints != null ? frozenPoints : 0);
        return zonePointsAccount;
    }
}