|
|
@@ -199,7 +199,7 @@ public class ShoppingCartService {
|
|
|
}
|
|
|
|
|
|
//计算价钱
|
|
|
- public ShoppingCart calculatePrice(Long cartId, Long userId, Long merchantId) {
|
|
|
+ public ShoppingCart calculatePrice(Long cartId, Long merchantId) {
|
|
|
|
|
|
//购物车
|
|
|
ShoppingCart cart = shoppingCartRepo.findById(cartId).orElseThrow(new BusinessException("无购物车"));
|
|
|
@@ -256,7 +256,7 @@ public class ShoppingCartService {
|
|
|
|
|
|
//查找是不是第一次购买
|
|
|
//List<OrderInfo> userOrders = orderInfoRepo.findAllByUserId(userId);
|
|
|
- List<OrderInfo> userOrdersMerchant = orderInfoRepo.findAllByUserIdAndMerchantId(userId, merchantId);
|
|
|
+ List<OrderInfo> userOrdersMerchant = orderInfoRepo.findAllByUserIdAndMerchantId(cart.getUserId(), merchantId);
|
|
|
//是新用户也是首单
|
|
|
// if (CollUtil.isEmpty(userOrders)) {
|
|
|
// shoppingCart.setNewUser(merchant.getNewUser());
|
|
|
@@ -330,19 +330,17 @@ public class ShoppingCartService {
|
|
|
|
|
|
this.changeOrderSpec(save, orderGoodsSpec);
|
|
|
|
|
|
- return this.calculatePrice(save.getId(), userId, save.getMerchantId());
|
|
|
+ return this.calculatePrice(save.getId(), save.getMerchantId());
|
|
|
}
|
|
|
|
|
|
//减规格
|
|
|
- public ShoppingCart sub(Long specId, Long userId) {
|
|
|
+ public ShoppingCart sub(Long specId) {
|
|
|
OrderGoodsSpec spec = orderGoodsSpecRepo.findById(specId).orElseThrow(new BusinessException("无订单详情"));
|
|
|
Long merchantId = spec.getGoods().getMerchantId();
|
|
|
Long cartId = spec.getShoppingCartId();
|
|
|
- //if (spec.getShoppingCartId() == null) {
|
|
|
orderGoodsSpecRepo.deleteById(specId);
|
|
|
- //}
|
|
|
//shoppingCartRepo.findById(spec.getShoppingCartId());
|
|
|
- return this.calculatePrice(cartId, userId, merchantId);
|
|
|
+ return this.calculatePrice(cartId, merchantId);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -366,4 +364,18 @@ public class ShoppingCartService {
|
|
|
return cart;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ 更改数量
|
|
|
+ */
|
|
|
+ public ShoppingCart changeNum(Long specId, Integer num) {
|
|
|
+ OrderGoodsSpec spec = orderGoodsSpecRepo.findById(specId).orElseThrow(new BusinessException("无订单详情"));
|
|
|
+ Long merchantId = spec.getGoods().getMerchantId();
|
|
|
+ Long cartId = spec.getShoppingCartId();
|
|
|
+
|
|
|
+ spec.setNum(num);
|
|
|
+ orderGoodsSpecRepo.save(spec);
|
|
|
+
|
|
|
+ return this.calculatePrice(cartId, merchantId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|