MerchantAddInfoController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.Main1;
  11. using MySystem.Service.Main1;
  12. using LitJson;
  13. using Library;
  14. using MySystem.Service.KxsMain;
  15. namespace MySystem.Areas.Api.Controllers.v1.Main1
  16. {
  17. [Area("Api")]
  18. [Route("/v1/QrCodePlateMain/[controller]/[action]")]
  19. public class MerchantAddInfoController : BaseController
  20. {
  21. public MerchantAddInfoController(IHttpContextAccessor accessor) : base(accessor)
  22. {
  23. }
  24. #region 进件管理-直连商户列表
  25. [Authorize]
  26. public JsonResult DirectList(string value)
  27. {
  28. value = PublicFunction.DesDecrypt(value);
  29. JsonData data = JsonMapper.ToObject(value);
  30. Dictionary<string, object> Other = new Dictionary<string, object>();
  31. List<Dictionary<string, object>> dataList = DirectListDo(value, out Other);
  32. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  33. }
  34. private List<Dictionary<string, object>> DirectListDo(string value, out Dictionary<string, object> Other)
  35. {
  36. JsonData data = JsonMapper.ToObject(value);
  37. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  38. string CertMerchantName = data["CertMerchantName"].ToString(); //商户名称
  39. string ServicePhone = data["ServicePhone"].ToString(); //客服电话
  40. string MakerCode = data["MakerCode"].ToString(); //所属创客编号
  41. string Status = data["Status"].ToString(); //商户状态(0 审核中 1 已通过 -1 审核失败 20 微信待签约 21 微信已签约 10 支付宝待签约 11 支付宝已签约)
  42. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  43. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  44. string condition = "";
  45. if (!string.IsNullOrEmpty(data["SubjectType"].ToString()))
  46. {
  47. if (data["SubjectType"].ToString() == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  48. if (data["SubjectType"].ToString() == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  49. condition += " and SubjectType='" + SubjectType + "'";
  50. }
  51. if (!string.IsNullOrEmpty(data["CertMerchantName"].ToString()))
  52. {
  53. condition += " and CertMerchantName='" + CertMerchantName + "'";
  54. }
  55. if (!string.IsNullOrEmpty(data["ServicePhone"].ToString()))
  56. {
  57. condition += " and ServicePhone='" + ServicePhone + "'";
  58. }
  59. if (!string.IsNullOrEmpty(data["MakerCode"].ToString()))
  60. {
  61. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  62. condition += " and Id in (" + Ids + ")";
  63. }
  64. if (!string.IsNullOrEmpty(data["Status"].ToString()))
  65. {
  66. if (Status == "0") condition += " and Status=0"; //审核中
  67. if (Status == "1") condition += " and Status=2 and QueryCount=2"; //已通过
  68. if (Status == "-1") condition += " and Status=-1"; //审核失败
  69. if (Status == "20") condition += " and Status=1"; //微信待签约
  70. if (Status == "21") condition += " and Status=2"; //微信已签约
  71. if (Status == "10") condition += " and Status=1"; //支付宝待签约
  72. if (Status == "11") condition += " and Status=2"; //支付宝已签约
  73. condition += "";
  74. }
  75. List<RelationData> relationData = new List<RelationData>();
  76. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  77. Other = new Dictionary<string, object>();
  78. int count = 0;
  79. List<Dictionary<string, object>> source = MerchantAddInfoService.List(relationData, condition, out count, pageNum, pageSize);
  80. foreach (Dictionary<string, object> subdata in source)
  81. {
  82. Dictionary<string, object> curData = new Dictionary<string, object>();
  83. var status = int.Parse(subdata["Status"].ToString());
  84. var queryCount = int.Parse(subdata["QueryCount"].ToString());
  85. //商户Id
  86. var MerchantId = int.Parse(subdata["Id"].ToString());
  87. //主体类型
  88. var subjectType = 0;
  89. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
  90. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
  91. curData.Add("Id", subdata["Id"].ToString()); //Id
  92. curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体)
  93. curData.Add("CertMerchantName", subdata["CertMerchantName"].ToString()); //商户名称
  94. curData.Add("ServicePhone", subdata["ServicePhone"].ToString()); //客服电话
  95. curData.Add("BizStoreAddress", subdata["BizStoreAddress"].ToString()); //门店地址
  96. curData.Add("CreateDate", subdata["CreateDate"].ToString() == null ? "" : DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //进件时间
  97. var userInfo = UsersService.Query(MerchantInfoService.Query(MerchantId).UserId);
  98. curData.Add("MakerCode", userInfo.MakerCode); //所属创客编号
  99. curData.Add("RealName", userInfo.RealName); //所属创客姓名
  100. //审核平台
  101. var AuditInfo = 0;
  102. if (status < 0 && queryCount >= 1) AuditInfo = 2;
  103. if (status >= 1 && queryCount < 0) AuditInfo = 1;
  104. curData.Add("AuditInfo", AuditInfo); //审核平台(1 支付宝 2 微信)
  105. dataList.Add(curData);
  106. }
  107. Other.Add("Count", count); //总数
  108. return dataList;
  109. }
  110. #endregion
  111. #region 进件管理-直连查看失败原因
  112. [Authorize]
  113. public JsonResult DirectQueryFailReason(string value)
  114. {
  115. value = PublicFunction.DesDecrypt(value);
  116. JsonData data = JsonMapper.ToObject(value);
  117. Dictionary<string, object> Obj = DirectQueryFailReasonDo(value);
  118. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  119. }
  120. private Dictionary<string, object> DirectQueryFailReasonDo(string value)
  121. {
  122. JsonData data = JsonMapper.ToObject(value);
  123. string MerchantId = data["MerchantId"].ToString(); //商户Id
  124. Dictionary<string, object> Obj = new Dictionary<string, object>();
  125. MerchantAddInfo query = new MerchantAddInfo();
  126. query = MerchantAddInfoService.Query(int.Parse(MerchantId));
  127. var info = "";
  128. if (query.Status == -1)
  129. {
  130. info += query.WeChatRemark + "\n";
  131. }
  132. if (query.QueryCount == -1)
  133. {
  134. info += query.AlipayRemark + "\n";
  135. }
  136. Obj.Add("Info", info); //失败原因
  137. return Obj;
  138. }
  139. #endregion
  140. #region 进件管理-直连进件详情
  141. [Authorize]
  142. public JsonResult DirectDetail(string value)
  143. {
  144. value = PublicFunction.DesDecrypt(value);
  145. JsonData data = JsonMapper.ToObject(value);
  146. Dictionary<string, object> Obj = DirectDetailDo(value);
  147. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  148. }
  149. private Dictionary<string, object> DirectDetailDo(string value)
  150. {
  151. JsonData data = JsonMapper.ToObject(value);
  152. string MerchantId = data["MerchantId"].ToString(); //商户Id
  153. Dictionary<string, object> Obj = new Dictionary<string, object>();
  154. Obj = MerchantAddInfoUtil.MerchantAddInfoDetail(int.Parse(MerchantId));
  155. return Obj;
  156. }
  157. #endregion
  158. #region 进件管理-直连提交进件
  159. [Authorize]
  160. public JsonResult DirectSubmit(string value)
  161. {
  162. value = PublicFunction.DesDecrypt(value);
  163. JsonData data = JsonMapper.ToObject(value);
  164. AppResultJson result = DirectSubmitDo(value);
  165. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  166. }
  167. private AppResultJson DirectSubmitDo(string value)
  168. {
  169. JsonData data = JsonMapper.ToObject(value);
  170. string MerchantId = data["MerchantId"].ToString(); //商户Id
  171. var info = MerchantAddInfoUtil.DirectSubmitDo(int.Parse(MerchantId));
  172. if (info == "success")
  173. {
  174. return new AppResultJson() { Status = "1", Info = "成功", Data = info };
  175. }
  176. else
  177. {
  178. return new AppResultJson() { Status = "-1", Info = "失败", Data = info };
  179. }
  180. }
  181. #endregion
  182. #region 商户管理-直连查询商户交易信息
  183. [Authorize]
  184. public JsonResult DirectQueryMerchantTradeInfo(string value)
  185. {
  186. value = PublicFunction.DesDecrypt(value);
  187. JsonData data = JsonMapper.ToObject(value);
  188. Dictionary<string, object> Obj = DirectQueryMerchantTradeInfoDo(value);
  189. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  190. }
  191. private Dictionary<string, object> DirectQueryMerchantTradeInfoDo(string value)
  192. {
  193. JsonData data = JsonMapper.ToObject(value);
  194. string MerchantName = data["MerchantName"].ToString(); //商户名称
  195. string Mobile = data["Mobile"].ToString(); //手机号码
  196. string MakerCode = data["MakerCode"].ToString(); //所属创客
  197. string MatchNo = data["MatchNo"].ToString(); //商户号
  198. string AliPID = data["AliPID"].ToString(); //支付宝PID
  199. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  200. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  201. Dictionary<string, object> Obj = new Dictionary<string, object>();
  202. Obj = MerchantAddInfoUtil.DirectQueryMerchantTradeInfoDo(MerchantName, Mobile, MakerCode, MatchNo, AliPID, WeChatNo, SubjectType);
  203. return Obj;
  204. }
  205. #endregion
  206. #region 商户管理-直连添加支付宝PID和微信商户号
  207. [Authorize]
  208. public JsonResult DirectAddPIDOrWeChatNo(string value)
  209. {
  210. value = PublicFunction.DesDecrypt(value);
  211. JsonData data = JsonMapper.ToObject(value);
  212. AppResultJson result = DirectAddPIDOrWeChatNoDo(value);
  213. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  214. }
  215. private AppResultJson DirectAddPIDOrWeChatNoDo(string value)
  216. {
  217. JsonData data = JsonMapper.ToObject(value);
  218. string MerchantId = data["MerchantId"].ToString(); //商户Id
  219. string AliPPID = data["AliPPID"].ToString(); //支付宝PID
  220. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  221. Dictionary<string, object> Obj = new Dictionary<string, object>();
  222. MerchantAddInfo query = new MerchantAddInfo();
  223. Dictionary<string, object> fields = new Dictionary<string, object>();
  224. fields.Add("create_date", DateTime.Now); //创建时间
  225. fields.Add("update_date", DateTime.Now); //修改时间
  226. AppResultJson resultJson = MerchantAddInfoService.Add(fields, false);
  227. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  228. }
  229. #endregion
  230. }
  231. }