From 5695b1c48332f96a3d3c2fe9547fa735d5df5442 Mon Sep 17 00:00:00 2001 From: zpc Date: Thu, 12 Feb 2026 11:21:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9D=83=E7=9B=8A=E9=A2=86?= =?UTF-8?q?=E5=8F=96=E4=BC=98=E6=83=A0=E5=88=B8=E6=97=B6=E4=BB=8E=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E8=A1=A8=E8=8E=B7=E5=8F=96=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E9=87=91=E9=A2=9D=E5=92=8C=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .kiro/settings/mcp.json | 4 +- .../HoneyBox.Core/Services/QuanYiService.cs | 46 ++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.kiro/settings/mcp.json b/.kiro/settings/mcp.json index 13742682..b68250e0 100644 --- a/.kiro/settings/mcp.json +++ b/.kiro/settings/mcp.json @@ -65,7 +65,7 @@ "D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js" ], "env": { - "MSSQL_SERVER": "192.168.195.15", + "MSSQL_SERVER": "1.13.21.84", "MSSQL_PORT": "1433", "MSSQL_USER": "sa", "MSSQL_PASSWORD": "Dbt@com@123", @@ -81,7 +81,7 @@ "D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js" ], "env": { - "MSSQL_SERVER": "192.168.195.15", + "MSSQL_SERVER": "1.13.21.84", "MSSQL_PORT": "1433", "MSSQL_USER": "sa", "MSSQL_PASSWORD": "Dbt@com@123", diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs index 3f7399e9..3bdbfc67 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/QuanYiService.cs @@ -180,29 +180,33 @@ public class QuanYiService : IQuanYiService { var endTime = DateTime.UtcNow.AddDays(reward.EffectiveDay ?? 7); + // 获取关联的优惠券信息 + Coupon? coupon = null; + if (reward.CouponId.HasValue) + { + coupon = await _dbContext.Coupons + .FirstOrDefaultAsync(c => c.Id == reward.CouponId.Value); + } + + // 优先使用优惠券表的数据,如果没有则使用奖品表的数据 + var jianPrice = coupon?.Price ?? reward.JianPrice ?? 0; + var manPrice = coupon?.ManPrice ?? reward.ManPrice ?? 0; + var couponTitle = coupon?.Title ?? reward.Title ?? "优惠券"; + var ttype = coupon?.Ttype ?? 0; + // Add to response rewards.Add(new QuanYiLingRewardDto { Id = reward.Id, - Title = reward.Title, + Title = couponTitle, Type = 1, - JianPrice = reward.JianPrice, - ManPrice = reward.ManPrice, + JianPrice = jianPrice, + ManPrice = manPrice, EffectiveDay = reward.EffectiveDay, EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"), ZNum = reward.ZNum }); - // Get coupon ttype - byte? ttype = null; - if (reward.CouponId.HasValue) - { - ttype = await _dbContext.Coupons - .Where(c => c.Id == reward.CouponId.Value) - .Select(c => c.Ttype) - .FirstOrDefaultAsync(); - } - // Create coupon receives for the user var zNum = reward.ZNum ?? 1; for (int i = 0; i < zNum; i++) @@ -210,15 +214,15 @@ public class QuanYiService : IQuanYiService var couponReceive = new CouponReceife { UserId = userId, - Title = reward.Title, - Price = reward.JianPrice ?? 0, - ManPrice = reward.ManPrice ?? 0, + Title = couponTitle, + Price = jianPrice, + ManPrice = manPrice, EndTime = endTime, CreatedAt = DateTime.UtcNow, - CouponId = reward.Id, + CouponId = reward.CouponId ?? reward.Id, State = 0, // State字段未使用 Status = 0, // 0=未使用/可用, 1=已使用, 2=已过期 - Ttype = ttype ?? 0 + Ttype = ttype }; _dbContext.CouponReceives.Add(couponReceive); } @@ -231,9 +235,9 @@ public class QuanYiService : IQuanYiService EquityLevel = equityLevel.Level, CouponId = reward.CouponId, Type = 1, - Title = reward.Title, - JianPrice = reward.JianPrice, - ManPrice = reward.ManPrice, + Title = couponTitle, + JianPrice = jianPrice, + ManPrice = manPrice, EffectiveDay = reward.EffectiveDay, EndTime = endTime, ZNum = reward.ZNum,