~ order overview done
~ template changes for users not logged in.
This commit is contained in:
parent
1965331149
commit
cc06ec797e
|
@ -6,7 +6,6 @@ import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,12 +33,14 @@ public class Order {
|
||||||
@NonNull private Payment payment;
|
@NonNull private Payment payment;
|
||||||
@NonNull private Address address;
|
@NonNull private Address address;
|
||||||
|
|
||||||
public String getItemNames() {
|
public String getFormattedPrice() {
|
||||||
List<String> titles = new ArrayList<>();
|
String res = "";
|
||||||
for(OrderItem item : items) {
|
res += price / 100;
|
||||||
titles.add(item.getBook().getTitle());
|
res += ",";
|
||||||
|
if (price % 100 < 10) {
|
||||||
|
res += "0";
|
||||||
}
|
}
|
||||||
|
res += price % 100;
|
||||||
return String.join(", ", titles);
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -36,7 +36,7 @@ public class CartBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String add(Book book) {
|
public String add(Book book) {
|
||||||
if (getUser() != null) {
|
if (getUser() != null && getUser().getId() != 0) {
|
||||||
for (ShoppingCartItem item : getItems()) {
|
for (ShoppingCartItem item : getItems()) {
|
||||||
if (item.getArticle().getId() == book.getId()) {
|
if (item.getArticle().getId() == book.getId()) {
|
||||||
Database.getInstance().shoppingCart().delete(item);
|
Database.getInstance().shoppingCart().delete(item);
|
||||||
|
@ -66,11 +66,6 @@ public class CartBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void setItems(List<ShoppingCartItem> list) {
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public String buy() {
|
public String buy() {
|
||||||
ArrayList<OrderItem> orderList = new ArrayList<>();
|
ArrayList<OrderItem> orderList = new ArrayList<>();
|
||||||
for (ShoppingCartItem item : getItems()) {
|
for (ShoppingCartItem item : getItems()) {
|
||||||
|
@ -80,7 +75,7 @@ public class CartBean {
|
||||||
for (ShoppingCartItem item : getItems()) {
|
for (ShoppingCartItem item : getItems()) {
|
||||||
Database.getInstance().shoppingCart().delete(item);
|
Database.getInstance().shoppingCart().delete(item);
|
||||||
}
|
}
|
||||||
return "index.jsf";
|
return "thanks.jsf";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
|
@ -10,17 +10,43 @@
|
||||||
|
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
<ui:repeat value="#{orderBean.orders}" var="order">
|
<ui:repeat value="#{orderBean.orders}" var="order">
|
||||||
<div class="m-row">
|
<div class="m-block m-primary">
|
||||||
<div class="m-col-t-12">
|
<div class="m-row">
|
||||||
<div class="m-block m-primary">
|
<div class="m-col-t-4">
|
||||||
#{order.itemNames}
|
<h:outputText value="#{order.date}">
|
||||||
#{order.payment.type.name}
|
<f:convertDateTime pattern="dd.MM.yyyy"/>
|
||||||
|
</h:outputText>
|
||||||
|
<ui:repeat value="#{order.items}" var="item">
|
||||||
|
<br/>
|
||||||
|
</ui:repeat>
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-4">
|
||||||
|
<ul>
|
||||||
|
<ui:repeat value="#{order.items}" var="item">
|
||||||
|
<li>
|
||||||
|
#{item.book.title} - #{item.book.authorsString}
|
||||||
|
</li>
|
||||||
|
</ui:repeat>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-4">
|
||||||
|
<p class="m-text-right">
|
||||||
|
#{order.payment.type.name}
|
||||||
|
</p>
|
||||||
|
<p class="m-text-right">
|
||||||
|
#{order.formattedPrice} €
|
||||||
|
</p>
|
||||||
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ui:repeat>
|
</ui:repeat>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
|
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
<div class="m-row">
|
<div class="m-row">
|
||||||
<ol class="m-col-t-6 m-col-m-none">
|
<ol class="m-col-t-6 m-col-m-none">
|
||||||
<li><a href="category.xhtml">Katalog</a></li>
|
<li><a href="category.xhtml">Katalog</a></li>
|
||||||
<li><a href="cart.jsf">(#{cartBean.itemCount}) Warenkorb</a></li>
|
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||||
|
<li><a href="cart.jsf">(#{cartBean.itemCount}) Warenkorb</a></li>
|
||||||
|
</h:panelGroup>
|
||||||
</ol>
|
</ol>
|
||||||
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
<h:panelGroup layout="block" rendered="#{userBean.loggedIn}">
|
||||||
<ol class="m-col-t-6 m-col-m-none" start="4">
|
<ol class="m-col-t-6 m-col-m-none" start="4">
|
||||||
|
@ -48,7 +50,9 @@
|
||||||
<li><a href="orders.jsf">Meine Bestellungen</a></li>
|
<li><a href="orders.jsf">Meine Bestellungen</a></li>
|
||||||
<li><a href="address.jsf">Adressen</a></li>
|
<li><a href="address.jsf">Adressen</a></li>
|
||||||
<li><a href="payments.jsf">Zahlungsmöglichkeiten</a></li>
|
<li><a href="payments.jsf">Zahlungsmöglichkeiten</a></li>
|
||||||
<li><a href="logout.jsf">Abmelden</a></li>
|
<h:form>
|
||||||
|
<li><h:commandLink action="#{userBean.logout}">Abmelden</h:commandLink></li>
|
||||||
|
</h:form>
|
||||||
</ol>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
Loading…
Reference in New Issue