Browse Source

Merge branch 'feature-dgy-获取好哒商户门店号' into DuGuYang

# Conflicts:
#	Startup.cs
DuGuYang 11 months ago
parent
commit
56fd374483
2 changed files with 115 additions and 0 deletions
  1. 1 0
      Startup.cs
  2. 114 0
      Util/HaoDa/GetStoreNoHelper.cs

+ 1 - 0
Startup.cs

@@ -143,6 +143,7 @@ namespace MySystem
             if(Library.ConfigurationManager.EnvironmentFlag == 2)
             {
                 GetTencentAddressInfoService.Instance.Start(); // 获取腾讯地图地址
+                GetStoreNoHelper.Instance.Start(); //获取商户门店号、微信支付宝商户号
                 MerchantConfirmService.Instance.Start(); //提交商户进件
                 CheckWeChatSignService.Instance.Start(); //查询商户审核状态
                 CheckWeChatBindService.Instance.Start(); //执行好哒微信绑定appid

+ 114 - 0
Util/HaoDa/GetStoreNoHelper.cs

@@ -0,0 +1,114 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using MySystem.Models.Main;
+using Library;
+using System.Threading;
+using Microsoft.Extensions.Hosting;
+using System.Threading.Tasks;
+using LitJson;
+/// <summary>
+/// 获取商户门店号、微信支付宝商户号
+/// </summary>
+
+namespace MySystem
+{
+    public class GetStoreNoHelper
+    {
+        public readonly static GetStoreNoHelper Instance = new GetStoreNoHelper();
+        private GetStoreNoHelper()
+        {
+        }
+
+        #region 
+        public void Start()
+        {
+            Thread th = new Thread(StartDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartDo()
+        {
+            while (true)
+            {
+                string MerchantId = RedisDbconn.Instance.RPop<string>("UnionPayGetStoreNoQueue");
+                if (!string.IsNullOrEmpty(MerchantId))
+                {
+                    DoSomeThing(MerchantId);
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
+        public void DoSomeThing(string MerchantId)
+        {
+            try
+            {
+                int Id = int.Parse(function.CheckInt(MerchantId));
+                WebCMSEntities db = new WebCMSEntities();
+                MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+                MerchantInfo merInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                if (string.IsNullOrEmpty(AddInfo.StoreNo) && string.IsNullOrEmpty(AddInfo.OutMchtNo))
+                {
+
+                    //查询商户审核状态
+                    var returnInfo = HaoDaHelper.Instance.QueryMerchantStatus(HaoDaHelper.BrhCode, AddInfo.MchtNo);
+                    var check = false;
+                    JsonData jsonObj = JsonMapper.ToObject(returnInfo);
+                    if (jsonObj["resultCode"].ToString() == "1")
+                    {
+                        var StoreNo = jsonObj["data"]["storeNo"].ToString();
+                        var OutMchtNo = jsonObj["data"]["outMchtNo"].ToString();
+
+                        if (!string.IsNullOrEmpty(StoreNo) && !string.IsNullOrEmpty(OutMchtNo))
+                        {
+                            AddInfo.StoreNo = StoreNo;
+                            AddInfo.OutMchtNo = OutMchtNo;
+                            db.SaveChanges();
+                        }
+
+                        //查询实名认证状态
+                        var result = HaoDaHelper.Instance.QueryAuthStatus(AddInfo.OutMchtNo, AddInfo.StoreNo);
+                        JsonData jsonData = JsonMapper.ToObject(result);
+
+                        if (jsonData["resultCode"].ToString() == "1")
+                        {
+                            var AliMerchantId = jsonObj["aliMerchantId"].ToString();
+                            var WeChatMerchantId = jsonObj["wechatMerchantId"].ToString();
+
+                            if (!string.IsNullOrEmpty(AliMerchantId) && !string.IsNullOrEmpty(WeChatMerchantId))
+                            {
+                                AddInfo.AliMerchantId = AliMerchantId;
+                                AddInfo.WeChatMerchantId = WeChatMerchantId;
+                                db.SaveChanges();
+                            }
+                            check = true;
+                        }
+                    }
+                    
+                    if (check)
+                    {
+                        AddInfo.Status = 0;
+                        merInfo.Status = 0;
+                        db.SaveChanges();
+                    }
+                    else
+                    {
+                        RedisDbconn.Instance.AddList("UnionPayGetStoreNoQueue", MerchantId.ToString());
+                    }
+                }
+                db.Dispose();
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "获取商户门店号队列异常");
+            }
+        }
+        #endregion
+    }
+}