package com.izouma.nineth.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.MintMaterialListConverter;
import com.izouma.nineth.domain.BaseEntity;
import com.izouma.nineth.domain.MintMaterial;
import com.izouma.nineth.domain.MintOrder;
import com.izouma.nineth.enums.MintOrderStatus;
import com.izouma.nineth.enums.PayMethod;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("铸造订单")
public class MintOrderDTO {

    @ExcelProperty("ID")
    private Long id;

    @ExcelProperty("用户ID")
    private Long userId;

    @ExcelProperty("手机号")
    private String phone;

    @ExcelProperty("铸造时间")
    private LocalDateTime createdAt;

    @ExcelProperty("铸造材料")
    private String material;

    @ExcelProperty("状态")
    private String status;

    @ExcelProperty("是否消耗藏品")
    private String consume;

    public MintOrderDTO(MintOrder mintOrder) {
        BeanUtils.copyProperties(mintOrder, this);
        this.status = mintOrder.getStatus().getDescription();
        this.consume = mintOrder.isConsume() ? "是" : "否";
        this.material = mintOrder.getMaterial().stream().map(MintMaterial::getName).collect(Collectors.joining(","));
    }

}
