Browse Source

Merge branch 'feat-lcl-盒力四射' of kxs-end/main-server into release-mainserver

lichunlei 11 months ago
parent
commit
141bb87b15
2 changed files with 79 additions and 0 deletions
  1. 78 0
      AppStart/Helper/HyfAddPrizeService.cs
  2. 1 0
      Startup.cs

+ 78 - 0
AppStart/Helper/HyfAddPrizeService.cs

@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Threading;
+using MySystem.PxcModels;
+using System.Data;
+
+namespace MySystem
+{
+    public class HyfAddPrizeService
+    {
+        public readonly static HyfAddPrizeService Instance = new HyfAddPrizeService();
+        private HyfAddPrizeService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(StartDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartDo()
+        {
+            while(true)
+            {
+                try
+                {
+                    DoSomething();
+                }
+                catch(Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "盒力四射加码奖励异常");
+                }
+                Thread.Sleep(20000);
+            }
+        }
+        public void DoSomething()
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            DateTime online = DateTime.Parse("2024-06-25 00:00:00");
+            DateTime end = DateTime.Parse("2025-01-01 00:00:00");
+            if(DateTime.Now > end) return;
+            List<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.BindingState == 1 && m.ActivationState == 1 && m.BindingTime >= online && (m.BrandId == 12 || m.BrandId == 13) && m.Sort == 0).ToList();
+            foreach (PosMachinesTwo pos in posList)
+            {
+                function.WriteLog(str: "机具号:" + pos.PosSn, "盒力四射加码奖励日志");
+                DateTime leftTime = pos.BindingTime.Value.AddDays(7);
+                DateTime rightTime = pos.BindingTime.Value.AddDays(30);
+                decimal amt = 0;
+                DataTable dt = CustomerSqlConn.dtable("select sum(TradeAmount) from PosMerchantTradeSummay where TradeDate>='" + leftTime.ToString("yyyyMMdd") + "' and TradeDate<='" + rightTime.ToString("yyyyMMdd") + "' and MerchantId=" + pos.BindMerchantId + "", MysqlConn.ReadSqlConnStr);
+                if(dt.Rows.Count > 0)
+                {
+                    amt = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
+                }
+                if(amt >= 1000)
+                {
+                    Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId);
+                    if (user != null)
+                    {
+                        function.WriteLog("机具所属人:" + user.Id, "盒力四射加码奖励日志");
+                        int GetUserId = user.Id;
+                        AlipayPayBack2Service.Instance.ChangeAccount(db, new Orders() { Id = pos.Id }, GetUserId, 50, 139);
+                        PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(edit != null)
+                        {
+                            edit.Sort = 1;
+                            db.SaveChanges();
+                        }
+                    }
+                }
+                function.WriteLog("\n\n\n", "盒力四射加码奖励日志");
+            }
+            db.Dispose();
+        }
+    }
+}

+ 1 - 0
Startup.cs

@@ -241,6 +241,7 @@ namespace MySystem
                 
                 PosChannelHelper.Instance.Start(); //实时查询查询终端收单机构
                 UpUserSaveService.Instance.Start(); //每天凌晨保存头一天的创客关系数据
+                HyfAddPrizeService.Instance.Start(); //盒力四射加码奖励发放
             // }