浏览代码

增加公用的发送消息队列方法
增加分账、生成邀请二维码、删除数据的服务程序

lichunlei 3 年之前
父节点
当前提交
47d041bb76
共有 30 个文件被更改,包括 202 次插入52 次删除
  1. 11 0
      AppStart/BothdisDbconn.cs
  2. 34 0
      AppStart/Helper/DelMySql/DeleteMySqlDataService.cs
  3. 49 0
      AppStart/Helper/MakeReferenceQrCodeService.cs
  4. 3 2
      AppStart/Helper/Profit/ProfitHelper.cs
  5. 47 0
      AppStart/Helper/ReceiveProfitService.cs
  6. 4 11
      AppStart/Helper/ReceiveTaskService.cs
  7. 11 3
      AppStart/Helper/SycnMysql/PublicTableHelper.cs
  8. 13 0
      AppStart/RabbitMQClient.cs
  9. 10 0
      AppStart/Tables/SetRedisDataList.cs
  10. 14 1
      Controllers/HomeController.cs
  11. 2 0
      Startup.cs
  12. 1 0
      appsettings.json
  13. 二进制
      bin/Debug/netcoreapp3.0/MySystem.dll
  14. 二进制
      bin/Debug/netcoreapp3.0/MySystem.pdb
  15. 1 0
      bin/Debug/netcoreapp3.0/appsettings.json
  16. 二进制
      bin/Debug/netcoreapp3.0/bsserver_com/static/ReferenceQrCode/6a927ee6fc6b3229.png
  17. 二进制
      bin/release/netcoreapp3.0/AopSdk.dll
  18. 0 17
      bin/release/netcoreapp3.0/MySystem.deps.json
  19. 二进制
      bin/release/netcoreapp3.0/MySystem.dll
  20. 二进制
      bin/release/netcoreapp3.0/MySystem.pdb
  21. 1 0
      bin/release/netcoreapp3.0/appsettings.json
  22. 0 17
      bin/release/netcoreapp3.0/publish/MySystem.deps.json
  23. 二进制
      bin/release/netcoreapp3.0/publish/MySystem.dll
  24. 二进制
      bin/release/netcoreapp3.0/publish/MySystem.pdb
  25. 1 0
      bin/release/netcoreapp3.0/publish/appsettings.json
  26. 二进制
      obj/Debug/netcoreapp3.0/MySystem.dll
  27. 二进制
      obj/Debug/netcoreapp3.0/MySystem.pdb
  28. 0 1
      obj/release/netcoreapp3.0/MySystem.csproj.FileListAbsolute.txt
  29. 二进制
      obj/release/netcoreapp3.0/MySystem.dll
  30. 二进制
      obj/release/netcoreapp3.0/MySystem.pdb

+ 11 - 0
AppStart/BothdisDbconn.cs

@@ -8,6 +8,17 @@ namespace MySystem
     {
         public readonly static BothdisDbconn Instance = new BothdisDbconn();
 
+
+        public void SendMq(string key, object obj)
+        {
+            SetRedisDataList data = new SetRedisDataList()
+            {
+                key = key,
+                val = Newtonsoft.Json.JsonConvert.SerializeObject(obj),
+            };
+            RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(data), "SetRedisDataList");
+        }
+
         #region 设置单个字段
         public void Set(string key, object value)
         {

+ 34 - 0
AppStart/Helper/DelMySql/DeleteMySqlDataService.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Linq;
+using MySystem.Models;
+using Library;
+
+namespace MySystem
+{
+    public class DeleteMySqlDataService
+    {
+        public readonly static DeleteMySqlDataService Instance = new DeleteMySqlDataService();
+        private DeleteMySqlDataService()
+        { }
+
+        public void Start(string TableString)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            try
+            {
+                string[] data = TableString.Split(':');
+                int Id = int.Parse(function.CheckInt(data[1]));
+                string Table = data[0];
+                
+            }
+            catch (Exception ex)
+            {
+                ErrorMsg msg = new ErrorMsg();
+                msg.Time = DateTime.Now;
+                msg.ErrorContent = ex.ToString();
+                TendisDbconn.Instance.AddList("Pop:MerchantInfo:Error", msg);
+            }
+            db.Dispose();
+        }
+    }
+}

+ 49 - 0
AppStart/Helper/MakeReferenceQrCodeService.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MySystem.Models;
+using Library;
+using LitJson;
+
+namespace MySystem
+{
+    public class MakeReferenceQrCodeService
+    {
+        public readonly static MakeReferenceQrCodeService Instance = new MakeReferenceQrCodeService();
+        private MakeReferenceQrCodeService()
+        { }
+
+        public void Start(string uid)
+        {
+            try
+            {
+                int UserId = int.Parse(function.CheckInt(uid));
+                if (UserId > 0)
+                {
+                    WebCMSEntities db = new WebCMSEntities();
+                    Users user = db.Users.FirstOrDefault(m => m.Id == UserId);
+                    if (user != null)
+                    { 
+                        string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "p/user-inviteregist-1?Id=" + user.Id, function.MD5_16(user.Id.ToString() + "8745"), "/bsserver_com/static/ReferenceQrCode/");
+                        user.ReferenceQrCode = path.Replace("//", "/").Replace("bsserver_com/", "");
+                        db.SaveChanges();
+                        PxcModels.WebCMSEntities pxcdb = new PxcModels.WebCMSEntities();
+                        Users tmpuser = db.Users.FirstOrDefault(m => m.Id == UserId);
+                        if (tmpuser != null)
+                        {
+                            tmpuser.ReferenceQrCode = user.ReferenceQrCode;
+                            pxcdb.SaveChanges();
+                        }
+                        pxcdb.Dispose();
+                        BothdisDbconn.Instance.SendMq("Pop:Users", user);
+                    }
+                    db.Dispose();
+                }
+            }
+            catch (Exception ex)
+            {
+                TendisDbconn.Instance.AddList("public_service", DateTime.Now.ToString() + ":" + ex.ToString());
+            }
+        }
+    }
+}

+ 3 - 2
AppStart/Helper/Profit/ProfitHelper.cs

@@ -34,6 +34,7 @@ namespace MySystem
         #region 消费队列
         public void StartListenTradeDo()
         {
+            // TODO: 增加事务处理
             bool op = true;
             while (op)
             {
@@ -110,13 +111,13 @@ namespace MySystem
                                         }
                                         TendisDbconn.Instance.Clear("ConsumerOrders:Divi:" + MerchantId);
                                         TendisDbconn.Instance.AddList("ConsumerOrders:Divi:" + MerchantId, orders.ToArray());
+                                        // FIXME: 从头部pop,从尾部add,没有中间出局的情况,出局直接弹出(不追加)
 
                                         //创客分润
                                         DoProfit(db, order);
 
                                         //代理商分润
                                         AgentProfit(db, order);
-
                                     }
                                 }
                             }
@@ -538,7 +539,7 @@ namespace MySystem
                         ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId && m.Status == 1);
                         if (order != null)
                         {
-                            
+                            // TODO: 
                         }
                         db.Dispose();
                     }

+ 47 - 0
AppStart/Helper/ReceiveProfitService.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using Library;
+using LitJson;
+
+namespace MySystem
+{
+    public class ReceiveProfitService
+    {
+        public readonly static ReceiveProfitService Instance = new ReceiveProfitService();
+        private ReceiveProfitService()
+        { }
+
+        public void Start(JobMqMsg jobInfo)
+        {
+            string content = "";
+            try
+            {
+                string OrderString = jobInfo.OrderString;
+                string Msg = "success";
+                if (OrderString == "SplitAccount")
+                {
+                    string Table = OrderString.Split(':')[1];
+                    ProfitHelper.Instance.StartListenSplitAccount();
+                }
+                jobInfo.Status = Msg == "success" ? 1 : 0;
+                jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
+                RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
+            }
+            catch (Exception ex)
+            {
+                if (!string.IsNullOrEmpty(content))
+                {
+                    Dictionary<string, string> data = new Dictionary<string, string>();
+                    data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+                    data.Add("ErrMsg", ex.ToString());
+                    TendisDbconn.Instance.AddList("public_err", data);
+                }
+                else
+                {
+                    TendisDbconn.Instance.AddList("public_service", DateTime.Now.ToString() + ":" + ex.ToString());
+                }
+            }
+        }
+    }
+}

+ 4 - 11
AppStart/Helper/ReceiveTaskService.cs

@@ -18,22 +18,15 @@ namespace MySystem
             try
             {
                 string OrderString = jobInfo.OrderString;
-                string Msg = "";
+                string Msg = "success";
                 if (OrderString.StartsWith("Ap:") && OrderString.EndsWith(":Sycn"))
                 {
                     string Table = OrderString.Split(':')[1];
                     PublicTableHelper.Instance.Start(Table);
                 }
-                if (!string.IsNullOrEmpty(Msg))
-                {
-                    jobInfo.Status = Msg == "success" ? 1 : 0;
-                    jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
-                    RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
-                }
-                else
-                { 
-                    TendisDbconn.Instance.AddList("MainPopWaitList", Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo));
-                }
+                jobInfo.Status = Msg == "success" ? 1 : 0;
+                jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
+                RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
             }
             catch (Exception ex)
             {

+ 11 - 3
AppStart/Helper/SycnMysql/PublicTableHelper.cs

@@ -16,7 +16,7 @@ namespace MySystem
             bool op = true;
             OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
             string result = "success";
-            int startId = TendisDbconn.Instance.Get<int>("Start" + table + "Id");
+            int startId = 0; //TendisDbconn.Instance.Get<int>("Start" + table + "Id");
             // int total = 0;
             while (op)
             {
@@ -37,14 +37,22 @@ namespace MySystem
                                 {
                                     if (!string.IsNullOrEmpty(dr[dc.ColumnName].ToString()))
                                     {
-                                        fields += dc.ColumnName + ",";
                                         if (dc.DataType == typeof(int) || dc.DataType == typeof(decimal) || dc.DataType == typeof(ulong))
                                         {
                                             fields += dc.ColumnName + "=" + dr[dc.ColumnName].ToString() + ",";
                                         }
                                         else
                                         {
-                                            fields += dc.ColumnName + "='" + dr[dc.ColumnName].ToString() + "',";
+                                            string val = "";
+                                            if (dc.DataType == typeof(DateTime))
+                                            {
+                                                val = DateTime.Parse(dr[dc.ColumnName].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
+                                            }
+                                            else
+                                            {
+                                                val = dr[dc.ColumnName].ToString();
+                                            }
+                                            fields += dc.ColumnName + "='" + val + "',";
                                         }
                                     }
                                 }

+ 13 - 0
AppStart/RabbitMQClient.cs

@@ -84,10 +84,23 @@ namespace MySystem
                     JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject<JobMqMsg>(MsgContent);
                     CheckAlipaySignService.Instance.Start(job);
                 }
+                else if (QueueName == "ConsumerOrdersDiviList")
+                { 
+                    JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject<JobMqMsg>(MsgContent);
+                    ReceiveProfitService.Instance.Start(job);
+                }
                 else if (QueueName == "MerchantConfirmList")
                 {
                     MerchantConfirmService.Instance.Start(MsgContent);
                 }
+                else if (QueueName == "MakeReferenceQrCode")
+                {
+                    MakeReferenceQrCodeService.Instance.Start(MsgContent);
+                }
+                else if (QueueName == "DeleteMySqlData")
+                {
+                    DeleteMySqlDataService.Instance.Start(MsgContent);
+                }
                 else if (QueueName == "SycnTableData")
                 {
                     JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject<JobMqMsg>(MsgContent);

+ 10 - 0
AppStart/Tables/SetRedisDataList.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+namespace MySystem
+{
+    public class SetRedisDataList
+    {
+        public string key { get; set; }
+        public string val { get; set; }
+    }
+}

+ 14 - 1
Controllers/HomeController.cs

@@ -58,7 +58,7 @@ namespace MySystem.Controllers
         private static object o = new object();
         public string test()
         {
-            MerchantConfirmService.Instance.Start("2");
+            // PublicTableHelper.Instance.Start("Users");
             // WebCMSEntities db = new WebCMSEntities();
             // MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 2) ?? new MerchantInfo();
             // BothdisDbconn.Instance.AddList("MerchantList:" + merchant.UserId, merchant);
@@ -84,6 +84,19 @@ namespace MySystem.Controllers
             return "ok";
         }
 
+        public string userqrcode(int uid)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            Users user = db.Users.FirstOrDefault(m => m.Id == uid);
+            if (user != null)
+            {
+                RabbitMQClient.Instance.SendMsg(user.Id.ToString(), "MakeReferenceQrCode");
+                return "ok";
+            }
+            db.Dispose();
+            return "fail";
+        }
+
         private void th1()
         {
             Thread th = new Thread(th1do);

+ 2 - 0
Startup.cs

@@ -214,9 +214,11 @@ namespace MySystem
 
 
             RabbitMQClient.Instance.StartReceive("MerchantConfirmList");
+            RabbitMQClient.Instance.StartReceive("MakeReferenceQrCode");
             RabbitMQClient.Instance.StartReceive("CheckWeChatSign");
             RabbitMQClient.Instance.StartReceive("CheckAlipaySign");
             RabbitMQClient.Instance.StartReceive("PublicMainServer");
+            RabbitMQClient.Instance.StartReceive("DeleteMySqlData");
             // RabbitMQClient.Instance.StartReceive("SycnTableData");
 
             // PayHelper.Instance.Start();

+ 1 - 0
appsettings.json

@@ -15,6 +15,7 @@
     "WebServiceUrl": "http://auth.yunmuit.com/Api/ProjectCheck/DataBase",
     "DbSchemeUrl": "http://auth.yunmuit.com/Api/ProjectCheck/GetDbScheme",
     "Host": "http://localhost:5047/",
+    "SourceHost": "http://bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
     "SqlConnStr": "server=47.108.207.184;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
     "Pxc1SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",

二进制
bin/Debug/netcoreapp3.0/MySystem.dll


二进制
bin/Debug/netcoreapp3.0/MySystem.pdb


+ 1 - 0
bin/Debug/netcoreapp3.0/appsettings.json

@@ -15,6 +15,7 @@
     "WebServiceUrl": "http://auth.yunmuit.com/Api/ProjectCheck/DataBase",
     "DbSchemeUrl": "http://auth.yunmuit.com/Api/ProjectCheck/GetDbScheme",
     "Host": "http://localhost:5047/",
+    "SourceHost": "http://bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
     "SqlConnStr": "server=47.108.207.184;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
     "Pxc1SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",

二进制
bin/Debug/netcoreapp3.0/bsserver_com/static/ReferenceQrCode/6a927ee6fc6b3229.png


二进制
bin/release/netcoreapp3.0/AopSdk.dll


+ 0 - 17
bin/release/netcoreapp3.0/MySystem.deps.json

@@ -41,7 +41,6 @@
           "ZKWeb.System.Drawing": "4.0.1",
           "aliyun-net-sdk-core": "2.0.0.0",
           "Aliyun.OSS": "2.9.1.0",
-          "AopSdk": "2.0.0.0",
           "LitJSON": "1.0.0.0",
           "MySystemLib": "1.0.0.0",
           "ThoughtWorks.QRCode": "1.0.3990.25764",
@@ -2082,17 +2081,6 @@
           "Aliyun.OSS.dll": {}
         }
       },
-      "AopSdk/2.0.0.0": {
-        "runtime": {
-          "AopSdk.dll": {
-            "assemblyVersion": "2.0.0.0",
-            "fileVersion": "2.0.0.0"
-          }
-        },
-        "compile": {
-          "AopSdk.dll": {}
-        }
-      },
       "LitJSON/1.0.0.0": {
         "runtime": {
           "LitJSON.dll": {
@@ -4839,11 +4827,6 @@
       "serviceable": false,
       "sha512": ""
     },
-    "AopSdk/2.0.0.0": {
-      "type": "reference",
-      "serviceable": false,
-      "sha512": ""
-    },
     "LitJSON/1.0.0.0": {
       "type": "reference",
       "serviceable": false,

二进制
bin/release/netcoreapp3.0/MySystem.dll


二进制
bin/release/netcoreapp3.0/MySystem.pdb


+ 1 - 0
bin/release/netcoreapp3.0/appsettings.json

@@ -15,6 +15,7 @@
     "WebServiceUrl": "http://auth.yunmuit.com/Api/ProjectCheck/DataBase",
     "DbSchemeUrl": "http://auth.yunmuit.com/Api/ProjectCheck/GetDbScheme",
     "Host": "http://localhost:5047/",
+    "SourceHost": "http://bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
     "SqlConnStr": "server=47.108.207.184;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
     "Pxc1SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",

+ 0 - 17
bin/release/netcoreapp3.0/publish/MySystem.deps.json

@@ -41,7 +41,6 @@
           "ZKWeb.System.Drawing": "4.0.1",
           "aliyun-net-sdk-core": "2.0.0.0",
           "Aliyun.OSS": "2.9.1.0",
-          "AopSdk": "2.0.0.0",
           "LitJSON": "1.0.0.0",
           "MySystemLib": "1.0.0.0",
           "ThoughtWorks.QRCode": "1.0.3990.25764",
@@ -2076,17 +2075,6 @@
           "Aliyun.OSS.dll": {}
         }
       },
-      "AopSdk/2.0.0.0": {
-        "runtime": {
-          "AopSdk.dll": {
-            "assemblyVersion": "2.0.0.0",
-            "fileVersion": "2.0.0.0"
-          }
-        },
-        "compile": {
-          "AopSdk.dll": {}
-        }
-      },
       "LitJSON/1.0.0.0": {
         "runtime": {
           "LitJSON.dll": {
@@ -4833,11 +4821,6 @@
       "serviceable": false,
       "sha512": ""
     },
-    "AopSdk/2.0.0.0": {
-      "type": "reference",
-      "serviceable": false,
-      "sha512": ""
-    },
     "LitJSON/1.0.0.0": {
       "type": "reference",
       "serviceable": false,

二进制
bin/release/netcoreapp3.0/publish/MySystem.dll


二进制
bin/release/netcoreapp3.0/publish/MySystem.pdb


+ 1 - 0
bin/release/netcoreapp3.0/publish/appsettings.json

@@ -15,6 +15,7 @@
     "WebServiceUrl": "http://auth.yunmuit.com/Api/ProjectCheck/DataBase",
     "DbSchemeUrl": "http://auth.yunmuit.com/Api/ProjectCheck/GetDbScheme",
     "Host": "http://localhost:5047/",
+    "SourceHost": "http://bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
     "SqlConnStr": "server=47.108.207.184;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
     "Pxc1SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",

二进制
obj/Debug/netcoreapp3.0/MySystem.dll


二进制
obj/Debug/netcoreapp3.0/MySystem.pdb


+ 0 - 1
obj/release/netcoreapp3.0/MySystem.csproj.FileListAbsolute.txt

@@ -182,7 +182,6 @@
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/aliyun-net-sdk-core.dll
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/Aliyun.OSS.dll
-/Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/AopSdk.dll
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/LitJSON.dll
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/MySystemLib.dll
 /Users/Shared/Previously Relocated Items/Security/MyDisk/我的/项目/myprogram_vs2019/KeXiaoShuang/MainServer/bin/release/netcoreapp3.0/ThoughtWorks.QRCode.dll

二进制
obj/release/netcoreapp3.0/MySystem.dll


二进制
obj/release/netcoreapp3.0/MySystem.pdb