From 976a372f42b438edd8465a66e084b36deef38500 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期一, 13 一月 2025 17:11:54 +0800
Subject: [PATCH] 12.18
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 5 +++++
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java | 5 +++++
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java | 7 +++++++
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java | 11 ++++++-----
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java | 14 ++++++++++++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 2 --
6 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java
index 014df1f..0371f9a 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java
@@ -39,6 +39,11 @@
public R editGoodsList(List<Goods> goods) {
return R.fail("编辑商品信息失败:" + cause.getMessage());
}
+
+ @Override
+ public R<Void> editGoodsNum(Integer goodsId, Integer num) {
+ return R.fail();
+ }
};
}
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java
index 0bb389f..b185031 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java
@@ -6,6 +6,7 @@
import com.ruoyi.other.api.factory.GoodsClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@@ -48,4 +49,10 @@
*/
@PostMapping("/goods/editGoods")
R editGoodsList(@RequestBody List<Goods> goods);
+
+ /**
+ * 商品销量增加
+ */
+ @PutMapping("/goods/editGoodsNum")
+ R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num);
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
index b768edd..1d369a8 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
@@ -82,10 +82,13 @@
int fromIndex = (int) ((current - 1) * size);
int toIndex = (int) Math.min(fromIndex + size, walletStatisticsDetailList.size());
- if (fromIndex >= walletStatisticsDetailList.size()) {
- return new WalletStatistics();
- }
+ Page<WalletStatisticsDetail> walletStatisticsDetailPage = new Page<>();
+ WalletStatistics walletStatistics = new WalletStatistics();
+ if (fromIndex >= walletStatisticsDetailList.size()) {
+ walletStatistics.setPage(walletStatisticsDetailPage);
+ return walletStatistics;
+ }
Map<Integer, BigDecimal> shopCommissionMap = walletStatisticsDetailList.stream()
.collect(Collectors.groupingBy(
@@ -103,8 +106,6 @@
List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex);
- WalletStatistics walletStatistics = new WalletStatistics();
- Page<WalletStatisticsDetail> walletStatisticsDetailPage = new Page<>();
walletStatisticsDetailPage.setCurrent(current);
walletStatisticsDetailPage.setSize(size);
walletStatisticsDetailPage.setTotal(walletStatisticsDetailList.size());
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 aa8cea0..8432791 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
@@ -1499,6 +1499,11 @@
List<OrderGood> list = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, order.getId()));
List<Integer> goodsIds = list.stream().map(OrderGood::getGoodsId).collect(Collectors.toList());
this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds));
+
+ //商品销量增加
+ for (Integer goodsId : goodsIds) {
+ goodsClient.editGoodsNum(goodsId, 1);
+ }
return R.ok();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
index 1a20f52..4edee52 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -10,6 +10,7 @@
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.redis.annotation.DistributedLock;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.VipSetting;
import com.ruoyi.other.api.feignClient.VipSettingClient;
@@ -220,5 +221,18 @@
goodsService.updateBatchById(goods);
return R.ok();
}
+
+
+ /**
+ * 商品销量增加
+ */
+ @PutMapping("/editGoodsNum")
+ @DistributedLock(lockNamePre = "#goods_lock", lockNamePost = "#goodsId")
+ public R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num){
+ Goods goods = goodsService.getById(goodsId);
+ goods.setSaleNum(goods.getSaleNum() + num);
+ goodsService.updateById(goods);
+ return R.ok();
+ }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index 2fbcf1b..7c0eae0 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -116,8 +116,6 @@
goods.setSellingPrice(price.getCash());
goods.setIntegral(price.getPoint());
}
- Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData();
- goods.setSaleNum(data);
}
//手动排序
--
Gitblit v1.7.1