This repository has been archived on 2020-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
e-commerce/web_backend/src/main/java/org/hso/ecommerce/entities/shop/CustomerOrder.java

60 lines
1.4 KiB
Java

package org.hso.ecommerce.entities.shop;
import org.hso.ecommerce.entities.user.User;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "customer_orders")
public class CustomerOrder {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic
public long id;
@ManyToOne(optional = false)
public User customer;
@Embedded
public Address destination;
@OneToMany(
targetEntity = CustomerOrderPosition.class,
mappedBy = "order", cascade = CascadeType.ALL
)
public List<CustomerOrderPosition> positions = new ArrayList<>();
@NotNull
public java.sql.Timestamp created;
@Column(nullable = true)
public String trackingId;
@Column(nullable = true)
public java.sql.Timestamp inDeliverySince;
@Column(nullable = true)
public java.sql.Timestamp deliveredAt;
public int totalNetCent;
public int totalGrossCent;
public int totalVatCent;
public String formatInDeliverySince(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(inDeliverySince);
}
public String formatCreated(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(created);
}
public String formatDeliveredAt(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(deliveredAt);
}
}