修改问题

This commit is contained in:
zpc 2024-10-15 17:07:03 +08:00
parent fd623af85b
commit 30c0b73217
3 changed files with 36 additions and 13 deletions

View File

@ -85,14 +85,15 @@ namespace HuanMeng.MiaoYu.Code.Music
var Currency = userInfoBLL[UserCurrencyType.]?.CurrencyMoney;
string sqlString = $@"select isnull(sum(PlayCount),0) PlayCount,isnull(sum(LikeCount),0) LikeCount,isnull(sum(DownloadCount),0) DownloadCount from M_Songs where AuthorId={_UserId}";
var info = Dao.daoDbMiaoYu.context.Database.SqlQueryRaw<MusicSongsInfo>(sqlString).FirstOrDefault();
var songVipInfo = IsMusicVipInfo();
List<CreateCharacterInfo> characters = new List<CreateCharacterInfo>();
return new BaseResponse<MusicUserDto>(ResonseCode.Success, "请求成功", new MusicUserDto
{
NickName = user.NickName,
UserId = user.Id,
UserIconUrl = string.IsNullOrEmpty(user?.UserIconUrl) ? "https://cos.shhuanmeng.com/default.png" : user?.UserIconUrl,
Vip = 0,
Vip = songVipInfo.isVip ? 1 : 0,
VipExpirationAt= songVipInfo.expirationAt,
DownloadCount = info.DownloadCount,
LikeCount = info.LikeCount,
PlayCount = info.PlayCount,
@ -208,6 +209,17 @@ namespace HuanMeng.MiaoYu.Code.Music
return new BaseResponse<List<MusicSongInfoDto>>(ResonseCode.Success, "", data);
}
private bool IsMusicVip()
{
var songVip = Dao.daoDbMiaoYu.context.M_SongVIP.FirstOrDefault(it => it.UserId == _UserId && it.ExpirationAt > DateTime.Now);
return songVip != null;
}
private (bool isVip, DateTime? expirationAt) IsMusicVipInfo()
{
var songVip = Dao.daoDbMiaoYu.context.M_SongVIP.FirstOrDefault(it => it.UserId == _UserId && it.ExpirationAt > DateTime.Now);
return (songVip != null, songVip != null ? songVip?.ExpirationAt : null);
}
/// <summary>
/// 创建音乐
@ -221,12 +233,9 @@ namespace HuanMeng.MiaoYu.Code.Music
{
throw new Exception("请先登录");
}
var songVip = Dao.daoDbMiaoYu.context.M_SongVIP.FirstOrDefault(it => it.UserId == _UserId && it.ExpirationAt > DateTime.Now);
bool isSongVip = false;
if (songVip != null)
{
isSongVip = true;
}
bool isSongVip = IsMusicVip();
UserInfoBLL userInfoBLL = new UserInfoBLL(Dao, _UserId);

View File

@ -76,19 +76,28 @@ namespace HuanMeng.MiaoYu.Code.Music
var httpClient = httpFactory.CreateClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Add("authorization", "Bearer hk-ylg6c31000042000fef54b80aec96b39e83b36f6e551440b");
//31214f23-329f-4b8f-b7e7-0443f17f174b
var url = $"https://api.openai-hk.com/suno/feed/{songs.SpecialId}";
var response = await httpClient.GetAsync(url);
if (response == null || !response.IsSuccessStatusCode)
{
//throw new Exception("创建音乐失败");
songs.State = -1;
dao.daoDbMiaoYu.context.SaveChanges();
if (DateTime.Now.Subtract(songs.CreationTimestamp).TotalDays > 1)
{
//throw new Exception("创建音乐失败");
songs.State = -1;
dao.daoDbMiaoYu.context.SaveChanges();
}
continue;
}
var responseContent = await response.Content.ReadAsStringAsync();
if (string.IsNullOrEmpty(responseContent))
{
songs.State = -1;
if (DateTime.Now.Subtract(songs.CreationTimestamp).TotalDays > 1)
{
//throw new Exception("创建音乐失败");
songs.State = -1;
dao.daoDbMiaoYu.context.SaveChanges();
}
dao.daoDbMiaoYu.context.SaveChanges();
continue;
}
@ -129,7 +138,7 @@ namespace HuanMeng.MiaoYu.Code.Music
}
}
Thread.Sleep(1000 * 5);
Thread.Sleep(1000 * 30);
}
}

View File

@ -36,5 +36,10 @@ namespace HuanMeng.MiaoYu.Model.Dto.Music
/// 是否有Vip
/// </summary>
public int Vip { get; set; }
/// <summary>
/// vip到期时间
/// </summary>
public DateTime? VipExpirationAt { get; set; }
}
}