AnnouncementServicesController.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using EMIS.CommonLogic.SystemServices;
  2. using EMIS.Utility.OnlinePay;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using Senparc.Weixin;
  8. using System.Web.Mvc;
  9. using Senparc.Weixin.MP.AdvancedAPIs;
  10. using EMIS.CommonLogic.ProjectShareManage;
  11. namespace EMIS.Web.ServiceControllers.SystemManage
  12. {
  13. public class AnnouncementServicesController : Controller
  14. {
  15. public IAnnouncementServices AnnouncementServices { get; set; }
  16. public IShareRecordServices shareRecordServices { get; set; }
  17. public ActionResult GetAnnouncementViewInfo(Guid? announcementID)
  18. {
  19. return Json(AnnouncementServices.GetAnnouncementViewInfo(announcementID), JsonRequestBehavior.AllowGet);
  20. }
  21. public ActionResult GetUserAnnouncementView(Guid userID, int pageIndex, int pageSize)
  22. {
  23. return Json(AnnouncementServices.GetUserAnnouncementView(userID, pageIndex, pageSize), JsonRequestBehavior.AllowGet);
  24. }
  25. public ActionResult GetWeChatAppID()
  26. {
  27. string appID = Config.SenparcWeixinSetting.TenPayV3_AppId;
  28. return Json(appID);
  29. }
  30. public ActionResult GetEmpowerUrl(string url,string announcementID,string loginID)
  31. {
  32. var announcementIDStr = announcementID.Replace("-", "");
  33. var stateStr = announcementIDStr + loginID;
  34. var urlStr = WechatHelper.GetBaseAuthorizeUrl(url, stateStr);
  35. //var openID = WechatHelper.GetOpenID(code);
  36. //var urlcode = Urlencode
  37. return Json(urlStr);
  38. }
  39. public ActionResult GetOpenID(string code)
  40. {
  41. try
  42. {
  43. var openID = WechatHelper.GetOpenID(code);
  44. return Json(openID);
  45. }
  46. catch (Exception ex)
  47. {
  48. return Json(ex.Message);
  49. }
  50. }
  51. public ActionResult CheckAndRecordScore(Guid? announcementID, string loginID, string openID)
  52. {
  53. try
  54. {
  55. shareRecordServices.CheckAndRecordScore(announcementID, loginID, openID);
  56. return Json("success");
  57. }
  58. catch (Exception)
  59. {
  60. return Json("fail");
  61. }
  62. }
  63. public ActionResult ChangeAnnouncementIDAndCheck(string stateStr)
  64. {
  65. var announcementIDStr = stateStr.Substring(0, 32);
  66. var LoginID = stateStr.Substring(32, stateStr.Length - 32);
  67. var announcementID = announcementIDStr.Insert(8, "-");
  68. announcementID = announcementID.Insert(13, "-");
  69. announcementID = announcementID.Insert(18, "-");
  70. announcementID = announcementID.Insert(23, "-");
  71. bool isok = AnnouncementServices.CheckAnnouncementID(announcementID);
  72. List<string> vs = new List<string>();
  73. vs.Add(announcementID);
  74. vs.Add(LoginID);
  75. if (isok)
  76. {
  77. return Json(vs);
  78. }
  79. else {
  80. return Json("");
  81. }
  82. }
  83. }
  84. }