Skip to content

Commit

Permalink
balancing user account
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaikar committed Nov 26, 2015
1 parent fe9e935 commit 31beae4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/main/java/com/ots/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,14 @@ public String makePayment(ModelMap model, HttpServletRequest request,
// Check if user has appropriate role or not if user does not has
// CANCEL_ORDER feature access, reject and log user out
ClientBean clientBean = (ClientBean) request.getSession().getAttribute("selectedClient");
model.addAttribute("amountDue",
(orderSerivceImpl.getTotalAmountToBePaid(Arrays.asList(orderIds.split(","))) * 100
+ clientBean.getBalanceAmount()));
Long orderCost = new Float(orderSerivceImpl.getTotalAmountToBePaid(Arrays.asList(orderIds.split(","))) * 100
+ clientBean.getBalanceAmount()*100).longValue();

System.out.println("orders_total_Amout: "+orderCost);

model.addAttribute("amountDue",
orderCost);

model.addAttribute("balAmount", clientBean.getBalanceAmount() + "$");
return ("payment");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ots/dao/OrderDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ public void setValues(java.sql.PreparedStatement ps) throws SQLException {
}
}, new RowMapper<Float>() {
public Float mapRow(ResultSet rs, int rowNum) throws SQLException {
System.out.println("rs.getdfloat"+rs.getFloat("total"));
return rs.getFloat("total");
}

});
System.out.println("-->"+orders);
return orders.get(0);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/ots/rowmapper/ClientRowMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class ClientRowMapper implements RowMapper<ClientBean> {
public ClientBean mapRow(ResultSet rs, int rowNum) throws SQLException {
ClientBean client = new ClientBean();
client.setClientId(rs.getString("client_id"));

client.setBalanceAmount(rs.getFloat("balance_amount"));
client.setLevel(rs.getString("level"));
client.setTotalOilQuantity(rs.getFloat("total_oil_quantity"));
// set all parameters of users row in the bean

return client;
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/ots/service/OrderServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public List<OrderSummaryBean> fetchAllOrders(String clientId) {
* @return
*/
public float getTotalAmountToBePaid(List<String> orderIds) {
return orderDaoImpl.getTotalAmountByOrderIds(orderIds);
float val = orderDaoImpl.getTotalAmountByOrderIds(orderIds);
System.out.println("===="+val);

return val;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ots/service/UserManagementServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public boolean insertIntoCancel(UserBean ub, ClientBean cb, String orderID)
* @return
*/
public Boolean updateOilAndBalanceOfClient(final String clientId,final float balanceAmount, final float totalOilQuantity ) {

System.out.println("User Account to be updated "+ clientId+" : "+balanceAmount+ " : "+totalOilQuantity);
return clientDao.updateOilAndBalanceOfClient(clientId, balanceAmount, totalOilQuantity);
}
}
1 change: 1 addition & 0 deletions src/main/resources/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oil_price=50
8 changes: 5 additions & 3 deletions src/main/webapp/WEB-INF/view/orderSummary.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@
</div>
<hr/>
<div class="row">
<div class="col-xs-24"></div>
<div class="col-xs-2">Account type: </div>
<div class="col-xs-2"><b style="color:#F4813A;font-size:14pt">${selectedClient.level}</b></div>

<div class="col-xs-2">Outstanding balance</div>
<div class="col-xs-2"><b style="color:#DE7E38;font-size:14pt">${selectedClient.balanceAmount} $</b></div>
<div class="col-xs-2"><b style="color:#1B0EC2;font-size:14pt">${selectedClient.balanceAmount} $</b></div>
<div class="col-xs-2">Total Oil owned:</div>
<div class="col-xs-2"><b style="color:#DE7E38;font-size:14pt">${selectedClient.totalOilQuantity} Lb</b></div>
<div class="col-xs-2"><b style="color:#FFCE44;font-size:14pt">${selectedClient.totalOilQuantity} Lb</b></div>
</div>
<div class="row" style="padidng-bottom: 10px; padding-top: 10px">
<div class="col-xs-4" style="text-align: center">
Expand Down

0 comments on commit 31beae4

Please sign in to comment.