From 269f85c77b5549828d12a825dfc54fa3a06d707e Mon Sep 17 00:00:00 2001 From: zpc Date: Wed, 28 Jan 2026 15:41:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E6=B6=88=E8=B4=B9=E6=97=B6=E6=9C=AA=E8=AE=B0=E5=BD=95=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E6=B5=81=E6=B0=B4=E7=9A=84=E9=97=AE=E9=A2=98=20-=20Or?= =?UTF-8?q?derService.DeductUserAssetsAsync=20=E5=A2=9E=E5=8A=A0=E4=BD=99?= =?UTF-8?q?=E9=A2=9D/=E7=A7=AF=E5=88=86/=E9=92=BB=E7=9F=B3=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E8=AE=B0=E5=BD=95=20-=20=E8=AE=B0=E5=BD=95=E5=88=B0?= =?UTF-8?q?=20ProfitMoney/ProfitIntegral/ProfitMoney2=20=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HoneyBox.Core/Services/OrderService.cs | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/OrderService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/OrderService.cs index 43a119a5..7b3d52ce 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/OrderService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/OrderService.cs @@ -1082,7 +1082,7 @@ public class OrderService : IOrderService order.PayTime = (int)currentTimestamp; // 扣减用户资产 - await DeductUserAssetsAsync(userId, paymentResult.UseMoney, paymentResult.UseIntegral, paymentResult.UseMoney2); + await DeductUserAssetsAsync(userId, paymentResult.UseMoney, paymentResult.UseIntegral, paymentResult.UseMoney2, goods.Title); // 使用优惠券 if (paymentResult.CouponId > 0) @@ -1254,26 +1254,61 @@ public class OrderService : IOrderService } /// - /// 扣减用户资产 + /// 扣减用户资产并记录流水 /// - private async Task DeductUserAssetsAsync(int userId, decimal useMoney, decimal useIntegral, decimal useMoney2) + private async Task DeductUserAssetsAsync(int userId, decimal useMoney, decimal useIntegral, decimal useMoney2, string goodsName = "") { var user = await _dbContext.Users.FindAsync(userId); if (user == null) return; + var content = string.IsNullOrEmpty(goodsName) ? "抽奖消费" : $"抽奖消费-{goodsName}"; + + // 扣减余额并记录流水 if (useMoney > 0) { user.Money -= useMoney; + _dbContext.ProfitMoneys.Add(new ProfitMoney + { + UserId = userId, + ChangeMoney = -useMoney, + Money = user.Money, + Type = 3, // 消费 + Content = content, + ShareUid = 0, + CreatedAt = DateTime.Now + }); } + // 扣减积分并记录流水 if (useIntegral > 0) { user.Integral -= useIntegral; + _dbContext.ProfitIntegrals.Add(new ProfitIntegral + { + UserId = userId, + ChangeMoney = -useIntegral, + Money = user.Integral, + Type = 3, // 消费 + Content = content, + ShareUid = 0, + CreatedAt = DateTime.Now + }); } + // 扣减钻石/哈尼券并记录流水 if (useMoney2 > 0 && user.Money2.HasValue) { user.Money2 -= useMoney2; + _dbContext.ProfitMoney2s.Add(new ProfitMoney2 + { + UserId = userId, + ChangeMoney = -useMoney2, + Money = user.Money2 ?? 0, + Type = 3, // 消费 + Content = content, + ShareUid = 0, + CreatedAt = DateTime.Now + }); } user.UpdatedAt = DateTime.Now; @@ -1517,7 +1552,7 @@ public class OrderService : IOrderService order.PayTime = (int)currentTimestamp; // 扣减用户资产 - await DeductUserAssetsAsync(userId, paymentResult.UseMoney, paymentResult.UseIntegral, paymentResult.UseMoney2); + await DeductUserAssetsAsync(userId, paymentResult.UseMoney, paymentResult.UseIntegral, paymentResult.UseMoney2, goods.Title); // 使用优惠券 if (paymentResult.CouponId > 0)