|
@@ -0,0 +1,58 @@
|
|
|
+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();
|
|
|
+ RedisDbconn.Instance.Clear("HelpProfitMerchantIds");
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,BrandId,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 >= 15000 and a.sum/3 <= 25000 limit 1000");
|
|
|
+ foreach(DataRow dr in dt.Rows)
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("HelpProfitMerchantIds", int.Parse(function.CheckInt(dr["MerchantId"].ToString())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|