feat:购物车模块

This commit is contained in:
dongtiandexue 2021-01-06 23:35:38 +08:00
parent 861c47e09a
commit e4b45afb19
4 changed files with 27 additions and 3 deletions

View File

@ -21,6 +21,6 @@ public class CartItemBo {
*/
@NotNull(message = "商品数量不能为空")
@Min(value = 0, message = "商品数量不能为负数")
private Integer num;
private Integer number;
}

View File

@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull;
@Data
@Accessors(chain = true)
public class CartItemChooseBo {
public class CartItemCheckBo {
/**
* 商品sku id
@ -18,6 +18,6 @@ public class CartItemChooseBo {
/**
* 商品数量
*/
private Integer choose = 1;
private Integer check = 1;
}

View File

@ -44,6 +44,8 @@ public class CartItemVo implements Serializable {
*/
private Long price;
private Long coupon = 0L;
/**
* 小计
*/
@ -109,6 +111,14 @@ public class CartItemVo implements Serializable {
this.price = price;
}
public Long getCoupon() {
return coupon;
}
public void setCoupon(Long coupon) {
this.coupon = coupon;
}
public Long getSubTotal() {
long total = 0;
if (price != null && number != null) {

View File

@ -20,6 +20,8 @@ public class CartVo implements Serializable {
private Long totalPrice;
private Long totalCoupon;
public List<CartItemVo> getItems() {
return items;
}
@ -51,4 +53,16 @@ public class CartVo implements Serializable {
public void setTotalPrice(Long totalPrice) {
this.totalPrice = totalPrice;
}
public Long getTotalCoupon() {
long total = 0L;
// if (items != null && items.size() > 0) {
// total = items.stream().filter(CartItemVo::isChecked).mapToLong(CartItemVo::getCoupon).sum();
// }
return total;
}
public void setTotalCoupon(Long totalCoupon) {
this.totalCoupon = totalCoupon;
}
}