use of io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo in project the-app by devops-dojo.
the class CartPanel method cartView.
private Component cartView() {
cartView = new ListView<CartItemInfo>("cart", cartListModel()) {
@Override
protected void populateItem(ListItem<CartItemInfo> item) {
WebMarkupContainer cartItem = new WebMarkupContainer("item");
cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name")));
cartItem.add(new IndicatingAjaxLink<Void>("delete") {
@Override
public void onClick(AjaxRequestTarget target) {
IModel<CartItemInfo> model = item.getModel();
send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target));
}
});
cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum"))));
item.add(cartItem);
}
};
cartView.setReuseItems(false);
cartView.setOutputMarkupId(true);
return cartView;
}
use of io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo in project the-app by devops-dojo.
the class InMemoryCartFulfillmentProviderImpl method addItem.
@Override
public CartItemInfo addItem(ProductInfo productInfo) {
CartItemInfo cartItemInfo = new CartItemInfo(productInfo);
getAllItems().add(cartItemInfo);
return cartItemInfo;
}
use of io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo in project the-app by devops-dojo.
the class RedisMicroserviceCartFulfillmentProviderImpl method addItem.
@Override
public CartItemInfo addItem(ProductInfo productInfo) {
synchronized (lock) {
CartItemInfo cartItemInfo = createCartItemInfo(productInfo);
CartItem map = mapToCartItem(cartItemInfo);
if (StringUtils.isEmpty(cartId)) {
cartId = strip(cartRepository.create(map), "\"");
} else {
cartRepository.add(cartId, map);
}
return cartItemInfo;
}
}
use of io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo in project the-app by devops-dojo.
the class AbstractFulfillmentProvider method getTotalSum.
public BigDecimal getTotalSum() {
BigDecimal sum = BigDecimal.ZERO;
for (CartItemInfo cartItemInfo : getAllItems()) {
sum = sum.add(cartItemInfo.getTotalSum());
}
double globalDiscount = Double.parseDouble(Config.getProperty("GLOBAL_DISCOUNT"));
double factor = globalDiscount / 100.0;
double result = sum.doubleValue() - (sum.doubleValue() * factor);
return new BigDecimal(result);
}
use of io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo in project the-app by devops-dojo.
the class AbstractFulfillmentProvider method getDiscountSum.
public BigDecimal getDiscountSum() {
BigDecimal sum = BigDecimal.ZERO;
for (CartItemInfo cartItemInfo : getAllItems()) {
sum = sum.add(cartItemInfo.getTotalSum());
}
double globalDiscount = Double.parseDouble(Config.getProperty("GLOBAL_DISCOUNT"));
double factor = globalDiscount / 100.0;
double result = sum.doubleValue() * factor;
return new BigDecimal(result);
}
Aggregations