浏览代码

运营中心5元的激活奖励发放队列

lichunlei 2 年之前
父节点
当前提交
886b10f2ea

+ 3 - 3
AppStart/Helper/LeaderPrizeService.cs

@@ -50,8 +50,8 @@ namespace MySystem
                             decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
                             decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
                             decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
-                            account.BalanceAmount += 5;
-                            account.TotalAmount += 5;
+                            account.BalanceAmount += 10;
+                            account.TotalAmount += 10;
                             decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
                             decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
                             decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
@@ -61,7 +61,7 @@ namespace MySystem
                                 UpdateDate = DateTime.Now,
                                 UserId = LeaderUserId, //创客
                                 ChangeType = 116, //变动类型
-                                ChangeAmount = 5, //变更金额
+                                ChangeAmount = 10, //变更金额
                                 BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
                                 AfterTotalAmount = AfterTotalAmount, //变更后总金额
                                 BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额

+ 90 - 0
AppStart/Helper/OperatePrizeService.cs

@@ -0,0 +1,90 @@
+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 OperatePrizeService
+    {
+        public readonly static OperatePrizeService Instance = new OperatePrizeService();
+        private OperatePrizeService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(dosomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void dosomething()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("OperatePrizeQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    try
+                    {
+                        int PosId = int.Parse(function.CheckInt(data));
+                        WebCMSEntities db = new WebCMSEntities();
+                        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == PosId);
+                        if (pos != null)
+                        {
+                            int OpId = pos.OpId;
+                            UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == OpId);
+                            if (account == null)
+                            {
+                                account = db.UserAccount.Add(new UserAccount()
+                                {
+                                    Id = OpId,
+                                    UserId = OpId,
+                                }).Entity;
+                                db.SaveChanges();
+                            }
+                            decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
+                            decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
+                            decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
+                            account.BalanceAmount += 5;
+                            account.TotalAmount += 5;
+                            decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
+                            decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
+                            decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
+                            UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
+                            {
+                                CreateDate = DateTime.Now,
+                                UpdateDate = DateTime.Now,
+                                UserId = OpId, //创客
+                                ChangeType = 121, //变动类型
+                                ChangeAmount = 5, //变更金额
+                                BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
+                                AfterTotalAmount = AfterTotalAmount, //变更后总金额
+                                BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
+                                AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
+                                BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
+                                AfterBalanceAmount = AfterBalanceAmount, //变更后余额
+                                QueryCount = PosId,
+                            }).Entity;
+                            db.SaveChanges();
+                        }
+                        db.Dispose();
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "运营中心奖励异常");
+                    }
+                    Thread.Sleep(100);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+    }
+}

+ 5 - 0
AppStart/Helper/SycnSpServer/SycnSpTradeService.cs

@@ -303,6 +303,11 @@ namespace MySystem
                                             {
                                                 RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
                                             }
+                                            //发放运营中奖励
+                                            if(pos.OpId > 0)
+                                            {
+                                                RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
+                                            }
                                         }
                                         // 立刷60天内刷满10000,再返40
                                         if (pos.BrandId == 6 && decimal.Parse(function.CheckNum(pos.SeoKeyword)) > 0 && pos.ActivationState == 1 && pos.CreditTrade >= 10000 && pos.BindingTime > DateTime.Now.AddDays(-60))

+ 1 - 0
Startup.cs

@@ -199,6 +199,7 @@ namespace MySystem
             BalancePayBackService.Instance.Start(); //余额支付队列
             ReservePayBackService.Instance.Start(); //储备金支付队列
             // LeaderPrizeService.Instance.Start(); //大盟主奖励发奖
+            // OperatePrizeService.Instance.Start(); //运营中心奖励发奖
             // MessageCenterService.Instance.Start(); // 消息队列
             // RecommendActStatService.Instance.Start(); //推荐王奖励数据统计
             // StoreApplyHelper.Instance.Start(); // 每月1号重置仓库额度