63 lines
3.0 KiB
Plaintext
63 lines
3.0 KiB
Plaintext
public BaseResponse<string> DownloadPng(int appId, long userId, long drawId)
|
|
{
|
|
//var photoAlbum = dao.daoUserData.context.T_User_PhotoAlbum.Where(t => t.Type == 0 && t.DrawId == drawId).FirstOrDefault();
|
|
var photoAlbum = dao.daoUserData.context.T_User_Gallery.Where(t => t.Type == 0 && t.DrawId == drawId).FirstOrDefault();
|
|
if (photoAlbum == null)
|
|
{
|
|
return new BaseResponse<string>(ResonseCode.Error, "未找到画廊数据");
|
|
}
|
|
var obj = dao.daoLog.context.T_Draw_Download_log.Where(t => t.UserId == userId && t.DrawId == drawId).FirstOrDefault();
|
|
var imgUrl = string.Empty;
|
|
if (obj != null)
|
|
{
|
|
imgUrl = dao.daoData.context.T_Draw_Log.Where(it => it.Id == drawId).Select(t => t.TaskResult).FirstOrDefault();
|
|
return new BaseResponse<string>(ResonseCode.Success, "", imgUrl);
|
|
}
|
|
var user = dao.daoUserData.context.T_Users_Data.Where(t => t.UserId == userId).FirstOrDefault();
|
|
if (user == null)
|
|
{
|
|
return new BaseResponse<string>(ResonseCode.Error, "用户不存在");
|
|
}
|
|
var like = dao.daoUserData.context.T_User_Like.FirstOrDefault(it => it.DrawId == drawId && it.UserId == userId);
|
|
if (like != null)
|
|
{
|
|
if (string.IsNullOrEmpty(imgUrl))
|
|
{
|
|
imgUrl = dao.daoData.context.T_Draw_Log.Where(it => it.Id == drawId).Select(t => t.TaskResult).FirstOrDefault();
|
|
}
|
|
return new BaseResponse<string>(ResonseCode.Success, "", imgUrl);
|
|
}
|
|
var currency = user.Currency;
|
|
if (currency <= 0)
|
|
{
|
|
return new BaseResponse<string>(ResonseCode.UserNotMoney, "用户金额不足");
|
|
}
|
|
if (obj == null)
|
|
{
|
|
var t_Draw_Download_Log = new T_Draw_Download_log
|
|
{
|
|
UserId = userId,
|
|
DrawId = drawId,
|
|
GalleryId = photoAlbum.Id,
|
|
CreateDateTime = DateTime.Now,
|
|
LastDownloadDateTime = DateTime.Now,
|
|
DownloadCount = 1,
|
|
DownloadConsume = 1
|
|
};
|
|
dao.daoLog.Add(t_Draw_Download_Log);
|
|
}
|
|
else
|
|
{
|
|
obj.DownloadConsume += 1;
|
|
obj.DownloadCount += 1;
|
|
obj.LastDownloadDateTime = DateTime.Now;
|
|
dao.daoLog.Update(obj);
|
|
}
|
|
new AccountBLL(dao).UpUserCurrencyInfo(userId, currency: -1);
|
|
dao.daoLog.context.SaveChanges();
|
|
if (string.IsNullOrEmpty(imgUrl))
|
|
{
|
|
imgUrl = dao.daoData.context.T_Draw_Log.Where(it => it.Id == drawId).Select(t => t.TaskResult).FirstOrDefault();
|
|
}
|
|
return new BaseResponse<string>(ResonseCode.Success, "", imgUrl);
|
|
} |