修复权益领取优惠券时从优惠券表获取正确的金额和标题
This commit is contained in:
parent
432ee4f992
commit
5695b1c483
|
|
@ -65,7 +65,7 @@
|
||||||
"D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js"
|
"D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"MSSQL_SERVER": "192.168.195.15",
|
"MSSQL_SERVER": "1.13.21.84",
|
||||||
"MSSQL_PORT": "1433",
|
"MSSQL_PORT": "1433",
|
||||||
"MSSQL_USER": "sa",
|
"MSSQL_USER": "sa",
|
||||||
"MSSQL_PASSWORD": "Dbt@com@123",
|
"MSSQL_PASSWORD": "Dbt@com@123",
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
"D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js"
|
"D:/CodeManage/HaniBlindBox/server/scripts/mssql-mcp-server/index.js"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"MSSQL_SERVER": "192.168.195.15",
|
"MSSQL_SERVER": "1.13.21.84",
|
||||||
"MSSQL_PORT": "1433",
|
"MSSQL_PORT": "1433",
|
||||||
"MSSQL_USER": "sa",
|
"MSSQL_USER": "sa",
|
||||||
"MSSQL_PASSWORD": "Dbt@com@123",
|
"MSSQL_PASSWORD": "Dbt@com@123",
|
||||||
|
|
|
||||||
|
|
@ -180,29 +180,33 @@ public class QuanYiService : IQuanYiService
|
||||||
{
|
{
|
||||||
var endTime = DateTime.UtcNow.AddDays(reward.EffectiveDay ?? 7);
|
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
|
// Add to response
|
||||||
rewards.Add(new QuanYiLingRewardDto
|
rewards.Add(new QuanYiLingRewardDto
|
||||||
{
|
{
|
||||||
Id = reward.Id,
|
Id = reward.Id,
|
||||||
Title = reward.Title,
|
Title = couponTitle,
|
||||||
Type = 1,
|
Type = 1,
|
||||||
JianPrice = reward.JianPrice,
|
JianPrice = jianPrice,
|
||||||
ManPrice = reward.ManPrice,
|
ManPrice = manPrice,
|
||||||
EffectiveDay = reward.EffectiveDay,
|
EffectiveDay = reward.EffectiveDay,
|
||||||
EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||||
ZNum = reward.ZNum
|
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
|
// Create coupon receives for the user
|
||||||
var zNum = reward.ZNum ?? 1;
|
var zNum = reward.ZNum ?? 1;
|
||||||
for (int i = 0; i < zNum; i++)
|
for (int i = 0; i < zNum; i++)
|
||||||
|
|
@ -210,15 +214,15 @@ public class QuanYiService : IQuanYiService
|
||||||
var couponReceive = new CouponReceife
|
var couponReceive = new CouponReceife
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
Title = reward.Title,
|
Title = couponTitle,
|
||||||
Price = reward.JianPrice ?? 0,
|
Price = jianPrice,
|
||||||
ManPrice = reward.ManPrice ?? 0,
|
ManPrice = manPrice,
|
||||||
EndTime = endTime,
|
EndTime = endTime,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
CouponId = reward.Id,
|
CouponId = reward.CouponId ?? reward.Id,
|
||||||
State = 0, // State字段未使用
|
State = 0, // State字段未使用
|
||||||
Status = 0, // 0=未使用/可用, 1=已使用, 2=已过期
|
Status = 0, // 0=未使用/可用, 1=已使用, 2=已过期
|
||||||
Ttype = ttype ?? 0
|
Ttype = ttype
|
||||||
};
|
};
|
||||||
_dbContext.CouponReceives.Add(couponReceive);
|
_dbContext.CouponReceives.Add(couponReceive);
|
||||||
}
|
}
|
||||||
|
|
@ -231,9 +235,9 @@ public class QuanYiService : IQuanYiService
|
||||||
EquityLevel = equityLevel.Level,
|
EquityLevel = equityLevel.Level,
|
||||||
CouponId = reward.CouponId,
|
CouponId = reward.CouponId,
|
||||||
Type = 1,
|
Type = 1,
|
||||||
Title = reward.Title,
|
Title = couponTitle,
|
||||||
JianPrice = reward.JianPrice,
|
JianPrice = jianPrice,
|
||||||
ManPrice = reward.ManPrice,
|
ManPrice = manPrice,
|
||||||
EffectiveDay = reward.EffectiveDay,
|
EffectiveDay = reward.EffectiveDay,
|
||||||
EndTime = endTime,
|
EndTime = endTime,
|
||||||
ZNum = reward.ZNum,
|
ZNum = reward.ZNum,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user