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,