MerchantDepositBackController.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.Models.Main;
  11. using LitJson;
  12. using Library;
  13. using System.Data;
  14. using MySystem.Service.Main;
  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 MerchantDepositBackController : BaseController
  23. {
  24. public MerchantDepositBackController(IHttpContextAccessor accessor) : base(accessor)
  25. {
  26. }
  27. #region 商户激活—商户服务费退还
  28. [Authorize]
  29. public JsonResult AddMerchantDepositBack(string value)
  30. {
  31. value = DesDecrypt(value);
  32. JsonData data = JsonMapper.ToObject(value);
  33. AppResultJson result = AddMerchantDepositBackDo(value);
  34. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  35. }
  36. private AppResultJson AddMerchantDepositBackDo(string value)
  37. {
  38. JsonData data = JsonMapper.ToObject(value);
  39. int MerchantId = int.Parse(function.CheckInt(data.getItem("MerchantId").ToString())); //商户Id
  40. int ReturnWay = int.Parse(function.CheckInt(data.getItem("ReturnWay").ToString())); //退还方式
  41. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  42. string ReturnNo = data["ReturnNo"].ToString(); //退还账号
  43. if (string.IsNullOrEmpty(data["MerchantId"].ToString()))
  44. {
  45. return new AppResultJson() { Status = "-1", Info = "请填写商户Id" };
  46. }
  47. if (!function.IsInt(data["MerchantId"].ToString()))
  48. {
  49. return new AppResultJson() { Status = "-1", Info = "请填写正确的商户Id" };
  50. }
  51. if (string.IsNullOrEmpty(data["ReturnWay"].ToString()))
  52. {
  53. return new AppResultJson() { Status = "-1", Info = "请填写退还方式" };
  54. }
  55. if (!function.IsInt(data["ReturnWay"].ToString()))
  56. {
  57. return new AppResultJson() { Status = "-1", Info = "请填写正确的退还方式" };
  58. }
  59. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:手机号");
  60. if (mobilecheck == null)
  61. {
  62. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  63. }
  64. if (mobilecheck.CheckCode != MobileCode)
  65. {
  66. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  67. }
  68. RedisDbconn.Instance.Clear("MobileCodeCheck:手机号");
  69. Dictionary<string, object> Obj = new Dictionary<string, object>();
  70. MerchantDepositBack query = new MerchantDepositBack();
  71. Dictionary<string, object> fields = new Dictionary<string, object>();
  72. fields.Add("CreateDate", DateTime.Now); //创建时间
  73. fields.Add("UpdateDate", DateTime.Now); //修改时间
  74. fields.Add("MerchantId", MerchantId); //商户Id
  75. fields.Add("ReturnWay", ReturnWay); //退还方式
  76. // AppResultJson resultJson = MerchantDepositBackService.Add(fields);
  77. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  78. }
  79. #endregion
  80. }
  81. }