package com.liquidnet.service.stone.vo;

import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.stone.entity.StoneScoreItems;
import com.liquidnet.service.stone.entity.StoneScoreOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@ApiModel
public class StoneOrderListVo implements Serializable, Cloneable {

    @ApiModelProperty(value = "orderId", example = "1")
    private String orderId;

    @ApiModelProperty(value = "积分物品封面图", example = "http://xxxxx.png")
    private String img;

    @ApiModelProperty(value = "用户id", example = "1")
    private String uid;

    @ApiModelProperty(value = "积分物品名称", example = "测试券")
    private String targetTitle;

    @ApiModelProperty(value = "购买数量", example = "1")
    private Integer number;

    @ApiModelProperty(value = "支付积分", example = "100.00")
    private Integer score;

    @ApiModelProperty(value = "支付价格", example = "0.00")
    private BigDecimal price;

    @ApiModelProperty(value = "状态状态[0-待支付|1-已支付|2-已关闭]", example = "1")
    private Integer status;

    @ApiModelProperty(value = "订单号", example = "123123")
    private String orderCode;

    @ApiModelProperty(value = "创建时间", example = "2021-12-01 12:21:32")
    private String createdAt;

    private static final StoneOrderListVo obj = new StoneOrderListVo();

    public static StoneOrderListVo getNew() {
        try {
            return (StoneOrderListVo) obj.clone();
        } catch (CloneNotSupportedException e) {
            return new StoneOrderListVo();
        }
    }

    public StoneOrderListVo copy(StoneScoreOrder source, String img, String uid) {
        if (null == source) return this;
        this.setOrderId(source.getOrderId());
        this.setImg(img);
        this.setUid(uid);
        this.setTargetTitle(source.getTargetTitle());
        this.setNumber(source.getNumber());
        this.setScore(source.getScore().intValue());
        this.setPrice(source.getPrice());
        this.setStatus(source.getStatus());
        this.setOrderCode(source.getOrderCode());
        this.setCreatedAt(DateUtil.Formatter.yyyyMMddHHmmss.format(source.getCreatedAt()));
        return this;
    }
}
