Explorar el Código

添加获取腾讯地图地址代码(未放开)

DuGuYang hace 1 año
padre
commit
086d84b0f2

+ 1 - 0
Startup.cs

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

+ 13 - 3
Util/HaoDa/HaoDaExtQueryAuthHelper.cs

@@ -40,7 +40,7 @@ public class HaoDaExtQueryAuthHelper
             //     Thread.Sleep(10000);
             // }
             DataTable dt = CustomerSqlConn.dtable("select Id from MerchantAddInfo where HdStatus=3 and `Status`=1 and WeChatMerchantId!='' and WeChatMerchantId is not null", AppConfig.Base.SqlConnStr);
-            foreach(DataRow dr in dt.Rows)
+            foreach (DataRow dr in dt.Rows)
             {
                 WeChatAddInfo(int.Parse(dr["Id"].ToString()));
                 Thread.Sleep(1000);
@@ -60,7 +60,7 @@ public class HaoDaExtQueryAuthHelper
             string result = WeChatFunctionForHD.Instance.QueryAuthMerchant(info.WeChatMerchantId);
             LogHelper.Instance.WriteLog(result, "获取微信商户开户意愿确认状态");
             JsonData jsonObj = JsonMapper.ToObject(result);
-            if(result.Contains("authorize_state"))
+            if (result.Contains("authorize_state"))
             {
                 if (jsonObj["authorize_state"].ToString() == "AUTHORIZE_STATE_AUTHORIZED")
                 {
@@ -68,6 +68,11 @@ public class HaoDaExtQueryAuthHelper
                     MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
                     info.Status = 2;
                     merchant.Status = 2;
+                    // if (merchant.Latitude == 0)
+                    // {
+                    //     //签约成功调用腾讯地图接口获取地址
+                    //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                    // }
                     db.SaveChanges();
                     LogHelper.Instance.WriteLog("startsend", "获取微信商户开户意愿确认状态");
                 }
@@ -110,7 +115,7 @@ public class HaoDaExtQueryAuthHelper
             //     Thread.Sleep(10000);
             // }
             DataTable dt = CustomerSqlConn.dtable("select Id from MerchantAddInfo where HdStatus=3 and `QueryCount`=1 and AliMerchantId!='' and AliMerchantId is not null", AppConfig.Base.SqlConnStr);
-            foreach(DataRow dr in dt.Rows)
+            foreach (DataRow dr in dt.Rows)
             {
                 AlipayAddInfo(int.Parse(dr["Id"].ToString()));
                 Thread.Sleep(1000);
@@ -143,6 +148,11 @@ public class HaoDaExtQueryAuthHelper
                     merchant.QueryCount = 2;
                     db.SaveChanges();
                     LogHelper.Instance.WriteLog("start1end", "获取支付宝商家认证状态");
+                    // if (merchant.Latitude == 0)
+                    // {
+                    //     //签约成功调用腾讯地图接口获取地址
+                    //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                    // }
                 }
                 // else
                 // {

+ 13 - 3
Util/HaoDa/HaoDaExtQueryHelper.cs

@@ -40,7 +40,7 @@ public class HaoDaExtQueryHelper
             //     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)
+            foreach (DataRow dr in dt.Rows)
             {
                 WeChatAddInfo(int.Parse(dr["Id"].ToString()), dr["ApplymentId"].ToString());
             }
@@ -89,6 +89,11 @@ public class HaoDaExtQueryHelper
                 merchant.Status = 2;
                 info.WeChatRemark = "";
                 LogHelper.Instance.WriteLog("start1end", "查询微信商户意愿申请状态");
+                // if (merchant.Latitude == 0)
+                // {
+                //     //签约成功调用腾讯地图接口获取地址
+                //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                // }
                 db.SaveChanges();
             }
             // else
@@ -129,7 +134,7 @@ public class HaoDaExtQueryHelper
             //     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)
+            foreach (DataRow dr in dt.Rows)
             {
                 AlipayAddInfo(int.Parse(dr["Id"].ToString()), dr["SeoTitle"].ToString());
             }
@@ -169,7 +174,7 @@ public class HaoDaExtQueryHelper
                 {
                     MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
                     LogHelper.Instance.WriteLog("start2", "查询支付宝商户意愿申请状态");
-                    if(result.Contains("\"qr_code\":"))
+                    if (result.Contains("\"qr_code\":"))
                     {
                         info.QueryCount = 1;
                         merchant.QueryCount = 1;
@@ -203,6 +208,11 @@ public class HaoDaExtQueryHelper
                     merchant.QueryCount = 2;
                     info.AlipayRemark = "";
                     LogHelper.Instance.WriteLog("start2end", "查询支付宝商户意愿申请状态");
+                    // if (merchant.Latitude == 0)
+                    // {
+                    //     //签约成功调用腾讯地图接口获取地址
+                    //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                    // }
                     db.SaveChanges();
                 }
                 // else

+ 48 - 0
Util/HaoDa/Tencent/GetTencentAddressInfoService.cs

@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using Library;
+using LitJson;
+
+namespace MySystem
+{
+    /// <summary>
+    /// 获取腾讯地图地址
+    /// </summary>
+    public class GetTencentAddressInfoService
+    {
+        public readonly static GetTencentAddressInfoService Instance = new GetTencentAddressInfoService();
+        private GetTencentAddressInfoService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(GetTencentAddress);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void GetTencentAddress()
+        {
+            while (true)
+            {
+                try
+                {
+                    string data = RedisDbconn.Instance.RPop<string>("GetTencentAddressInfoQueue");
+                    JsonData jsonObj = JsonMapper.ToObject(data);
+                    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);
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具执行扣费异常");
+                }
+                Thread.Sleep(100000);
+            }
+        }
+    }
+}

+ 5 - 0
Util/HaoDa/TestHaoDaService.cs

@@ -313,6 +313,11 @@ namespace MySystem
                         merchant.QueryCount = 2;
                         info.AlipayRemark = "";
                         LogHelper.Instance.WriteLog("start2end", "查询支付宝商户意愿申请状态");
+                        // if (merchant.Latitude == 0)
+                        // {
+                        //     //签约成功调用腾讯地图接口获取地址
+                        //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        // }
                         db.SaveChanges();
                     }
                     // else

+ 26 - 16
Util/HaoDa/WeChatPayBackService.cs

@@ -59,7 +59,7 @@ namespace MySystem
                 string OrderNo = jsonObj["outOrderNo"].ToString();
                 string HdOrderNo = jsonObj["orderNo"].ToString();
                 string TradeNo = "";
-                if(content.Contains("\"payChannelOrderNo\""))
+                if (content.Contains("\"payChannelOrderNo\""))
                 {
                     TradeNo = jsonObj["payChannelOrderNo"].ToString();
                 }
@@ -80,17 +80,27 @@ namespace MySystem
                     LogHelper.Instance.WriteLog("赋值", "微信支付回调监控");
                     MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
                     MerchantAddInfo addinfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
-                    if(addinfo.Status == 1 && order.PayMode == 2)
+                    if (addinfo.Status == 1 && order.PayMode == 2)
                     {
                         addinfo.Status = 2;
                         merchant.Status = 2;
                         addinfo.WeChatRemark = "";
+                        // if (merchant.Latitude == 0)
+                        // {
+                        //     //签约成功调用腾讯地图接口获取地址
+                        //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        // }
                     }
-                    else if(addinfo.QueryCount == 1 && order.PayMode == 1)
+                    else if (addinfo.QueryCount == 1 && order.PayMode == 1)
                     {
                         addinfo.QueryCount = 2;
                         merchant.QueryCount = 2;
                         addinfo.AlipayRemark = "";
+                        // if (merchant.Latitude == 0)
+                        // {
+                        //     //签约成功调用腾讯地图接口获取地址
+                        //     RedisDbconn.Instance.AddList("GetTencentAddressInfoQueue", "{\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        // }
                     }
                     order.UserId = merchant.UserId;
                     LogHelper.Instance.WriteLog("创客:" + merchant.UserId, "微信支付回调监控");
@@ -108,17 +118,17 @@ namespace MySystem
 
                     Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
                     var machines = db1.PosMachines.Select(m => new { m.SeoDescription, m.DeviceKind, m.BrandId, m.Detail, m.BindMerchantId }).Where(m => m.DeviceKind == "2" && m.BindMerchantId == order.MerchantId);
-                    foreach(var machine in machines)
+                    foreach (var machine in machines)
                     {
-                        if(!string.IsNullOrEmpty(addinfo.AliMerchantId) && machine.BrandId == 1)
+                        if (!string.IsNullOrEmpty(addinfo.AliMerchantId) && machine.BrandId == 1)
                         {
                             AliIotFunction.Instance.IotTradeVoice(machine.SeoDescription, addinfo.AliMerchantId, order.PayMoney.ToString("f2"), "OTHER");
                         }
-                        else if(machine.BrandId == 2)
+                        else if (machine.BrandId == 2)
                         {
                             TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"), machine.Detail, order.PayMoney.ToString("f2"));
                         }
-                        else if(machine.BrandId == 3)
+                        else if (machine.BrandId == 3)
                         {
                             MqLinksHelper.Instance.doSomething(machine.Detail, order.PayMoney.ToString("f2"));
                         }
@@ -176,7 +186,7 @@ namespace MySystem
                                     string acctNo = AppConfig.Haoda.AcctNo; //账户号,分账接收方账户号
                                     string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
                                     string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
-                                    
+
                                     decimal settleAmount = (decimal)order.SettleAmount / 100M;
                                     decimal divideAmt = (1 - 0.0038M) * order.PayMoney;
                                     divideAmt = decimal.Parse(divideAmt.ToString("f2"));
@@ -184,10 +194,10 @@ namespace MySystem
                                     hdfee = decimal.Parse(hdfee.ToString("f2"));
                                     decimal servicefee = 0.01M * order.PayMoney - hdfee;
                                     servicefee = decimal.Parse(servicefee.ToString("f2"));
-                                    decimal amount = order.PayMoney*(1-0.0038M) - servicefee;
+                                    decimal amount = order.PayMoney * (1 - 0.0038M) - servicefee;
                                     amount = decimal.Parse(amount.ToString("f2"));
                                     decimal otherAmt = settleAmount - servicefee - amount;
-                                    if(otherAmt != 0)
+                                    if (otherAmt != 0)
                                     {
                                         amount += otherAmt;
                                     }
@@ -198,7 +208,7 @@ namespace MySystem
                                     string amountAmount = amount.ToString("f0");
                                     string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount));
                                     order.DivideLog = "请求分账日志:" + result;
-                                    if(result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
+                                    if (result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
                                     {
                                         Status = 1;
                                     }
@@ -216,7 +226,7 @@ namespace MySystem
                                 }
                             }
                             order.Status = Status;
-                            if(Status == 2)
+                            if (Status == 2)
                             {
                                 order.DivideFlag = 1;
                                 order.DivideDate = DateTime.Now;
@@ -284,10 +294,10 @@ namespace MySystem
                                 hdfee = decimal.Parse(hdfee.ToString("f2"));
                                 decimal servicefee = 0.01M * order.SettleAmount - hdfee;
                                 servicefee = decimal.Parse(servicefee.ToString("f2"));
-                                decimal amount = order.SettleAmount*(1-0.0038M) - servicefee;
+                                decimal amount = order.SettleAmount * (1 - 0.0038M) - servicefee;
                                 amount = decimal.Parse(amount.ToString("f2"));
                                 decimal otherAmt = divideAmt - servicefee - amount;
-                                if(otherAmt != 0)
+                                if (otherAmt != 0)
                                 {
                                     amount += otherAmt;
                                 }
@@ -335,7 +345,7 @@ namespace MySystem
                     {
                         //{"id":137403,"mchtNo":"1494637","tradeMchtNo":"030500107115593","channelMchtNo":"030500107115593","orderNo":"G2231123C02179895853","channelOrderNo":"50231123B00032642694","txSubCode":31,"paymentType":2,"status":0,"partStatus":0,"partAmount":0,"payAmount":1000,"payServiceFee":4,"settleAmount":996,"totalPerkAmount":0,"payTime":"2023-11-23 23:36:05","algoDate":"2023-11-23 00:00:00","bizDate":"2023-11-23 00:00:00","storeNo":"21627867","deviceSn":" ","cupsNo":"ylzf","cardType":0,"notPartAmount":996,"realAmount":996}
                         LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content, "监听支付结算订单");
-                        if(content.Contains("\"settleAmount\"") && content.Contains("\"txSubCode\":31,"))
+                        if (content.Contains("\"settleAmount\"") && content.Contains("\"txSubCode\":31,"))
                         {
                             LogHelper.Instance.WriteLog("符合条件", "监听支付结算订单");
                             JsonData jsonObj = JsonMapper.ToObject(content);
@@ -345,7 +355,7 @@ namespace MySystem
                             LogHelper.Instance.WriteLog("settleAmount:" + settleAmount, "监听支付结算订单");
                             WebCMSEntities db = new WebCMSEntities();
                             ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.SeoTitle == orderNo);
-                            if(order != null)
+                            if (order != null)
                             {
                                 order.SettleAmount = settleAmount;
                                 db.SaveChanges();

+ 1 - 0
appsettings.Development.json

@@ -22,6 +22,7 @@
     "OSSSecret": "Q6P2vSNEY2LBNdygO8gUCkBZQpiswZ",
     "OSSEndpoint": "oss-cn-hangzhou.aliyuncs.com",
     "OSSBucketName": "yunmuit",
+    "TencentKey":"GU3BZ-JYL6Q-ETG5Y-BGPXM-QFQV6-PZBLW",
     "AppSource": "/skin/app/default/",
     "JwtSecret": "JvDHuowbOnWiyxMIFc9gG5rw1LSSc0xx68L31oRfxS0",
     "JwtIss": "TpAdminServer",