WeChatController.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using Microsoft.AspNetCore.Authorization;
  9. using System.Web;
  10. using MySystem.MainModels;
  11. using LitJson;
  12. using Library;
  13. using System.IO;
  14. namespace MySystem.Areas.Api.Controllers.v1
  15. {
  16. [Area("Api")]
  17. [Route("Api/[controller]/[action]")]
  18. public class WeChatController : BaseController
  19. {
  20. public WeChatController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  21. {
  22. }
  23. #region 微信服务平台支付回调
  24. public string Notice()
  25. {
  26. StreamReader sr = new StreamReader(Request.Body);
  27. string requestMes = sr.ReadToEnd();
  28. function.WriteLog(DateTime.Now.ToString() + "\r\n" + requestMes + "\r\n\r\n", "微信服务平台支付回调");
  29. return "success";
  30. }
  31. #endregion
  32. public Dictionary<string, string> test()
  33. {
  34. string AppId = "wx5417e0770bb19c4e";
  35. string MchId = "1611167423";
  36. string SubMchId = "1619775262";
  37. string Description = "四川探火网络科技有限责任公司";
  38. string OpenId = "omawy5VjduiPpSo9GNldzYZlioZE";
  39. string Key = "VyULlqfAW2gBfCNfLdupcL7zlha7d93F";
  40. string NotifyUrl = Host + "api/wechat/notice";
  41. // Dictionary<string, string> dic = new WeChatFunction(_accessor.HttpContext).Pay(AppId, MchId, SubMchId, 0.1M, DateTime.Now.ToString("yyyyMMddHHmmssfff"), Description, OpenId, Key, NotifyUrl);
  42. Dictionary<string, string> dic = new WeChatFunction(_accessor.HttpContext).Refund(AppId, MchId, SubMchId, 1M, 1M, "2022020817492424848364549", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Description, OpenId, Key, NotifyUrl);
  43. return dic;
  44. }
  45. }
  46. }