UserInviteFriendsController.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.AspNetCore.Http;
  7. using Microsoft.Extensions.Logging;
  8. using Microsoft.Extensions.Options;
  9. using Microsoft.AspNetCore.Authorization;
  10. using System.Web;
  11. using MySystem.MainModels;
  12. using LitJson;
  13. using Library;
  14. using System.Text;
  15. /// <summary>
  16. /// 邀请好友接口
  17. /// </summary>
  18. namespace MySystem.Areas.Api.Controllers.v1
  19. {
  20. [Area("Api")]
  21. [Route("/Api/v1/[controller]/[action]")]
  22. public class UserInviteFriendsController : BaseController
  23. {
  24. public UserInviteFriendsController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. {
  26. }
  27. #region 获取邀请图片列表
  28. [Authorize]
  29. public JsonResult InviteFriendsPhotoList(string value)
  30. {
  31. value = DesDecrypt(value);
  32. JsonData data = JsonMapper.ToObject(value);
  33. List<Dictionary<string, object>> dataList = InviteFriendsPhotoListDo(value);
  34. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
  35. }
  36. public List<Dictionary<string, object>> InviteFriendsPhotoListDo(string value)
  37. {
  38. JsonData data = JsonMapper.ToObject(value);
  39. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  40. for (int i = 1; i <= 4; i++)
  41. {
  42. Dictionary<string, object> Obj = new Dictionary<string, object>();
  43. var photo = DefaultPic("/static/qrcodebg/" + i + ".png");
  44. Obj.Add("Id", i);
  45. Obj.Add("PicPath", photo);
  46. dataList.Add(Obj);
  47. }
  48. return dataList;
  49. }
  50. #endregion
  51. #region 根据邀请图片生成信息
  52. [Authorize]
  53. public JsonResult InviteFriendsList(string value)
  54. {
  55. value = DesDecrypt(value);
  56. JsonData data = JsonMapper.ToObject(value);
  57. Dictionary<string, object> Obj = InviteFriendsListDo(value);
  58. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  59. }
  60. public Dictionary<string, object> InviteFriendsListDo(string value)
  61. {
  62. JsonData data = JsonMapper.ToObject(value);
  63. var photoId = function.CheckInt(data["photoId"].ToString());
  64. int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
  65. string result = function.GetWebRequest(Library.ConfigurationManager.AppSettings["QrCodeHost"].ToString() + "/home/getqrcode?uid=" + UserId + "&pid=" + photoId + "");//通过http请求获取数据路径
  66. Dictionary<string, object> Obj = new Dictionary<string, object>();
  67. Users query = UsersDbconn.Instance.Get(UserId) ?? new Users();
  68. Obj.Add("RealName", query.RealName); //创客姓名
  69. Obj.Add("MakerCode", query.MakerCode); //创客推荐码
  70. Obj.Add("ReferenceQrCode", SourceHost + result); //推广二维码地址
  71. return Obj;
  72. }
  73. #endregion
  74. }
  75. }