12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- using MySystem.PxcModels;
- using Library;
- using System.Threading;
- using Microsoft.Extensions.Hosting;
- using System.Threading.Tasks;
- namespace MySystem
- {
- public class HelpProfitPreMerchantHelper
- {
- public readonly static HelpProfitPreMerchantHelper Instance = new HelpProfitPreMerchantHelper();
- private HelpProfitPreMerchantHelper()
- {
- }
-
- public void Start()
- {
- Thread th = new Thread(StartFor);
- th.IsBackground = true;
- th.Start();
- }
- public void StartFor()
- {
- while (true)
- {
- if(DateTime.Now.Hour >= 2 && DateTime.Now.Hour <= 3)
- {
- StatEveryDay(DateTime.Now.ToString("yyyyMMdd"));
- }
- Thread.Sleep(600000);
- }
- }
- public void StatEveryDay(string Date)
- {
- string check = function.ReadInstance("/HelpProfitResetMerchant/" + Date + ".txt");
- if (!string.IsNullOrEmpty(check))
- {
- return;
- }
- function.WritePage("/HelpProfitResetMerchant/", Date + ".txt", DateTime.Now.ToString());
- DateTime start = DateTime.Parse(Date.Substring(0, 4) + "-" + Date.Substring(4, 2) + "-" + Date.Substring(6, 2) + " 00:00:00");
- string Month1 = start.ToString("yyyyMM");
- string Month2 = start.AddMonths(-1).ToString("yyyyMM");
- string Month3 = start.AddMonths(-2).ToString("yyyyMM");
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
- string GetCount = function.ReadInstance("/PublicParam/HelpProfitMerCount.txt");
- if(string.IsNullOrEmpty(GetCount))
- {
- GetCount = "1000";
- function.WritePage("/PublicParam/", "HelpProfitMerCount.txt", GetCount);
- }
- RedisDbconn.Instance.Clear("HelpProfitMerchantIds");
- DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,SUM(TradeAmount) sum FROM PosMerchantTradeSummay WHERE MerchantId not in (select MerchantId from HelpProfitMerIds) AND TradeMonth in ('" + Month1 + "','" + Month2 + "','" + Month3 + "') GROUP BY MerchantId)a WHERE a.sum/3 >= 35000 and a.sum/3 <= 50000 limit " + GetCount);
- foreach(DataRow dr in dt.Rows)
- {
- RedisDbconn.Instance.AddList("HelpProfitMerchantIds", int.Parse(function.CheckInt(dr["MerchantId"].ToString())));
- }
- }
- }
- }
|