修改海报接口

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

@ -50,5 +50,13 @@ namespace GDZZ.Application
/// </summary> /// </summary>
public const string MINI_ACCESSTOKEN = "AccessToken:"; public const string MINI_ACCESSTOKEN = "AccessToken:";
#endregion #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 #endregion
} }
} }

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace GDZZ.Application.Help namespace GDZZ.Application.Help
{ {
@ -72,7 +73,22 @@ namespace GDZZ.Application.Help
#endregion #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 GDZZ.Core.Service;
using TencentCloud.Sms.V20210111.Models; using TencentCloud.Sms.V20210111.Models;
using TencentCloud.Common; using TencentCloud.Common;
using Polly;
using System.IO;
using System.Diagnostics.Eventing.Reader;
namespace GDZZ.Application.Service.Auth namespace GDZZ.Application.Service.Auth
{ {
@ -493,6 +496,10 @@ namespace GDZZ.Application.Service.Auth
[HttpGet("/Mini/GetShareCode")] [HttpGet("/Mini/GetShareCode")]
public async Task<string> GetShareCode(string scene, string page) 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(); var value = await cacheService.GetAccessTokenAsync();
if (value == null) if (value == null)
{ {
@ -500,9 +507,23 @@ namespace GDZZ.Application.Service.Auth
await cacheService.SetAccessTokenAsync(token.Result.AccessToken); await cacheService.SetAccessTokenAsync(token.Result.AccessToken);
value = token.Result.AccessToken; value = token.Result.AccessToken;
} }
var res = await this._wechatOAuth.GetShareCodeAsync(value,scene, page); var res = await this._wechatOAuth.GetShareCodeAsync(value,scene, page);
var fileName = Path.Combine(App.WebHostEnvironment.WebRootPath+ UserManager.UserId + "_" + DateTime.Now + "png");
return Convert.ToBase64String(res); 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<SeIF> self; //职业仓储
private readonly SqlSugarRepository<Consume> ComsumeRep; //消费记录仓储 private readonly SqlSugarRepository<Consume> ComsumeRep; //消费记录仓储
private readonly SqlSugarRepository<Balance> balance; //余额仓储 private readonly SqlSugarRepository<Balance> balance; //余额仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储 private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储 private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
private readonly SqlSugarRepository<ReFund> refundRep; //退款仓储 private readonly SqlSugarRepository<ReFund> refundRep; //退款仓储
private readonly WechatOAuth _wechatOAuth; //微信权限服务 private readonly WechatOAuth _wechatOAuth; //微信权限服务
private readonly IHttpContextAccessor _httpContextAccessor; //http服务 private readonly IHttpContextAccessor _httpContextAccessor; //http服务
@ -425,6 +423,9 @@ namespace GDZZ.Application.Service.WXPay
[Route("Mini/v1/GetBalance")] [Route("Mini/v1/GetBalance")]
public async Task<dynamic> MerchantTransfer(TransferInput wxRefundInput) public async Task<dynamic> MerchantTransfer(TransferInput wxRefundInput)
{ {
throw Oops.Oh("参数错误"); throw Oops.Oh("参数错误");
} }
#endregion #endregion

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

Loading…
Cancel
Save