package cn.reghao.tnb.file.app.zorder.model.vo;

import cn.reghao.jutil.jdk.converter.DateTimeConverter;
import cn.reghao.tnb.content.api.dto.ItemSnapshot;
import cn.reghao.tnb.file.app.zorder.model.constant.OrderStatus;
import cn.reghao.tnb.file.app.zorder.model.po.Order;

/**
 * @author reghao
 * @date 2024-04-19 16:58:24
 */
public class OrderDetail {
    private Long itemId;
    private Long orderId;
    private String title;
    private String picUrl;
    private double price;
    private int amount;
    private int status;
    private String statusText;
    private String createAt;

    public OrderDetail(Order order, ItemSnapshot itemSnapshot) {
        this.itemId = itemSnapshot.getItemId();
        this.orderId = order.getOrderId();
        this.title = itemSnapshot.getTitle();
        this.picUrl = itemSnapshot.getPicUrl();
        this.price = itemSnapshot.getPrice();
        this.amount = order.getAmount();
        this.status = OrderStatus.getByCode(order.getStatus()).getCode();
        this.statusText = OrderStatus.getByCode(order.getStatus()).getDesc();
        this.createAt = DateTimeConverter.format(order.getCreateTime());
    }
}
