File History: src/main/java/com/paymentlink/model/entity/Order.java

← View file content

File Content at Commit 9c24ca4

1 package com.paymentlink.model.entity;
2
3 import com.fasterxml.jackson.annotation.JsonManagedReference;
4 import jakarta.persistence.*;
5 import lombok.AllArgsConstructor;
6 import lombok.Builder;
7 import lombok.Data;
8 import lombok.NoArgsConstructor;
9 import org.hibernate.annotations.CreationTimestamp;
10 import org.hibernate.annotations.UpdateTimestamp;
11
12 import java.time.LocalDateTime;
13 import java.util.ArrayList;
14 import java.util.List;
15
16 @Entity
17 @Table(name = "orders")
18 @Data
19 @NoArgsConstructor
20 @AllArgsConstructor
21 @Builder
22 public class Order {
23
24 @Id
25 @GeneratedValue(strategy = GenerationType.IDENTITY)
26 private Long id;
27
28 @Column(name = "order_id", unique = true, nullable = false)
29 private String orderId; // Custom format: ORD-{timestamp}-{random}
30
31 @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
32 @Builder.Default
33 @JsonManagedReference
34 private List<OrderItem> items = new ArrayList<>();
35
36 @Column(nullable = false)
37 private String status; // pending, completed, failed
38
39 @Column(nullable = false)
40 private Long subtotal; // In cents
41
42 @Column(nullable = false)
43 private Long total; // In cents
44
45 @Column(length = 3, nullable = false)
46 @Builder.Default
47 private String currency = "USD"; // Currency charged to customer
48
49 @Column(name = "original_currency", length = 3)
50 @Builder.Default
51 private String originalCurrency = "USD"; // Product's base currency
52
53 @Column(name = "original_amount")
54 private Long originalAmount; // Original price before conversion
55
56 @Column(name = "exchange_rate")
57 private Double exchangeRate; // Rate used for conversion (for record-keeping)
58
59 @Column(name = "customer_email")
60 private String customerEmail;
61
62 @Column(name = "customer_name")
63 private String customerName;
64
65 @Column(name = "customer_phone")
66 private String customerPhone;
67
68 @Column(name = "customer_contact_preference")
69 private String customerContactPreference;
70
71 @Column(name = "shipping_address")
72 private String shippingAddress;
73
74 @Column(name = "shipping_city")
75 private String shippingCity;
76
77 @Column(name = "shipping_state")
78 private String shippingState;
79
80 @Column(name = "shipping_zip")
81 private String shippingZip;
82
83 @Column(name = "shipping_country")
84 private String shippingCountry;
85
86 @Column(name = "shipping_method")
87 private String shippingMethod;
88
89 @Column(name = "shipping_cost")
90 private Long shippingCost; // In cents
91
92 @Column(name = "tax_amount")
93 private Long taxAmount; // In cents
94
95 @Column(name = "tracking_id")
96 private String trackingId;
97
98 private String carrier;
99
100 @Column(name = "node_id")
101 private String nodeId;
102
103 @CreationTimestamp
104 @Column(name = "created_at", updatable = false)
105 private LocalDateTime createdAt;
106
107 @UpdateTimestamp
108 @Column(name = "updated_at")
109 private LocalDateTime updatedAt;
110
111 // Helper method to add item
112 public void addItem(OrderItem item) {
113 items.add(item);
114 item.setOrder(this);
115 }
116 }
117
118

Commits

Commit Author Date Message File SHA Actions
f0438c2 <f69e50@finnacloud.com> 1766443042 +0300 12/22/2025, 10:37:22 PM increment once more 6ec1ac3 View
188fc92 <f69e50@finnacloud.com> 1766442998 +0300 12/22/2025, 10:36:38 PM increment 6ec1ac3 View
4617f76 <f69e50@finnacloud.com> 1766442953 +0300 12/22/2025, 10:35:53 PM rename branch from main to master oops 6ec1ac3 View
e6d1548 <f69e50@finnacloud.com> 1766442769 +0300 12/22/2025, 10:32:49 PM add initial test workflow file 6ec1ac3 View
9c24ca4 <f69e50@finnacloud.com> 1766442705 +0300 12/22/2025, 10:31:45 PM add CI configuration and test script for Jenkins build 6ec1ac3 Hide
690c1f6 <f69e50@finnacloud.com> 1766368110 +0300 12/22/2025, 1:48:30 AM initialize backend structure with controllers, DTOs, and configuration files 6ec1ac3 View