修改海报接口

development
温天培 1 year ago
parent 3f0385ac55
commit 44a7f35c99

@ -50,5 +50,13 @@ namespace GDZZ.Application
/// </summary>
public const string MINI_ACCESSTOKEN = "AccessToken:";
#endregion
#region 二维码
/// <summary>
/// 二维码生成
/// </summary>
public const string MINI_QRCODE = "QRCode:";
#endregion
}
}

@ -173,6 +173,24 @@ namespace GDZZ.Application.Help
}
#endregion
#region 二维码
public async Task<string> GetQRCodeAsync(long UserID)
{
string cacheKey = SystemConst.MINI_QRCODE + $"{UserID}";
return await _redisCache.GetAsync<string>(cacheKey);
}
public async Task SetQRCodeAsync(long UserID,string Url)
{
string cacheKey = SystemConst.MINI_QRCODE+$"{UserID}";
await _redisCache.SetAsync(cacheKey, Url);
}
#endregion
}
}

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace GDZZ.Application.Help
{
@ -72,7 +73,22 @@ namespace GDZZ.Application.Help
#endregion
#region 二维码生成
/// <summary>
/// 存储二维码bate[]
/// </summary>
/// <returns></returns>
Task<string> GetQRCodeAsync(long UserID);
/// <summary>
/// 存储二维码bate[]
/// </summary>
/// <returns></returns>
Task SetQRCodeAsync(long UserID, string Url);
#endregion
}
}

@ -20,6 +20,9 @@ using Mapster;
using GDZZ.Core.Service;
using TencentCloud.Sms.V20210111.Models;
using TencentCloud.Common;
using Polly;
using System.IO;
using System.Diagnostics.Eventing.Reader;
namespace GDZZ.Application.Service.Auth
{
@ -493,6 +496,10 @@ namespace GDZZ.Application.Service.Auth
[HttpGet("/Mini/GetShareCode")]
public async Task<string> GetShareCode(string scene, string page)
{
var url = await this.cacheService.GetQRCodeAsync(UserManager.UserId);
if(url != null)
return url;
var value = await cacheService.GetAccessTokenAsync();
if (value == null)
{
@ -501,8 +508,22 @@ namespace GDZZ.Application.Service.Auth
value = token.Result.AccessToken;
}
var res = await this._wechatOAuth.GetShareCodeAsync(value,scene, page);
return Convert.ToBase64String(res);
var fileName = Path.Combine(App.WebHostEnvironment.WebRootPath+ UserManager.UserId + "_" + DateTime.Now + "png");
Console.WriteLine(fileName);
try
{
MemoryStream ms = new MemoryStream(res);
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
ms.WriteTo(fs);
ms.Close();
fs.Close();
await this.cacheService.SetQRCodeAsync(UserManager.UserId, fileName);
}
catch (Exception e)
{
throw Oops.Oh(e.Message);
}
return fileName;
}

@ -40,11 +40,9 @@ namespace GDZZ.Application.Service.WXPay
private readonly SqlSugarRepository<SeIF> self; //职业仓储
private readonly SqlSugarRepository<Consume> ComsumeRep; //消费记录仓储
private readonly SqlSugarRepository<Balance> balance; //余额仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
private readonly SqlSugarRepository<ReFund> refundRep; //退款仓储
private readonly WechatOAuth _wechatOAuth; //微信权限服务
private readonly IHttpContextAccessor _httpContextAccessor; //http服务
@ -425,6 +423,9 @@ namespace GDZZ.Application.Service.WXPay
[Route("Mini/v1/GetBalance")]
public async Task<dynamic> MerchantTransfer(TransferInput wxRefundInput)
{
throw Oops.Oh("参数错误");
}
#endregion

@ -89,6 +89,7 @@
<ItemGroup>
<Folder Include="templates\" />
<Folder Include="wwwroot\Upload\Default\" />
<Folder Include="wwwroot\Upload\QRCode\" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save