MerchantAddInfoController.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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 DirectQueryMerchantTradeInfo(string value)
  174. {
  175. value = PublicFunction.DesDecrypt(value);
  176. JsonData data = JsonMapper.ToObject(value);
  177. Dictionary<string, object> Other = new Dictionary<string, object>();
  178. List<Dictionary<string, object>> dataList = DirectQueryMerchantTradeInfoDo(value, out Other);
  179. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  180. }
  181. private List<Dictionary<string, object>> DirectQueryMerchantTradeInfoDo(string value, out Dictionary<string, object> Other)
  182. {
  183. JsonData data = JsonMapper.ToObject(value);
  184. string MerchantName = data["MerchantName"].ToString(); //商户名称
  185. string Mobile = data["Mobile"].ToString(); //手机号码
  186. string MakerCode = data["MakerCode"].ToString(); //所属创客
  187. string AliPID = data["AliPID"].ToString(); //支付宝PID
  188. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  189. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  190. string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
  191. string ActDate = data["ActDate"].ToString(); //激活时间
  192. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  193. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  194. string condition = "";
  195. var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
  196. condition = " and Id in (" + merIds + ")";
  197. if (!string.IsNullOrEmpty(MerchantName))
  198. {
  199. condition += " and CertMerchantName like '%" + MerchantName + "%'";
  200. }
  201. if (!string.IsNullOrEmpty(Mobile))
  202. {
  203. condition += " and MobilePhone='" + Mobile + "'";
  204. }
  205. if (!string.IsNullOrEmpty(MakerCode))
  206. {
  207. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  208. condition += " and Id in (" + Ids + ")";
  209. }
  210. if (!string.IsNullOrEmpty(AliPID))
  211. {
  212. condition += " and AlipayPid='" + AliPID + "'";
  213. }
  214. if (!string.IsNullOrEmpty(WeChatNo))
  215. {
  216. condition += " and SubMchid='" + WeChatNo + "'";
  217. }
  218. if (!string.IsNullOrEmpty(SubjectType))
  219. {
  220. if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  221. if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  222. condition += " and SubjectType='" + SubjectType + "'";
  223. }
  224. if (!string.IsNullOrEmpty(IsAct))
  225. {
  226. var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
  227. condition += " and Id in (" + Ids + ")";
  228. }
  229. if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
  230. {
  231. string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
  232. string start = datelist[0];
  233. string end = datelist[1];
  234. var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
  235. condition += " and Id in (" + Ids + ")";
  236. }
  237. List<RelationData> relationData = new List<RelationData>();
  238. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  239. Other = new Dictionary<string, object>();
  240. int count = 0;
  241. List<Dictionary<string, object>> source = MerchantAddInfoService.List(relationData, condition, out count, pageNum, pageSize);
  242. foreach (Dictionary<string, object> subdata in source)
  243. {
  244. Dictionary<string, object> curData = new Dictionary<string, object>();
  245. //商户Id
  246. var MerchantId = int.Parse(subdata["Id"].ToString());
  247. var merInfo = MerchantInfoService.Query(MerchantId);
  248. var userInfo = UsersService.Query(merInfo.UserId);
  249. curData.Add("MerchantId", subdata["Id"].ToString()); //商户Id
  250. curData.Add("IsAct", merInfo.IsAct); //激活状态(0 未激活 1 已激活)
  251. var actDate = "";
  252. var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
  253. if (order.Id > 0)
  254. {
  255. actDate = order.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
  256. }
  257. curData.Add("ActDate", actDate); //激活时间
  258. curData.Add("MerchantName", subdata["CertMerchantName"].ToString()); //商户名称
  259. curData.Add("Mobile", subdata["MobilePhone"].ToString()); //手机号码
  260. curData.Add("MakerCode", userInfo.MakerCode); //所属创客
  261. curData.Add("RealName", userInfo.RealName); //所属创客姓名
  262. var subjectType = 0;
  263. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_ENTERPRISE") subjectType = 1; //企业公司
  264. if (subdata["SubjectType"].ToString() == "SUBJECT_TYPE_INDIVIDUAL") subjectType = 2; //个体工商户
  265. curData.Add("AliPID", subdata["AlipayPid"].ToString()); //支付宝PID
  266. curData.Add("AliPayToken", subdata["AlipayAuthToken"].ToString()); //支付宝token
  267. curData.Add("WeChatNo", subdata["SubMchid"].ToString()); //微信商户号
  268. curData.Add("SubjectType", subjectType); //主体类型(1 企业 2 个体 3 小微)
  269. var amountInfo = MerchantAmountSummayService.Sum("TradeCount,TotalActual,TradeAmount", " and MerchantId=" + MerchantId + "");
  270. curData.Add("OrderCount", decimal.Parse(amountInfo["TradeCount"].ToString())); //订单总数
  271. curData.Add("InComeAmount", decimal.Parse(amountInfo["TotalActual"].ToString()).ToString("f2")); //实收总金额
  272. curData.Add("TradeAmount", decimal.Parse(amountInfo["TradeAmount"].ToString()).ToString("f2")); //营业总金额
  273. dataList.Add(curData);
  274. }
  275. Other.Add("Count", count); //总数
  276. return dataList;
  277. #endregion
  278. }
  279. #region 商户管理-直连修改商户微信或支付宝签约状态为成功
  280. [Authorize]
  281. public JsonResult DirectEditAlipayOrWeChatStatus(string value)
  282. {
  283. value = PublicFunction.DesDecrypt(value);
  284. JsonData data = JsonMapper.ToObject(value);
  285. AppResultJson result = DirectEditAlipayOrWeChatStatusDo(value);
  286. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  287. }
  288. private AppResultJson DirectEditAlipayOrWeChatStatusDo(string value)
  289. {
  290. JsonData data = JsonMapper.ToObject(value);
  291. int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
  292. int Kind = int.Parse(function.CheckInt(data["Kind"].ToString())); //类型(0 所有 1 支付宝 2 微信)
  293. Dictionary<string, object> Obj = new Dictionary<string, object>();
  294. var query = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantAddInfo();
  295. var querys = main1db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId) ?? new MerchantInfo();
  296. Dictionary<string, object> fields = new Dictionary<string, object>();
  297. if (Kind == 0)
  298. {
  299. query.QueryCount = 2;
  300. query.Status = 2;
  301. querys.QueryCount = 2;
  302. querys.Status = 2;
  303. }
  304. if (Kind == 1)
  305. {
  306. query.QueryCount = 2;
  307. querys.QueryCount = 2;
  308. }
  309. if (Kind == 2)
  310. {
  311. query.Status = 2;
  312. querys.Status = 2;
  313. }
  314. main1db.SaveChanges();
  315. return new AppResultJson() { Status = "1", Info = "修改成功", Data = Obj };
  316. }
  317. #endregion
  318. #region 商户管理-直连添加支付宝PID和微信商户号
  319. [Authorize]
  320. public JsonResult DirectAddPIDOrWeChatNo(string value)
  321. {
  322. value = PublicFunction.DesDecrypt(value);
  323. JsonData data = JsonMapper.ToObject(value);
  324. AppResultJson result = DirectAddPIDOrWeChatNoDo(value);
  325. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  326. }
  327. private AppResultJson DirectAddPIDOrWeChatNoDo(string value)
  328. {
  329. JsonData data = JsonMapper.ToObject(value);
  330. string MerchantId = data["MerchantId"].ToString(); //商户Id
  331. string AliPPID = data["AliPPID"].ToString(); //支付宝PID
  332. string AliPayToken = data["AliPayToken"].ToString(); //支付宝token
  333. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  334. Dictionary<string, object> Obj = new Dictionary<string, object>();
  335. // var query = MerchantAddInfoService.Query(int.Parse(MerchantId));
  336. var Id = int.Parse(MerchantId);
  337. var query = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
  338. Dictionary<string, object> fields = new Dictionary<string, object>();
  339. if (query.Id > 0)
  340. {
  341. if (string.IsNullOrEmpty(query.AlipayPid))
  342. {
  343. // fields.Add("AlipayPid", AliPPID); //支付宝PID
  344. query.AlipayPid = AliPPID;
  345. }
  346. if (!string.IsNullOrEmpty(AliPayToken))
  347. {
  348. // fields.Add("AlipayAuthToken", AliPayToken); //支付宝token
  349. query.AlipayAuthToken = AliPayToken;
  350. }
  351. if (string.IsNullOrEmpty(query.SubMchid))
  352. {
  353. // fields.Add("SubMchid", WeChatNo); //微信商户号
  354. query.SubMchid = WeChatNo;
  355. }
  356. }
  357. main1db.SaveChanges();
  358. // AppResultJson resultJson = MerchantAddInfoService.Edit(fields, int.Parse(MerchantId), false);
  359. return new AppResultJson() { Status = "1", Info = "添加成功", Data = Obj };
  360. }
  361. #endregion
  362. #region 节点操作-直联提交微信商户进件
  363. [Authorize]
  364. public JsonResult DirectWeChatMerchantAdd(string value)
  365. {
  366. value = PublicFunction.DesDecrypt(value);
  367. JsonData data = JsonMapper.ToObject(value);
  368. AppResultJson result = DirectWeChatMerchantAddDo(value);
  369. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  370. }
  371. private AppResultJson DirectWeChatMerchantAddDo(string value)
  372. {
  373. JsonData data = JsonMapper.ToObject(value);
  374. Dictionary<string, object> Obj = new Dictionary<string, object>();
  375. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  376. var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
  377. var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
  378. merAddInfo.Status = 0;
  379. merInfo.Status = 0;
  380. RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"2\"}");
  381. main1db.SaveChanges();
  382. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  383. }
  384. #endregion
  385. #region 节点操作-直联提交支付宝商户进件
  386. [Authorize]
  387. public JsonResult DirectAlipayMerchantAdd(string value)
  388. {
  389. value = PublicFunction.DesDecrypt(value);
  390. JsonData data = JsonMapper.ToObject(value);
  391. AppResultJson result = DirectAlipayMerchantAddDo(value);
  392. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  393. }
  394. private AppResultJson DirectAlipayMerchantAddDo(string value)
  395. {
  396. JsonData data = JsonMapper.ToObject(value);
  397. Dictionary<string, object> Obj = new Dictionary<string, object>();
  398. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  399. var merAddInfo = main1db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
  400. var merInfo = main1db.MerchantInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantInfo();
  401. merAddInfo.QueryCount = 0;
  402. merInfo.QueryCount = 0;
  403. RedisDbconn.Instance.AddList("MerchantConfirmQueue", "{\"MerchantId\":\"" + id + "\",\"Kind\":\"1\"}");
  404. main1db.SaveChanges();
  405. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  406. }
  407. #endregion
  408. #region 节点操作-直联查询微信商户审核状态
  409. [Authorize]
  410. public JsonResult DirectWeChatMerchantQueryAudit(string value)
  411. {
  412. value = PublicFunction.DesDecrypt(value);
  413. JsonData data = JsonMapper.ToObject(value);
  414. Dictionary<string, object> Obj = DirectWeChatMerchantQueryAuditDo(value);
  415. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  416. }
  417. private Dictionary<string, object> DirectWeChatMerchantQueryAuditDo(string value)
  418. {
  419. JsonData data = JsonMapper.ToObject(value);
  420. Dictionary<string, object> Obj = new Dictionary<string, object>();
  421. MerchantAddInfo query = new MerchantAddInfo();
  422. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  423. query = MerchantAddInfoService.Query(id);
  424. Obj.Add("WeChatSignUrl", query.WeChatSignUrl); //微信签约地址
  425. Obj.Add("WeChatRemark", query.WeChatRemark); //微信备注
  426. Obj.Add("WeChatMerchantId", query.WeChatMerchantId); //微信商户号
  427. Obj.Add("Status", query.Status); //微信审核状态
  428. if (query.Status < 2)
  429. {
  430. RedisDbconn.Instance.AddList("WeChatSignQueue", new MerchantSign()
  431. {
  432. BusinessCode = query.BusinessCode,
  433. MerchantAddInfoId = id,
  434. Status = ""
  435. });
  436. }
  437. return Obj;
  438. }
  439. #endregion
  440. #region 节点操作-直联查询支付宝商户审核状态
  441. [Authorize]
  442. public JsonResult DirectAlipayMerchantQueryAudit(string value)
  443. {
  444. value = PublicFunction.DesDecrypt(value);
  445. JsonData data = JsonMapper.ToObject(value);
  446. Dictionary<string, object> Obj = DirectAlipayMerchantQueryAuditDo(value);
  447. return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
  448. }
  449. private Dictionary<string, object> DirectAlipayMerchantQueryAuditDo(string value)
  450. {
  451. JsonData data = JsonMapper.ToObject(value);
  452. Dictionary<string, object> Obj = new Dictionary<string, object>();
  453. MerchantAddInfo query = new MerchantAddInfo();
  454. int id = int.Parse(function.CheckInt(data["id"].ToString()));
  455. query = MerchantAddInfoService.Query(id);
  456. Obj.Add("AlipayPid", query.AlipayPid); //支付宝唯一标识
  457. Obj.Add("AlipayAuthToken", query.AlipayAuthToken); //支付宝商家令牌
  458. Obj.Add("AlipaySignUrl", query.AlipaySignUrl); //支付宝签约地址
  459. Obj.Add("AlipayRemark", query.AlipayRemark); //支付宝备注
  460. Obj.Add("Status", query.QueryCount); //支付宝审核状态
  461. if (query.Status < 2)
  462. {
  463. RedisDbconn.Instance.AddList("AlipaySignQueue", new MerchantSign()
  464. {
  465. BusinessCode = query.SeoTitle,
  466. MerchantAddInfoId = id,
  467. Status = ""
  468. });
  469. }
  470. return Obj;
  471. }
  472. #endregion
  473. #region 商户管理-直连查询商户交易信息导出
  474. [Authorize]
  475. public JsonResult ExportDirectQueryMerchantTradeInfo(string value)
  476. {
  477. value = PublicFunction.DesDecrypt(value);
  478. JsonData data = JsonMapper.ToObject(value);
  479. AppResultJson result = ExportDirectQueryMerchantTradeInfoDo(value);
  480. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  481. }
  482. private AppResultJson ExportDirectQueryMerchantTradeInfoDo(string value)
  483. {
  484. JsonData data = JsonMapper.ToObject(value);
  485. string MerchantName = data["MerchantName"].ToString(); //商户名称
  486. string Mobile = data["Mobile"].ToString(); //手机号码
  487. string MakerCode = data["MakerCode"].ToString(); //所属创客
  488. string AliPID = data["AliPID"].ToString(); //支付宝PID
  489. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  490. string SubjectType = data["SubjectType"].ToString(); //主体类型(1 企业 2 个体)
  491. string IsAct = data["IsAct"].ToString(); //激活状态(0 未激活 1 已激活)
  492. string ActDate = data["ActDate"].ToString(); //激活时间
  493. string condition = "";
  494. var merIds = MerchantInfoUtil.QueryAnyIsOkMerchantId();
  495. condition = " and Id in (" + merIds + ")";
  496. if (!string.IsNullOrEmpty(MerchantName))
  497. {
  498. condition += " and CertMerchantName like '%" + MerchantName + "%'";
  499. }
  500. if (!string.IsNullOrEmpty(Mobile))
  501. {
  502. condition += " and MobilePhone='" + Mobile + "'";
  503. }
  504. if (!string.IsNullOrEmpty(MakerCode))
  505. {
  506. var Ids = MerchantInfoUtil.QueryMerchantIdByMakerCode(MakerCode);
  507. condition += " and Id in (" + Ids + ")";
  508. }
  509. if (!string.IsNullOrEmpty(AliPID))
  510. {
  511. condition += " and AlipayPid='" + AliPID + "'";
  512. }
  513. if (!string.IsNullOrEmpty(WeChatNo))
  514. {
  515. condition += " and SubMchid='" + WeChatNo + "'";
  516. }
  517. if (!string.IsNullOrEmpty(SubjectType))
  518. {
  519. if (SubjectType == "1") SubjectType = "SUBJECT_TYPE_ENTERPRISE"; //企业公司
  520. if (SubjectType == "2") SubjectType = "SUBJECT_TYPE_INDIVIDUAL"; //个体工商户
  521. condition += " and SubjectType='" + SubjectType + "'";
  522. }
  523. if (!string.IsNullOrEmpty(IsAct))
  524. {
  525. var Ids = MerchantInfoUtil.QueryIsActMerchantId(int.Parse(IsAct));
  526. condition += " and Id in (" + Ids + ")";
  527. }
  528. if (!string.IsNullOrEmpty(data["ActDate"].ToString()))
  529. {
  530. string[] datelist = ActDate.Split(new string[] { " - " }, StringSplitOptions.None);
  531. string start = datelist[0];
  532. string end = datelist[1];
  533. var Ids = MerchantInfoUtil.QueryActDateMerchantId(start, end);
  534. condition += " and Id in (" + Ids + ")";
  535. }
  536. Dictionary<string, object> Obj = new Dictionary<string, object>();
  537. 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";
  538. var FileName = "商户管理-直连查询商户交易信息" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  539. string SendData = "{\"Operater\":\"" + AppConfig.LoginSession.sysId + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
  540. RedisDbconn.Instance.AddList("ExportQueue", SendData);
  541. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  542. }
  543. #endregion
  544. #region 重置交易额-直连重置商户交易额
  545. [Authorize]
  546. public JsonResult DirectResetMerchantAmount(string value)
  547. {
  548. value = PublicFunction.DesDecrypt(value);
  549. JsonData data = JsonMapper.ToObject(value);
  550. AppResultJson result = DirectResetMerchantAmountDo(value);
  551. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  552. }
  553. private AppResultJson DirectResetMerchantAmountDo(string value)
  554. {
  555. JsonData data = JsonMapper.ToObject(value);
  556. string MerchantId = data["MerchantId"].ToString(); //商户Id
  557. string TradeDate = data["TradeDate"].ToString(); //交易时间
  558. if (string.IsNullOrEmpty(data["MerchantId"].ToString()) || string.IsNullOrEmpty(data["TradeDate"].ToString()))
  559. {
  560. return new AppResultJson() { Status = "-1", Info = "商户Id和交易时间不能为空" };
  561. }
  562. string[] datelist = TradeDate.Split(new string[] { " - " }, StringSplitOptions.None);
  563. string start = DateTime.Parse(datelist[0]).ToString("yyyyMMdd");
  564. string end = DateTime.Parse(datelist[1]).ToString("yyyyMMdd");
  565. string info = "{\"MerchantId\":\"" + MerchantId + "\",\"StartDate\":\"" + start + "\",\"EndDate\": \"" + end + "\"}";
  566. RedisDbconn.Instance.AddList("ResetMerchantStatDataQueue", info);
  567. Dictionary<string, object> Obj = new Dictionary<string, object>();
  568. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  569. }
  570. #endregion
  571. }
  572. }