package com.yonge.cooleshow.biz.dal.wrapper.coupon;

import com.alibaba.fastjson.JSON;
import com.yonge.cooleshow.biz.dal.enums.coupon.CouponInventoryEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 优惠券库存量调整
 * Created by Eric.Shang on 2022/9/5.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CouponInventoryWrapper implements Serializable {

    private Long id;
    private Long userId;
    private Long couponId;
    private CouponInventoryEnum dataType;
    private Integer number;
    private String remark;
    private Integer status;
    private Date createdTime;

    private String username;
    private String realName;

    public String jsonString() {
        return JSON.toJSONString(this);
    }

    public String getUsername() {
        if (StringUtils.isEmpty(this.username)
                && StringUtils.isNotEmpty(getRealName())) {

            return getRealName();
        }
        return username;
    }
}
