show all Orders
This commit is contained in:
parent
106b00a907
commit
b5495bda3d
|
@ -0,0 +1,7 @@
|
|||
package org.hso.ecommerce.action.user;
|
||||
|
||||
import org.hso.ecommerce.entities.user.User;
|
||||
|
||||
public class ChangeUserAction {
|
||||
|
||||
}
|
|
@ -1,14 +1,19 @@
|
|||
package org.hso.ecommerce.controller;
|
||||
|
||||
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||
import org.hso.ecommerce.entities.user.User;
|
||||
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
|
||||
import org.hso.ecommerce.repos.user.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
|
@ -17,6 +22,9 @@ public class UserController {
|
|||
@Autowired
|
||||
private final UserRepository userRepository = null;
|
||||
|
||||
@Autowired
|
||||
private final CustomerOrderRepository customerOrderRepository = null;
|
||||
|
||||
@GetMapping("/")
|
||||
public String user() {
|
||||
return "redirect:/user/settings";
|
||||
|
@ -37,14 +45,63 @@ public class UserController {
|
|||
|
||||
@GetMapping("/notifications/")
|
||||
public String userNotifications() {
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/notifications/index";
|
||||
}
|
||||
|
||||
@GetMapping("/orders/")
|
||||
public String userOrdeers() {
|
||||
public String userOrdeers(HttpSession session,
|
||||
Model model) {
|
||||
|
||||
List<CustomerOrder> orders = customerOrderRepository.getOrdersByUserId((long) session.getAttribute("userId"));
|
||||
|
||||
model.addAttribute("orders", orders);
|
||||
|
||||
return "user/orders/index";
|
||||
}
|
||||
|
||||
@PostMapping("/settings/changeMail")
|
||||
public String changeMail(@RequestParam("email") String email){
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/settings";
|
||||
}
|
||||
|
||||
@PostMapping("/settings/changePwd")
|
||||
public String changePwd(){
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/settings";
|
||||
}
|
||||
|
||||
@PostMapping("/settings/changeAddress")
|
||||
public String changeAddress(){
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/settings";
|
||||
}
|
||||
|
||||
@PostMapping("/settings/changeAdSettings")
|
||||
public String changeAdSettings(){
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/settings";
|
||||
}
|
||||
|
||||
@PostMapping("/settings/changePaymentInfo")
|
||||
public String changePaymentInfo(){
|
||||
|
||||
//TODO: implement this
|
||||
|
||||
return "user/settings";
|
||||
}
|
||||
|
||||
// @GetMapping("/bonuspoints")
|
||||
// public String userBonuspoints() {
|
||||
// return "user/bonuspoints";
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.hso.ecommerce.entities.user.User;
|
|||
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
|
||||
import org.hso.ecommerce.repos.booking.BookingRepository;
|
||||
import org.hso.ecommerce.repos.shop.ArticleRepository;
|
||||
import org.hso.ecommerce.repos.shop.CustomerOderRepository;
|
||||
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
|
||||
import org.hso.ecommerce.repos.user.UserRepository;
|
||||
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
|
||||
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
|
||||
|
@ -45,7 +45,7 @@ public class ShopCheckoutController {
|
|||
private final WarehouseBookingRepository warehouseBookingRepository = null;
|
||||
|
||||
@Autowired
|
||||
private final CustomerOderRepository customerOderRepository = null;
|
||||
private final CustomerOrderRepository customerOderRepository = null;
|
||||
|
||||
@Autowired
|
||||
private final WarehouseBookingPositionSlotEntryRepository wbeseRepo = null;
|
||||
|
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
|
@ -43,4 +44,16 @@ public class CustomerOrder {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ public class CustomerOrderPosition {
|
|||
|
||||
public int pricePerUnit;
|
||||
public int quantity;
|
||||
|
||||
public int getSumPrice(){
|
||||
return article.getPriceGross() * quantity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ public class User {
|
|||
return id;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public boolean validatePassword(String password) {
|
||||
return BCrypt.checkpw(password, passwordHash);
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package org.hso.ecommerce.repos.shop;
|
||||
|
||||
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CustomerOderRepository extends JpaRepository<CustomerOrder, Long> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.hso.ecommerce.repos.shop;
|
||||
|
||||
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Long> {
|
||||
|
||||
@Query("SELECT co FROM CustomerOrder co WHERE co.customer.id = :userId")
|
||||
List<CustomerOrder> getOrdersByUserId(long userId);
|
||||
|
||||
}
|
||||
|
|
@ -21,26 +21,22 @@
|
|||
<main class="sidebar-layout content-width">
|
||||
<nav th:replace="fragments/customer :: sidebar"></nav>
|
||||
<div class="content-width detailflex">
|
||||
<div>
|
||||
<h2 id="20202701"> Bestellung vom 27.01.2020 </h2>
|
||||
<div th:each="order: ${orders}">
|
||||
<h2 id="20202701" th:text="|Bestellung vom ${order.formatCreated()}" />
|
||||
<div>
|
||||
<table class="key-value">
|
||||
<tr>
|
||||
<th>Lieferstatus</th>
|
||||
<td><b>Unterwegs</b> <br/> Vorraussichtliche Ankunft: 29.01.2020</td>
|
||||
<td th:if="${order.deliveredAt == null}"><b>Unterwegs</b> <br/> Vorraussichtliche Ankunft: TODO TODO TODO TODO</td>
|
||||
<td th:if="${order.deliveredAt != null}"><b>Angekommen</b> <br/> Ankunft: <span th:text="${order.formatDeliveredAt()}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sendeverfolgungsnummer</th>
|
||||
<td>XE51451436DE</td>
|
||||
<td th:text="${order.trackingId}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
Hans Maier <br/>
|
||||
Hauptstraße 12<br/>
|
||||
74880 Musterstadt<br/>
|
||||
Deutschland <br/>
|
||||
</td>
|
||||
<td th:text="${order.destination.toString()}" />
|
||||
</tr>
|
||||
<!--<tr>
|
||||
<th>Eingelösste Bonuspunkte</th>
|
||||
|
@ -55,17 +51,11 @@
|
|||
<th>Menge</th>
|
||||
<th>Preis (Brutto)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a th:href="@{/shop/articles/4151}"><img th:src="@{/img/product-1.jpg}" class="s"/><a></td>
|
||||
<td><a th:href="@{/shop/articles/4151}">Kamera<a/></td>
|
||||
<td> 1</td>
|
||||
<td>100,50 EUR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a th:href="@{/shop/articles/4151}"><img th:src="@{/img/product-2.jpg}" class="s"/><a/></td>
|
||||
<td><a th:href="@{/shop/articles/4151}">Earbuds<a/></td>
|
||||
<td> 3</td>
|
||||
<td>63,95 EUR</td>
|
||||
<tr th:each="position: ${order.positions}">
|
||||
<td><a th:href="@{/shop/articles/{id}(id = ${position.article.id})}"><img th:src="@{/shop/articles/{id}/image.jpg(id=${position.article.id})}" class="s"/></a></td>
|
||||
<td><a th:href="@{/shop/articles/{id}(id = ${position.article.id})}" th:text="${position.article.title}" class="s"></a></td>
|
||||
<td th:text="${position.quantity}" />
|
||||
<td th:text="${#numbers.formatDecimal(position.getSumPrice() * 0.01, 1, 'POINT', 2, 'COMMA')}" />
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
@ -77,7 +67,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td>Artikel (Netto)</td>
|
||||
<td> 120,00 EUR</td>
|
||||
<td th:text="${#numbers.formatDecimal(order.totalNetCent * 0.01, 1, 'POINT', 2, 'COMMA')}" />
|
||||
</tr>
|
||||
<!--<tr>
|
||||
<td></td>
|
||||
|
@ -88,14 +78,8 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Umsatzsteuer (19%)</td>
|
||||
<td> 42,00 EUR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Umsatzsteuer (7%)</td>
|
||||
<td> 2,00 EUR</td>
|
||||
<td>Umsatzsteuer</td>
|
||||
<td th:text="${#numbers.formatDecimal(order.totalVatCent * 0.01, 1, 'POINT', 2, 'COMMA')}" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
|
@ -104,7 +88,7 @@
|
|||
<h3>Gesammtpreis</h3>
|
||||
</td>
|
||||
<td>
|
||||
<h3>240,79 EUR</h3>
|
||||
<h3 th:text="${#numbers.formatDecimal(order.totalGrossCent * 0.01, 1, 'POINT', 2, 'COMMA')}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<main class="sidebar-layout content-width">
|
||||
<nav th:replace="fragments/customer :: sidebar"></nav>
|
||||
<div class="content-width">
|
||||
<form class="detailflex">
|
||||
<form method="POST" th:action="@{/user/settings/changeMail}">
|
||||
<div>
|
||||
<h2> Login Daten </h2>
|
||||
</div>
|
||||
|
|
Reference in New Issue