Merge pull request 'feature/fix_delivery_api' (#116) from feature/fix_delivery_api into master

Reviewed-on: #116
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
This commit is contained in:
Jannik 2020-06-24 18:38:03 +02:00
commit 2290f01a8f
4 changed files with 21 additions and 5 deletions

View File

@ -4,10 +4,13 @@ import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.springframework.web.client.ResourceAccessException;
import java.sql.Timestamp;
import java.util.Date;
public class EnableTrackingAction {
public static void addTrackingInfo(CustomerOrder customerOrder) throws ResourceAccessException {
customerOrder.trackingId = new RestServiceForDelivery().getDeliveryID(customerOrder);
public static void addTrackingInfo(RestServiceForDelivery deliveryService, CustomerOrder customerOrder) throws ResourceAccessException {
customerOrder.inDeliverySince = new Timestamp(new Date().getTime());
customerOrder.trackingId = deliveryService.getDeliveryID(customerOrder);
}
}

View File

@ -3,6 +3,7 @@ package org.hso.ecommerce.controller;
import org.hso.ecommerce.action.user.CreateDeliveryData;
import org.hso.ecommerce.action.user.UpdateUserSettingsAction;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.app.config.AppSettings;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
@ -31,6 +32,9 @@ public class UserController {
@Autowired
private final RestServiceForDelivery restServiceForDelivery = null;
@Autowired
private final AppSettings appSettings = null;
@GetMapping("/")
public String user() {
return "redirect:/user/settings";
@ -58,6 +62,7 @@ public class UserController {
.collect(Collectors.toList());
model.addAttribute("orderDeliveryDataMap", customerOrderDeliveryDataMap);
model.addAttribute("deliveryService", appSettings.getParcelServiceName());
return "user/orders/index";
}

View File

@ -1,6 +1,7 @@
package org.hso.ecommerce.controller.intern.warehouse;
import org.hso.ecommerce.action.shop.EnableTrackingAction;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.warehouse.WarehouseBooking;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,6 +24,9 @@ public class TodoController {
@Autowired
private final WarehouseBookingRepository warehouseBookingRepository = null;
@Autowired
private final RestServiceForDelivery deliveryService = null;
@GetMapping("todo")
public String accountingWarehouseTodo(
Model model
@ -77,7 +81,7 @@ public class TodoController {
// Update Delivery Date
if (booking.get().reason.customerOrder != null) {
try{
EnableTrackingAction.addTrackingInfo(booking.get().reason.customerOrder);
EnableTrackingAction.addTrackingInfo(deliveryService, booking.get().reason.customerOrder);
}
catch(ResourceAccessException e)
{

View File

@ -27,6 +27,10 @@
<div th:if="${!orderDeliveryDataMap.isEmpty()}" th:each="order: ${orderDeliveryDataMap}">
<div>
<table class="key-value">
<tr>
<th>Bestelldatum</th>
<td th:text="${order.customerOrder.created}"></td>
</tr>
<tr>
<th>Lieferstatus</th>
<td th:if="${order.deliveryData.allOk()}"><span th:text="${order.deliveryData.getStatus()}"/>
@ -48,7 +52,7 @@
</tr>
<tr>
<th>Sendeverfolgungsnummer</th>
<td th:text="${order.customerOrder.trackingId!=null} ? ${order.customerOrder.trackingId} : 'Es wurde noch keine Sendungsnummer vergeben'"></td>
<td th:text="${order.customerOrder.trackingId!=null} ? ${deliveryService + ', ' + order.customerOrder.trackingId} : 'Es wurde noch keine Sendungsnummer vergeben'"></td>
</tr>
<tr>
<th></th>