From cd641d6cc453845c597f8038cc2acb7f5efca320 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Wed, 24 Jun 2020 01:18:16 +0200 Subject: [PATCH 1/2] Fix #113 by fixing initialization of RestServiceForDelivery. --- .../hso/ecommerce/action/shop/EnableTrackingAction.java | 9 ++++++--- .../controller/intern/warehouse/TodoController.java | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/action/shop/EnableTrackingAction.java b/prototype/src/main/java/org/hso/ecommerce/action/shop/EnableTrackingAction.java index d608dea..6726ee2 100644 --- a/prototype/src/main/java/org/hso/ecommerce/action/shop/EnableTrackingAction.java +++ b/prototype/src/main/java/org/hso/ecommerce/action/shop/EnableTrackingAction.java @@ -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); } } diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java index c8fb54f..93ed323 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/warehouse/TodoController.java @@ -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) { From b9e87f5bd486a969ca0348c711b2316e23d62be3 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Wed, 24 Jun 2020 01:19:37 +0200 Subject: [PATCH 2/2] Add additional infos for order history in /user/... fixes #109 --- .../java/org/hso/ecommerce/controller/UserController.java | 5 +++++ .../src/main/resources/templates/user/orders/index.html | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java b/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java index 45c4d32..b4ffc25 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/UserController.java @@ -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"; } diff --git a/prototype/src/main/resources/templates/user/orders/index.html b/prototype/src/main/resources/templates/user/orders/index.html index d54074e..354e213 100644 --- a/prototype/src/main/resources/templates/user/orders/index.html +++ b/prototype/src/main/resources/templates/user/orders/index.html @@ -27,6 +27,10 @@
+ + + + - +
Bestelldatum
Lieferstatus @@ -48,7 +52,7 @@
Sendeverfolgungsnummer