Explorar o código

Merge branch 'DuGuYang' into feature-dgy-变更结算卡信息

# Conflicts:
#	Startup.cs
#	Util/HaoDa/TestHaoDaService.cs
DuGuYang hai 10 meses
pai
achega
4800694285
Modificáronse 48 ficheiros con 2592 adicións e 190 borrados
  1. 1 0
      Config/Base.cs
  2. 267 73
      Controllers/HomeController.cs
  3. 14 0
      Entity/AgentProfit.cs
  4. 1 0
      Entity/HaoDa/AddNewMerchant.cs
  5. 2 0
      Entity/SubUser.cs
  6. 19 0
      Models/Main/AgentLevels.cs
  7. 25 0
      Models/Main/AgentProfitRecord.cs
  8. 23 0
      Models/Main/AgentTradeStatSummary.cs
  9. 1 0
      Models/Main/ConsumerOrders.cs
  10. 1 0
      Models/Main/MerchantAddInfo.cs
  11. 7 0
      Models/Main/MerchantInfo.cs
  12. 21 0
      Models/Main/ProfitRecordForAgent.cs
  13. 287 0
      Models/Main/WebCMSEntities.cs
  14. 19 0
      Models/Main1/AgentLevels.cs
  15. 25 0
      Models/Main1/AgentProfitRecord.cs
  16. 23 0
      Models/Main1/AgentTradeStatSummary.cs
  17. 6 0
      Models/Main1/ConsumerOrders.cs
  18. 24 0
      Models/Main1/CustomQuery.cs
  19. 21 0
      Models/Main1/ExportExcels.cs
  20. 2 0
      Models/Main1/MerchantAddInfo.cs
  21. 29 0
      Models/Main1/MerchantDepositBack.cs
  22. 25 0
      Models/Main1/MerchantDepositOrder.cs
  23. 12 0
      Models/Main1/MerchantInfo.cs
  24. 34 0
      Models/Main1/MerchantParamSetRecord.cs
  25. 2 2
      Models/Main1/MerchantTradeSummary.cs
  26. 21 0
      Models/Main1/ProfitRecordForAgent.cs
  27. 23 0
      Models/Main1/SysWithdrawalApplyRecord.cs
  28. 19 0
      Models/Main1/UserAgent.cs
  29. 823 7
      Models/Main1/WebCMSEntities.cs
  30. 38 0
      Models/Tables/TmpOrder.cs
  31. 25 21
      Startup.cs
  32. 110 0
      Util/HaoDa/AgentProfitHelper.cs
  33. 16 11
      Util/HaoDa/AlipayFunctionForHD.cs
  34. 2 1
      Util/HaoDa/CheckWeChatSignService.cs
  35. 114 0
      Util/HaoDa/GetStoreNoHelper.cs
  36. 15 3
      Util/HaoDa/HaoDaExtQueryAuthHelper.cs
  37. 13 3
      Util/HaoDa/HaoDaExtQueryHelper.cs
  38. 9 1
      Util/HaoDa/HaoDaHelper.cs
  39. 69 0
      Util/HaoDa/ProfitCheckHelper.cs
  40. 179 24
      Util/HaoDa/ProfitHelper.cs
  41. 70 0
      Util/HaoDa/Tencent/GetTencentAddressInfoService.cs
  42. 15 18
      Util/HaoDa/TestHaoDaService.cs
  43. 15 8
      Util/HaoDa/WeChatFunctionForHD.cs
  44. 50 16
      Util/HaoDa/WeChatPayBackService.cs
  45. 53 0
      Util/PublicFunction.cs
  46. 15 2
      Util/RedisDbconn.cs
  47. 2 0
      appsettings.Development.json
  48. 5 0
      global.json

+ 1 - 0
Config/Base.cs

@@ -7,6 +7,7 @@ namespace AppConfig
     {
         public static string ApiKey = "G6H7@J8%";
         public static string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
+        public static string OssHost = Library.ConfigurationManager.AppSettings["OssHost"].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();

+ 267 - 73
Controllers/HomeController.cs

@@ -10,6 +10,8 @@ using LitJson;
 using System.Data;
 using MySystem.Models.Main;
 using System.Text.RegularExpressions;
+using Aop.Api.Domain;
+using MySystem.Models;
 
 namespace MySystem.Controllers
 {
@@ -27,7 +29,17 @@ namespace MySystem.Controllers
             return View();
         }
 
-        public string test(decimal a, decimal b, decimal g)
+        // public string test2(int id)
+        // {
+        //     WebCMSEntities db = new WebCMSEntities();
+        //     MerchantAddInfo AddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.Id == id) ?? new MerchantAddInfo();
+        //     AddInfo.MchtNo = "";
+        //     string result = HaoDaHelper.Instance.AddNewMerchant(AddNewMerchantSetUtil.SetValue(AddInfo));
+        //     db.Dispose();
+        //     return result;
+        // }
+
+        public string test()
         {
             // List<int> MerchantIds = new List<int>();
             // MerchantIds.Add(5);
@@ -39,71 +51,143 @@ namespace MySystem.Controllers
             // MqLinksHelper.Instance.doSomething("LKB01230600250000585","100");
 
             WebCMSEntities db = new WebCMSEntities();
+            DateTime start = DateTime.Parse("2024-03-10 00:00:00");
+            List<ConsumerOrders> orders = db.ConsumerOrders.Where(m => m.Status > 0 && m.IsAct == 1 && m.CreateDate > start && m.CurDivi < m.MaxDivi && m.SettleAmount > 0).OrderBy(m => m.Id).ToList();
+            foreach(ConsumerOrders order in orders)
+            {
+                bool check = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 10000).Any(m => m.Id == order.Id);
+                bool check1 = db.ConsumerProfit.Any(m => m.OrderId == order.Id);
+                if(!check && !check1)
+                {
+                    RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                    ConsumerOrders edit = db.ConsumerOrders.FirstOrDefault(m => m.Id == order.Id);
+                    if(edit != null)
+                    {
+                        edit.ReturnFlag = 1;
+                        db.SaveChanges();
+                    }
+                }
+                else
+                {
+                    if(!check)
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                        ConsumerOrders edit = db.ConsumerOrders.FirstOrDefault(m => m.Id == order.Id);
+                        if(edit != null)
+                        {
+                            edit.ReturnFlag = 1;
+                            db.SaveChanges();
+                        }
+                    }
+                    else if(!check1)
+                    {
+                        ConsumerOrders edit = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 10000).FirstOrDefault(m => m.Id == order.Id);
+                        long count = RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId,edit);
+                        if(count > 0)
+                        {
+                            RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                        }
+                    }
+                }
+                if(order.ReturnFlag == 0 && check && check1)
+                {
+                    ConsumerOrders edit = db.ConsumerOrders.FirstOrDefault(m => m.Id == order.Id);
+                    if(edit != null)
+                    {
+                        edit.ReturnFlag = 1;
+                        db.SaveChanges();
+                    }
+                }
+            }
+
             // Dictionary<string, decimal> ids = new Dictionary<string, decimal>();
-            // ids.Add("2023110100101889870873103", 165.01M);
-            // ids.Add("2023110823050361106411696", 162.39M);
-            // ids.Add("2023103111150680882895028", 129.97M);
-            // ids.Add("2023110115111893112798296", 186.66M);
-            // ids.Add("2023110119350047351848839", 219.15M);
-            // ids.Add("2023103121092345128864326", 132.51M);
-            // ids.Add("2023110119465569176817757", 219.16M);
-            // ids.Add("2023110119570851706448968", 219.16M);
-            // ids.Add("2023110119282078572281345", 208.32M);
-            // ids.Add("2023103111025117492478602", 151.62M);
-            // ids.Add("2023103111023104266492281", 129.96M);
-            // ids.Add("2023103111020866149098706", 140.79M);
-            // ids.Add("2023103111014803279616494", 162.45M);
-            // ids.Add("2023103111011872712858973", 173.28M);
+            // ids.Add("2023123120272680842405573", 30.08M);
             // foreach(string orderno in ids.Keys)
             // {
             //     decimal cur = ids[orderno];
             //     ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
             //     order.CurDivi = cur;
+            //     order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
+            //     order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":90,");
             //     RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
             // }
 
-            // DataTable dt = CustomerSqlConn.dtable("select o.OrderNo,money from (select fd61,sum(money) money from OrderAdd where reason='NULL' group by fd61 order by sum(money)) tb left join ConsumerOrders o on tb.fd61=o.SeoTitle", AppConfig.Base.SqlConnStr);
+            // string content = function.ReadInstance("/222.log");
+            // string[] contents = content.Split('\n');
+            // foreach(string sub in contents)
+            // {
+            //     // RedisDbconn.Instance.AddList("WeChatPayBackHd", sub);
+            //     RedisDbconn.Instance.AddList("PartOrderQueue", sub);
+            // }
+
+            // DataTable dt = CustomerSqlConn.dtable("select tb.Id,tb.PayMode,p.Id pId from (select Id,PayMode from ConsumerOrders where CreateDate>='2024-01-18 00:00:00' and `Status`>0) tb left join ConsumerProfit p on tb.Id=p.OrderId", AppConfig.Base.SqlConnStr);
+            // foreach(DataRow dr in dt.Rows)
+            // {
+            //     string Id = dr["Id"].ToString();
+            //     string PayMode = dr["PayMode"].ToString();
+            //     string pId = dr["pId"].ToString();
+            //     if(string.IsNullOrEmpty(pId))
+            //     {
+            //         RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + PayMode + ":List", Id);
+            //     }
+            // }
+
+            string str = "";
+            // str += "<table>";
+            // str += "<tr><td>订单号</td><td>下单时间</td><td>商家分红天数</td><td>当前分红金额</td><td>最大分红</td></tr>";
+            // List<int> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1940", 1, 10000).Select(m => m.Id).ToList();
+            // DataTable dt = CustomerSqlConn.dtable("select OrderId,sum(GetMoney) money from ConsumerProfit where MerchantId=1940 and CreateDate>='2023-12-01 00:00:00' group by OrderId order by OrderId", AppConfig.Base.SqlConnStr);
             // foreach(DataRow dr in dt.Rows)
             // {
             //     decimal cur = decimal.Parse(dr["money"].ToString());
-            //     string orderno = dr["OrderNo"].ToString();
-            //     ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
-            //     if(cur < order.MaxDivi)
+            //     int OrderId = int.Parse(dr["OrderId"].ToString());
+            //     if(!orders.Contains(OrderId))
             //     {
-            //         order.CurDivi = cur;
-            //         order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
-            //         RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
-            //         var list = db.ConsumerProfit.Where(m => m.OrderId == order.Id).OrderBy(m => m.Id).ToList();
-            //         foreach(var sub in list)
+            //         // string orderno = dr["OrderNo"].ToString();
+            //         ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId) ?? new ConsumerOrders();
+            //         if(order.MaxDivi - cur >= 1)
             //         {
-            //             if(cur >= sub.GetMoney)
-            //             {
-            //                 cur -= sub.GetMoney;
-            //             }
-            //             else
-            //             {
-            //                 if(cur > 0)
-            //                 {
-            //                     var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
-            //                     if(edit != null)
-            //                     {
-            //                         edit.GetMoney = cur;
-            //                         db.SaveChanges();
-            //                     }
-            //                 }
-            //                 else
-            //                 {
-            //                     var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
-            //                     if(edit != null)
-            //                     {
-            //                         db.ConsumerProfit.Remove(edit);
-            //                         db.SaveChanges();
-            //                     }
-            //                 }
-            //             }
+            //             order.CurDivi = cur;
+            //             MerchantParamSet set = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
+            //             order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
+            //             // order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":365,");
+            //             str += "<tr><td>" + order.OrderNo + "</td><td>" + order.UpdateDate.Value.ToString() + "</td><td>" + set.ProfitDays + "</td><td>" + cur + "</td><td>" + order.MaxDivi + "</td></tr>";
+            //             // RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+            //             // var list = db.ConsumerProfit.Where(m => m.OrderId == order.Id).OrderBy(m => m.Id).ToList();
+            //             // foreach(var sub in list)
+            //             // {
+            //             //     if(cur >= sub.GetMoney)
+            //             //     {
+            //             //         cur -= sub.GetMoney;
+            //             //     }
+            //             //     else
+            //             //     {
+            //             //         if(cur > 0)
+            //             //         {
+            //             //             var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
+            //             //             if(edit != null)
+            //             //             {
+            //             //                 edit.GetMoney = cur;
+            //             //                 db.SaveChanges();
+            //             //             }
+            //             //         }
+            //             //         else
+            //             //         {
+            //             //             var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
+            //             //             if(edit != null)
+            //             //             {
+            //             //                 db.ConsumerProfit.Remove(edit);
+            //             //                 db.SaveChanges();
+            //             //             }
+            //             //         }
+            //             //     }
+            //             // }
             //         }
             //     }
             // }
+            // str += "</table>";
+
+
 
             // List<int> ids = new List<int>();
             // ids.Add(4058);
@@ -144,6 +228,18 @@ namespace MySystem.Controllers
 
             db.Dispose();
 
+            // RedisDbconn.Instance.AddRightList("testlist", "1");
+            // RedisDbconn.Instance.AddRightList("testlist", "2");
+            // RedisDbconn.Instance.AddRightList("testlist", "3");
+            // RedisDbconn.Instance.AddRightList("testlist", "4");
+            // RedisDbconn.Instance.AddRightList("testlist", "5");
+            // RedisDbconn.Instance.AddRightList("testlist", "6");
+            // RedisDbconn.Instance.AddRightList("testlist", "7");
+            // RedisDbconn.Instance.AddRightList("testlist", "8");
+            // RedisDbconn.Instance.AddRightList("testlist", "9");
+
+            // str = RedisDbconn.Instance.RPopLPush<string>("testlist", "testlist"); 
+
             // decimal settleAmount = b / 100M;
             // decimal divideAmt = (1 - 0.0038M) * a;
             // divideAmt = decimal.Parse(divideAmt.ToString("f2"));
@@ -165,7 +261,46 @@ namespace MySystem.Controllers
             // string amountAmount = amount.ToString("f0");
 
             // return amountAmount + ":" + seviceAmount;
-            return "ok";
+
+            // List<int> ids = new List<int>();
+            // ids.Add(191);
+            // foreach(int id in ids)
+            // {
+            //     RedisDbconn.Instance.AddList("MerchantConfirmHdQueue", "{\"MerchantId\":\"" + id.ToString() + "\"}");
+            // }
+
+            // List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1940", 1, 10000);
+            // int index = orders.Count;
+            // foreach(ConsumerOrders order in orders)
+            // {
+            //     index -= 1;
+            //     // decimal persent = order.CurDivi / order.MaxDivi;
+            //     // if(order.CurDivi > order.MaxDivi)
+            //     // {
+            //         // RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+            //         order.MaxDivi = order.PayMoney * 0.8M;
+            //         RedisDbconn.Instance.SetList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, index, order);
+            //     // }
+            // }
+
+            // DataTable dt = CustomerSqlConn.dtable("select DISTINCT MerchantId,PayMode from ConsumerOrders where IsAct=1 and `Status`>0 and MerchantId!=1940 order by MerchantId,PayMode", AppConfig.Base.SqlConnStr);
+            // foreach(DataRow dr in dt.Rows)
+            // {
+            //     string PayMode = dr["PayMode"].ToString();
+            //     string MerchantId = dr["MerchantId"].ToString();
+            //     List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, 1, 10000);
+            //     foreach(ConsumerOrders order in orders)
+            //     {
+            //         decimal check = order.MaxDivi - order.CurDivi;
+            //         if(check < 0.01M)
+            //         {
+            //             function.WriteLog("MerchantId:" + order.MerchantId);
+            //             RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+            //         }
+            //     }
+            // }
+
+            return str;
         }
 
         public string bindapp(int mid)
@@ -181,37 +316,96 @@ namespace MySystem.Controllers
             //     });
             // }
 
-            Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
+            // Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
+            // WebCMSEntities db = new WebCMSEntities();
+            // MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
+            // MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
+            // string pwd = "417027";
+            // merchant.LoginPwd = function.MD532(pwd);
+            // Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
+            // if (info == null)
+            // {
+            //     info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
+            //     {
+            //         LoginMobile = merchantadd.MobilePhone,
+            //     }).Entity;
+            //     db1.SaveChanges();
+            // }
+            // info.LoginPwd = function.MD532(pwd);
+            // db1.SaveChanges();
+            // Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
+            // if (infolink == null)
+            // {
+            //     infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
+            //     {
+            //         LoginId = info.Id,
+            //         MerchantId = merchantadd.Id,
+            //         Kind = 2,
+            //     }).Entity;
+            //     db1.SaveChanges();
+            // }
+            // db1.Dispose();
+            // db.Dispose();
+
+            return "ok";
+        }
+    
+        
+        public string clearQueue(int OrderId, int MerchantId, int PayMode)
+        {
+            // List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId + "", 1, 100000);
+            // foreach(ConsumerOrders sub in list)
+            // {
+            //     if(sub.Id == OrderId)
+            //     {
+            //         RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:2:1272", sub);
+            //     }
+            // }
+            return "ok";
+        }
+    
+    
+        //补返现
+        public string back(string no)
+        {
             WebCMSEntities db = new WebCMSEntities();
-            MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
-            MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
-            string pwd = "417027";
-            merchant.LoginPwd = function.MD532(pwd);
-            Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
-            if (info == null)
+            ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
+            if(order != null)
             {
-                info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
+                List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId + "", 1, 100000);
+                ConsumerOrders check = list.FirstOrDefault(m => m.Id == order.Id);
+                bool op = db.ConsumerProfit.Any(m => m.OrderId == order.Id);
+                if(check == null)
                 {
-                    LoginMobile = merchantadd.MobilePhone,
-                }).Entity;
-                db1.SaveChanges();
+                    if(!op)
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                    }
+                    else
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                    }
+                }
+                db.Dispose();
             }
-            info.LoginPwd = function.MD532(pwd);
-            db1.SaveChanges();
-            Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
-            if (infolink == null)
+            return "ok";
+        }
+
+        public string goonback(int mid, int pm, string date)
+        {
+            DateTime start = DateTime.Parse(date + " 00:00:00");
+            DateTime end = start.AddDays(1);
+            WebCMSEntities db = new WebCMSEntities();
+            List<ConsumerOrders> queue = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + pm + ":" + mid + "", 1, 100000);
+            List<ConsumerOrders> list = db.ConsumerOrders.Where(m => m.MerchantId == mid && m.PayMode == pm && m.Status > 0 && m.IsAct == 1 && m.CreateDate >= start && m.CreateDate < end).ToList();
+            foreach(ConsumerOrders sub in list)
             {
-                infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
+                if(!queue.Any(m => m.Id == sub.Id) && sub.CurDivi < sub.MaxDivi)
                 {
-                    LoginId = info.Id,
-                    MerchantId = merchantadd.Id,
-                    Kind = 2,
-                }).Entity;
-                db1.SaveChanges();
+                    RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + pm + ":" + mid, sub);
+                }
             }
-            db1.Dispose();
             db.Dispose();
-
             return "ok";
         }
     }

+ 14 - 0
Entity/AgentProfit.cs

@@ -0,0 +1,14 @@
+using System;
+namespace MySystem
+{
+    public class AgentProfit
+    {
+        public int IsAct { get; set; }
+        public string ManageAreas { get; set; }
+        public int AgentLevel { get; set; }
+        public decimal TotalAmount { get; set; }
+        public decimal Percent { get; set; }
+        public decimal Profit { get; set; }
+        public decimal ProfitResult { get; set; }
+    }
+}

+ 1 - 0
Entity/HaoDa/AddNewMerchant.cs

@@ -39,6 +39,7 @@ namespace MySystem
         public string resserveMobile { get; set; }//银行预留手机号 channelkind为000001时必填
         public string userName { get; set; }//商户法人姓名
         public string periodValidity { get; set; }//法人身份证有效期 格式:20150101-20200101,若结束日期为长期填20150101-长期
+        // public string oprInvitedCode { get; set; }
         public List<ImageItem> images { get; set; }//图片
 
     }

+ 2 - 0
Entity/SubUser.cs

@@ -9,5 +9,7 @@ namespace MySystem
         public string ParentNav { get; set; }
         public int UserLevel { get; set; }
         public int PreUserLevel { get; set; }
+        public int PreLeaderLevel { get; set; }
+        public int PreOpLevel { get; set; }
     }
 }

+ 19 - 0
Models/Main/AgentLevels.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main
+{
+    public partial class AgentLevels
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string Name { get; set; }
+        public decimal Percent { get; set; }
+        public decimal UnActPercent { get; set; }
+        public string Operator { get; set; }
+    }
+}

+ 25 - 0
Models/Main/AgentProfitRecord.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main
+{
+    public partial class AgentProfitRecord
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string TradeMonth { get; set; }
+        public string Remark { get; set; }
+        public int CheckStatus { get; set; }
+        public decimal TradeProfit { get; set; }
+        public decimal CreditTradeAmt { get; set; }
+        public int ProfitType { get; set; }
+        public int UserId { get; set; }
+        public int ActFlag { get; set; }
+        public string Operator { get; set; }
+        public string OrderNo { get; set; }
+    }
+}

+ 23 - 0
Models/Main/AgentTradeStatSummary.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main
+{
+    public partial class AgentTradeStatSummary
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string ManageAreas { get; set; }
+        public int IsAct { get; set; }
+        public int TradeCount { get; set; }
+        public int PayMode { get; set; }
+        public decimal TotalAmount { get; set; }
+        public string TradeMonth { get; set; }
+        public string TradeDate { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 1 - 0
Models/Main/ConsumerOrders.cs

@@ -35,5 +35,6 @@ namespace MySystem.Models.Main
         public string TradePayNo { get; set; }
         public int SetRecordId { get; set; }
         public int SettleAmount { get; set; }
+        public ulong ReturnFlag { get; set; }
     }
 }

+ 1 - 0
Models/Main/MerchantAddInfo.cs

@@ -148,5 +148,6 @@ namespace MySystem.Models.Main
         public DateTime? HdPassDate { get; set; }
         public ulong HdBindWeChat { get; set; }
         public string MerchantType { get; set; }
+        public int PlaceType { get; set; }
     }
 }

+ 7 - 0
Models/Main/MerchantInfo.cs

@@ -48,5 +48,12 @@ namespace MySystem.Models.Main
         public int ExamineStatus { get; set; }
         public int Months { get; set; }
         public int IsAct { get; set; }
+        public DateTime? EndTime { get; set; }
+        public DateTime? StartTime { get; set; }
+        public string BusinessHours { get; set; }
+        public string BriefIntroduction { get; set; }
+        public int Popularity { get; set; }
+        public decimal Latitude { get; set; }
+        public decimal Longitude { get; set; }
     }
 }

+ 21 - 0
Models/Main/ProfitRecordForAgent.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main
+{
+    public partial class ProfitRecordForAgent
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string TradeMonth { get; set; }
+        public decimal TradeAmount { get; set; }
+        public string Remark { get; set; }
+        public int BrandId { get; set; }
+        public decimal ProfitAmount { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 287 - 0
Models/Main/WebCMSEntities.cs

@@ -24,6 +24,9 @@ namespace MySystem.Models.Main
         public virtual DbSet<ActivityRedPackageTop10> ActivityRedPackageTop10 { get; set; }
         public virtual DbSet<Advertisment> Advertisment { get; set; }
         public virtual DbSet<AgentLevelSet> AgentLevelSet { get; set; }
+        public virtual DbSet<AgentLevels> AgentLevels { get; set; }
+        public virtual DbSet<AgentProfitRecord> AgentProfitRecord { get; set; }
+        public virtual DbSet<AgentTradeStatSummary> AgentTradeStatSummary { get; set; }
         public virtual DbSet<AppBottomNavs> AppBottomNavs { get; set; }
         public virtual DbSet<AppVersion> AppVersion { get; set; }
         public virtual DbSet<AppVideo> AppVideo { get; set; }
@@ -170,6 +173,7 @@ namespace MySystem.Models.Main
         public virtual DbSet<ProfitReceiveRecord> ProfitReceiveRecord { get; set; }
         public virtual DbSet<ProfitReceives> ProfitReceives { get; set; }
         public virtual DbSet<ProfitRecord> ProfitRecord { get; set; }
+        public virtual DbSet<ProfitRecordForAgent> ProfitRecordForAgent { get; set; }
         public virtual DbSet<ProfitRewardExport> ProfitRewardExport { get; set; }
         public virtual DbSet<ProfitRewardRecord> ProfitRewardRecord { get; set; }
         public virtual DbSet<ProfitSubsidyDetail> ProfitSubsidyDetail { get; set; }
@@ -925,6 +929,193 @@ namespace MySystem.Models.Main
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<AgentLevels>(entity =>
+            {
+                entity.HasComment("区域代理等级");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.Name)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("名称")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Operator)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("操作人")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Percent)
+                    .HasColumnType("decimal(18,5)")
+                    .HasComment("分润比例");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.UnActPercent)
+                    .HasColumnType("decimal(18,5)")
+                    .HasComment("非活动分润比例");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
+            modelBuilder.Entity<AgentProfitRecord>(entity =>
+            {
+                entity.HasComment("区域代理等级");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.ActFlag)
+                    .HasColumnType("int(11)")
+                    .HasComment("交易类型");
+
+                entity.Property(e => e.CheckStatus)
+                    .HasColumnType("int(11)")
+                    .HasComment("验证和同步账户状态");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.CreditTradeAmt)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("贷记卡交易总金额");
+
+                entity.Property(e => e.Operator)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("操作人")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.OrderNo)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("订单号")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.ProfitType)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客分润类型");
+
+                entity.Property(e => e.Remark)
+                    .HasColumnType("varchar(64)")
+                    .HasComment("备注")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.TradeMonth)
+                    .HasColumnType("varchar(6)")
+                    .HasComment("交易月")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.TradeProfit)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("交易分润");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.UserId)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
+            modelBuilder.Entity<AgentTradeStatSummary>(entity =>
+            {
+                entity.HasComment("创客区域代理");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.IsAct)
+                    .HasColumnType("int(11)")
+                    .HasComment("是否活动");
+
+                entity.Property(e => e.ManageAreas)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("管辖区域")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.PayMode)
+                    .HasColumnType("int(11)")
+                    .HasComment("支付方式");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.TotalAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("订单总额");
+
+                entity.Property(e => e.TradeCount)
+                    .HasColumnType("int(11)")
+                    .HasComment("交易笔数");
+
+                entity.Property(e => e.TradeDate)
+                    .HasColumnType("varchar(8)")
+                    .HasComment("交易日")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.TradeMonth)
+                    .HasColumnType("varchar(6)")
+                    .HasComment("交易月")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.UserId)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
             modelBuilder.Entity<AppBottomNavs>(entity =>
             {
                 entity.Property(e => e.Id).HasColumnType("int(11)");
@@ -2295,6 +2486,11 @@ namespace MySystem.Models.Main
 
                 entity.Property(e => e.QueryCount).HasColumnType("int(11)");
 
+                entity.Property(e => e.ReturnFlag)
+                    .HasColumnType("bit(1)")
+                    .HasDefaultValueSql("b'0'")
+                    .HasComment("返现队列标记");
+
                 entity.Property(e => e.ReturnMoney).HasColumnType("decimal(18,2)");
 
                 entity.Property(e => e.SeoDescription)
@@ -5674,6 +5870,10 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.PlaceType)
+                    .HasColumnType("int(11)")
+                    .HasComment("场所类型");
+
                 entity.Property(e => e.ProductImg)
                     .HasColumnName("productImg")
                     .HasColumnType("varchar(200)")
@@ -6761,6 +6961,18 @@ namespace MySystem.Models.Main
 
                 entity.Property(e => e.BindStatus).HasColumnType("int(11)");
 
+                entity.Property(e => e.BriefIntroduction)
+                    .HasColumnType("longtext")
+                    .HasComment("简介")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.BusinessHours)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("营业时间段")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.CreateDate).HasColumnType("datetime");
 
                 entity.Property(e => e.CreateMan)
@@ -6768,6 +6980,10 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.EndTime)
+                    .HasColumnType("datetime")
+                    .HasComment("营业结束时间");
+
                 entity.Property(e => e.ExamineStatus)
                     .HasColumnType("int(11)")
                     .HasComment("服务费考核状态");
@@ -6784,6 +7000,10 @@ namespace MySystem.Models.Main
 
                 entity.Property(e => e.LastConsumeDate).HasColumnType("datetime");
 
+                entity.Property(e => e.Latitude)
+                    .HasColumnType("decimal(18,8)")
+                    .HasComment("纬度");
+
                 entity.Property(e => e.LoginPwd)
                     .HasColumnType("varchar(32)")
                     .HasCharSet("utf8")
@@ -6794,6 +7014,10 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.Longitude)
+                    .HasColumnType("decimal(18,8)")
+                    .HasComment("经度");
+
                 entity.Property(e => e.Mobile)
                     .HasColumnType("varchar(11)")
                     .HasCharSet("utf8")
@@ -6813,6 +7037,10 @@ namespace MySystem.Models.Main
                     .HasCharSet("utf8")
                     .HasCollation("utf8_general_ci");
 
+                entity.Property(e => e.Popularity)
+                    .HasColumnType("int(11)")
+                    .HasComment("人气值");
+
                 entity.Property(e => e.QueryCount).HasColumnType("int(11)");
 
                 entity.Property(e => e.SeoDescription)
@@ -6836,6 +7064,10 @@ namespace MySystem.Models.Main
 
                 entity.Property(e => e.Sort).HasColumnType("int(11)");
 
+                entity.Property(e => e.StartTime)
+                    .HasColumnType("datetime")
+                    .HasComment("营业开始时间");
+
                 entity.Property(e => e.Status).HasColumnType("int(11)");
 
                 entity.Property(e => e.TotalActActual).HasColumnType("decimal(18,2)");
@@ -11951,6 +12183,61 @@ namespace MySystem.Models.Main
                 entity.Property(e => e.Version).HasColumnType("int(11)");
             });
 
+            modelBuilder.Entity<ProfitRecordForAgent>(entity =>
+            {
+                entity.HasComment("区域代理分润记录");
+
+                entity.Property(e => e.Id).HasColumnType("int(11)");
+
+                entity.Property(e => e.BrandId)
+                    .HasColumnType("int(11)")
+                    .HasComment("品牌");
+
+                entity.Property(e => e.CreateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("创建时间");
+
+                entity.Property(e => e.ProfitAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("分润金额");
+
+                entity.Property(e => e.Remark)
+                    .HasColumnType("varchar(64)")
+                    .HasComment("备注")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.Sort)
+                    .HasColumnType("int(11)")
+                    .HasComment("排序序号");
+
+                entity.Property(e => e.Status)
+                    .HasColumnType("int(11)")
+                    .HasComment("状态");
+
+                entity.Property(e => e.TradeAmount)
+                    .HasColumnType("decimal(18,2)")
+                    .HasComment("交易额");
+
+                entity.Property(e => e.TradeMonth)
+                    .HasColumnType("varchar(6)")
+                    .HasComment("月份")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.UpdateDate)
+                    .HasColumnType("datetime")
+                    .HasComment("修改时间");
+
+                entity.Property(e => e.UserId)
+                    .HasColumnType("int(11)")
+                    .HasComment("创客");
+
+                entity.Property(e => e.Version)
+                    .HasColumnType("int(11)")
+                    .HasComment("版本号");
+            });
+
             modelBuilder.Entity<ProfitRewardExport>(entity =>
             {
                 entity.Property(e => e.Id).HasColumnType("int(11)");

+ 19 - 0
Models/Main1/AgentLevels.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class AgentLevels
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string Name { get; set; }
+        public decimal Percent { get; set; }
+        public decimal UnActPercent { get; set; }
+        public string Operator { get; set; }
+    }
+}

+ 25 - 0
Models/Main1/AgentProfitRecord.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class AgentProfitRecord
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string TradeMonth { get; set; }
+        public string Remark { get; set; }
+        public int CheckStatus { get; set; }
+        public decimal TradeProfit { get; set; }
+        public decimal CreditTradeAmt { get; set; }
+        public int ProfitType { get; set; }
+        public int UserId { get; set; }
+        public int ActFlag { get; set; }
+        public string Operator { get; set; }
+        public string OrderNo { get; set; }
+    }
+}

+ 23 - 0
Models/Main1/AgentTradeStatSummary.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class AgentTradeStatSummary
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string ManageAreas { get; set; }
+        public int IsAct { get; set; }
+        public int TradeCount { get; set; }
+        public int PayMode { get; set; }
+        public decimal TotalAmount { get; set; }
+        public string TradeMonth { get; set; }
+        public string TradeDate { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 6 - 0
Models/Main1/ConsumerOrders.cs

@@ -29,5 +29,11 @@ namespace MySystem.Models.Main1
         public ulong IsAct { get; set; }
         public int UserId { get; set; }
         public decimal MerchantActualAmount { get; set; }
+        public string DivideLog { get; set; }
+        public string TradePayNo { get; set; }
+        public int SetRecordId { get; set; }
+        public int DivideFlag { get; set; }
+        public DateTime? DivideDate { get; set; }
+        public ulong ReturnFlag { get; set; }
     }
 }

+ 24 - 0
Models/Main1/CustomQuery.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class CustomQuery
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string AdminNames { get; set; }
+        public string Title { get; set; }
+        public string SqlContent { get; set; }
+    }
+}

+ 21 - 0
Models/Main1/ExportExcels.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class ExportExcels
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string FileName { get; set; }
+        public int SysId { get; set; }
+        public string FileUrl { get; set; }
+    }
+}

+ 2 - 0
Models/Main1/MerchantAddInfo.cs

@@ -144,5 +144,7 @@ namespace MySystem.Models.Main1
         public string OutMchtNo { get; set; }
         public string AliMerchantId { get; set; }
         public string WeChatMerchantId { get; set; }
+        public string MerchantType { get; set; }
+        public int PlaceType { get; set; }
     }
 }

+ 29 - 0
Models/Main1/MerchantDepositBack.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class MerchantDepositBack
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string Remark { get; set; }
+        public int UserId { get; set; }
+        public string ApplyNo { get; set; }
+        public int ReturnWay { get; set; }
+        public decimal ReturnAmount { get; set; }
+        public string BankCardNo { get; set; }
+        public string AlipayAccountNo { get; set; }
+        public int MerchantId { get; set; }
+    }
+}

+ 25 - 0
Models/Main1/MerchantDepositOrder.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class MerchantDepositOrder
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string OrderNo { get; set; }
+        public decimal ActPayPrice { get; set; }
+        public int UserId { get; set; }
+        public int MerchantId { get; set; }
+    }
+}

+ 12 - 0
Models/Main1/MerchantInfo.cs

@@ -43,5 +43,17 @@ namespace MySystem.Models.Main1
         public int ActStat { get; set; }
         public DateTime? SignDate { get; set; }
         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 DateTime? EndTime { get; set; }
+        public DateTime? StartTime { get; set; }
+        public string BusinessHours { get; set; }
+        public string BriefIntroduction { get; set; }
+        public int Popularity { get; set; }
+        public decimal Latitude { get; set; }
+        public decimal Longitude { get; set; }
     }
 }

+ 34 - 0
Models/Main1/MerchantParamSetRecord.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class MerchantParamSetRecord
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public int AfterDiviPersons { get; set; }
+        public decimal AfterDiviPercent { get; set; }
+        public int AfterProfitDays { get; set; }
+        public decimal AfterGetPercent { get; set; }
+        public decimal AfterMinPayMoney { get; set; }
+        public int AfterIsAll { get; set; }
+        public int MerchantId { get; set; }
+        public int BeforeDiviPersons { get; set; }
+        public decimal BeforeDiviPercent { get; set; }
+        public int BeforeProfitDays { get; set; }
+        public decimal BeforeGetPercent { get; set; }
+        public decimal BeforeMinPayMoney { get; set; }
+        public int BeforeIsAll { get; set; }
+    }
+}

+ 2 - 2
Models/Main1/MerchantTradeSummary.cs

@@ -17,14 +17,14 @@ namespace MySystem.Models.Main1
         public string SeoTitle { get; set; }
         public string SeoKeyword { get; set; }
         public string SeoDescription { get; set; }
+        public decimal AliPayInFactAmount { get; set; }
+        public decimal WeChatInfactAmount { get; set; }
         public int OderCount { get; set; }
         public decimal InFactAmount { get; set; }
         public decimal TradeAmount { get; set; }
         public string TradeDate { get; set; }
         public string TradeMonth { get; set; }
         public int MerchantId { get; set; }
-        public decimal AliPayInFactAmount { get; set; }
-        public decimal WeChatInfactAmount { get; set; }
         public decimal ActAmount { get; set; }
         public decimal NonActAmount { get; set; }
     }

+ 21 - 0
Models/Main1/ProfitRecordForAgent.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class ProfitRecordForAgent
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string TradeMonth { get; set; }
+        public decimal TradeAmount { get; set; }
+        public string Remark { get; set; }
+        public int BrandId { get; set; }
+        public decimal ProfitAmount { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 23 - 0
Models/Main1/SysWithdrawalApplyRecord.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class SysWithdrawalApplyRecord
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string AccountNo { get; set; }
+        public string ApplyNo { get; set; }
+    }
+}

+ 19 - 0
Models/Main1/UserAgent.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models.Main1
+{
+    public partial class UserAgent
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public int AgentLevel { get; set; }
+        public string ManageAreas { get; set; }
+        public int UserId { get; set; }
+        public string Operator { get; set; }
+    }
+}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 823 - 7
Models/Main1/WebCMSEntities.cs


+ 38 - 0
Models/Tables/TmpOrder.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.Models
+{
+    public partial class TmpOrder
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public decimal CurDivi { get; set; }
+        public decimal MaxDivi { get; set; }
+        public string SnNo { get; set; }
+        public decimal ReturnMoney { get; set; }
+        public decimal PayMoney { get; set; }
+        public int PayMode { get; set; }
+        public string OrderNo { get; set; }
+        public int ConsumerId { get; set; }
+        public int MerchantId { get; set; }
+        public ulong IsAct { get; set; }
+        public int UserId { get; set; }
+        public decimal MerchantActualAmount { get; set; }
+        public string DivideLog { get; set; }
+        public string TradePayNo { get; set; }
+        public int SetRecordId { get; set; }
+        public int DivideFlag { get; set; }
+        public DateTime? DivideDate { get; set; }
+    }
+}

+ 25 - 21
Startup.cs

@@ -140,26 +140,30 @@ namespace MySystem
                 TestHaoDaService.Instance.Start(); //好哒测试
                 // MerchantStandardService.Instance.Start();
             }
-            // if(Library.ConfigurationManager.EnvironmentFlag == 2)
-            // {
-            //     MerchantConfirmService.Instance.Start(); //提交商户进件
-            //     CheckWeChatSignService.Instance.Start(); //查询商户审核状态
-            //     CheckWeChatBindService.Instance.Start(); //执行好哒微信绑定appid
-            //     ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现
-            //     HaoDaExtHelper.Instance.StartWeChat();
-            //     HaoDaExtHelper.Instance.StartAlipay();
-            //     HaoDaExtQueryHelper.Instance.StartWeChat();
-            //     HaoDaExtQueryHelper.Instance.StartAlipay();
-            //     HaoDaExtQueryAuthHelper.Instance.StartWeChat();
-            //     HaoDaExtQueryAuthHelper.Instance.StartAlipay();
-            //     HaoDaAuthQueryHelper.Instance.Start(); //查询实名认证状态
-            //     WeChatPayBackService.Instance.Start(); //支付回调
-            //     WeChatPayBackService.Instance.StartProfitShare(); //分账队列
-            //     WeChatPayBackService.Instance.StartSettleOrder(); //接收分账结算金额
-            //     WeChatPayBackService.Instance.StartDivi(); //补分账
-            //     ProfitHelper.Instance.StartListenTrade(); //返现队列-支付宝
-            //     ProfitHelper.Instance.StartListenWxTrade(); //返现队列-微信
-            //     ProfitHelper.Instance.StartListenProfit(); //每月分润
+            if(Library.ConfigurationManager.EnvironmentFlag == 2)
+            {
+                GetTencentAddressInfoService.Instance.Start(); // 获取腾讯地图地址
+                GetStoreNoHelper.Instance.Start(); //获取商户门店号、微信支付宝商户号
+                MerchantConfirmService.Instance.Start(); //提交商户进件
+                CheckWeChatSignService.Instance.Start(); //查询商户审核状态
+                CheckWeChatBindService.Instance.Start(); //执行好哒微信绑定appid
+                ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现
+                HaoDaExtHelper.Instance.StartWeChat();
+                HaoDaExtHelper.Instance.StartAlipay();
+                HaoDaExtQueryHelper.Instance.StartWeChat();
+                HaoDaExtQueryHelper.Instance.StartAlipay();
+                HaoDaExtQueryAuthHelper.Instance.StartWeChat();
+                HaoDaExtQueryAuthHelper.Instance.StartAlipay();
+                HaoDaAuthQueryHelper.Instance.Start(); //查询实名认证状态
+                WeChatPayBackService.Instance.Start(); //支付回调
+                WeChatPayBackService.Instance.StartProfitShare(); //分账队列
+                WeChatPayBackService.Instance.StartSettleOrder(); //接收分账结算金额
+                WeChatPayBackService.Instance.StartDivi(); //补分账
+                ProfitHelper.Instance.StartListenTrade(); //返现队列-支付宝
+                ProfitHelper.Instance.StartListenWxTrade(); //返现队列-微信
+                ProfitHelper.Instance.StartSetDivi(); //设置订单当前返现金额
+                ProfitHelper.Instance.StartListenProfit(); //每月分润
+                ProfitCheckHelper.Instance.Start(); //检查订单是否在队列里
 
             //     AlipayPayBackFeeService.Instance.Start();
             //     ActiveRewardService.Instance.StartAct();
@@ -170,7 +174,7 @@ namespace MySystem
             //     MerchantStandardService.Instance.Start(); //商户缴纳服务费次月活动交易额大于等于1W,奖励进件创客50元
             //     MerchantStandardService.Instance.StartThree(); //商户缴纳服务费次月起连续不间断三个月,每月活动交易额大于1W,奖励进件创客100元
             //     MerchantStandardService.Instance.StartActive();
-            // }
+            }
         }
 
         //初始化数据结构

+ 110 - 0
Util/HaoDa/AgentProfitHelper.cs

@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using Library;
+using LitJson;
+using System.Threading;
+using Microsoft.Extensions.Hosting;
+using System.Threading.Tasks;
+using MySystem.Models.Main;
+
+namespace MySystem
+{
+    public class AgentProfitHelper
+    {
+        public readonly static AgentProfitHelper Instance = new AgentProfitHelper();
+        private AgentProfitHelper()
+        {
+        }
+
+
+        public void StartListenProfit()
+        {
+            Thread th = new Thread(StartListenProfitDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListenProfitDo()
+        {
+            while(true)
+            {
+                if(DateTime.Now.Day < 10 && DateTime.Now.Hour > 2 && DateTime.Now.Hour < 23)
+                {
+                    try
+                    {
+                        DoProfit();
+                    }
+                    catch(Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧区域代理分润异常");
+                    }
+                    Thread.Sleep(600000);
+                }
+                else
+                {
+                    Thread.Sleep(3600000);
+                }
+            }
+        }
+
+        //分润算法
+        public void DoProfit()
+        {
+            string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
+            string check = function.ReadInstance("/AgentProfitFlag/" + TradeMonth + ".txt");
+            if(!string.IsNullOrEmpty(check))
+            {
+                return;
+            }
+            function.WritePage("/AgentProfitFlag/", TradeMonth + ".txt", DateTime.Now.ToString());
+            MySystem.Models.Main1.WebCMSEntities dbnew1 = new MySystem.Models.Main1.WebCMSEntities();
+            WebCMSEntities dbnew = new WebCMSEntities();
+            List<AgentProfit> ProfitList = new List<AgentProfit>();
+            DataTable dt = CustomerSqlConn.dtable("select IsAct,ManageAreas,AgentLevel,TotalAmount,(case when IsAct=1 then l.Percent else l.UnActPercent end) Percent,(case when IsAct=1 then l.Percent*TotalAmount else l.UnActPercent*TotalAmount end) Profit from (select IsAct,ManageAreas,(LENGTH(ManageAreas)-LENGTH(REPLACE(ManageAreas,',',''))+1) AgentLevel,sum(TotalAmount) TotalAmount from AgentTradeStatSummary where TradeMonth='" + TradeMonth + "' group by IsAct,ManageAreas) tb left join AgentLevels l on tb.AgentLevel=l.Id", AppConfig.Base.SqlConnStr);
+            foreach(DataRow dr in dt.Rows)
+            {
+                ProfitList.Add(new AgentProfit()
+                {
+                    IsAct = int.Parse(dr["IsAct"].ToString()),
+                    ManageAreas = dr["ManageAreas"].ToString(),
+                    AgentLevel = int.Parse(dr["IsAct"].ToString()),
+                    TotalAmount = decimal.Parse(dr["TotalAmount"].ToString()),
+                    Percent = decimal.Parse(dr["Percent"].ToString()),
+                    Profit = decimal.Parse(dr["Profit"].ToString()),
+                });
+            }
+            foreach(AgentProfit SubProfit in ProfitList)
+            {
+                int SubLevel = SubProfit.AgentLevel + 1;
+                decimal SubProfitAmt = 0;
+                if(ProfitList.Any(m => m.ManageAreas.StartsWith(SubProfit.ManageAreas) && m.AgentLevel == SubLevel && m.IsAct == SubProfit.IsAct))
+                {
+                    SubProfitAmt = ProfitList.Where(m => m.ManageAreas.StartsWith(SubProfit.ManageAreas) && m.AgentLevel == SubLevel && m.IsAct == SubProfit.IsAct).Sum(m => m.Profit);
+                }
+                if(SubProfitAmt > 0) SubProfit.ProfitResult -= SubProfitAmt;
+            }
+            foreach(AgentProfit SubProfit in ProfitList)
+            {
+                MySystem.Models.Main1.UserAgent user = dbnew1.UserAgent.FirstOrDefault(m => m.ManageAreas == SubProfit.ManageAreas);
+                if(user != null)
+                {
+                    dbnew.AgentProfitRecord.Add(new AgentProfitRecord()
+                    {
+                        CreateDate = DateTime.Now,
+                        UpdateDate = DateTime.Now,
+                        TradeMonth = TradeMonth,
+                        Remark = "来客吧区域代理奖励\n" + SubProfit.ManageAreas,
+                        TradeProfit = SubProfit.ProfitResult,
+                        CreditTradeAmt = SubProfit.TotalAmount,
+                        UserId = user.UserId,
+                    });
+                    dbnew.Dispose();
+                }
+            }
+            dbnew1.Dispose();
+            dbnew.Dispose();
+        }
+    }
+}

+ 16 - 11
Util/HaoDa/AlipayFunctionForHD.cs

@@ -35,12 +35,10 @@ namespace MySystem
             string identity_type = info.SubjectType;
             string store_address = info.BizStoreAddress;
             string merchant_type = "STORE";
-            if(!string.IsNullOrEmpty(info.MerchantType))
-            {
-                merchant_type = info.MerchantType;
-            }
-            if(merchant_type == "STALL")
+            var placeType = info.PlaceType; // 小微商户经营场所类型(0 固定场所 1 流动摊贩)
+            if (placeType == 1)
             {
+                merchant_type = "STALL";
                 store_address = "无";
             }
             if (identity_type == "SUBJECT_TYPE_ENTERPRISE") identity_type = "ENTERPRISE";
@@ -63,7 +61,7 @@ namespace MySystem
             if (info.SubjectType == "SUBJECT_TYPE_SMALL")
             {
                 info.LicenseCopy = info.IdCardCopy;
-                for(int i = 0; i < 9; i++)
+                for (int i = 0; i < 9; i++)
                 {
                     CertMerchantName = CertMerchantName.Replace(i.ToString(), "");
                 }
@@ -107,9 +105,15 @@ namespace MySystem
                     city_code = district_code.Substring(0, 4) + "00";
                     province_code = district_code.Substring(0, 2) + "0000";
                     string[] CityNames = cityItem.CityName.Split(',');
-                    district = CityNames[CityNames.Length - 3];
-                    city = CityNames[CityNames.Length - 2];
-                    province = CityNames[CityNames.Length - 1];
+                    province = CityNames[0];
+                    if (CityNames.Length >= 2)
+                    {
+                        city = CityNames[1];
+                    }
+                    if (CityNames.Length >= 3)
+                    {
+                        district = CityNames[2];
+                    }
                 }
                 BizContent += "    \"support_credentials\":{" +
                 "      \"merchant_type\":\"" + merchant_type + "\"," +
@@ -217,10 +221,11 @@ namespace MySystem
         {
             IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AppId, PrivateKey, "json", "1.0", "RSA2", AlipayPublicKey, "utf-8", false);
             string fileName = path.Substring(path.LastIndexOf("/") + 1);
-            string imageBase64 = function.imageToBase64String(function.getPath(path));
+            // string imageBase64 = function.imageToBase64String(function.getPath(path));
             // imageBase64 = imageBase64.Substring(imageBase64.IndexOf(";base64,") + 8);
             AntMerchantExpandIndirectImageUploadRequest request = new AntMerchantExpandIndirectImageUploadRequest();
-            FileItem imageContent = new FileItem(fileName, Convert.FromBase64String(imageBase64));
+            // FileItem imageContent = new FileItem(fileName, Convert.FromBase64String(imageBase64));
+            FileItem imageContent = PublicFunction.GetNetFileItem(AppConfig.Base.OssHost + path);
             request.ImageContent = imageContent;
             request.ImageType = "jpg";
             try

+ 2 - 1
Util/HaoDa/CheckWeChatSignService.cs

@@ -58,8 +58,9 @@ namespace MySystem
                         MerchantId = dr["Id"].ToString(),
                         MerchantNo = dr["MchtNo"].ToString(),
                     });
+                    Thread.Sleep(10000);
                 }
-                Thread.Sleep(120000);
+                Thread.Sleep(3600000);
             }
         }
 

+ 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
+    }
+}

+ 15 - 3
Util/HaoDa/HaoDaExtQueryAuthHelper.cs

@@ -40,9 +40,10 @@ 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);
             }
             Thread.Sleep(120000);
         }
@@ -59,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")
                 {
@@ -67,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("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                    }
                     db.SaveChanges();
                     LogHelper.Instance.WriteLog("startsend", "获取微信商户开户意愿确认状态");
                 }
@@ -109,9 +115,10 @@ 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);
             }
             Thread.Sleep(120000);
         }
@@ -141,6 +148,11 @@ public class HaoDaExtQueryAuthHelper
                     merchant.QueryCount = 2;
                     db.SaveChanges();
                     LogHelper.Instance.WriteLog("start1end", "获取支付宝商家认证状态");
+                    if (merchant.Latitude == 0)
+                    {
+                        //签约成功调用腾讯地图接口获取地址
+                        RedisDbconn.Instance.AddList("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"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("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"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("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                    }
                     db.SaveChanges();
                 }
                 // else

+ 9 - 1
Util/HaoDa/HaoDaHelper.cs

@@ -38,6 +38,12 @@ namespace MySystem
         string BoxPublicKey = "";
         public static string BrhCode = "030145";
 
+        // string BoxRequestUrl = "https://openapi.iboxpay.com";
+        // string BoxAppId = "AP8322645764893728768";
+        // string BoxAppSecret = "je1TElprp3jzWETsG3FcWqtmpreEHqZS";
+        // string BoxPublicKey = "";
+        // public static string BrhCode = "";
+
 
         /// <summary>
         /// 新创建商户
@@ -47,6 +53,7 @@ namespace MySystem
         public string AddNewMerchant(AddNewMerchant request)
         {
             request.brh = BrhCode;
+            // request.oprInvitedCode = "T1715836";
             LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒新创建商户");
 
             string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
@@ -866,7 +873,8 @@ namespace MySystem
             {
                 return "";
             }
-            FileItem item = new FileItem(function.getPath(value.Split(',')[0]));
+            FileItem item = PublicFunction.GetNetFileItem(AppConfig.Base.OssHost + value.Split(',')[0]);
+            // FileItem item = new FileItem(function.getPath(value.Split(',')[0]));
             Dictionary<string, FileItem> files = new Dictionary<string, FileItem>();
             files.Add("file", item);
             var upLoadInfo = JsonMapper.ToObject(HaoDaHelper.Instance.DoPost(BoxRequestUrl + "/api/file/v1/upload_file", token, file, files, "utf-8"));

+ 69 - 0
Util/HaoDa/ProfitCheckHelper.cs

@@ -0,0 +1,69 @@
+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;
+
+namespace MySystem
+{
+    public class ProfitCheckHelper
+    {
+        public readonly static ProfitCheckHelper Instance = new ProfitCheckHelper();
+        private ProfitCheckHelper()
+        {
+        }
+
+        #region 检查订单是否在队列里
+        public void Start()
+        {
+            Thread th = new Thread(StartDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartDo()
+        {
+            while (true)
+            {
+                string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerProfitCheck");
+                if (!string.IsNullOrEmpty(orderidstring))
+                {
+                    DoSomeThing(orderidstring);
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
+        public void DoSomeThing(string orderidstring)
+        { 
+            try
+            {
+                int orderId = int.Parse(function.CheckInt(orderidstring));
+                WebCMSEntities db = new WebCMSEntities();
+                ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == orderId);
+                if(order != null)
+                {
+                    var list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId);
+                    if(!list.Any(m => m.Id == orderId) && !db.ConsumerProfit.Any(m => m.OrderId == orderId))
+                    {
+                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                    }
+                }
+                db.Dispose();
+            }
+            catch(Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "检查订单是否在队列里异常");
+            }
+        }
+        #endregion
+    }
+}

+ 179 - 24
Util/HaoDa/ProfitHelper.cs

@@ -7,6 +7,8 @@ using Library;
 using System.Threading;
 using Microsoft.Extensions.Hosting;
 using System.Threading.Tasks;
+using LitJson;
+using MySystem.Models;
 
 namespace MySystem
 {
@@ -107,9 +109,14 @@ namespace MySystem
                                 {
                                     function.WriteLog("返现队列开始", "返现逻辑日志");
                                     RedisDbconn.Instance.AddRightList("ConsumerOrdersHd:Divi:" + PayMode + ":" + order.MerchantId, order);
+                                    order.ReturnFlag = 1;
+                                    db.SaveChanges();
                                     DiviMoney = DiviMoney / DiviPersons;
+                                    DiviMoney = PublicFunction.NumberFormat(DiviMoney);
                                     List<int> deletes = new List<int>();
                                     long CurDiviPersons = DiviPersons;
+                                    int DiviTimes = 0;
+                                    int CheckTime = 0;
                                     long QueueCount = RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
                                     long CurQueueCount = QueueCount;
                                     if (CurDiviPersons >= CurQueueCount)
@@ -122,19 +129,19 @@ namespace MySystem
                                     }
 
                                     // 减去自己付的订单
-                                    int OutCount = 0; // 出局人数
                                     List<int> orderids = new List<int>();
                                     function.WriteLog("人数:" + CurDiviPersons, "返现逻辑日志");
                                     while (CurDiviPersons > 0)
                                     {
-                                        ConsumerOrders suborder = RedisDbconn.Instance.RPop<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
+                                        ConsumerOrders suborder = RedisDbconn.Instance.RPopLPush<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, "ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId);
                                         if (suborder != null)
                                         {
+                                            decimal TmpCurDivi = suborder.CurDivi;
                                             function.WriteLog("返现对象订单:" + suborder.Id, "返现逻辑日志");
-                                            MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
+                                            MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(suborder.SeoDescription);
                                             int subProfitDays = subset.ProfitDays; //分红期限(天)
                                             bool IsOut = suborder.UpdateDate.Value.AddDays(subProfitDays) < DateTime.Now ? true : false;
-                                            if (suborder.CurDivi < suborder.MaxDivi && !IsOut)
+                                            if (suborder.CurDivi < suborder.MaxDivi && suborder.MaxDivi - suborder.CurDivi >= 0.01M && !IsOut)
                                             {
                                                 function.WriteLog("没出局:" + suborder.CurDivi + "--" + suborder.MaxDivi, "返现逻辑日志");
                                                 //如果没过期并且当前退款金额没超过最大退款金额,就执行
@@ -146,17 +153,50 @@ namespace MySystem
                                                 function.WriteLog("GetMoney:" + GetMoney, "返现逻辑日志");
                                                 if (GetMoney > minProfit)
                                                 {
-                                                    suborder.CurDivi += GetMoney;
                                                     MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == suborder.MerchantId) ?? new MerchantAddInfo();
                                                     
                                                     //聚合支付退款
+                                                    bool BackStatus = false;
+
+                                                    //拆单算法
+                                                    string MerchantList = function.CheckNull(RedisDbconn.Instance.Get<string>("SplitOrderMerchants"));
+                                                    string SplitOrderStatus = function.CheckNull(RedisDbconn.Instance.Get<string>("SplitOrderStatus"));
+                                                    if(MerchantList.Contains("," + suborder.MerchantId + ",") || SplitOrderStatus == "1")
+                                                    {
+                                                        CheckTime = SplitOrder(suborder.PayMoney,subset.MinPayMoney);
+                                                        function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
+                                                        if(CheckTime > 0)
+                                                        {
+                                                            if(set.DiviPersons - DiviTimes < CheckTime)
+                                                            {
+                                                                CheckTime = set.DiviPersons - DiviTimes;
+                                                            }
+                                                            function.WriteLog("CheckTime:" + CheckTime, "返现逻辑日志");
+                                                            GetMoney = GetMoney * CheckTime;
+                                                            db.SaveChanges();
+                                                            function.WriteLog("CurDiviPersons1:" + CurDiviPersons, "返现逻辑日志");
+                                                            if(RedisDbconn.Instance.Count("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId) >= set.DiviPersons)
+                                                            {
+                                                                CurDiviPersons -= CheckTime - 1;
+                                                            }
+                                                            function.WriteLog("CurDiviPersons2:" + CurDiviPersons, "返现逻辑日志");
+                                                            decimal CheckMoney = suborder.MaxDivi - suborder.CurDivi;
+                                                            if (GetMoney >= CheckMoney)
+                                                            {
+                                                                GetMoney = CheckMoney;
+                                                            }
+                                                        }
+                                                    }
+                                                    suborder.CurDivi += GetMoney;
+
                                                     decimal RefundAmount = GetMoney * 100;
-                                                    RefundAmount = Math.Round(RefundAmount, 2);
-                                                    if(!orderids.Contains(suborder.Id))
+                                                    RefundAmount = PublicFunction.NumberFormat(RefundAmount, 0);
+                                                    if(!orderids.Contains(suborder.Id) && DiviTimes < set.DiviPersons)
                                                     {
                                                         function.WriteLog("请求退款接口", "返现逻辑日志");
-                                                        var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, "HDTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), suborder.OrderNo, RefundAmount.ToString("f0"));
-                                                        if(info.Contains("\"resultCode\":\"1\""))
+                                                        string RefundNo = "HDTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+                                                        var info = HaoDaHelper.Instance.AggregatedPayRefund(merchantAdd.OutMchtNo, merchantAdd.StoreNo, RefundNo, suborder.OrderNo, RefundAmount.ToString("f0"));
+                                                        if(info.Contains("\"resultCode\":\"1\"") && info.Contains("\"tradeStatus\":\"2\""))
                                                         {
                                                             db.ConsumerProfit.Add(new ConsumerProfit()
                                                             {
@@ -169,25 +209,42 @@ namespace MySystem
                                                                 Sort = OrderId,
                                                                 SeoTitle = suborder.OrderNo,
                                                                 SeoKeyword = suborder.PayMoney.ToString(),
+                                                                SeoDescription = RefundNo,
                                                             });
                                                             db.SaveChanges();
+                                                            BackStatus = true;
                                                         }
                                                         function.WriteLog("接口返回:" + info, "返现逻辑日志");
                                                         orderids.Add(suborder.Id);
+                                                        DiviTimes += CheckTime;
                                                     }
 
-                                                    merchant.ActCurrentAmount += Math.Round(GetMoney, 2); //活动已返金额
-                                                    db.SaveChanges();
-                                                    function.WriteLog(suborder.CurDivi + ":" + suborder.MaxDivi, "返现逻辑日志");
-                                                    if (suborder.CurDivi < suborder.MaxDivi)
-                                                    {
-                                                        function.WriteLog("返现未达最大值继续", "返现逻辑日志");
-                                                        RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
-                                                    }
-                                                    else
+                                                    if(BackStatus)
                                                     {
-                                                        function.WriteLog("返现达最大值,出局", "返现逻辑日志");
-                                                        OutCount += 1;
+                                                        merchant.ActCurrentAmount += Math.Round(GetMoney, 2); //活动已返金额
+                                                        db.SaveChanges();
+                                                        function.WriteLog(suborder.CurDivi + ":" + suborder.MaxDivi, "返现逻辑日志");
+                                                        if (suborder.CurDivi < suborder.MaxDivi)
+                                                        {
+                                                            function.WriteLog("返现未达最大值继续", "返现逻辑日志");
+                                                            // RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
+                                                            RedisDbconn.Instance.SetList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, 0, suborder);
+                                                            RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.CurDivi + "\"}");
+                                                        }
+                                                        else
+                                                        {
+                                                            suborder.CurDivi = TmpCurDivi;
+                                                            function.WriteLog("返现达最大值,出局", "返现逻辑日志");
+                                                            ConsumerOrders editOrder = db.ConsumerOrders.FirstOrDefault(m => m.Id == suborder.Id);
+                                                            if (editOrder != null)
+                                                            {
+                                                                editOrder.ReturnFlag = 0;
+                                                                db.SaveChanges();
+                                                                RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
+                                                            }
+                                                            function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
+                                                            RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
+                                                        }
                                                     }
                                                     Thread.Sleep(1000);
                                                 }
@@ -195,6 +252,17 @@ namespace MySystem
                                             else
                                             {
                                                 //否者计算人数不计入退款名额
+                                                suborder.CurDivi = TmpCurDivi;
+                                                function.WriteLog("返现达最大值,出局", "返现逻辑日志");
+                                                ConsumerOrders editOrder = db.ConsumerOrders.FirstOrDefault(m => m.Id == suborder.Id);
+                                                if (editOrder != null)
+                                                {
+                                                    editOrder.ReturnFlag = 0;
+                                                    db.SaveChanges();
+                                                    RedisDbconn.Instance.AddList("ConsumerOrdersSetDiviHd", "{\"OrderId\":\"" + suborder.Id + "\",\"DiviAmt\":\"" + suborder.MaxDivi + "\"}");
+                                                }
+                                                function.WriteLog("删除队列数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(suborder), "返现逻辑日志");
+                                                RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId, suborder);
                                                 CurDiviPersons += 1;
                                                 function.WriteLog("出局:CurDiviPersons:" + CurDiviPersons, "返现逻辑日志");
                                             }
@@ -212,17 +280,39 @@ namespace MySystem
                             }
                         }
                     }
+                    else
+                    {
+                        function.WriteLog("没找到订单:" + orderidstring, "返现逻辑日志");
+                        // Thread.Sleep(2000);
+                        // List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId + "", 1, 100000);
+                        // ConsumerOrders check = list.FirstOrDefault(m => m.Id == order.Id);
+                        // bool op = db.ConsumerProfit.Any(m => m.OrderId == order.Id);
+                        // if(check == null && !op)
+                        // {
+                        //     RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                        // }
+                    }
                     tran.Commit();
                 }
                 catch (Exception ex)
                 {
-                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "自定义分润程序监听队列异常");
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "分红返现异常");
                     tran.Rollback();
+                    RedisDbconn.Instance.AddList("ConsumerProfitCheck", orderidstring);
                 }
             }
             db.Dispose();            
             function.WriteLog("结束返现:" + orderidstring + "\n\n\n", "返现逻辑日志");
         }
+
+        //拆单算法
+        private int SplitOrder(decimal OrderAmt, decimal MinMoney)
+        {
+            decimal percenter = OrderAmt/MinMoney;
+            int Times = int.Parse(percenter.ToString().Split('.')[0]);
+            if(Times < 1) Times = 1;
+            return Times;
+        }
         #endregion
 
 
@@ -242,9 +332,16 @@ namespace MySystem
         {
             while(true)
             {
-                if(DateTime.Now.Day < 10 && DateTime.Now.Hour > 2 && DateTime.Now.Hour < 5)
+                if(DateTime.Now.Day < 10 && DateTime.Now.Hour > 2 && DateTime.Now.Hour < 23)
                 {
-                    DoProfit();
+                    try
+                    {
+                        DoProfit();
+                    }
+                    catch(Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧分润异常");
+                    }
                     Thread.Sleep(600000);
                 }
                 else
@@ -405,7 +502,7 @@ namespace MySystem
                         user = users[curFloor - 1];
                     }
                     SubUser selfUser = GetUser(user.UserId, Month) ?? new SubUser();
-                    int UserLevel = selfUser.PreUserLevel > selfUser.UserLevel ? selfUser.PreUserLevel : selfUser.UserLevel; //当前会员等级
+                    int UserLevel = GetUserLevel(selfUser); //当前会员等级
                     //判断当前创客是否有直推的激活机具,并且在活动时间内
                     if (curLevel == maxLevel)
                     {
@@ -471,15 +568,73 @@ namespace MySystem
                 user.ParentNav = dt.Rows[0]["ParentNav"].ToString();
                 user.UserLevel = int.Parse(dt.Rows[0]["UserLevel"].ToString());
                 user.PreUserLevel = int.Parse(dt.Rows[0]["PreUserLevel"].ToString());
+                user.PreLeaderLevel = int.Parse(dt.Rows[0]["PreLeaderLevel"].ToString());
+                user.PreOpLevel = int.Parse(dt.Rows[0]["PreOpLevel"].ToString());
             }
             return user;
         }
 
+        public int GetUserLevel(SubUser user)
+        {
+            int level = user.UserLevel;
+            if(user.PreUserLevel > level) level = user.PreUserLevel;
+            if(user.PreLeaderLevel > level) level = user.PreLeaderLevel;
+            if(user.PreOpLevel > level) level = user.PreOpLevel;
+            return level;
+        }
+
         public DataTable GetDataTable(string sqlstr)
         {
             DataTable dt = CustomerSqlConn.dtable(sqlstr, Library.ConfigurationManager.AppSettings["KxsStatSqlConnStr"].ToString());
             return dt;
         }
         #endregion
+
+
+
+
+        public void StartSetDivi()
+        {
+            Thread th = new Thread(StartSetDiviDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartSetDiviDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("ConsumerOrdersSetDiviHd");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    SetDivi(content);
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        public void SetDivi(string content)
+        { 
+            try
+            {
+                JsonData jsonObj = JsonMapper.ToObject(content);
+                int orderId = int.Parse(function.CheckInt(jsonObj["OrderId"].ToString()));
+                decimal diviAmt = decimal.Parse(function.CheckNum(jsonObj["DiviAmt"].ToString()));
+                WebCMSEntities db = new WebCMSEntities();
+                ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == orderId);
+                if(order != null)
+                {
+                    order.CurDivi = diviAmt;
+                    db.SaveChanges();
+                }
+                db.Dispose();
+            }
+            catch(Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置订单当前返现金额异常");
+            }
+        }
     }
 }

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

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using Library;
+using LitJson;
+using MySystem.Models.Main;
+
+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)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("GetTencentAddressInfoQueueHd");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    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(), "获取腾讯地图地址线程异常");
+                    }
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+    }
+}

+ 15 - 18
Util/HaoDa/TestHaoDaService.cs

@@ -47,7 +47,7 @@ namespace MySystem
 
             // HaoDaHelper.Instance.OrderDivideAccountsQuery("FZ2023110315225748140470708", "1492500"); //查询分账结果
             // WebCMSEntities db = new WebCMSEntities();
-            
+
             // List<int> ids = new List<int>();
             // foreach(int id in ids)
             // {
@@ -176,7 +176,7 @@ namespace MySystem
                             int Status = 2;
                             MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
                             MerchantParamSet set = db.MerchantParamSet.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantParamSet();
-                            
+
                             MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
                             //发起分账
                             string applyNo = "FZ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8); //批次号
@@ -187,7 +187,7 @@ namespace MySystem
                             string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
                             decimal amount = order.PayMoney * (1M - 0.0038M) * 100;
                             string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amount.ToString().Split('.')[0], "0"));
-                            if(result.Contains("\"resultCode\":\"0\"") && result.Contains("分账金额不足"))
+                            if (result.Contains("\"resultCode\":\"0\"") && result.Contains("分账金额不足"))
                             {
                                 Status = 1;
                             }
@@ -314,6 +314,11 @@ namespace MySystem
                         merchant.QueryCount = 2;
                         info.AlipayRemark = "";
                         LogHelper.Instance.WriteLog("start2end", "查询支付宝商户意愿申请状态");
+                        if (merchant.Latitude == 0)
+                        {
+                            //签约成功调用腾讯地图接口获取地址
+                            RedisDbconn.Instance.AddList("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        }
                         db.SaveChanges();
                     }
                     // else
@@ -390,7 +395,7 @@ namespace MySystem
                 WebCMSEntities db = new WebCMSEntities();
                 MerchantAddInfo info = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
                 string result = WeChatFunctionForHD.Instance.QueryMerchant(ApplymentId);
-                
+
                 Dictionary<string, object> reqdic = new Dictionary<string, object>();
                 reqdic.Add("Id", Id); // 商户Id
                 reqdic.Add("ApplymentId", ApplymentId); // 商户Id
@@ -598,14 +603,6 @@ namespace MySystem
             // JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, Infos["data"]["taskId"].ToString()));
             JsonData results = JsonMapper.ToObject(HaoDaHelper.Instance.QueryChangeCardStatus(AddInfo.MchtNo, "16592654"));
         }
-    
-    
-    
-    
-    
-    
-    
-    
         public void refund()
         {
             Thread th = new Thread(refunddo);
@@ -614,23 +611,23 @@ namespace MySystem
         }
         public void refunddo()
         {
-            for(int month = 10; month <= 11; month ++)
+            for (int month = 10; month <= 11; month++)
             {
-                for(int day = 1; day <= 31; day ++)
+                for (int day = 1; day <= 31; day++)
                 {
                     string content = function.ReadInstance("/log/好哒聚合支付退款/2023/" + month + "/" + day + "/content.log");
-                    if(!string.IsNullOrEmpty(content))
+                    if (!string.IsNullOrEmpty(content))
                     {
                         content = content.Replace("\n\n\n", "####");
                         content = content.Replace("\n", "");
                         content = content.Replace("####", "\n");
                         MatchCollection mc = Regex.Matches(content, "请求参数.*?退款次数超出限制");
-                        foreach(Match m in mc)
+                        foreach (Match m in mc)
                         {
                             string mchtNo = Regex.Match(m.Value, "\"mchtNo\":\".*?\"").Value.Replace("\"mchtNo\":\"", "").Replace("\"", "");
                             string storeNo = Regex.Match(m.Value, "\"storeNo\":\".*?\"").Value.Replace("\"storeNo\":\"", "").Replace("\"", "");
                             string outOrderNo = Regex.Match(m.Value, "\"outOrderNo\":\".*?\"").Value.Replace("\"outOrderNo\":\"", "").Replace("\"", "");
-                            string refundAmount = Regex.Match(m.Value, "\"refundAmount\":\".*?\"").Value.Replace("\"refundAmount\":\"", "").Replace("\"", "");                
+                            string refundAmount = Regex.Match(m.Value, "\"refundAmount\":\".*?\"").Value.Replace("\"refundAmount\":\"", "").Replace("\"", "");
                             function.WriteLog("mchtNo:" + mchtNo + ";storeNo:" + storeNo + ";outOrderNo:" + outOrderNo + ";refundAmount:" + refundAmount + ";", "补充退款日志");
                             var info = HaoDaHelper.Instance.AggregatedPayRefund(mchtNo, storeNo, "HDTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), outOrderNo, refundAmount);
                             function.WriteLog(info + "\n\n", "补充退款日志");
@@ -640,6 +637,6 @@ namespace MySystem
                 }
             }
         }
-    
+
     }
 }

+ 15 - 8
Util/HaoDa/WeChatFunctionForHD.cs

@@ -40,7 +40,7 @@ namespace MySystem
         {
             Dictionary<string, object> result = new Dictionary<string, object>();
             string business_code = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-            if(!string.IsNullOrEmpty(info.WeChatMerchantId))
+            if (!string.IsNullOrEmpty(info.WeChatMerchantId))
             {
                 result.Add("channel_id", info.WeChatMerchantId); //渠道商户号
             }
@@ -68,7 +68,7 @@ namespace MySystem
             if (info.SubjectType == "SUBJECT_TYPE_SMALL")
             {
                 info.LicenseCopy = info.IdCardCopy;
-                for(int i = 0; i < 9; i++)
+                for (int i = 0; i < 9; i++)
                 {
                     CertMerchantName = CertMerchantName.Replace(i.ToString(), "");
                 }
@@ -95,7 +95,13 @@ namespace MySystem
             if (info.SubjectType == "SUBJECT_TYPE_SMALL")
             {
                 Dictionary<string, object> assist_prove_info = new Dictionary<string, object>();
-                assist_prove_info.Add("micro_biz_type", "MICRO_TYPE_STORE"); //小微经营类型
+                string micro_biz_type = "MICRO_TYPE_STORE";
+                var placeType = info.PlaceType; // 小微商户经营场所类型(0 固定场所-MICRO_TYPE_STORE 1 流动摊贩-MICRO_TYPE_MOBILE)
+                if (placeType == 1)
+                {
+                    micro_biz_type = "MICRO_TYPE_MOBILE";
+                }
+                assist_prove_info.Add("micro_biz_type", micro_biz_type); //小微经营类型
                 assist_prove_info.Add("store_name", info.BizStoreName); //门店名称
                 assist_prove_info.Add("store_address_code", info.AreaNo); //门店省市编码
                 assist_prove_info.Add("store_address", info.BizStoreAddress); //门店地址
@@ -103,7 +109,7 @@ namespace MySystem
                 assist_prove_info.Add("store_indoor_copy", GetMediaId("/" + info.IndoorPic)); //店内环境照片
                 subject_info.Add("assist_prove_info", assist_prove_info); //辅助证明材料信息
             }
-            
+
             result.Add("subject_info", subject_info);
 
             Dictionary<string, object> identification_info = new Dictionary<string, object>();
@@ -350,10 +356,11 @@ namespace MySystem
             }
             string filePath = function.getPath(imgPath);
             var filename = Path.GetFileName(filePath);
-            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
-            Byte[] imgBytesIn = new Byte[fs.Length];
-            fs.Read(imgBytesIn, 0, imgBytesIn.Length);
-            fs.Close();
+            // FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
+            // Byte[] imgBytesIn = new Byte[fs.Length];
+            // fs.Read(imgBytesIn, 0, imgBytesIn.Length);
+            // fs.Close();
+            byte[] imgBytesIn = PublicFunction.GetNetFileData(AppConfig.Base.OssHost + imgPath);
 
             byte[] hash = SHA256Managed.Create().ComputeHash(imgBytesIn);
 

+ 50 - 16
Util/HaoDa/WeChatPayBackService.cs

@@ -51,41 +51,59 @@ namespace MySystem
 
         public void dosomething(string content)
         {
+            LogHelper.Instance.WriteLog("\n\n" + DateTime.Now.ToString() + "\n" + content, "微信支付回调监控");
             JsonData jsonObj = JsonMapper.ToObject(content);
             if (jsonObj.Count > 0)
             {
+                LogHelper.Instance.WriteLog("json通过", "微信支付回调监控");
                 string OrderNo = jsonObj["outOrderNo"].ToString();
                 string HdOrderNo = jsonObj["orderNo"].ToString();
                 string TradeNo = "";
-                if(content.Contains("\"payChannelOrderNo\""))
+                if (content.Contains("\"payChannelOrderNo\""))
                 {
                     TradeNo = jsonObj["payChannelOrderNo"].ToString();
                 }
+                LogHelper.Instance.WriteLog("OrderNo:" + OrderNo, "微信支付回调监控");
+                LogHelper.Instance.WriteLog("HdOrderNo:" + HdOrderNo, "微信支付回调监控");
+                LogHelper.Instance.WriteLog("TradeNo:" + TradeNo, "微信支付回调监控");
                 WebCMSEntities db = new WebCMSEntities();
                 ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 0);
                 if (order != null)
                 {
+                    LogHelper.Instance.WriteLog("找到订单", "微信支付回调监控");
                     order.Status = 1;
                     order.UpdateDate = DateTime.Now;
                     order.PayMoney = order.PayMoney;
                     order.MaxDivi = order.MaxDivi;
                     order.SeoTitle = HdOrderNo;
                     order.SeoKeyword = TradeNo;
+                    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("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"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("GetTencentAddressInfoQueueHd", "{\"MerChantId\":\"" + merchant.Id + "\",\"Address\":\"" + merchant.Areas + merchant.Address + "\"}");
+                        }
                     }
                     order.UserId = merchant.UserId;
+                    LogHelper.Instance.WriteLog("创客:" + merchant.UserId, "微信支付回调监控");
                     ConsumerOrders check = db.ConsumerOrders.FirstOrDefault(m => m.Id < order.Id && m.Status > 0 && m.PayMode == order.PayMode && m.MerchantId == order.MerchantId);
                     if (check != null)
                     {
@@ -96,27 +114,36 @@ namespace MySystem
                         order.QueryCount = 1;
                     }
                     db.SaveChanges();
+                    LogHelper.Instance.WriteLog("检测商户订单数:" + order.QueryCount, "微信支付回调监控");
 
                     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"));
                         }
                     }
                     db1.Dispose();
+                    LogHelper.Instance.WriteLog("执行完毕", "微信支付回调监控");
+                }
+                else
+                {
+                    LogHelper.Instance.WriteLog("没找到订单", "微信支付回调监控");
+                    Thread.Sleep(2000);
+                    RedisDbconn.Instance.AddList("WeChatPayBackHd", content);
                 }
                 db.Dispose();
+                LogHelper.Instance.WriteLog("结束", "微信支付回调监控");
             }
         }
 
@@ -159,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"));
@@ -167,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;
                                     }
@@ -181,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;
                                     }
@@ -199,7 +226,7 @@ namespace MySystem
                                 }
                             }
                             order.Status = Status;
-                            if(Status == 2)
+                            if (Status == 2)
                             {
                                 order.DivideFlag = 1;
                                 order.DivideDate = DateTime.Now;
@@ -267,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;
                                 }
@@ -317,25 +344,32 @@ namespace MySystem
                     try
                     {
                         //{"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}
-                        if(content.Contains("\"settleAmount\"") && content.Contains("\"txSubCode\":31,"))
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content, "监听支付结算订单");
+                        if (content.Contains("\"settleAmount\"") && content.Contains("\"txSubCode\":31,"))
                         {
+                            LogHelper.Instance.WriteLog("符合条件", "监听支付结算订单");
                             JsonData jsonObj = JsonMapper.ToObject(content);
                             string orderNo = jsonObj["orderNo"].ToString();
                             int settleAmount = int.Parse(function.CheckInt(jsonObj["settleAmount"].ToString()));
+                            LogHelper.Instance.WriteLog("orderNo:" + orderNo, "监听支付结算订单");
+                            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();
+                                LogHelper.Instance.WriteLog("finish", "监听支付结算订单");
                             }
                             else
                             {
                                 Thread.Sleep(2000);
                                 RedisDbconn.Instance.AddList("PartOrderQueue", content);
+                                LogHelper.Instance.WriteLog("again", "监听支付结算订单");
                             }
                             db.Dispose();
                         }
+                        LogHelper.Instance.WriteLog("\n\n", "监听支付结算订单");
                     }
                     catch (Exception ex)
                     {

+ 53 - 0
Util/PublicFunction.cs

@@ -10,6 +10,7 @@ using Microsoft.IdentityModel.Tokens;
 using System.Security.Claims;
 using System.IdentityModel.Tokens.Jwt;
 using System.Text;
+using Aop.Api.Util;
 
 namespace MySystem
 {
@@ -233,5 +234,57 @@ namespace MySystem
             return decimal.Parse(str);
         }
     
+
+
+
+
+        #region 获取网络文件内容
+
+        public static string GetNetFileContent(string url)
+        {
+            string textContent = "";     
+            using (var client = new System.Net.WebClient())
+            {
+                try
+                {
+                    textContent = client.DownloadString(url); // 通过 DownloadString 方法获取网页内容
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "获取网络文件内容异常");
+                }
+            }
+            return textContent;
+        }
+
+        public static byte[] GetNetFileData(string url)
+        {
+            byte[] textContent = new byte[] { };
+            using (var client = new System.Net.WebClient())
+            {
+                try
+                {
+                    textContent = client.DownloadData(url); // 通过 DownloadString 方法获取网页内容
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "获取网络文件流异常");
+                }
+            }
+            return textContent;
+        }
+
+        public static FileItem GetNetFileItem(string url)
+        {
+            string fileName = url;
+            if(fileName.Contains("/"))
+            {
+                fileName = fileName.Substring(fileName.LastIndexOf("/") + 1);
+            }
+            FileItem item = new FileItem(fileName, GetNetFileData(url));
+            return item;
+        }
+
+        #endregion
     }
 }

+ 15 - 2
Util/RedisDbconn.cs

@@ -127,8 +127,7 @@ namespace MySystem
         #region 修改列表对象
         public bool SetList(string key, int index, object value)
         {
-            long itemindex = RedisHelper.LLen(key) - index - 1;
-            return RedisHelper.LSet(key, itemindex, value);
+            return RedisHelper.LSet(key, index, value);
             // return false;
         }
         #endregion
@@ -148,6 +147,20 @@ namespace MySystem
         }
         #endregion
 
+        #region 移除列表对象
+        public long DelFromList(string key, object value, int count = 1)
+        {
+            return RedisHelper.LRem(key, count, value);
+        }
+        #endregion
+
+        #region 移动列表元素位置
+        public T RPopLPush<T>(string key, string tokey)
+        {
+            return RedisHelper.RPopLPush<T>(key, tokey);
+        }
+        #endregion
+
         #region 添加排序列表对象
         public long AddSort(string key, object value, decimal score)
         {

+ 2 - 0
appsettings.Development.json

@@ -9,6 +9,7 @@
   "AllowedHosts": "*",
   "Setting": {
     "Host": "http://localhost:6003/",
+    "OssHost": "http://oss.kxssaas.com",
     "Database": "TpAdminServer",
     "SqlConnStr1": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
     "SqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer2;charset=utf8;",
@@ -21,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",

+ 5 - 0
global.json

@@ -0,0 +1,5 @@
+{
+  "sdk": {
+    "version": "3.0.100"
+  }
+}

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio