MerchantAddInfoController.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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 WeChatStatus = data["WeChatStatus"].ToString(); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
  42. string AliPayStatus = data["AliPayStatus"].ToString(); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
  43. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  44. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  45. string condition = "";
  46. var merIds = MerchantInfoUtil.QuerySenedMerchantId();
  47. condition = " and Id in (" + merIds + ")";
  48. if (!string.IsNullOrEmpty(data["SubjectType"].ToString()))
  49. {
  50. if (data["SubjectType"].ToString() == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  51. if (data["SubjectType"].ToString() == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  52. condition += " and SubjectType='" + SubjectType + "'";
  53. }
  54. if (!string.IsNullOrEmpty(data["CertMerchantName"].ToString()))
  55. {
  56. condition += " and CertMerchantName like '%" + CertMerchantName + "%'";
  57. }
  58. if (!string.IsNullOrEmpty(data["ServicePhone"].ToString()))
  59. {
  60. condition += " and ServicePhone='" + ServicePhone + "'";
  61. }
  62. if (!string.IsNullOrEmpty(data["MakerCode"].ToString()))
  63. {
  64. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  65. condition += " and Id in (" + Ids + ")";
  66. }
  67. if (!string.IsNullOrEmpty(data["WeChatStatus"].ToString()))
  68. {
  69. condition += " and Status=" + WeChatStatus + "";
  70. }
  71. if (!string.IsNullOrEmpty(data["AliPayStatus"].ToString()))
  72. {
  73. condition += " and QueryCount=" + AliPayStatus + "";
  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() == "" ? "" : 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. curData.Add("WeChatStatus", status); //微信状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
  101. curData.Add("AliPayStatus", queryCount); //支付宝状态(-1 审核失败 0 待审核 1 待签约 2 已通过)
  102. dataList.Add(curData);
  103. }
  104. Other.Add("Count", count); //总数
  105. return dataList;
  106. }
  107. #endregion
  108. #region 进件管理-直连查看失败原因
  109. [Authorize]
  110. public JsonResult DirectQueryFailReason(string value)
  111. {
  112. value = PublicFunction.DesDecrypt(value);
  113. JsonData data = JsonMapper.ToObject(value);
  114. Dictionary<string, object> Obj = DirectQueryFailReasonDo(value);
  115. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  116. }
  117. private Dictionary<string, object> DirectQueryFailReasonDo(string value)
  118. {
  119. JsonData data = JsonMapper.ToObject(value);
  120. string MerchantId = data["MerchantId"].ToString(); //商户Id
  121. Dictionary<string, object> Obj = new Dictionary<string, object>();
  122. var query = MerchantAddInfoService.Query(int.Parse(MerchantId));
  123. Obj.Add("HdReason", query.WeChatRemark); //好哒原因
  124. Obj.Add("WeChatReason", query.WeChatRemark); //微信原因
  125. Obj.Add("AlipayReason", query.AlipayRemark); //支付宝原因
  126. return Obj;
  127. }
  128. #endregion
  129. #region 进件管理-直连进件详情
  130. [Authorize]
  131. public JsonResult DirectDetail(string value)
  132. {
  133. value = PublicFunction.DesDecrypt(value);
  134. JsonData data = JsonMapper.ToObject(value);
  135. Dictionary<string, object> Obj = DirectDetailDo(value);
  136. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  137. }
  138. private Dictionary<string, object> DirectDetailDo(string value)
  139. {
  140. JsonData data = JsonMapper.ToObject(value);
  141. string MerchantId = data["MerchantId"].ToString(); //商户Id
  142. Dictionary<string, object> Obj = new Dictionary<string, object>();
  143. Obj = MerchantAddInfoUtil.MerchantAddInfoDetail(int.Parse(MerchantId));
  144. return Obj;
  145. }
  146. #endregion
  147. #region 进件管理-直连提交进件
  148. [Authorize]
  149. public JsonResult DirectSubmit(string value)
  150. {
  151. value = PublicFunction.DesDecrypt(value);
  152. JsonData data = JsonMapper.ToObject(value);
  153. AppResultJson result = DirectSubmitDo(value);
  154. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  155. }
  156. private AppResultJson DirectSubmitDo(string value)
  157. {
  158. JsonData data = JsonMapper.ToObject(value);
  159. string MerchantId = data["MerchantId"].ToString(); //商户Id
  160. var info = MerchantAddInfoUtil.DirectSubmitDo(int.Parse(MerchantId));
  161. if (info == "success")
  162. {
  163. return new AppResultJson() { Status = "1", Info = "成功", Data = info };
  164. }
  165. else
  166. {
  167. return new AppResultJson() { Status = "-1", Info = "失败", Data = info };
  168. }
  169. }
  170. #endregion
  171. #region 进件管理-直连更新签约码
  172. [Authorize]
  173. public JsonResult DirectUpdateSignUrl(string value)
  174. {
  175. value = PublicFunction.DesDecrypt(value);
  176. JsonData data = JsonMapper.ToObject(value);
  177. AppResultJson result = DirectUpdateSignUrlDo(value);
  178. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  179. }
  180. private AppResultJson DirectUpdateSignUrlDo(string value)
  181. {
  182. JsonData data = JsonMapper.ToObject(value);
  183. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString()));
  184. string Kind = data["Kind"].ToString(); //类型(1 支付宝 2 微信 )
  185. Dictionary<string, object> Obj = new Dictionary<string, object>();
  186. RedisDbconn.Instance.AddList("UpdateSignUrlQueue", "{\"MerchantId\":\"" + MerchantId + "\",\"Kind\":\"" + Kind + "\"}");
  187. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  188. }
  189. #endregion
  190. #region 商户管理-直连查询商户交易信息
  191. [Authorize]
  192. public JsonResult DirectQueryMerchantTradeInfo(string value)
  193. {
  194. value = PublicFunction.DesDecrypt(value);
  195. JsonData data = JsonMapper.ToObject(value);
  196. Dictionary<string, object> Other = new Dictionary<string, object>();
  197. List<Dictionary<string, object>> dataList = DirectQueryMerchantTradeInfoDo(value, out Other);
  198. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  199. }
  200. private List<Dictionary<string, object>> DirectQueryMerchantTradeInfoDo(string value, out Dictionary<string, object> Other)
  201. {
  202. JsonData data = JsonMapper.ToObject(value);
  203. string MerchantName = data["MerchantName"].ToString(); //商户名称
  204. string Mobile = data["Mobile"].ToString(); //手机号码
  205. string MakerCode = data["MakerCode"].ToString(); //所属创客
  206. string AliPID = data["AliPID"].ToString(); //支付宝PID
  207. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  208. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  209. string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
  210. string ActDate = data["ActDate"].ToString(); //激活时间
  211. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  212. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  213. string condition = "";
  214. var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
  215. condition = " and Id in (" + merIds + ")";
  216. if (!string.IsNullOrEmpty(MerchantName))
  217. {
  218. condition += " and CertMerchantName like '%" + MerchantName + "%'";
  219. }
  220. if (!string.IsNullOrEmpty(Mobile))
  221. {
  222. condition += " and MobilePhone='" + Mobile + "'";
  223. }
  224. if (!string.IsNullOrEmpty(MakerCode))
  225. {
  226. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  227. condition += " and Id in (" + Ids + ")";
  228. }
  229. if (!string.IsNullOrEmpty(AliPID))
  230. {
  231. condition += " and AlipayPid='" + AliPID + "'";
  232. }
  233. if (!string.IsNullOrEmpty(WeChatNo))
  234. {
  235. condition += " and SubMchid='" + WeChatNo + "'";
  236. }
  237. if (!string.IsNullOrEmpty(SubjectType))
  238. {
  239. if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  240. if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  241. condition += " and SubjectType='" + SubjectType + "'";
  242. }
  243. if (!string.IsNullOrEmpty(IsAct))
  244. {
  245. var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
  246. condition += " and Id in (" + Ids + ")";
  247. }
  248. if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
  249. {
  250. string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
  251. string start = datelist[0];
  252. string end = datelist[1];
  253. var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
  254. condition += " and Id in (" + Ids + ")";
  255. }
  256. List<RelationData> relationData = new List<RelationData>();
  257. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  258. Other = new Dictionary<string, object>();
  259. int count = 0;
  260. List<Dictionary<string, object>> source = MerchantAddInfoService.List(relationData, condition, out count, pageNum, pageSize);
  261. foreach (Dictionary<string, object> subdata in source)
  262. {
  263. Dictionary<string, object> curData = new Dictionary<string, object>();
  264. //商户Id
  265. var MerchantId = int.Parse(subdata["Id"].ToString());
  266. var merInfo = MerchantInfoService.Query(MerchantId);
  267. var userInfo = UsersService.Query(merInfo.UserId);
  268. curData.Add("MerchantId", subdata["Id"].ToString()); //商户Id
  269. curData.Add("IsAct", merInfo.IsAct); //激活状态(0 未激活 1 已激活)
  270. var actDate = "";
  271. var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
  272. if (order.Id > 0)
  273. {
  274. actDate = order.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
  275. }
  276. curData.Add("ActDate", actDate); //激活时间
  277. curData.Add("MerchantName", subdata["CertMerchantName"].ToString()); //商户名称
  278. curData.Add("Mobile", subdata["MobilePhone"].ToString()); //手机号码
  279. curData.Add("MakerCode", userInfo.MakerCode); //所属创客
  280. curData.Add("RealName", userInfo.RealName); //所属创客姓名
  281. var subjectType = 0;
  282. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
  283. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
  284. curData.Add("AliPID", subdata["AlipayPid"].ToString()); //支付宝PID
  285. curData.Add("AliPayToken", subdata["AlipayAuthToken"].ToString()); //支付宝token
  286. curData.Add("WeChatNo", subdata["SubMchid"].ToString()); //微信商户号
  287. curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体 3 小微)
  288. var amountInfo = MerchantAmountSummayService.Sum("TradeCount,TotalActual,TradeAmount", " and MerchantId=" + MerchantId + "");
  289. curData.Add("OrderCount", decimal.Parse(amountInfo["TradeCount"].ToString())); //订单总数
  290. curData.Add("InComeAmount", decimal.Parse(amountInfo["TotalActual"].ToString()).ToString("f2")); //实收总金额
  291. curData.Add("TradeAmount", decimal.Parse(amountInfo["TradeAmount"].ToString()).ToString("f2")); //营业总金额
  292. dataList.Add(curData);
  293. }
  294. Other.Add("Count", count); //总数
  295. return dataList;
  296. #endregion
  297. }
  298. #region 商户管理-直连添加支付宝PID和微信商户号
  299. [Authorize]
  300. public JsonResult DirectAddPIDOrWeChatNo(string value)
  301. {
  302. value = PublicFunction.DesDecrypt(value);
  303. JsonData data = JsonMapper.ToObject(value);
  304. AppResultJson result = DirectAddPIDOrWeChatNoDo(value);
  305. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  306. }
  307. private AppResultJson DirectAddPIDOrWeChatNoDo(string value)
  308. {
  309. JsonData data = JsonMapper.ToObject(value);
  310. string MerchantId = data["MerchantId"].ToString(); //商户Id
  311. string AliPPID = data["AliPPID"].ToString(); //支付宝PID
  312. string AliPayToken = data["AliPayToken"].ToString(); //支付宝token
  313. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  314. Dictionary<string, object> Obj = new Dictionary<string, object>();
  315. // var query = MerchantAddInfoService.Query(int.Parse(MerchantId));
  316. var Id = int.Parse(MerchantId);
  317. var query = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
  318. Dictionary<string, object> fields = new Dictionary<string, object>();
  319. if (query.Id > 0)
  320. {
  321. if (string.IsNullOrEmpty(query.AlipayPid))
  322. {
  323. // fields.Add("AlipayPid", AliPPID); //支付宝PID
  324. query.AlipayPid = AliPPID;
  325. }
  326. if (!string.IsNullOrEmpty(AliPayToken))
  327. {
  328. // fields.Add("AlipayAuthToken", AliPayToken); //支付宝token
  329. query.AlipayAuthToken = AliPayToken;
  330. }
  331. if (string.IsNullOrEmpty(query.SubMchid))
  332. {
  333. // fields.Add("SubMchid", WeChatNo); //微信商户号
  334. query.SubMchid = WeChatNo;
  335. }
  336. }
  337. main1db.SaveChanges();
  338. // AppResultJson resultJson = MerchantAddInfoService.Edit(fields, int.Parse(MerchantId), false);
  339. return new AppResultJson() { Status = "1", Info = "添加成功", Data = Obj };
  340. }
  341. #endregion
  342. #region 节点操作-直联提交微信商户进件
  343. [Authorize]
  344. public JsonResult DirectWeChatMerchantAdd(string value)
  345. {
  346. value = PublicFunction.DesDecrypt(value);
  347. JsonData data = JsonMapper.ToObject(value);
  348. AppResultJson result = DirectWeChatMerchantAddDo(value);
  349. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  350. }
  351. private AppResultJson DirectWeChatMerchantAddDo(string value)
  352. {
  353. JsonData data = JsonMapper.ToObject(value);
  354. Dictionary<string, object> Obj = new Dictionary<string, object>();
  355. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  356. var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
  357. var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
  358. merAddInfo.Status = 0;
  359. merInfo.Status = 0;
  360. RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"2\"}");
  361. main1db.SaveChanges();
  362. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  363. }
  364. #endregion
  365. #region 节点操作-直联提交支付宝商户进件
  366. [Authorize]
  367. public JsonResult DirectAlipayMerchantAdd(string value)
  368. {
  369. value = PublicFunction.DesDecrypt(value);
  370. JsonData data = JsonMapper.ToObject(value);
  371. AppResultJson result = DirectAlipayMerchantAddDo(value);
  372. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  373. }
  374. private AppResultJson DirectAlipayMerchantAddDo(string value)
  375. {
  376. JsonData data = JsonMapper.ToObject(value);
  377. Dictionary<string, object> Obj = new Dictionary<string, object>();
  378. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  379. var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
  380. var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
  381. merAddInfo.QueryCount = 0;
  382. merInfo.QueryCount = 0;
  383. RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"1\"}");
  384. main1db.SaveChanges();
  385. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  386. }
  387. #endregion
  388. #region 节点操作-直联查询微信商户审核状态
  389. [Authorize]
  390. public JsonResult DirectWeChatMerchantQueryAudit(string value)
  391. {
  392. value = PublicFunction.DesDecrypt(value);
  393. JsonData data = JsonMapper.ToObject(value);
  394. Dictionary<string, object> Obj = DirectWeChatMerchantQueryAuditDo(value);
  395. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  396. }
  397. private Dictionary<string, object> DirectWeChatMerchantQueryAuditDo(string value)
  398. {
  399. JsonData data = JsonMapper.ToObject(value);
  400. Dictionary<string, object> Obj = new Dictionary<string, object>();
  401. MerchantAddInfo query = new MerchantAddInfo();
  402. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  403. query = MerchantAddInfoService.Query(id);
  404. Obj.Add("WeChatSignUrl", query.WeChatSignUrl); //微信签约地址
  405. Obj.Add("WeChatRemark", query.WeChatRemark); //微信备注
  406. Obj.Add("WeChatMerchantId", query.WeChatMerchantId); //微信商户号
  407. Obj.Add("Status", query.Status); //微信审核状态
  408. if (query.Status < 2)
  409. {
  410. RedisDbconn.Instance.AddList("WeChatSignQueue", new MerchantSign()
  411. {
  412. BusinessCode = query.BusinessCode,
  413. MerchantAddInfoId = id,
  414. Status = ""
  415. });
  416. }
  417. return Obj;
  418. }
  419. #endregion
  420. #region 节点操作-直联查询支付宝商户审核状态
  421. [Authorize]
  422. public JsonResult DirectAlipayMerchantQueryAudit(string value)
  423. {
  424. value = PublicFunction.DesDecrypt(value);
  425. JsonData data = JsonMapper.ToObject(value);
  426. Dictionary<string, object> Obj = DirectAlipayMerchantQueryAuditDo(value);
  427. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  428. }
  429. private Dictionary<string, object> DirectAlipayMerchantQueryAuditDo(string value)
  430. {
  431. JsonData data = JsonMapper.ToObject(value);
  432. Dictionary<string, object> Obj = new Dictionary<string, object>();
  433. MerchantAddInfo query = new MerchantAddInfo();
  434. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  435. query = MerchantAddInfoService.Query(id);
  436. Obj.Add("AlipayPid", query.AlipayPid); //支付宝唯一标识
  437. Obj.Add("AlipayAuthToken", query.AlipayAuthToken); //支付宝商家令牌
  438. Obj.Add("AlipaySignUrl", query.AlipaySignUrl); //支付宝签约地址
  439. Obj.Add("AlipayRemark", query.AlipayRemark); //支付宝备注
  440. Obj.Add("Status", query.QueryCount); //支付宝审核状态
  441. if (query.Status < 2)
  442. {
  443. RedisDbconn.Instance.AddList("AlipaySignQueue", new MerchantSign()
  444. {
  445. BusinessCode = query.SeoTitle,
  446. MerchantAddInfoId = id,
  447. Status = ""
  448. });
  449. }
  450. return Obj;
  451. }
  452. #endregion
  453. #region 商户管理-直连查询商户交易信息导出
  454. [Authorize]
  455. public JsonResult ExportDirectQueryMerchantTradeInfo(string value)
  456. {
  457. value = PublicFunction.DesDecrypt(value);
  458. JsonData data = JsonMapper.ToObject(value);
  459. AppResultJson result = ExportDirectQueryMerchantTradeInfoDo(value);
  460. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  461. }
  462. private AppResultJson ExportDirectQueryMerchantTradeInfoDo(string value)
  463. {
  464. JsonData data = JsonMapper.ToObject(value);
  465. string MerchantName = data["MerchantName"].ToString(); //商户名称
  466. string Mobile = data["Mobile"].ToString(); //手机号码
  467. string MakerCode = data["MakerCode"].ToString(); //所属创客
  468. string AliPID = data["AliPID"].ToString(); //支付宝PID
  469. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  470. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  471. string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
  472. string ActDate = data["ActDate"].ToString(); //激活时间
  473. string condition = "";
  474. var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
  475. condition = " and Id in (" + merIds + ")";
  476. if (!string.IsNullOrEmpty(MerchantName))
  477. {
  478. condition += " and CertMerchantName like '%" + MerchantName + "%'";
  479. }
  480. if (!string.IsNullOrEmpty(Mobile))
  481. {
  482. condition += " and MobilePhone='" + Mobile + "'";
  483. }
  484. if (!string.IsNullOrEmpty(MakerCode))
  485. {
  486. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  487. condition += " and Id in (" + Ids + ")";
  488. }
  489. if (!string.IsNullOrEmpty(AliPID))
  490. {
  491. condition += " and AlipayPid='" + AliPID + "'";
  492. }
  493. if (!string.IsNullOrEmpty(WeChatNo))
  494. {
  495. condition += " and SubMchid='" + WeChatNo + "'";
  496. }
  497. if (!string.IsNullOrEmpty(SubjectType))
  498. {
  499. if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  500. if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  501. condition += " and SubjectType='" + SubjectType + "'";
  502. }
  503. if (!string.IsNullOrEmpty(IsAct))
  504. {
  505. var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
  506. condition += " and Id in (" + Ids + ")";
  507. }
  508. if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
  509. {
  510. string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
  511. string start = datelist[0];
  512. string end = datelist[1];
  513. var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
  514. condition += " and Id in (" + Ids + ")";
  515. }
  516. Dictionary<string, object> Obj = new Dictionary<string, object>();
  517. var Sql = "SELECT a.Id '商户Id',(CASE WHEN b.IsAct=0 THEN '未激活' WHEN b.IsAct=1 THEN '已激活' ELSE '' end) '激活状态',c.UpdateDate '激活时间',a.CertMerchantName '商户名称',a.MobilePhone '手机号码',b.UserId '所属创客Id',a.AlipayPid '支付宝PID',a.AlipayAuthToken '支付宝token',a.SubMchid '微信商户号',(CASE WHEN a.SubjectType='SUBJECT_TYPE_ENTERPRISE' THEN '企业公司' WHEN a.SubjectType='SUBJECT_TYPE_INDIVIDUAL' THEN '个体工商户' ELSE '' end) SubjectType,(SELECT SUM(TradeCount) TradeCount FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '订单总数',(SELECT SUM(TotalActual) TotalActual FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id)' 实收总金额',(SELECT SUM(TradeAmount) TradeAmount FROM MerchantAmountSummay WHERE 1=1 AND MerchantId=a.Id) '营业总金额' FROM(SELECT Id,CertMerchantName,MobilePhone,SubjectType,AlipayPid,AlipayAuthToken,SubMchid FROM MerchantAddInfo WHERE 1=1 " + condition + " AND (Status=2 or QueryCount=2)) a LEFT JOIN (SELECT Id,IsAct,UserId FROM MerchantInfo WHERE 1=1 AND Status=2 or QueryCount=2) b ON a.Id=b.Id LEFT JOIN (SELECT MerchantId,UpdateDate FROM MerchantDepositOrder WHERE `Status`>0)c ON a.Id=c.MerchantId ORDER BY a.Id";
  518. var FileName = "商户管理-直连查询商户交易信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  519. string SendData = "{\"Operater\":\"" + AppConfig.LoginSession.sysId + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
  520. RedisDbconn.Instance.AddList("ExportQueue", SendData);
  521. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  522. }
  523. #endregion
  524. #region 重置交易额-直连重置商户交易额
  525. [Authorize]
  526. public JsonResult DirectResetMerchantAmount(string value)
  527. {
  528. value = PublicFunction.DesDecrypt(value);
  529. JsonData data = JsonMapper.ToObject(value);
  530. AppResultJson result = DirectResetMerchantAmountDo(value);
  531. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  532. }
  533. private AppResultJson DirectResetMerchantAmountDo(string value)
  534. {
  535. JsonData data = JsonMapper.ToObject(value);
  536. string MerchantId = data["MerchantId"].ToString(); //商户Id
  537. string TradeDate = data["TradeDate"].ToString(); //交易时间
  538. if (string.IsNullOrEmpty(data["MerchantId"].ToString()) || string.IsNullOrEmpty(data["TradeDate"].ToString()))
  539. {
  540. return new AppResultJson() { Status = "-1", Info = "商户Id和交易时间不能为空" };
  541. }
  542. string[] datelist = TradeDate.Split(new string[] { " - " }, StringSplitOptions.None);
  543. string start = DateTime.Parse(datelist[0]).ToString("yyyyMMdd");
  544. string end = DateTime.Parse(datelist[1]).ToString("yyyyMMdd");
  545. string info = "{\"MerchantId\":\"" + MerchantId + "\",\"StartDate\":\"" + start + "\",\"EndDate\": \"" + end + "\"}";
  546. RedisDbconn.Instance.AddList("ResetMerchantStatDataQueue", info);
  547. Dictionary<string, object> Obj = new Dictionary<string, object>();
  548. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  549. }
  550. #endregion
  551. }
  552. }