From 96d936331f7840b8157b64ad8bb9cbace99c1557 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期三, 15 一月 2025 21:16:49 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 73 ++++++++++++++++--------------------
1 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
index 307c92a..5d23be9 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.account.api.vo.PaymentUserCoupon;
import com.ruoyi.account.api.vo.PaymentUserCouponVo;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.mapper.ShoppingCartMapper;
@@ -190,7 +191,7 @@
info.setVip(appUser.getVipId());
GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData();
//没有秒杀活动或者添加的普通商品则不使用秒杀活动价格
- if(null == goodsSeckill || type == 1){
+ if((null == goodsSeckill || (null == goodsSeckill.getCashPayment() && null == goodsSeckill.getPointPayment())) || type == 1){
//没有秒杀价,则判断门店特价
GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice();
goodsBargainPrice.setGoodsId(goodsId);
@@ -209,17 +210,17 @@
area.setVip(appUser.getVipId());
area.setGoodsId(goodsId);
GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData();
- if(null == goodsArea){
+ if(null == goodsArea || (null == goodsArea.getCashPayment() && null == goodsArea.getPointPayment())){
//没有地区价格,则使用会员价格
GoodsVip goodsVip = goodsVipClient.getGoodsVip(goodsId, appUser.getVipId()).getData();
- if(null == goodsVip){
+ if(null == goodsVip || (null == goodsVip.getCashPayment() && null == goodsVip.getPointPayment())){
//没有配置价格,直接使用原始基础价格
return null;
}else{
price.setCash(goodsVip.getSellingPrice());
price.setPoint(goodsVip.getIntegral());
- price.setCashPayment(goodsVip.getCashPayment() == 1);
- price.setPointPayment(goodsVip.getPointPayment() == 1);
+ price.setCashPayment(null != goodsVip.getCashPayment() && goodsVip.getCashPayment() == 1);
+ price.setPointPayment(null != goodsVip.getPointPayment() && goodsVip.getPointPayment() == 1);
price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints());
price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission());
price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints());
@@ -236,8 +237,8 @@
}else{
price.setCash(goodsArea.getSellingPrice());
price.setPoint(goodsArea.getIntegral());
- price.setCashPayment(goodsArea.getCashPayment() == 1);
- price.setPointPayment(goodsArea.getPointPayment() == 1);
+ price.setCashPayment(null !=goodsArea.getCashPayment() && goodsArea.getCashPayment() == 1);
+ price.setPointPayment(null !=goodsArea.getPointPayment() && goodsArea.getPointPayment() == 1);
price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints());
price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission());
price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints());
@@ -304,8 +305,8 @@
if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){
price.setPoint(goodsSeckill.getIntegral());
}
- price.setCashPayment(goodsSeckill.getCashPayment() == 1);
- price.setPointPayment(goodsSeckill.getPointPayment() == 1);
+ price.setCashPayment(null != goodsSeckill.getCashPayment() && goodsSeckill.getCashPayment() == 1);
+ price.setPointPayment(null != goodsSeckill.getPointPayment() && goodsSeckill.getPointPayment() == 1);
price.setEndTime(goodsSeckill.getEndTime());
price.setEarnSpendingPoints(goodsSeckill.getEarnSpendingPoints());
price.setSuperiorSubcommission(goodsSeckill.getSuperiorSubcommission());
@@ -329,6 +330,15 @@
@Override
public Long addGoods(ShoppingCart shoppingCart) {
Long userid = tokenService.getLoginUserApplet().getUserid();
+ long goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid);
+ long count = count(new LambdaQueryWrapper<ShoppingCart>()
+ .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId())
+ .eq(ShoppingCart::getAppUserId, userid));
+ goodsSaleNum += count;
+ Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
+ if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + shoppingCart.getNumber()) > goods.getPurchaseLimit()){
+ throw new ServiceException("超出购买数量限制");
+ }
ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
.eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1));
if(null != one){
@@ -351,15 +361,16 @@
*/
@Override
public R setGoodsNumber(SetGoodsNumber setGoodsNumber) {
+
+ ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId());
if(0 >= setGoodsNumber.getNumber()){
return R.fail("修改数量不能小于等于0");
}
- ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId());
if(null != shoppingCart){
- Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
- if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && goods.getPurchaseLimit() < setGoodsNumber.getNumber()){
+ Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
+ if(null != goods1.getPurchaseLimit() && -1 != goods1.getPurchaseLimit() && goods1.getPurchaseLimit() < setGoodsNumber.getNumber()){
return R.fail("修改数量不能大于限购数量");
}
@@ -418,12 +429,14 @@
BigDecimal bigDecimal = BigDecimal.ZERO;
for (MyShoppingCartVo myShoppingCartVo : goodsList) {
bigDecimal = bigDecimal.add(myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber())));
+ myShoppingCartVo.setEarnSpendingPoints(myShoppingCartVo.getEarnSpendingPoints() * myShoppingCartVo.getNumber());
}
confirmOrderVo.setOrderMoney(bigDecimal);
}else{
int sum = 0;
for (MyShoppingCartVo myShoppingCartVo : goodsList) {
- sum += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber());
+ sum += ((null != myShoppingCartVo.getPoint() ? myShoppingCartVo.getPoint() : 0) * myShoppingCartVo.getNumber());
+ myShoppingCartVo.setEarnSpendingPoints((null != myShoppingCartVo.getEarnSpendingPoints() ? myShoppingCartVo.getEarnSpendingPoints() : 0) * myShoppingCartVo.getNumber());
}
confirmOrderVo.setOrderPoint(sum);
}
@@ -569,11 +582,11 @@
}
}else{
//部分商品适用
- BigDecimal goodsMoney = BigDecimal.ZERO;
+ BigDecimal goodsMoney = BigDecimal.ZERO;
for (MyShoppingCartVo myShoppingCartVo : goodsList) {
Integer goodsId = myShoppingCartVo.getGoodsId();
BigDecimal cash = myShoppingCartVo.getCash();
- if(forGoodIds.contains(goodsId)){
+ if(forGoodIds.contains(String.valueOf(goodsId))){
goodsMoney = goodsMoney.add(cash);
}
}
@@ -721,7 +734,7 @@
num += num1;
ShoppingCart shoppingCart = this.getById(id);
//判断当前数量是否已经超出限购数量(需要计算已经购买的数量)
- Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type);
+ Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type, userid);
Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
if(1 == type){
if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + num1) > goods.getPurchaseLimit()){
@@ -1005,7 +1018,7 @@
}
if(3 == shoppingCartPayment.getPaymentType()){
Integer availablePoint = appUser.getAvailablePoint();
- if(availablePoint < orderPoint){
+ if(availablePoint.compareTo(orderPoint) < 0){
return R.fail("账户可用积分不足");
}
}
@@ -1148,11 +1161,7 @@
userCouponClient.editUserCoupon(userCoupon);
}
}
- //添加查询快递信息队列
- if(StringUtils.isNotEmpty(order.getExpressJson())){
- //一小时后定时查询快递信息
- redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC));
- }
+
//删除购物车数据
userid = tokenService.getLoginUserApplet().getUserid();
@@ -1265,11 +1274,7 @@
userCouponClient.editUserCoupon(userCoupon);
}
}
- //添加查询快递信息队列
- if(StringUtils.isNotEmpty(order.getExpressJson())){
- //一小时后定时查询快递信息
- redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC));
- }
+
}
//积分支付
if(3 == shoppingCartPayment.getPaymentType()){
@@ -1392,14 +1397,7 @@
//删除购物车数据
this.removeBatchByIds(ids);
}
- //添加查询快递信息队列
- if(StringUtils.isNotEmpty(order.getExpressJson())){
- //一小时后定时查询快递信息
- SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData();
- JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
- Integer waitTime = jsonObject.getInteger("waitTime");
- redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC));
- }
+
}
//添加账户余额支付明细
@@ -1491,11 +1489,6 @@
userCoupon.setUseTime(LocalDateTime.now());
userCouponClient.editUserCoupon(userCoupon);
}
- }
- //添加查询快递信息队列
- if(StringUtils.isNotEmpty(order.getExpressJson())){
- //一小时后定时查询快递信息
- redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC));
}
//删除购物车数据
--
Gitblit v1.7.1