using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Authorization; using System.Web; using MySystem.MainModels; using LitJson; using Library; using System.IO; namespace MySystem.Areas.Api.Controllers.v1 { [Area("Api")] [Route("Api/[controller]/[action]")] public class WeChatController : BaseController { public WeChatController(IHttpContextAccessor accessor, ILogger logger, IOptions setting) : base(accessor, logger, setting) { } #region 微信服务平台支付回调 public Dictionary Notice() { StreamReader sr = new StreamReader(Request.Body); string requestMes = sr.ReadToEnd(); function.WriteLog(DateTime.Now.ToString() + "\r\n" + requestMes + "\r\n\r\n", "微信服务平台支付回调"); RedisDbconn.Instance.AddList("WeChatPayBack", requestMes); Dictionary dic = new Dictionary(); dic.Add("code", "SUCCESS"); dic.Add("message", ""); return dic; } #endregion public Dictionary test() { string AppId = "wx5417e0770bb19c4e"; string MchId = "1611167423"; string SubMchId = "1619775262"; string Description = "四川探火网络科技有限责任公司"; string OpenId = "omawy5VjduiPpSo9GNldzYZlioZE"; string Key = AppConfig.WeChatParam.AesGemKey; string NotifyUrl = Host + "api/wechat/notice"; // Dictionary dic = new WeChatFunction(_accessor.HttpContext).Pay(AppId, MchId, SubMchId, 0.1M, DateTime.Now.ToString("yyyyMMddHHmmssfff"), Description, OpenId, Key, NotifyUrl); Dictionary dic = new WeChatFunction(_accessor.HttpContext).Refund(AppId, MchId, SubMchId, 1M, 1M, "2022020817492424848364549", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Description, OpenId, Key, NotifyUrl); return dic; } } }