From 113247a1e3ac8c03f59cd7d4f1e74ce657ebc31a Mon Sep 17 00:00:00 2001 From: zpc Date: Mon, 9 Feb 2026 23:17:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=92=BB=E7=9F=B3?= =?UTF-8?q?=E5=85=85=E5=80=BC=E5=8F=91=E6=94=BE=E5=88=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将diamond奖励类型从Money2改为Money字段 - 移除废弃的Money2奖励分支 - 修复GoodsService中Distinct排序警告 --- .../HoneyBox.Core/Services/GoodsService.cs | 8 ++++--- .../Services/PaymentNotifyService.cs | 21 +++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/GoodsService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/GoodsService.cs index 17171437..b0b4c8ab 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/GoodsService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/GoodsService.cs @@ -693,16 +693,18 @@ public class GoodsService : IGoodsService /// private async Task> GetJoinUsersAsync(int goodsId, int goodsNum, int orderType) { + // 使用子查询获取每个用户的最新订单ID,然后按此排序 var userIds = await _dbContext.OrderItems .Where(oi => oi.GoodsId == goodsId && oi.Num == goodsNum && oi.ShangId >= ShangCountIdRange[0] && oi.ShangId <= ShangCountIdRange[1] && oi.OrderType == orderType) - .OrderByDescending(oi => oi.Id) - .Select(oi => oi.UserId) - .Distinct() + .GroupBy(oi => oi.UserId) + .Select(g => new { UserId = g.Key, MaxId = g.Max(x => x.Id) }) + .OrderByDescending(x => x.MaxId) .Take(5) + .Select(x => x.UserId) .ToListAsync(); if (!userIds.Any()) diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/PaymentNotifyService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/PaymentNotifyService.cs index 43034ad1..af4296f6 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/PaymentNotifyService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/PaymentNotifyService.cs @@ -1156,7 +1156,7 @@ public class PaymentNotifyService : IPaymentNotifyService { var rewardType = item.Type?.ToLower() switch { - "diamond" => 1, // 钻石 -> Money2 + "diamond" => 2, // 钻石 -> Money (余额就是钻石) "balance" => 2, // 余额 -> Money "integral" => 4, // 积分 -> Integral "coupon" => 5, // 优惠券 @@ -1222,22 +1222,7 @@ public class PaymentNotifyService : IPaymentNotifyService switch (rewardType) { - case 1: // 钻石 (Money2) - user.Money2 = (user.Money2 ?? 0) + value; - // 记录钻石变动 - _dbContext.ProfitMoney2s.Add(new ProfitMoney2 - { - UserId = userId, - ChangeMoney = value, - Money = user.Money2 ?? 0, - Type = 1, - Content = source, - ShareUid = 0, - CreatedAt = DateTime.Now - }); - return $"钻石+{value}"; - - case 2: // UU币/余额 (Money) + case 2: // 钻石/余额 (Money) user.Money += value; // 记录余额变动 _dbContext.ProfitMoneys.Add(new ProfitMoney @@ -1250,7 +1235,7 @@ public class PaymentNotifyService : IPaymentNotifyService ShareUid = 0, CreatedAt = DateTime.Now }); - return $"余额+{value}"; + return $"钻石+{value}"; case 3: // 哈尼券/达达券 - 暂不支持,记录到积分 case 4: // 积分 (Integral)