MerchantAddInfoController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 QueryCount=1"; //支付宝待签约
  72. if (Status == "11") condition += " and QueryCount=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 MerStatus = 0;
  102. // if (status == 0) MerStatus = 0; //审核中
  103. if (status == 2 && queryCount == 2) MerStatus = 1; //已通过
  104. if (status == -1) MerStatus = -1; //审核失败
  105. if (status == 1) MerStatus = 20; //微信待签约
  106. if (status == 2) MerStatus = 21; //微信已签约
  107. if (queryCount == 1) MerStatus = 10; //支付宝待签约
  108. if (queryCount == 2) MerStatus = 11; //支付宝已签约
  109. curData.Add("Status", MerStatus); //商户状态
  110. //审核平台
  111. var AuditInfo = 0;
  112. if (status < 0 && queryCount >= 1) AuditInfo = 2;
  113. if (status >= 1 && queryCount < 0) AuditInfo = 1;
  114. curData.Add("AuditInfo", AuditInfo); //审核平台(1 支付宝 2 微信)
  115. dataList.Add(curData);
  116. }
  117. Other.Add("Count", count); //总数
  118. return dataList;
  119. }
  120. #endregion
  121. #region 进件管理-直连查看失败原因
  122. [Authorize]
  123. public JsonResult DirectQueryFailReason(string value)
  124. {
  125. value = PublicFunction.DesDecrypt(value);
  126. JsonData data = JsonMapper.ToObject(value);
  127. Dictionary<string, object> Obj = DirectQueryFailReasonDo(value);
  128. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  129. }
  130. private Dictionary<string, object> DirectQueryFailReasonDo(string value)
  131. {
  132. JsonData data = JsonMapper.ToObject(value);
  133. string MerchantId = data["MerchantId"].ToString(); //商户Id
  134. Dictionary<string, object> Obj = new Dictionary<string, object>();
  135. MerchantAddInfo query = new MerchantAddInfo();
  136. query = MerchantAddInfoService.Query(int.Parse(MerchantId));
  137. var info = "";
  138. if (query.Status == -1)
  139. {
  140. info += query.WeChatRemark + "\n";
  141. }
  142. if (query.QueryCount == -1)
  143. {
  144. info += query.AlipayRemark + "\n";
  145. }
  146. Obj.Add("Info", info); //失败原因
  147. return Obj;
  148. }
  149. #endregion
  150. #region 进件管理-直连进件详情
  151. [Authorize]
  152. public JsonResult DirectDetail(string value)
  153. {
  154. value = PublicFunction.DesDecrypt(value);
  155. JsonData data = JsonMapper.ToObject(value);
  156. Dictionary<string, object> Obj = DirectDetailDo(value);
  157. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  158. }
  159. private Dictionary<string, object> DirectDetailDo(string value)
  160. {
  161. JsonData data = JsonMapper.ToObject(value);
  162. string MerchantId = data["MerchantId"].ToString(); //商户Id
  163. Dictionary<string, object> Obj = new Dictionary<string, object>();
  164. Obj = MerchantAddInfoUtil.MerchantAddInfoDetail(int.Parse(MerchantId));
  165. return Obj;
  166. }
  167. #endregion
  168. #region 进件管理-直连提交进件
  169. [Authorize]
  170. public JsonResult DirectSubmit(string value)
  171. {
  172. value = PublicFunction.DesDecrypt(value);
  173. JsonData data = JsonMapper.ToObject(value);
  174. AppResultJson result = DirectSubmitDo(value);
  175. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  176. }
  177. private AppResultJson DirectSubmitDo(string value)
  178. {
  179. JsonData data = JsonMapper.ToObject(value);
  180. string MerchantId = data["MerchantId"].ToString(); //商户Id
  181. var info = MerchantAddInfoUtil.DirectSubmitDo(int.Parse(MerchantId));
  182. if (info == "success")
  183. {
  184. return new AppResultJson() { Status = "1", Info = "成功", Data = info };
  185. }
  186. else
  187. {
  188. return new AppResultJson() { Status = "-1", Info = "失败", Data = info };
  189. }
  190. }
  191. #endregion
  192. #region 商户管理-直连查询商户交易信息
  193. [Authorize]
  194. public JsonResult DirectQueryMerchantTradeInfo(string value)
  195. {
  196. value = PublicFunction.DesDecrypt(value);
  197. JsonData data = JsonMapper.ToObject(value);
  198. Dictionary<string, object> Obj = DirectQueryMerchantTradeInfoDo(value);
  199. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  200. }
  201. private Dictionary<string, object> DirectQueryMerchantTradeInfoDo(string value)
  202. {
  203. JsonData data = JsonMapper.ToObject(value);
  204. string MerchantName = data["MerchantName"].ToString(); //商户名称
  205. string Mobile = data["Mobile"].ToString(); //手机号码
  206. string MakerCode = data["MakerCode"].ToString(); //所属创客
  207. string MatchNo = data["MatchNo"].ToString(); //商户号
  208. string AliPID = data["AliPID"].ToString(); //支付宝PID
  209. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  210. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  211. Dictionary<string, object> Obj = new Dictionary<string, object>();
  212. Obj = MerchantAddInfoUtil.DirectQueryMerchantTradeInfoDo(MerchantName, Mobile, MakerCode, MatchNo, AliPID, WeChatNo, SubjectType);
  213. return Obj;
  214. }
  215. #endregion
  216. #region 商户管理-直连添加支付宝PID和微信商户号
  217. [Authorize]
  218. public JsonResult DirectAddPIDOrWeChatNo(string value)
  219. {
  220. value = PublicFunction.DesDecrypt(value);
  221. JsonData data = JsonMapper.ToObject(value);
  222. AppResultJson result = DirectAddPIDOrWeChatNoDo(value);
  223. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  224. }
  225. private AppResultJson DirectAddPIDOrWeChatNoDo(string value)
  226. {
  227. JsonData data = JsonMapper.ToObject(value);
  228. string MerchantId = data["MerchantId"].ToString(); //商户Id
  229. string AliPPID = data["AliPPID"].ToString(); //支付宝PID
  230. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  231. Dictionary<string, object> Obj = new Dictionary<string, object>();
  232. MerchantAddInfo query = new MerchantAddInfo();
  233. Dictionary<string, object> fields = new Dictionary<string, object>();
  234. fields.Add("create_date", DateTime.Now); //创建时间
  235. fields.Add("update_date", DateTime.Now); //修改时间
  236. AppResultJson resultJson = MerchantAddInfoService.Add(fields, false);
  237. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  238. }
  239. #endregion
  240. }
  241. }