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;
|
package org.hso.ecommerce.controller;
|
||||||
|
|
||||||
|
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||||
import org.hso.ecommerce.entities.user.User;
|
import org.hso.ecommerce.entities.user.User;
|
||||||
|
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
|
||||||
import org.hso.ecommerce.repos.user.UserRepository;
|
import org.hso.ecommerce.repos.user.UserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
|
@ -17,6 +22,9 @@ public class UserController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private final UserRepository userRepository = null;
|
private final UserRepository userRepository = null;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final CustomerOrderRepository customerOrderRepository = null;
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String user() {
|
public String user() {
|
||||||
return "redirect:/user/settings";
|
return "redirect:/user/settings";
|
||||||
|
@ -37,14 +45,63 @@ public class UserController {
|
||||||
|
|
||||||
@GetMapping("/notifications/")
|
@GetMapping("/notifications/")
|
||||||
public String userNotifications() {
|
public String userNotifications() {
|
||||||
|
|
||||||
|
//TODO: implement this
|
||||||
|
|
||||||
return "user/notifications/index";
|
return "user/notifications/index";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/orders/")
|
@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";
|
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")
|
// @GetMapping("/bonuspoints")
|
||||||
// public String userBonuspoints() {
|
// public String userBonuspoints() {
|
||||||
// return "user/bonuspoints";
|
// 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.BookingAccountEntryRepository;
|
||||||
import org.hso.ecommerce.repos.booking.BookingRepository;
|
import org.hso.ecommerce.repos.booking.BookingRepository;
|
||||||
import org.hso.ecommerce.repos.shop.ArticleRepository;
|
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.user.UserRepository;
|
||||||
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
|
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
|
||||||
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
|
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
|
||||||
|
@ -45,7 +45,7 @@ public class ShopCheckoutController {
|
||||||
private final WarehouseBookingRepository warehouseBookingRepository = null;
|
private final WarehouseBookingRepository warehouseBookingRepository = null;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private final CustomerOderRepository customerOderRepository = null;
|
private final CustomerOrderRepository customerOderRepository = null;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private final WarehouseBookingPositionSlotEntryRepository wbeseRepo = null;
|
private final WarehouseBookingPositionSlotEntryRepository wbeseRepo = null;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.hso.ecommerce.entities.user.User;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -43,4 +44,16 @@ public class CustomerOrder {
|
||||||
public int totalNetCent;
|
public int totalNetCent;
|
||||||
public int totalGrossCent;
|
public int totalGrossCent;
|
||||||
public int totalVatCent;
|
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 pricePerUnit;
|
||||||
public int quantity;
|
public int quantity;
|
||||||
|
|
||||||
|
public int getSumPrice(){
|
||||||
|
return article.getPriceGross() * quantity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ public class User {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean validatePassword(String password) {
|
public boolean validatePassword(String password) {
|
||||||
return BCrypt.checkpw(password, passwordHash);
|
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">
|
<main class="sidebar-layout content-width">
|
||||||
<nav th:replace="fragments/customer :: sidebar"></nav>
|
<nav th:replace="fragments/customer :: sidebar"></nav>
|
||||||
<div class="content-width detailflex">
|
<div class="content-width detailflex">
|
||||||
<div>
|
<div th:each="order: ${orders}">
|
||||||
<h2 id="20202701"> Bestellung vom 27.01.2020 </h2>
|
<h2 id="20202701" th:text="|Bestellung vom ${order.formatCreated()}" />
|
||||||
<div>
|
<div>
|
||||||
<table class="key-value">
|
<table class="key-value">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Lieferstatus</th>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Sendeverfolgungsnummer</th>
|
<th>Sendeverfolgungsnummer</th>
|
||||||
<td>XE51451436DE</td>
|
<td th:text="${order.trackingId}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<td>
|
<td th:text="${order.destination.toString()}" />
|
||||||
Hans Maier <br/>
|
|
||||||
Hauptstraße 12<br/>
|
|
||||||
74880 Musterstadt<br/>
|
|
||||||
Deutschland <br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<!--<tr>
|
<!--<tr>
|
||||||
<th>Eingelösste Bonuspunkte</th>
|
<th>Eingelösste Bonuspunkte</th>
|
||||||
|
@ -55,17 +51,11 @@
|
||||||
<th>Menge</th>
|
<th>Menge</th>
|
||||||
<th>Preis (Brutto)</th>
|
<th>Preis (Brutto)</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr th:each="position: ${order.positions}">
|
||||||
<td><a th:href="@{/shop/articles/4151}"><img th:src="@{/img/product-1.jpg}" class="s"/><a></td>
|
<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/4151}">Kamera<a/></td>
|
<td><a th:href="@{/shop/articles/{id}(id = ${position.article.id})}" th:text="${position.article.title}" class="s"></a></td>
|
||||||
<td> 1</td>
|
<td th:text="${position.quantity}" />
|
||||||
<td>100,50 EUR</td>
|
<td th:text="${#numbers.formatDecimal(position.getSumPrice() * 0.01, 1, 'POINT', 2, 'COMMA')}" />
|
||||||
</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>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -77,7 +67,7 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Artikel (Netto)</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>
|
||||||
<!--<tr>
|
<!--<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
@ -88,14 +78,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Umsatzsteuer (19%)</td>
|
<td>Umsatzsteuer</td>
|
||||||
<td> 42,00 EUR</td>
|
<td th:text="${#numbers.formatDecimal(order.totalVatCent * 0.01, 1, 'POINT', 2, 'COMMA')}" />
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td>Umsatzsteuer (7%)</td>
|
|
||||||
<td> 2,00 EUR</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
@ -104,7 +88,7 @@
|
||||||
<h3>Gesammtpreis</h3>
|
<h3>Gesammtpreis</h3>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h3>240,79 EUR</h3>
|
<h3 th:text="${#numbers.formatDecimal(order.totalGrossCent * 0.01, 1, 'POINT', 2, 'COMMA')}"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<main class="sidebar-layout content-width">
|
<main class="sidebar-layout content-width">
|
||||||
<nav th:replace="fragments/customer :: sidebar"></nav>
|
<nav th:replace="fragments/customer :: sidebar"></nav>
|
||||||
<div class="content-width">
|
<div class="content-width">
|
||||||
<form class="detailflex">
|
<form method="POST" th:action="@{/user/settings/changeMail}">
|
||||||
<div>
|
<div>
|
||||||
<h2> Login Daten </h2>
|
<h2> Login Daten </h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in New Issue