添加启动时扣除钻石
This commit is contained in:
parent
99fb809794
commit
a4413d2eaf
|
|
@ -142,9 +142,16 @@ public class PlayGameBLL : CloudGamingBase
|
|||
};
|
||||
await Dao.DaoPhone.Context.T_User_GameList.AddAsync(userGameList);
|
||||
await Dao.DaoPhone.Context.SaveChangesAsync();
|
||||
//启动游戏
|
||||
gameInfoCache?.PlayGameStart(gameResponse?.Data?.ScId ?? 0, userGameList.Id, playGameSettings.DisplayGrade, jyResponseData);
|
||||
gameInfoCache.Ip = HttpContextAccessor.HttpContext.GetClientIpAddress();
|
||||
gameInfoCache.Channel = AppRequestInfo.Channel;
|
||||
var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
if (diamondNumHour > 0)
|
||||
{
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, 0, (int)diamondNumHour * 1);
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
}
|
||||
var gameResponse1 = JsonConvert.DeserializeObject<Dictionary<string, object>>(jyResponseData.ResponseContent);
|
||||
if (gameResponse1 != null && gameResponse1.TryGetValue("data", out var xxx))
|
||||
{
|
||||
|
|
@ -250,26 +257,7 @@ public class PlayGameBLL : CloudGamingBase
|
|||
}
|
||||
|
||||
}
|
||||
var (issuccess, currlogId, diamId) = await this.UserPlayGameDiamondConsumeMoney(-gameDiamondNumHour, gameInfoCache.GameName, gameInfoCache.CurrencyLogId, gameInfoCache.DiamondListId, $"{diamondNumHour}/分钟");
|
||||
if (!issuccess)
|
||||
{
|
||||
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation()
|
||||
{
|
||||
ActionId = (int)PlayGameStatus.用户扣款错误,
|
||||
Content = $"扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};"
|
||||
});
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
throw MessageBox.ErrorShow("扣款出现错误");
|
||||
}
|
||||
gameInfoCache.SpendingDiamonds += gameDiamondNumHour;
|
||||
userInfo.UserPlayGameTime += minutes;
|
||||
await this.SaveUserInfoCacheChangesAsync();
|
||||
gameInfoCache.CurrencyLogId = currlogId;
|
||||
gameInfoCache.DiamondListId = diamId;
|
||||
//修改最后扣费时间
|
||||
gameInfoCache.LastChargingAt = (gameInfoCache.LastChargingAt ?? gameInfoCache.CreateDateTime).AddMinutes(minutes);
|
||||
await Dao.DaoUser.Context.SaveChangesAsync();
|
||||
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, minutes, gameDiamondNumHour);
|
||||
}
|
||||
}
|
||||
//用户剩余游玩时间
|
||||
|
|
@ -300,6 +288,34 @@ public class PlayGameBLL : CloudGamingBase
|
|||
|
||||
}
|
||||
|
||||
private async Task BalanceDeductionFee(UserInfoCache userInfo, PlayGameUserInfo gameInfoCache, double diamondNumHour, int minutes, decimal gameDiamondNumHour)
|
||||
{
|
||||
var (issuccess, currlogId, diamId) = await this.UserPlayGameDiamondConsumeMoney(-gameDiamondNumHour, gameInfoCache.GameName, gameInfoCache.CurrencyLogId, gameInfoCache.DiamondListId, $"{diamondNumHour}/分钟");
|
||||
if (!issuccess)
|
||||
{
|
||||
var Content = $"扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
if (minutes == 0)
|
||||
{
|
||||
Content = $"启动扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
}
|
||||
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation()
|
||||
{
|
||||
ActionId = (int)PlayGameStatus.用户扣款错误,
|
||||
Content = Content
|
||||
});
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
throw MessageBox.ErrorShow("扣款出现错误");
|
||||
}
|
||||
gameInfoCache.SpendingDiamonds +=gameDiamondNumHour;
|
||||
userInfo.UserPlayGameTime += minutes;
|
||||
await this.SaveUserInfoCacheChangesAsync();
|
||||
gameInfoCache.CurrencyLogId = currlogId;
|
||||
gameInfoCache.DiamondListId = diamId;
|
||||
//修改最后扣费时间
|
||||
gameInfoCache.LastChargingAt = (gameInfoCache.LastChargingAt ?? gameInfoCache.CreateDateTime).AddMinutes(minutes);
|
||||
await Dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户主动结束游戏
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class PlayGameUserInfo
|
|||
/// <summary>
|
||||
/// 用户本次玩游戏共花销多少钻石
|
||||
/// </summary>
|
||||
public int SpendingDiamonds { get; set; }
|
||||
public decimal SpendingDiamonds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
|
|
@ -172,7 +172,7 @@ public class PlayGameUserInfo
|
|||
GameId = GameId,
|
||||
GameName = GameName,
|
||||
UserPlayGameDiamonds = UserPlayGameDiamonds,
|
||||
SpendingDiamonds = SpendingDiamonds,
|
||||
SpendingDiamonds = (int)SpendingDiamonds,
|
||||
UserId = UserId,
|
||||
CreateDateTime = CreateDateTime,
|
||||
LastDateTime = LastDateTime,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user