Jelajahi Sumber

添加同步商户交易额队列

lcl 1 tahun lalu
induk
melakukan
fa72ef4948

+ 57 - 0
AppStart/Helper/SycnMerchantTradeService.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.PxcModels;
+
+namespace MySystem
+{
+    public class SycnMerchantTradeService
+    {
+        public readonly static SycnMerchantTradeService Instance = new SycnMerchantTradeService();
+        private SycnMerchantTradeService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(StartDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartDo()
+        {
+            while (true)
+            {
+                try
+                {
+                    string content = RedisDbconn.Instance.RPop<string>("SycnMerchantTradeQueue");
+                    if(!string.IsNullOrEmpty(content))
+                    {
+                        function.WriteLog("content:" + content, "同步商户交易额");
+                        JsonData jsonObj = JsonMapper.ToObject(content);
+                        int OldPosId = int.Parse(function.CheckInt(jsonObj["OldPosId"].ToString()));
+                        int NewPosId = int.Parse(function.CheckInt(jsonObj["NewPosId"].ToString()));
+                        if(OldPosId != NewPosId)
+                        {
+                            CustomerSqlConn.op("update PosMerchantTradeSummay set MerchantId=" + NewPosId + " where MerchantId=" + OldPosId, MysqlConn.SqlConnStr);
+                        }
+                        Thread.Sleep(500);
+                    }
+                    else
+                    {
+                        Thread.Sleep(60000);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "同步商户交易额异常");
+                    Thread.Sleep(300000);
+                }
+            }
+        }
+    }
+}

+ 1 - 0
AppStart/Helper/SycnSpServer/SycnSpMerchantService.cs

@@ -149,6 +149,7 @@ namespace MySystem
                                 add.MerchantMobile = Mer.MerMobile;
                                 add.MerchantName = Mer.MerName;
                                 pos.BindMerchantId = add.Id;
+                                pos.LastMerchantId = add.Id;
                                 db.SaveChanges();
                                 PxcModels.Users buser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users();
                                 if(buser.BusinessFlag == 1)

+ 1 - 0
PxcModels/PosMachinesTwo.cs

@@ -61,5 +61,6 @@ namespace MySystem.PxcModels
         public int RecycStatus { get; set; }
         public string OutBatchNo { get; set; }
         public int WithholdFlag { get; set; }
+        public int LastMerchantId { get; set; }
     }
 }

+ 12 - 0
PxcModels/TableSplit.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class TableSplit
+    {
+        public string TableName { get; set; }
+        public int EndId { get; set; }
+        public int StartId { get; set; }
+    }
+}

+ 29 - 5
PxcModels/WebCMSEntities.cs

@@ -218,6 +218,7 @@ namespace MySystem.PxcModels
         public virtual DbSet<SysLog> SysLog { get; set; }
         public virtual DbSet<SysRechargeRecord> SysRechargeRecord { get; set; }
         public virtual DbSet<SystemSet> SystemSet { get; set; }
+        public virtual DbSet<TableSplit> TableSplit { get; set; }
         public virtual DbSet<TeamApply> TeamApply { get; set; }
         public virtual DbSet<TeamApplyForTeamName> TeamApplyForTeamName { get; set; }
         public virtual DbSet<TeamApplyForTeamNo> TeamApplyForTeamNo { get; set; }
@@ -8938,11 +8939,8 @@ namespace MySystem.PxcModels
 
             modelBuilder.Entity<Orders>(entity =>
             {
-                entity.HasIndex(e => e.StoreId)
-                    .HasName("OrdersStoreIdIndex");
-
-                entity.HasIndex(e => new { e.UserId, e.ParentOrderId })
-                    .HasName("OrdersListIndex");
+                entity.HasIndex(e => new { e.StoreId, e.UserId, e.ParentOrderId, e.CreateDate })
+                    .HasName("OrdersIndex");
 
                 entity.Property(e => e.Id).HasColumnType("int(11)");
 
@@ -9792,6 +9790,10 @@ namespace MySystem.PxcModels
                     .HasColumnType("bit(1)")
                     .HasDefaultValueSql("b'0'");
 
+                entity.Property(e => e.LastMerchantId)
+                    .HasColumnType("int(11)")
+                    .HasComment("最后一次绑定商户号");
+
                 entity.Property(e => e.LeaderUserId).HasColumnType("int(11)");
 
                 entity.Property(e => e.OpId).HasColumnType("int(11)");
@@ -15111,6 +15113,28 @@ namespace MySystem.PxcModels
                     .HasCollation("utf8_general_ci");
             });
 
+            modelBuilder.Entity<TableSplit>(entity =>
+            {
+                entity.HasKey(e => e.TableName)
+                    .HasName("PRIMARY");
+
+                entity.HasComment("表优化配置");
+
+                entity.Property(e => e.TableName)
+                    .HasColumnType("varchar(50)")
+                    .HasComment("表名")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
+                entity.Property(e => e.EndId)
+                    .HasColumnType("int(11)")
+                    .HasComment("结束Id");
+
+                entity.Property(e => e.StartId)
+                    .HasColumnType("int(11)")
+                    .HasComment("开始Id");
+            });
+
             modelBuilder.Entity<TeamApply>(entity =>
             {
                 entity.HasComment("开团申请");

+ 1 - 0
Startup.cs

@@ -210,6 +210,7 @@ namespace MySystem
                 PrePosRingService.Instance.Start(); //预发未申请提醒
                 PrePosWithholdService.Instance.Start(); //预发机过期未申请提交到预扣款
                 PrePosWithholdService.Instance.StartPre(); //预发机申请成功,处理预扣款
+                SycnMerchantTradeService.Instance.Start(); //同步商户交易额
 
                 MessageCenterService.Instance.Start(); // 消息队列
                 SetFeeFlagService.Instance.Start(); //118天提前通知创客费率调升消息