Переглянути джерело

好哒绑定微信延迟5分钟绑定

lcl 1 рік тому
батько
коміт
ff26c03562

+ 2 - 0
Models/Main/MerchantAddInfo.cs

@@ -145,5 +145,7 @@ namespace MySystem.Models.Main
         public string AliMerchantId { get; set; }
         public string WeChatMerchantId { get; set; }
         public int HdStatus { get; set; }
+        public DateTime? HdPassDate { get; set; }
+        public ulong HdBindWeChat { get; set; }
     }
 }

+ 1 - 1
Models/Main/MerchantInfo.cs

@@ -45,8 +45,8 @@ namespace MySystem.Models.Main
         public decimal AllocationAmount { get; set; }
         public decimal ActMaxAmount { get; set; }
         public decimal ActCurrentAmount { get; set; }
-        public int IsAct { get; set; }
         public int ExamineStatus { get; set; }
         public int Months { get; set; }
+        public int IsAct { get; set; }
     }
 }

+ 9 - 0
Models/Main/WebCMSEntities.cs

@@ -5423,6 +5423,15 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.HdBindWeChat)
+                    .HasColumnType("bit(1)")
+                    .HasDefaultValueSql("b'0'")
+                    .HasComment("好哒绑定微信状态");
+
+                entity.Property(e => e.HdPassDate)
+                    .HasColumnType("datetime")
+                    .HasComment("好哒审核通过时间");
+
                 entity.Property(e => e.HdStatus)
                     .HasColumnType("int(11)")
                     .HasComment("好哒进件状态");

+ 1 - 0
Startup.cs

@@ -143,6 +143,7 @@ namespace MySystem
             {
                 MerchantConfirmService.Instance.Start(); //提交商户进件
                 CheckWeChatSignService.Instance.Start(); //查询商户审核状态
+                CheckWeChatBindService.Instance.Start(); //执行好哒微信绑定appid
                 ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现
                 HaoDaExtHelper.Instance.StartWeChat();
                 HaoDaExtHelper.Instance.StartAlipay();

+ 70 - 0
Util/HaoDa/CheckWeChatBindService.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using MySystem.Models.Main;
+using Library;
+using LitJson;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+namespace MySystem
+{
+    public class CheckWeChatBindService
+    {
+        public readonly static CheckWeChatBindService Instance = new CheckWeChatBindService();
+        private CheckWeChatBindService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(StartListen);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListen()
+        {
+            while (true)
+            {
+                string CheckDate = DateTime.Now.AddMinutes(-5).ToString("yyyy-MM-dd HH:mm:ss");
+                DataTable dt = CustomerSqlConn.dtable("select Id from MerchantAddInfo where HdStatus=3 and HdBindWeChat=0 and HdPassDate<'" + CheckDate + "' and OutMchtNo!='' and OutMchtNo is not null", AppConfig.Base.SqlConnStr);
+                foreach(DataRow dr in dt.Rows)
+                {
+                    StartDo(int.Parse(function.CheckInt(dr["Id"].ToString())));
+                }
+                Thread.Sleep(10000);
+            }
+        }
+
+        public string StartDo(int MerchantId)
+        {
+            try
+            {
+                WebCMSEntities db = new WebCMSEntities();
+                MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == MerchantId);
+                if (merchantadd != null)
+                {
+                    //绑定微信appid接口
+                    JsonData bindInfo = JsonMapper.ToObject(HaoDaHelper.Instance.BindWeChatAppId(merchantadd.OutMchtNo, merchantadd.StoreNo, AppConfig.Haoda.SubAppId));
+                    //失败
+                    if (bindInfo["resultCode"].ToString() == "0")
+                    {
+                        merchantadd.AlipayRemark = bindInfo["errorDesc"].ToString();
+                    }
+                    else
+                    {
+                        merchantadd.HdBindWeChat = 1;
+                    }
+                    db.SaveChanges();
+                }
+                db.Dispose();
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "好哒商户进件状态查询异常");
+            }
+            return "";
+        }
+    }
+}

+ 1 - 7
Util/HaoDa/CheckWeChatSignService.cs

@@ -123,13 +123,7 @@ namespace MySystem
                                 {
                                     merchantadd.ToAcctNo += "," + AppConfig.Haoda.AcctNo + ",";
                                 }
-                                //绑定微信appid接口
-                                JsonData bindInfo = JsonMapper.ToObject(HaoDaHelper.Instance.BindWeChatAppId(merchantadd.OutMchtNo, merchantadd.StoreNo, AppConfig.Haoda.SubAppId));
-                                //失败
-                                if (bindInfo["resultCode"].ToString() == "0")
-                                {
-                                    merchantadd.AlipayRemark = bindInfo["errorDesc"].ToString();
-                                }
+                                merchantadd.HdPassDate = DateTime.Now;
                             }
                         }
                         db.SaveChanges();

+ 1 - 0
Util/HaoDa/TestHaoDaService.cs

@@ -42,6 +42,7 @@ namespace MySystem
             // WeChatFunctionForHD.Instance.QueryAuthMerchant("600955391");
             // AlipayFunctionForHD.Instance.AuthOrderAuthQuery("2088820718243322");
             // StartProfitShareListen();
+            // HaoDaHelper.Instance.BindWeChatAppId("1490230", "21622558", AppConfig.Haoda.SubAppId);
         }
 
         public void StartProfitShareListen()