From 49e96cc15baf35d710fe3a049fb97aff6a1af132 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 25 二月 2025 19:35:33 +0800
Subject: [PATCH] 修改分佣逻辑

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 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 efbe37e..d4e8d6f 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
@@ -41,6 +41,9 @@
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.util.*;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -1431,8 +1434,26 @@
 			orderBalancePayment.setDistributionAmount(distributionAmount);
 			orderBalancePaymentService.save(orderBalancePayment);
 		}
+		
+		//异步线程执行分佣临时数据构建
+		ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), new ThreadPoolExecutor.DiscardPolicy());
+		threadPoolExecutor.execute(new Runnable() {
+			@Override
+			public void run() {
+				commissionService.calculationCommissionUser();
+				commissionService.calculationCommissionShop();
+			}
+		});
 		return R.ok(order.getId().toString());
 	}
+
+
+
+
+
+
+
+
 
 	
 	public String getNumber(Integer size){
@@ -1526,6 +1547,16 @@
 		for (Integer goodsId : goodsIds) {
 			goodsClient.editGoodsNum(goodsId, 1);
 		}
+		
+		//异步线程执行分佣临时数据构建
+		ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), new ThreadPoolExecutor.DiscardPolicy());
+		threadPoolExecutor.execute(new Runnable() {
+			@Override
+			public void run() {
+				commissionService.calculationCommissionUser();
+				commissionService.calculationCommissionShop();
+			}
+		});
 		return R.ok();
 	}
 	

--
Gitblit v1.7.1