DuGuYang 1 年之前
父节点
当前提交
389cb2b521

+ 10 - 10
AppStart/Helper/CheckAlipaySignService.cs

@@ -110,11 +110,11 @@ namespace MySystem
                                             merchant.SignDate = DateTime.Now;
                                         }
                                     }
-                                    // if (merchant.Latitude == 0)
-                                    // {
-                                    //     //签约成功调用腾讯地图接口获取地址
-                                    //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
-                                    // }
+                                    if (merchant.Latitude == 0)
+                                    {
+                                        //签约成功调用腾讯地图接口获取地址
+                                        RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                                    }
                                 }
                             }
                             else
@@ -129,11 +129,11 @@ namespace MySystem
                                         merchant.SignDate = DateTime.Now;
                                     }
                                 }
-                                // if (merchant.Latitude == 0)
-                                // {
-                                //     //签约成功调用腾讯地图接口获取地址
-                                //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
-                                // }
+                                if (merchant.Latitude == 0)
+                                {
+                                    //签约成功调用腾讯地图接口获取地址
+                                    RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                                }
                             }
                             db.SaveChanges();
                         }

+ 5 - 5
AppStart/Helper/CheckWeChatSignService.cs

@@ -101,11 +101,11 @@ namespace MySystem
                                 merchant.SignDate = DateTime.Now;
                             }
                         }
-                        // if (merchant.Latitude == 0)
-                        // {
-                        //     //签约成功调用腾讯地图接口获取地址
-                        //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
-                        // }
+                        if (merchant.Latitude == 0)
+                        {
+                            //签约成功调用腾讯地图接口获取地址
+                            RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        }
                         db.SaveChanges();
                     }
                 }

+ 30 - 9
AppStart/Helper/Tencent/GetTencentAddressInfoService.cs

@@ -29,19 +29,40 @@ namespace MySystem
         {
             while (true)
             {
-                try
+                string data = RedisDbconn.Instance.RPop<string>("GetTencentAddressInfoQueue");
+                if (!string.IsNullOrEmpty(data))
                 {
-                    string data = RedisDbconn.Instance.RPop<string>("GetTencentAddressInfoQueue");
-                    JsonData jsonObj = JsonMapper.ToObject(data);
-                    int Address = int.Parse(jsonObj["Data"]["Address"].ToString());
-                    var Key = Library.ConfigurationManager.AppSettings["TencentKey"].ToString();
-                    var info = function.GetWebRequest("https://apis.map.qq.com/ws/geocoder/v1/?address=" + Address + "&key=" + Key);
+                    try
+                    {
+                        JsonData jsonObj = JsonMapper.ToObject(data);
+                        int Id = int.Parse(jsonObj["Data"]["MerchantId"].ToString());
+                        string Address = jsonObj["Data"]["Address"].ToString();
+                        string Key = Library.ConfigurationManager.AppSettings["TencentKey"].ToString();
+                        var info = function.GetWebRequest("https://apis.map.qq.com/ws/geocoder/v1/?address=" + Address + "&key=" + Key);
+                        JsonData result = JsonMapper.ToObject(info);
+                        //创建成功
+                        if (result["status"].ToString() == "0")
+                        {
+                            WebCMSEntities db = new WebCMSEntities();
+                            var merInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
+                            if (merInfo.Id > 0)
+                            {
+                                merInfo.Longitude = decimal.Parse(result["result"]["location"]["lng"].ToString());
+                                merInfo.Latitude = decimal.Parse(result["result"]["location"]["lat"].ToString());
+                                db.SaveChanges();
+                                db.Dispose();
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "获取腾讯地图地址线程异常");
+                    }
                 }
-                catch (Exception ex)
+                else
                 {
-                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "获取腾讯地图地址线程异常");
+                    Thread.Sleep(60000);
                 }
-                Thread.Sleep(100000);
             }
         }
     }

+ 1 - 1
Startup.cs

@@ -189,7 +189,7 @@ namespace MySystem
             }
             if(Library.ConfigurationManager.EnvironmentFlag == 2)
             {
-                // GetTencentAddressInfoService.Instance.Start(); // 获取腾讯地图地址
+                GetTencentAddressInfoService.Instance.Start(); // 获取腾讯地图地址
                 UpdateSignUrlService.Instance.Start(); //更新签约码
                 MerchantConfirmService.Instance.Start(); //特约商户进件队列
                 CheckAlipaySignService.Instance.Start(); //特约商户签约队列(支付宝)