Kaynağa Gözat

修改查询审核状态监听模式

lichunlei 1 yıl önce
ebeveyn
işleme
aa9721fd64

+ 3 - 0
Config/Base.cs

@@ -9,6 +9,9 @@ namespace AppConfig
         public static string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
         public static string Database = Library.ConfigurationManager.AppSettings["Database"].ToString();
         public static string defaultImage = Library.ConfigurationManager.AppSettings["Host"].ToString() + "/skin/app/default/static/images/default.jpg";
+        public static string SqlConnStr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+
+
         #region 数据库结构
         public static Dictionary<string, Dictionary<string, string>> mainTables = new Dictionary<string, Dictionary<string, string>>();
 

+ 31 - 20
Util/HaoDa/CheckWeChatSignService.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Data;
 using MySystem.Models.Main;
 using Library;
 using LitJson;
@@ -26,29 +27,39 @@ namespace MySystem
         {
             while (true)
             {
-                string content = RedisDbconn.Instance.RPop<string>("WeChatSignHdQueue");
-                if (!string.IsNullOrEmpty(content))
+                // string content = RedisDbconn.Instance.RPop<string>("WeChatSignHdQueue");
+                // if (!string.IsNullOrEmpty(content))
+                // {
+                //     if (content == "sleep")
+                //     {
+                //         RedisDbconn.Instance.AddList("WeChatSignHdQueue", "sleep");
+                //         Thread.Sleep(60000);
+                //     }
+                //     else
+                //     {
+                //         QueryMerchantStatus queryMerchantStatus = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryMerchantStatus>(content);
+                //         string result = StartDo(queryMerchantStatus);
+                //         if (result == "wait")
+                //         {
+                //             Thread.Sleep(500);
+                //             RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
+                //         }
+                //     }
+                // }
+                // else
+                // {
+                //     Thread.Sleep(2000);
+                // }
+                DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where Id in (select Id from MerchantInfo where Sort=1 and `Status`=0 and QueryCount=0) and MchtNo!='' and MchtNo is not null", AppConfig.Base.SqlConnStr);
+                foreach(DataRow dr in dt.Rows)
                 {
-                    if (content == "sleep")
+                    StartDo(new QueryMerchantStatus()
                     {
-                        RedisDbconn.Instance.AddList("WeChatSignHdQueue", "sleep");
-                        Thread.Sleep(60000);
-                    }
-                    else
-                    {
-                        QueryMerchantStatus queryMerchantStatus = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryMerchantStatus>(content);
-                        string result = StartDo(queryMerchantStatus);
-                        if (result == "wait")
-                        {
-                            Thread.Sleep(500);
-                            RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
-                        }
-                    }
-                }
-                else
-                {
-                    Thread.Sleep(2000);
+                        MerchantId = dr["Id"].ToString(),
+                        MerchantNo = dr["MchtNo"].ToString(),
+                    });
                 }
+                Thread.Sleep(60000);
             }
         }
 

+ 8 - 5
Util/HaoDa/HaoDaExtHelper.cs

@@ -55,8 +55,10 @@ public class HaoDaExtHelper
                 LogHelper.Instance.WriteLog("success", "提交微信商户意愿申请单");
                 JsonData json = JsonMapper.ToObject(result);
                 string applyment_id = json["applyment_id"].ToString();
-                RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + applyment_id + "\"}");
-                RedisDbconn.Instance.AddList("WeChatAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
+                info.ApplymentId = applyment_id;
+                db.SaveChanges();
+                // RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + applyment_id + "\"}");
+                // RedisDbconn.Instance.AddList("WeChatAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
                 LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "提交微信商户意愿申请单");
                 LogHelper.Instance.WriteLog("end", "提交微信商户意愿申请单");
             }
@@ -121,8 +123,10 @@ public class HaoDaExtHelper
                 LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "提交支付宝商户意愿申请单");
                 LogHelper.Instance.WriteLog("success", "提交支付宝商户意愿申请单");
                 string order_no = jsonObj["alipay_merchant_indirect_authorder_create_response"]["order_no"].ToString();
-                RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + order_no + "\"}");
-                RedisDbconn.Instance.AddList("AlipayAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
+                info.SeoTitle = order_no;
+                db.SaveChanges();
+                // RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + order_no + "\"}");
+                // RedisDbconn.Instance.AddList("AlipayAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
                 LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "提交支付宝商户意愿申请单");
                 LogHelper.Instance.WriteLog("end", "提交支付宝商户意愿申请单");
             }
@@ -137,7 +141,6 @@ public class HaoDaExtHelper
                 LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "提交支付宝商户意愿申请单");
                 LogHelper.Instance.WriteLog("end", "提交支付宝商户意愿申请单");
                 db.SaveChanges();
-
             }
             db.Dispose();
         }

+ 39 - 26
Util/HaoDa/HaoDaExtQueryAuthHelper.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Linq;
+using System.Data;
 using Microsoft.Extensions.Hosting;
 using MySystem;
 using MySystem.Models;
@@ -28,16 +29,22 @@ public class HaoDaExtQueryAuthHelper
     {
         while (true)
         {
-            string content = RedisDbconn.Instance.RPop<string>("WeChatAuthResultForHaoDaQueue");
-            if (!string.IsNullOrEmpty(content))
+            // string content = RedisDbconn.Instance.RPop<string>("WeChatAuthResultForHaoDaQueue");
+            // if (!string.IsNullOrEmpty(content))
+            // {
+            //     JsonData json = JsonMapper.ToObject(content);
+            //     WeChatAddInfo(int.Parse(json["MerchantId"].ToString()));
+            // }
+            // else
+            // {
+            //     Thread.Sleep(10000);
+            // }
+            DataTable dt = CustomerSqlConn.dtable("select Id from MerchantAddInfo where HdStatus=3 and `Status`=1", AppConfig.Base.SqlConnStr);
+            foreach(DataRow dr in dt.Rows)
             {
-                JsonData json = JsonMapper.ToObject(content);
-                WeChatAddInfo(int.Parse(json["MerchantId"].ToString()));
-            }
-            else
-            {
-                Thread.Sleep(10000);
+                WeChatAddInfo(int.Parse(dr["Id"].ToString()));
             }
+            Thread.Sleep(60000);
         }
     }
 
@@ -61,12 +68,12 @@ public class HaoDaExtQueryAuthHelper
                 db.SaveChanges();
                 LogHelper.Instance.WriteLog("startsend", "获取微信商户开户意愿确认状态");
             }
-            else
-            {
-                LogHelper.Instance.WriteLog("starte", "获取微信商户开户意愿确认状态");
-                RedisDbconn.Instance.AddList("WeChatAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
-                LogHelper.Instance.WriteLog("start2end", "获取微信商户开户意愿确认状态");
-            }
+            // else
+            // {
+            //     LogHelper.Instance.WriteLog("starte", "获取微信商户开户意愿确认状态");
+            //     RedisDbconn.Instance.AddList("WeChatAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
+            //     LogHelper.Instance.WriteLog("start2end", "获取微信商户开户意愿确认状态");
+            // }
             db.Dispose();
         }
         catch (Exception ex)
@@ -88,16 +95,22 @@ public class HaoDaExtQueryAuthHelper
     {
         while (true)
         {
-            string content = RedisDbconn.Instance.RPop<string>("AlipayAuthResultForHaoDaQueue");
-            if (!string.IsNullOrEmpty(content))
+            // string content = RedisDbconn.Instance.RPop<string>("AlipayAuthResultForHaoDaQueue");
+            // if (!string.IsNullOrEmpty(content))
+            // {
+            //     JsonData json = JsonMapper.ToObject(content);
+            //     AlipayAddInfo(int.Parse(json["MerchantId"].ToString()));
+            // }
+            // else
+            // {
+            //     Thread.Sleep(10000);
+            // }
+            DataTable dt = CustomerSqlConn.dtable("select Id from MerchantAddInfo where HdStatus=3 and `QueryCount`=1", AppConfig.Base.SqlConnStr);
+            foreach(DataRow dr in dt.Rows)
             {
-                JsonData json = JsonMapper.ToObject(content);
-                AlipayAddInfo(int.Parse(json["MerchantId"].ToString()));
-            }
-            else
-            {
-                Thread.Sleep(10000);
+                AlipayAddInfo(int.Parse(dr["Id"].ToString()));
             }
+            Thread.Sleep(60000);
         }
     }
 
@@ -126,10 +139,10 @@ public class HaoDaExtQueryAuthHelper
                     db.SaveChanges();
                     LogHelper.Instance.WriteLog("start1end", "获取支付宝商家认证状态");
                 }
-                else
-                {
-                    RedisDbconn.Instance.AddList("AlipayAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
-                }
+                // else
+                // {
+                //     RedisDbconn.Instance.AddList("AlipayAuthResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\"}");
+                // }
             }
             db.Dispose();
         }

+ 39 - 26
Util/HaoDa/HaoDaExtQueryHelper.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Linq;
+using System.Data;
 using Microsoft.Extensions.Hosting;
 using MySystem;
 using MySystem.Models;
@@ -28,16 +29,22 @@ public class HaoDaExtQueryHelper
     {
         while (true)
         {
-            string content = RedisDbconn.Instance.RPop<string>("WeChatResultForHaoDaQueue");
-            if (!string.IsNullOrEmpty(content))
+            // string content = RedisDbconn.Instance.RPop<string>("WeChatResultForHaoDaQueue");
+            // if (!string.IsNullOrEmpty(content))
+            // {
+            //     JsonData json = JsonMapper.ToObject(content);
+            //     WeChatAddInfo(int.Parse(json["MerchantId"].ToString()), json["ApplymentId"].ToString());
+            // }
+            // else
+            // {
+            //     Thread.Sleep(10000);
+            // }
+            DataTable dt = CustomerSqlConn.dtable("select Id,ApplymentId from MerchantAddInfo where HdStatus=3 and `Status`=0 and ApplymentId!='' and ApplymentId is not null", AppConfig.Base.SqlConnStr);
+            foreach(DataRow dr in dt.Rows)
             {
-                JsonData json = JsonMapper.ToObject(content);
-                WeChatAddInfo(int.Parse(json["MerchantId"].ToString()), json["ApplymentId"].ToString());
-            }
-            else
-            {
-                Thread.Sleep(10000);
+                WeChatAddInfo(int.Parse(dr["Id"].ToString()), dr["ApplymentId"].ToString());
             }
+            Thread.Sleep(60000);
         }
     }
 
@@ -84,12 +91,12 @@ public class HaoDaExtQueryHelper
                 LogHelper.Instance.WriteLog("start1end", "查询微信商户意愿申请状态");
                 db.SaveChanges();
             }
-            else
-            {
-                LogHelper.Instance.WriteLog("starte", "查询微信商户意愿申请状态");
-                RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + ApplymentId + "\"}");
-                LogHelper.Instance.WriteLog("start2end", "查询微信商户意愿申请状态");
-            }
+            // else
+            // {
+            //     LogHelper.Instance.WriteLog("starte", "查询微信商户意愿申请状态");
+            //     RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + ApplymentId + "\"}");
+            //     LogHelper.Instance.WriteLog("start2end", "查询微信商户意愿申请状态");
+            // }
             db.Dispose();
         }
         catch (Exception ex)
@@ -111,16 +118,22 @@ public class HaoDaExtQueryHelper
     {
         while (true)
         {
-            string content = RedisDbconn.Instance.RPop<string>("AlipayResultForHaoDaQueue");
-            if (!string.IsNullOrEmpty(content))
+            // string content = RedisDbconn.Instance.RPop<string>("AlipayResultForHaoDaQueue");
+            // if (!string.IsNullOrEmpty(content))
+            // {
+            //     JsonData json = JsonMapper.ToObject(content);
+            //     AlipayAddInfo(int.Parse(json["MerchantId"].ToString()), json["order_no"].ToString());
+            // }
+            // else
+            // {
+            //     Thread.Sleep(10000);
+            // }
+            DataTable dt = CustomerSqlConn.dtable("select Id,SeoTitle from MerchantAddInfo where HdStatus=3 and `QueryCount`=0 and SeoTitle!='' and SeoTitle is not null", AppConfig.Base.SqlConnStr);
+            foreach(DataRow dr in dt.Rows)
             {
-                JsonData json = JsonMapper.ToObject(content);
-                AlipayAddInfo(int.Parse(json["MerchantId"].ToString()), json["order_no"].ToString());
-            }
-            else
-            {
-                Thread.Sleep(10000);
+                AlipayAddInfo(int.Parse(dr["Id"].ToString()), dr["SeoTitle"].ToString());
             }
+            Thread.Sleep(60000);
         }
     }
 
@@ -192,10 +205,10 @@ public class HaoDaExtQueryHelper
                     LogHelper.Instance.WriteLog("start2end", "查询支付宝商户意愿申请状态");
                     db.SaveChanges();
                 }
-                else
-                {
-                    RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + OrderNo + "\"}");
-                }
+                // else
+                // {
+                //     RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + OrderNo + "\"}");
+                // }
             }
             else
             {

+ 1 - 1
Util/HaoDa/MerchantConfirmService.cs

@@ -145,7 +145,7 @@ namespace MySystem
                             QueryMerchantStatus queryMerchantStatus = new QueryMerchantStatus();
                             queryMerchantStatus.MerchantId = MerchantId.ToString();
                             queryMerchantStatus.MerchantNo = AddInfo.MchtNo;
-                            RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
+                            // RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
                         }
                         //创建失败
                         else

+ 11 - 11
Util/HaoDa/TestHaoDaService.cs

@@ -76,7 +76,7 @@ namespace MySystem
                 {
                     LogHelper.Instance.WriteLog("success", "提交支付宝商户意愿申请单");
                     string order_no = jsonObj["alipay_merchant_indirect_authorder_create_response"]["order_no"].ToString();
-                    RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + order_no + "\"}");
+                    // RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + order_no + "\"}");
                     LogHelper.Instance.WriteLog("end", "提交支付宝商户意愿申请单");
                 }
                 else
@@ -154,10 +154,10 @@ namespace MySystem
                         LogHelper.Instance.WriteLog("start2end", "查询支付宝商户意愿申请状态");
                         db.SaveChanges();
                     }
-                    else
-                    {
-                        RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + OrderNo + "\"}");
-                    }
+                    // else
+                    // {
+                    //     RedisDbconn.Instance.AddList("AlipayResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"order_no\":\"" + OrderNo + "\"}");
+                    // }
                 }
                 else
                 {
@@ -198,7 +198,7 @@ namespace MySystem
                     LogHelper.Instance.WriteLog("success", "提交微信商户意愿申请单");
                     JsonData json = JsonMapper.ToObject(result);
                     string applyment_id = json["applyment_id"].ToString();
-                    RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + applyment_id + "\"}");
+                    // RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + applyment_id + "\"}");
                     LogHelper.Instance.WriteLog("end", "提交微信商户意愿申请单");
                 }
                 else if (result.Contains("\"message\":"))
@@ -257,10 +257,10 @@ namespace MySystem
                     info.WeChatRemark = jsonObj["reject_reason"].ToString();
                     db.SaveChanges();
                 }
-                else
-                {
-                    RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + ApplymentId + "\"}");
-                }
+                // else
+                // {
+                //     RedisDbconn.Instance.AddList("WeChatResultForHaoDaQueue", "{\"MerchantId\":\"" + Id + "\",\"ApplymentId\":\"" + ApplymentId + "\"}");
+                // }
                 db.Dispose();
             }
             catch (Exception ex)
@@ -354,7 +354,7 @@ namespace MySystem
                         QueryMerchantStatus queryMerchantStatus = new QueryMerchantStatus();
                         queryMerchantStatus.MerchantId = MerchantId.ToString();
                         queryMerchantStatus.MerchantNo = AddInfo.MchtNo;
-                        RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
+                        // RedisDbconn.Instance.AddList("WeChatSignHdQueue", queryMerchantStatus);
                     }
                     //创建失败
                     else