fix: 修复钻石充值发放到错误字段的问题

- 将diamond奖励类型从Money2改为Money字段
- 移除废弃的Money2奖励分支
- 修复GoodsService中Distinct排序警告
This commit is contained in:
zpc 2026-02-09 23:17:27 +08:00
parent d23c9aa861
commit 113247a1e3
2 changed files with 8 additions and 21 deletions

View File

@ -693,16 +693,18 @@ public class GoodsService : IGoodsService
/// </summary> /// </summary>
private async Task<List<string>> GetJoinUsersAsync(int goodsId, int goodsNum, int orderType) private async Task<List<string>> GetJoinUsersAsync(int goodsId, int goodsNum, int orderType)
{ {
// 使用子查询获取每个用户的最新订单ID然后按此排序
var userIds = await _dbContext.OrderItems var userIds = await _dbContext.OrderItems
.Where(oi => oi.GoodsId == goodsId .Where(oi => oi.GoodsId == goodsId
&& oi.Num == goodsNum && oi.Num == goodsNum
&& oi.ShangId >= ShangCountIdRange[0] && oi.ShangId >= ShangCountIdRange[0]
&& oi.ShangId <= ShangCountIdRange[1] && oi.ShangId <= ShangCountIdRange[1]
&& oi.OrderType == orderType) && oi.OrderType == orderType)
.OrderByDescending(oi => oi.Id) .GroupBy(oi => oi.UserId)
.Select(oi => oi.UserId) .Select(g => new { UserId = g.Key, MaxId = g.Max(x => x.Id) })
.Distinct() .OrderByDescending(x => x.MaxId)
.Take(5) .Take(5)
.Select(x => x.UserId)
.ToListAsync(); .ToListAsync();
if (!userIds.Any()) if (!userIds.Any())

View File

@ -1156,7 +1156,7 @@ public class PaymentNotifyService : IPaymentNotifyService
{ {
var rewardType = item.Type?.ToLower() switch var rewardType = item.Type?.ToLower() switch
{ {
"diamond" => 1, // 钻石 -> Money2 "diamond" => 2, // 钻石 -> Money (余额就是钻石)
"balance" => 2, // 余额 -> Money "balance" => 2, // 余额 -> Money
"integral" => 4, // 积分 -> Integral "integral" => 4, // 积分 -> Integral
"coupon" => 5, // 优惠券 "coupon" => 5, // 优惠券
@ -1222,22 +1222,7 @@ public class PaymentNotifyService : IPaymentNotifyService
switch (rewardType) switch (rewardType)
{ {
case 1: // 钻石 (Money2) case 2: // 钻石/余额 (Money)
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)
user.Money += value; user.Money += value;
// 记录余额变动 // 记录余额变动
_dbContext.ProfitMoneys.Add(new ProfitMoney _dbContext.ProfitMoneys.Add(new ProfitMoney
@ -1250,7 +1235,7 @@ public class PaymentNotifyService : IPaymentNotifyService
ShareUid = 0, ShareUid = 0,
CreatedAt = DateTime.Now CreatedAt = DateTime.Now
}); });
return $"余额+{value}"; return $"钻石+{value}";
case 3: // 哈尼券/达达券 - 暂不支持,记录到积分 case 3: // 哈尼券/达达券 - 暂不支持,记录到积分
case 4: // 积分 (Integral) case 4: // 积分 (Integral)