lichunlei 2 years ago
parent
commit
c10e13f9f4

+ 20 - 4
AppStart/Helper/AlipayPayBack2Service.cs

@@ -267,30 +267,41 @@ namespace MySystem
                                     return;
                                     return;
                                 }
                                 }
                                 int ParentUserId = user.ParentUserId;
                                 int ParentUserId = user.ParentUserId;
+                                List<int> proids = new List<int>();
+                                proids.Add(10);
+                                proids.Add(11);
                                 while(ParentUserId > 0)
                                 while(ParentUserId > 0)
                                 {
                                 {
                                     Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
                                     Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
                                     int machineCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.PosSnType == 0); //判断是否拥有3台购买机
                                     int machineCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.PosSnType == 0); //判断是否拥有3台购买机
                                     int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
                                     int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
                                     int couponCount = db.PosCoupons.Count(m => m.UserId == ParentUserId && m.IsUse == 0); //判断是否拥有3张券
                                     int couponCount = db.PosCoupons.Count(m => m.UserId == ParentUserId && m.IsUse == 0); //判断是否拥有3张券
-                                    function.WriteLog("MakerCode:" + user.MakerCode, "推荐下单奖励监控日志");
+                                    function.WriteLog("MakerCode:" + puser.MakerCode, "推荐下单奖励监控日志");
                                     function.WriteLog("machineCount:" + machineCount, "推荐下单奖励监控日志");
                                     function.WriteLog("machineCount:" + machineCount, "推荐下单奖励监控日志");
                                     function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
                                     function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
                                     if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
                                     if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
                                     {
                                     {
                                         function.WriteLog("满足条件", "推荐下单奖励监控日志");
                                         function.WriteLog("满足条件", "推荐下单奖励监控日志");
-                                        if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个上级创客只能获得一次
+                                        if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个创客第一次下单,上级可得
                                         {
                                         {
-                                            bool check = db.UserAccountRecord.Any(m => m.UserId == ParentUserId && m.ChangeType == 112);
+                                            List<int> oids = new List<int>();
+                                            var orderpros = db.OrderProduct.Select(m => new { m.OrderId,m.UserId,m.ProductId }).Where(m => m.UserId == order.UserId && proids.Contains(m.ProductId)).ToList();
+                                            foreach(var orderpro in orderpros)
+                                            {
+                                                oids.Add(orderpro.OrderId);
+                                            }
+                                            bool check = db.Orders.Any(m => oids.Contains(m.Id) && m.Status > 0);
                                             if(!check)
                                             if(!check)
                                             {
                                             {
                                                 DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
                                                 DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                                directPrize = true;
                                             }
                                             }
                                         }
                                         }
                                         else
                                         else
                                         {
                                         {
                                             // 盟主直推奖励,可以每次下单获得
                                             // 盟主直推奖励,可以每次下单获得
                                             DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
                                             DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                            directPrize = true;
                                         }
                                         }
 
 
                                         //推荐下单上级获得30天的机具循环天数
                                         //推荐下单上级获得30天的机具循环天数
@@ -304,7 +315,6 @@ namespace MySystem
                                             }
                                             }
                                         }
                                         }
                                         db.SaveChanges();
                                         db.SaveChanges();
-                                        directPrize = true;
                                     }
                                     }
                                     if(puser.LeaderLevel > 0)
                                     if(puser.LeaderLevel > 0)
                                     {
                                     {
@@ -351,6 +361,12 @@ namespace MySystem
                     {
                     {
                         RecommendMethod(order.UserId, order.CreateDate.Value.ToString("yyyyMM"));
                         RecommendMethod(order.UserId, order.CreateDate.Value.ToString("yyyyMM"));
                     }
                     }
+                    //分仓向总仓申请机具额度
+                    if(pro.ProductId == 24 || pro.ProductId == 25 || pro.ProductId == 26)
+                    {
+                        string SendData = "{\"Kind\":\"1\",\"Data\":{\"OrderId\":\"" + order.Id + "\"}}";
+                        RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
+                    }
                 }
                 }
                 else
                 else
                 {
                 {

+ 93 - 0
AppStart/Timer/StoreApplyHelper.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using MySystem;
+using MySystem.PxcModels;
+using Library;
+using LitJson;
+
+public class StoreApplyHelper
+{
+    public readonly static StoreApplyHelper Instance = new StoreApplyHelper();
+    private StoreApplyHelper()
+    {
+    }
+
+    public void Start()
+    {
+        Thread th = new Thread(DoWorks);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void DoWorks()
+    {
+        while (true)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            try
+            {
+                if(DateTime.Now.Day == 1 && DateTime.Now.Hour > 0 && DateTime.Now.Hour < 3)
+                {
+                    string check = function.ReadInstance("/StoreApply/" + DateTime.Now.ToString("yyyyMM") + ".txt");
+                    if(string.IsNullOrEmpty(check))
+                    {
+                        function.WritePage("/StoreApply/", DateTime.Now.ToString("yyyyMM") + ".txt", DateTime.Now.ToString());
+
+                        db.SaveChanges();
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "计算分仓申请机具额度异常");
+            }
+            db.Dispose();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "计算分仓申请机具额度日志");
+            Thread.Sleep(60000);
+        }
+    }
+
+    public void StartEverTime()
+    {
+        Thread th = new Thread(StartEverTimeDo);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void StartEverTimeDo()
+    {
+        while (true)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            try
+            {
+                string data = RedisDbconn.Instance.Get<string>("StoreApplyQueue");
+                if(!string.IsNullOrEmpty(data))
+                {
+                    JsonData jsonObj = JsonMapper.ToObject(data);
+                    if(jsonObj["Kind"].ToString() == "1")
+                    {
+                        int OrderId = int.Parse(jsonObj["Data"]["OrderId"].ToString());
+                        Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId);
+                        if(order != null)
+                        {
+                            decimal TotalPrice = order.TotalPrice;
+                            UserAccount account = db.UserAccount.FirstOrDefault();
+                        }
+                    }
+                    db.SaveChanges();
+                }
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "分仓向总仓申请机具线程异常");
+            }
+            db.Dispose();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "分仓向总仓申请机具线程日志");
+            Thread.Sleep(60000);
+        }
+    }
+}

+ 1 - 0
Models/UserAccount.cs

@@ -35,5 +35,6 @@ namespace MySystem.Models
         public decimal TempAmount { get; set; }
         public decimal TempAmount { get; set; }
         public decimal FixedAmount { get; set; }
         public decimal FixedAmount { get; set; }
         public decimal LeaderReserve { get; set; }
         public decimal LeaderReserve { get; set; }
+        public decimal ValidAmount { get; set; }
     }
     }
 }
 }

+ 2 - 0
Models/WebCMSEntities.cs

@@ -11979,6 +11979,8 @@ namespace MySystem.Models
 
 
                 entity.Property(e => e.UserType).HasColumnType("int(11)");
                 entity.Property(e => e.UserType).HasColumnType("int(11)");
 
 
+                entity.Property(e => e.ValidAmount).HasColumnType("decimal(18,2)");
+
                 entity.Property(e => e.Version).HasColumnType("int(11)");
                 entity.Property(e => e.Version).HasColumnType("int(11)");
 
 
                 entity.Property(e => e.WithdrawAmount).HasColumnType("decimal(18,2)");
                 entity.Property(e => e.WithdrawAmount).HasColumnType("decimal(18,2)");

+ 1 - 0
PxcModels/UserAccount.cs

@@ -35,5 +35,6 @@ namespace MySystem.PxcModels
         public decimal TempAmount { get; set; }
         public decimal TempAmount { get; set; }
         public decimal FixedAmount { get; set; }
         public decimal FixedAmount { get; set; }
         public decimal LeaderReserve { get; set; }
         public decimal LeaderReserve { get; set; }
+        public decimal ValidAmount { get; set; }
     }
     }
 }
 }

+ 2 - 0
PxcModels/WebCMSEntities.cs

@@ -11979,6 +11979,8 @@ namespace MySystem.PxcModels
 
 
                 entity.Property(e => e.UserType).HasColumnType("int(11)");
                 entity.Property(e => e.UserType).HasColumnType("int(11)");
 
 
+                entity.Property(e => e.ValidAmount).HasColumnType("decimal(18,2)");
+
                 entity.Property(e => e.Version).HasColumnType("int(11)");
                 entity.Property(e => e.Version).HasColumnType("int(11)");
 
 
                 entity.Property(e => e.WithdrawAmount).HasColumnType("decimal(18,2)");
                 entity.Property(e => e.WithdrawAmount).HasColumnType("decimal(18,2)");