|
@@ -15,555 +15,5 @@ namespace MySystem
|
|
private TestService()
|
|
private TestService()
|
|
{ }
|
|
{ }
|
|
|
|
|
|
- public void Start()
|
|
|
|
- {
|
|
|
|
- Thread th = new Thread(ReduceMoreSubsidy);
|
|
|
|
- th.IsBackground = true;
|
|
|
|
- th.Start();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void ResetTradeRecordUserId()
|
|
|
|
- {
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- List<int> posids = new List<int>();
|
|
|
|
- posids.Add(13312);
|
|
|
|
- // OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- foreach (int posid in posids)
|
|
|
|
- {
|
|
|
|
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posid);
|
|
|
|
- if (pos != null)
|
|
|
|
- {
|
|
|
|
- // OtherMySqlConn.op("update TradeRecord set UserId=" + pos.UserId + " where SnNo='" + pos.PosSn + "'");
|
|
|
|
- // function.WriteLog(DateTime.Now.ToString() + ":" + pos.UserId + "-" + pos.PosSn, "重置非商户型创客交易记录Id");
|
|
|
|
- RedisDbconn.Instance.AddList("TmpResetUserTradeQueue", pos.UserId + "#cut#2022-04-01 00:00:00#cut#2022-05-11 00:00:00#cut#" + pos.BrandId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // // OtherMySqlConn.connstr = ;
|
|
|
|
- db.Dispose();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void StartReset()
|
|
|
|
- {
|
|
|
|
- Thread th = new Thread(doSomething);
|
|
|
|
- th.IsBackground = true;
|
|
|
|
- th.Start();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void doSomething()
|
|
|
|
- {
|
|
|
|
- while (true)
|
|
|
|
- {
|
|
|
|
- string content = RedisDbconn.Instance.RPop<string>("TmpResetUserTradeQueue");
|
|
|
|
- if (!string.IsNullOrEmpty(content))
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
|
|
|
|
- int UserId = int.Parse(datalist[0]);
|
|
|
|
- DateTime sdate = DateTime.Parse(datalist[1]);
|
|
|
|
- DateTime edate = DateTime.Parse(datalist[2]);
|
|
|
|
- int BrandId = int.Parse(datalist[3]);
|
|
|
|
- function.WriteLog(DateTime.Now.ToString(), "重置创客交易额");
|
|
|
|
- List<string> uids = new List<string>();
|
|
|
|
- DataTable userDt = OtherMySqlConn.dtable("select Id,ParentNav from Users where Id=" + UserId);
|
|
|
|
- if (userDt.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- while (sdate <= edate)
|
|
|
|
- {
|
|
|
|
- string date = sdate.ToString("yyyy-MM-dd");
|
|
|
|
- string TradeDate = date.Replace("-", "");
|
|
|
|
- string TradeMonth = TradeDate.Substring(0, 6);
|
|
|
|
- string start = date + " 00:00:00";
|
|
|
|
- string end = DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
|
|
|
|
- string startId = "0", endId = "9999999999";
|
|
|
|
- DataTable startDt = OtherMySqlConn.dtable("select min(Id) from TradeRecord where CreateDate>='" + start + "'");
|
|
|
|
- if (startDt.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- startId = startDt.Rows[0][0].ToString();
|
|
|
|
- }
|
|
|
|
- DataRow userDr = userDt.Rows[0];
|
|
|
|
- string ParentNav = userDr["ParentNav"].ToString();
|
|
|
|
- function.WriteLog(UserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天交易额日志");
|
|
|
|
- OtherMySqlConn.op("delete from UserTradeDaySummary where UserId=" + UserId + " and BrandId=" + BrandId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and SeoTitle='self'");
|
|
|
|
- DataTable selfdt = OtherMySqlConn.dtable("select BrandId,BankCardType,QrPayFlag,sum(TradeAmount) from TradeRecord where Id>=" + startId + " and Id<=" + endId + " and CreateDate>='" + start + "' and CreateDate<'" + end + "' and UserId=" + UserId + " and BrandId=" + BrandId + " group by BrandId,BankCardType,QrPayFlag");
|
|
|
|
- function.WriteLog(UserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天交易额日志");
|
|
|
|
- foreach (DataRow selfDr in selfdt.Rows)
|
|
|
|
- {
|
|
|
|
- int BankCardType = int.Parse(selfDr["BankCardType"].ToString());
|
|
|
|
- int QrPayFlag = int.Parse(selfDr["QrPayFlag"].ToString());
|
|
|
|
- decimal TradeAmount = decimal.Parse(selfDr[3].ToString());
|
|
|
|
- UserTradeDaySummary selfStat = db.UserTradeDaySummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.QueryCount == QrPayFlag && m.SeoTitle == "self");
|
|
|
|
- if (selfStat == null)
|
|
|
|
- {
|
|
|
|
- selfStat = db.UserTradeDaySummary.Add(new UserTradeDaySummary()
|
|
|
|
- {
|
|
|
|
- UserId = UserId,
|
|
|
|
- TradeMonth = TradeMonth,
|
|
|
|
- TradeDate = TradeDate,
|
|
|
|
- BrandId = BrandId,
|
|
|
|
- QueryCount = QrPayFlag,
|
|
|
|
- SeoTitle = "self",
|
|
|
|
- }).Entity;
|
|
|
|
- db.SaveChanges();
|
|
|
|
- }
|
|
|
|
- if (BankCardType == 0)
|
|
|
|
- {
|
|
|
|
- selfStat.DirectDebitTradeAmt += TradeAmount;
|
|
|
|
- }
|
|
|
|
- else if (BankCardType != 0)
|
|
|
|
- {
|
|
|
|
- selfStat.DirectTradeAmt += TradeAmount;
|
|
|
|
- }
|
|
|
|
- db.SaveChanges();
|
|
|
|
- }
|
|
|
|
- if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
- {
|
|
|
|
- ParentNav += "," + UserId + ",";
|
|
|
|
- string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
- foreach (string NavUserIdString in ParentNavList)
|
|
|
|
- {
|
|
|
|
- if (!uids.Contains(NavUserIdString + start))
|
|
|
|
- {
|
|
|
|
- uids.Add(NavUserIdString + start);
|
|
|
|
- int NavUserId = int.Parse(NavUserIdString);
|
|
|
|
- function.WriteLog(NavUserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天交易额日志");
|
|
|
|
- OtherMySqlConn.op("delete from UserTradeDaySummary where UserId=" + NavUserId + " and BrandId=" + BrandId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and SeoTitle='team'");
|
|
|
|
- DataTable teamDt = OtherMySqlConn.dtable("select BrandId,BankCardType,QrPayFlag,sum(TradeAmount) from TradeRecord where Id>=" + startId + " and Id<=" + endId + " and CreateDate>='" + start + "' and CreateDate<'" + end + "' and UserId in (select Id from Users where ParentNav like '%," + NavUserId + ",%' or Id=" + NavUserId + ") and BrandId=" + BrandId + " group by BrandId,BankCardType,QrPayFlag");
|
|
|
|
- function.WriteLog(NavUserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天交易额日志");
|
|
|
|
- foreach (DataRow teamDr in teamDt.Rows)
|
|
|
|
- {
|
|
|
|
- int BankCardType = int.Parse(teamDr["BankCardType"].ToString());
|
|
|
|
- int QrPayFlag = int.Parse(teamDr["QrPayFlag"].ToString());
|
|
|
|
- decimal TradeAmount = decimal.Parse(teamDr[3].ToString());
|
|
|
|
- UserTradeDaySummary teamStat = db.UserTradeDaySummary.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.QueryCount == QrPayFlag && m.SeoTitle == "team");
|
|
|
|
- if (teamStat == null)
|
|
|
|
- {
|
|
|
|
- teamStat = db.UserTradeDaySummary.Add(new UserTradeDaySummary()
|
|
|
|
- {
|
|
|
|
- UserId = NavUserId,
|
|
|
|
- TradeMonth = TradeMonth,
|
|
|
|
- TradeDate = TradeDate,
|
|
|
|
- BrandId = BrandId,
|
|
|
|
- QueryCount = QrPayFlag,
|
|
|
|
- SeoTitle = "team",
|
|
|
|
- }).Entity;
|
|
|
|
- db.SaveChanges();
|
|
|
|
- }
|
|
|
|
- if (BankCardType == 0)
|
|
|
|
- {
|
|
|
|
- teamStat.NonDirectDebitTradeAmt += TradeAmount;
|
|
|
|
- }
|
|
|
|
- else if (BankCardType != 0)
|
|
|
|
- {
|
|
|
|
- teamStat.NonDirectTradeAmt += TradeAmount;
|
|
|
|
- }
|
|
|
|
- db.SaveChanges();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- sdate = sdate.AddDays(1);
|
|
|
|
- Thread.Sleep(200);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- db.Dispose();
|
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\r\n\r\n", "重置创客交易额");
|
|
|
|
- }
|
|
|
|
- catch (Exception ex)
|
|
|
|
- {
|
|
|
|
- function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "重置创客交易额异常");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Thread.Sleep(5000);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public void statTrade()
|
|
|
|
- {
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,BrandId,MerchantId,QrPayFlag,PayType,VipFlag,DATE_FORMAT(CreateDate,'%Y%m%d'),sum(TradeAmount) from TradeRecord where Id>=574439 and UserId>0 and MerchantId in (5962,32731,14396,14,855,2586,2911,1839,6368,2598,79,47,21884,3243,3259,11637,5082,9767,5381,7091,4652,16159,24752,6183,18417,5285,17980,20862,3678,6567,11,21529,2647,10799,9024,24367,17045,14977,17249,847,3901,35077,21982,4496,5121,1383,153,12051,13036,20036,24984,21155,4720,15512,26592,4073,15241,7981,7079,9853,23689,24284,23731,4103,5959,85,31,24936,23781,9566,5658,10898,4929,26997,248,15916,9444,4760,7022,8697,9754,3482,255,793,14351,14149,3049,13390,3796,9209,27862,656,2413,9017,1649,282,8,14112,16313,15545,5639,2809,3733,16717,11541,9774,18000,20341,20273,10047,16151,28510,20193,4650,2498,2597,23242,11325,34592,12362,29281,15165,208,2196,3709,2715,6494,16034,3368,17283,4513,3309,2979,2854,6497,251,17906,7598,2327,6856,2347,2675,4,10991,138,784,350,7961,3385,29349,23533,31893,5036,15382,6934,3778,5922,24357,6222,6755,8887) and CreateDate>='2022-06-01 00:00:00' and MerHelpFlag=1 and BankCardType!=0 and CreateDate<'2022-07-01 00:00:00' group by UserId,BrandId,MerchantId,QrPayFlag,PayType,VipFlag,DATE_FORMAT(CreateDate,'%Y%m%d') order by DATE_FORMAT(CreateDate,'%Y%m%d')");
|
|
|
|
- List<string> IdBrands = new List<string>();
|
|
|
|
- if(dt.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- foreach(DataRow dr in dt.Rows)
|
|
|
|
- {
|
|
|
|
- int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
|
- int MerchantId = int.Parse(dr["MerchantId"].ToString());
|
|
|
|
- int BrandId = int.Parse(dr["BrandId"].ToString());
|
|
|
|
- int QrPayFlag = int.Parse(dr["QrPayFlag"].ToString());
|
|
|
|
- int PayType = int.Parse(dr["PayType"].ToString());
|
|
|
|
- int VipFlag = int.Parse(dr["VipFlag"].ToString());
|
|
|
|
- string TradeDate = dr[6].ToString();
|
|
|
|
- decimal HelpDirectTradeAmt = decimal.Parse(dr[7].ToString());
|
|
|
|
- function.WriteLog("update TradeDaySummary set HelpDirectTradeAmt=HelpDirectTradeAmt-" + HelpDirectTradeAmt + ",NotHelpDirectTradeAmt=NotHelpDirectTradeAmt+" + HelpDirectTradeAmt + " where UserId=" + UserId + " and BrandId=" + BrandId + " and TradeDate='" + TradeDate + "' and QueryCount=" + QrPayFlag + " and PayType=" + PayType + " and VipFlag=" + VipFlag + " and SeoTitle='self';\n", "多余机器分润");
|
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
|
- string ParentNav = user.ParentNav;
|
|
|
|
- ParentNav += "," + UserId + ",";
|
|
|
|
- if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
- {
|
|
|
|
- string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
- foreach (string NavUserIdString in ParentNavList)
|
|
|
|
- {
|
|
|
|
- function.WriteLog("update TradeDaySummary set HelpNonDirectTradeAmt=HelpNonDirectTradeAmt-" + HelpDirectTradeAmt + ",NotHelpNonDirectTradeAmt=NotHelpNonDirectTradeAmt+" + HelpDirectTradeAmt + " where UserId=" + NavUserIdString + " and BrandId=" + BrandId + " and TradeDate='" + TradeDate + "' and QueryCount=" + QrPayFlag + " and PayType=" + PayType + " and VipFlag=" + VipFlag + " and SeoTitle='team';\n", "多余机器分润");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<ProfitResult> results = StartProftForPosByDate(BrandId, UserId, HelpDirectTradeAmt);
|
|
|
|
- foreach(ProfitResult result in results)
|
|
|
|
- {
|
|
|
|
- int DirectFlag = result.DirectFlag;
|
|
|
|
- function.WriteLog("update ProfitRecord set ProfitAmount=ProfitAmount-" + result.Money + " where UserId=" + result.UserId + " and SeoTitle='202206' and DirectFlag=" + DirectFlag + " and BrandId=" + BrandId + ";\n", "多余机器分润");
|
|
|
|
- function.WriteLog("update UserMachineData set TradeProfit=TradeProfit-" + result.Money + " where IdBrand='" + UserId + "_" + BrandId + "';\n", "多余机器分润");
|
|
|
|
- }
|
|
|
|
- if(!IdBrands.Contains(UserId+"-"+MerchantId))
|
|
|
|
- {
|
|
|
|
- IdBrands.Add(UserId + "-" + MerchantId);
|
|
|
|
- DataTable sub = OtherMySqlConn.dtable("select SubsidyProfit from ProfitSubsidyDetail where TradeMonth='202206' and SubsidyUserId=" + UserId + " and MerchantId=" + MerchantId + "");
|
|
|
|
- if(sub.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- string SubsidyProfit = sub.Rows[0][0].ToString();
|
|
|
|
- function.WriteLog("delete from ProfitSubsidyDetail where TradeMonth='202206' and SubsidyUserId=" + UserId + " and MerchantId=" + MerchantId + ";\n", "多余机器分润");
|
|
|
|
- function.WriteLog("update UserMachineData set OtherProfit=OtherProfit-" + SubsidyProfit + " where IdBrand='" + UserId + "_" + BrandId + "';\n", "多余机器分润");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- db.Dispose();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<ProfitResult> StartProftForPosByDate(int BrandId, int UserId, decimal HelpDirectTradeAmt)
|
|
|
|
- {
|
|
|
|
- List<ProfitResult> result = new List<ProfitResult>();
|
|
|
|
- // ProfitObjects obj = RedisDbconn.Instance.Get<ProfitObjects>("pobj" + BrandId);
|
|
|
|
- // if (obj.Status == 1) //判断分润是否开启
|
|
|
|
- // {
|
|
|
|
- // WebCMSEntities dbnew = new WebCMSEntities();
|
|
|
|
- // try
|
|
|
|
- // {
|
|
|
|
- // List<UserLevelSet> levels = dbnew.UserLevelSet.ToList();
|
|
|
|
- // Users selfUser = dbnew.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
|
- // int Days = int.Parse(RedisDbconn.Instance.Get<string>("pobjrule:" + BrandId + ":HelpPolicy:Days")); //天数
|
|
|
|
- // int maxLevel = obj.MaxLevel; //最大等级
|
|
|
|
- // decimal diffLevelProfit = 0; //等级级差
|
|
|
|
- // int curLevel = 0; //当前层级的会员等级
|
|
|
|
- // string ParentNav = selfUser.ParentNav;
|
|
|
|
- // if (string.IsNullOrEmpty(ParentNav))
|
|
|
|
- // {
|
|
|
|
- // ParentNav = ",0,";
|
|
|
|
- // }
|
|
|
|
- // if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
- // {
|
|
|
|
- // ParentNav += "," + UserId + ",";
|
|
|
|
- // string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
- // Array.Reverse(ParentNavList); //反转顺序
|
|
|
|
- // int level = 0;
|
|
|
|
- // DateTime now = DateTime.Now;
|
|
|
|
- // if (HelpDirectTradeAmt > 0)
|
|
|
|
- // {
|
|
|
|
- // foreach (string UserIdString in ParentNavList)
|
|
|
|
- // {
|
|
|
|
- // level += 1;
|
|
|
|
- // int uid = int.Parse(UserIdString);
|
|
|
|
- // Users user = dbnew.Users.FirstOrDefault(m => m.Id == uid) ?? new Users();
|
|
|
|
- // int UserLevel = user.UserLevel; //当前会员等级
|
|
|
|
- // UserRankWhite rank = dbnew.UserRankWhite.FirstOrDefault(m => m.Id == user.Id && m.UpdateDate > now);
|
|
|
|
- // if (rank != null)
|
|
|
|
- // {
|
|
|
|
- // if (rank.Rank > UserLevel)
|
|
|
|
- // {
|
|
|
|
- // UserLevel = rank.Rank;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
|
|
- // {
|
|
|
|
- // break;
|
|
|
|
- // }
|
|
|
|
- // if (UserLevel <= maxLevel && UserLevel > curLevel)
|
|
|
|
- // {
|
|
|
|
- // int LevelKindId = ProfitHelperV2.Instance.GetLevelKindId(BrandId, 1, 1);
|
|
|
|
- // ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
|
|
|
|
- // int LevelKindId2 = ProfitHelperV2.Instance.GetLevelKindId(BrandId, 0, 1);
|
|
|
|
- // ProfitObjectLevels objlevel2 = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId2 + ":" + UserLevel); //获取当前等级参数
|
|
|
|
- // if (objlevel != null && objlevel2 != null)
|
|
|
|
- // {
|
|
|
|
- // decimal getLevelProfit = 0; //等级分润
|
|
|
|
- // if (objlevel.Percents > 0 && objlevel2.Percents > 0)
|
|
|
|
- // {
|
|
|
|
- // //获取创客分润规则,注册日开始算起,3个自然月内算扶持期
|
|
|
|
- // getLevelProfit += HelpDirectTradeAmt * (objlevel.Percents - objlevel2.Percents);
|
|
|
|
- // }
|
|
|
|
- // decimal money = getLevelProfit;
|
|
|
|
- // getLevelProfit -= diffLevelProfit;
|
|
|
|
- // diffLevelProfit = money;
|
|
|
|
- // if (getLevelProfit >= obj.MinProfitVal)
|
|
|
|
- // {
|
|
|
|
- // result.Add(new ProfitResult()
|
|
|
|
- // {
|
|
|
|
- // UserId = user.Id,
|
|
|
|
- // UserNav = user.ParentNav,
|
|
|
|
- // Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
|
|
- // ProfitRate = objlevel.Percents,
|
|
|
|
- // Message = "交易分润",
|
|
|
|
- // BankCardType = 1,
|
|
|
|
- // DirectFlag = selfUser.Id == user.Id ? 1 : 0,
|
|
|
|
- // BrandId = BrandId,
|
|
|
|
- // IsSubsidy = 0,
|
|
|
|
- // TradeAmount = HelpDirectTradeAmt,
|
|
|
|
- // HelpFlag = 1,
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // curLevel = UserLevel;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // catch (Exception ex)
|
|
|
|
- // {
|
|
|
|
- // function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月统计分润异常");
|
|
|
|
- // }
|
|
|
|
- // dbnew.Dispose();
|
|
|
|
- // }
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public void helpprofit()
|
|
|
|
- {
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select Id,KqMerNo from PosMerchantInfo where Id in (select MerchantId from HelpProfitMerchantForUser) and BrandId!=1");
|
|
|
|
- foreach(DataRow dr in dt.Rows)
|
|
|
|
- {
|
|
|
|
- int MerchantId = int.Parse(dr["Id"].ToString());
|
|
|
|
- string KqMerNo = dr["KqMerNo"].ToString();
|
|
|
|
- int Id = RedisDbconn.Instance.RPop<int>("HelpProfitMerchantIds");
|
|
|
|
- if(Id > 0)
|
|
|
|
- {
|
|
|
|
- OtherMySqlConn.op("update HelpProfitMerIds set MerchantId=" + Id + " where MerchantId=" + MerchantId + "");
|
|
|
|
- OtherMySqlConn.op("update PosMerchantInfo set SeoKeyword='' where Id=" + MerchantId);
|
|
|
|
- OtherMySqlConn.op("update PosMerchantInfo set SeoKeyword='已被申领为商机' where Id=" + Id);
|
|
|
|
- OtherMySqlConn.op("update PosCoupons set HelpProfitMerchantId=" + Id + " where HelpProfitMerchantId=" + MerchantId + "");
|
|
|
|
- OtherMySqlConn.op("update HelpProfitMerchantForUser set MerchantId=" + Id + ",Sort=1,MerNo='" + KqMerNo + "' where MerchantId=" + MerchantId + "");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- #region 每月交易额统计
|
|
|
|
- public void tradeAmt()
|
|
|
|
- {
|
|
|
|
- while(true)
|
|
|
|
- {
|
|
|
|
- if(DateTime.Now.Hour > 4)
|
|
|
|
- {
|
|
|
|
- tradeAmtDo();
|
|
|
|
- }
|
|
|
|
- Thread.Sleep(60000);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- public void tradeAmtDo()
|
|
|
|
- {
|
|
|
|
- function.WriteLog("start:" + DateTime.Now.ToString(), "每月交易额统计");
|
|
|
|
- string month = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
|
|
- string html = "<table>";
|
|
|
|
- html += "<tr>";
|
|
|
|
- html += "<td>创客编号</td>";
|
|
|
|
- html += "<td>创客名称</td>";
|
|
|
|
- html += "<td>创客身份证号</td>";
|
|
|
|
- html += "<td>创客手机号</td>";
|
|
|
|
- html += "<td>顶级创客编号</td>";
|
|
|
|
- html += "<td>顶级创客名称</td>";
|
|
|
|
- html += "<td>交易额</td>";
|
|
|
|
- html += "<td>最大市场交易额</td>";
|
|
|
|
- html += "</tr>";
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,sum(HelpNonDirectTradeAmt+NotHelpNonDirectTradeAmt+HelpNonDirectCreditTradeAmt+NotHelpNonDirectCreditTradeAmt) from TradeDaySummary where Id>=2194025 and TradeMonth='" + month + "' and SeoTitle='team' group by UserId having sum(HelpNonDirectTradeAmt+NotHelpNonDirectTradeAmt+HelpNonDirectCreditTradeAmt+NotHelpNonDirectCreditTradeAmt)>=3000000 and sum(HelpNonDirectTradeAmt+NotHelpNonDirectTradeAmt+HelpNonDirectCreditTradeAmt+NotHelpNonDirectCreditTradeAmt)<10000000");
|
|
|
|
- function.WriteLog("总数:" + dt.Rows.Count, "每月交易额统计");
|
|
|
|
- foreach(DataRow dr in dt.Rows)
|
|
|
|
- {
|
|
|
|
- int UserId = int.Parse(function.CheckInt(dr["UserId"].ToString()));
|
|
|
|
- decimal TradeAmt = decimal.Parse(function.CheckNum(dr[1].ToString()));
|
|
|
|
- decimal MaxTradeAmt = 0;
|
|
|
|
- List<decimal> subTradeAmtList = new List<decimal>();
|
|
|
|
- DataTable subdt = OtherMySqlConn.dtable("select Id from Users where ParentUserId=" + UserId + " and AuthFlag=1");
|
|
|
|
- foreach(DataRow subdr in subdt.Rows)
|
|
|
|
- {
|
|
|
|
- int SubUserId = int.Parse(function.CheckInt(subdr["Id"].ToString()));
|
|
|
|
- decimal subTradeAmt = 0;
|
|
|
|
- DataTable subuserdt = OtherMySqlConn.dtable("select sum(HelpNonDirectTradeAmt+NotHelpNonDirectTradeAmt+HelpNonDirectCreditTradeAmt+NotHelpNonDirectCreditTradeAmt) from TradeDaySummary where Id>=2194025 and TradeMonth='" + month + "' and SeoTitle='team' and UserId=" + SubUserId);
|
|
|
|
- if(subuserdt.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- subTradeAmt = decimal.Parse(function.CheckNum(subuserdt.Rows[0][0].ToString()));
|
|
|
|
- }
|
|
|
|
- subTradeAmtList.Add(subTradeAmt);
|
|
|
|
- }
|
|
|
|
- if(subTradeAmtList.Count > 0)
|
|
|
|
- {
|
|
|
|
- MaxTradeAmt = subTradeAmtList.Max(m => m);
|
|
|
|
- }
|
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
|
- int TopUserId = 0;
|
|
|
|
- string ParentNav = user.ParentNav;
|
|
|
|
- if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
- {
|
|
|
|
- string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
- if (ParentNavList.Length > 1)
|
|
|
|
- {
|
|
|
|
- TopUserId = int.Parse(ParentNavList[1]);
|
|
|
|
- }
|
|
|
|
- else if (ParentNavList.Length == 1)
|
|
|
|
- {
|
|
|
|
- TopUserId = int.Parse(ParentNavList[0]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
|
- html += "<tr>";
|
|
|
|
- html += "<td>" + user.MakerCode + "</td>";
|
|
|
|
- html += "<td>" + user.RealName + "</td>";
|
|
|
|
- html += "<td>" + user.CertId + "</td>";
|
|
|
|
- html += "<td>" + user.Mobile + "</td>";
|
|
|
|
- html += "<td>" + tuser.MakerCode + "</td>";
|
|
|
|
- html += "<td>" + tuser.RealName + "</td>";
|
|
|
|
- html += "<td>" + TradeAmt + "</td>";
|
|
|
|
- html += "<td>" + MaxTradeAmt + "</td>";
|
|
|
|
- html += "</tr>";
|
|
|
|
- function.WriteLog(DateTime.Now.ToString(), "每月交易额统计");
|
|
|
|
- function.WriteLog(UserId.ToString(), "每月交易额统计");
|
|
|
|
- }
|
|
|
|
- html += "</table>";
|
|
|
|
- db.SaveChanges();
|
|
|
|
- function.WritePage("/htmlfile/", month + ".html", html);
|
|
|
|
- function.WriteLog("end:" + DateTime.Now.ToString(), "每月交易额统计");
|
|
|
|
- }
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- #region 查找8月多余补贴
|
|
|
|
-
|
|
|
|
- // public void Subsidy()
|
|
|
|
- // {
|
|
|
|
- // while(true)
|
|
|
|
- // {
|
|
|
|
- // if(DateTime.Now.Hour > 4)
|
|
|
|
- // {
|
|
|
|
- // SubsidyDo();
|
|
|
|
- // }
|
|
|
|
- // Thread.Sleep(60000);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- public void SubsidyDo()
|
|
|
|
- {
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,ProductType,ChangeAmount from UserAccountRecord where ChangeType=111 and CreateDate>='2022-09-01 00:00:00' and CreateDate<'2022-10-01 00:00:00' order by Id");
|
|
|
|
- function.WriteLog("总数:" + dt.Rows.Count, "查找8月多余补贴");
|
|
|
|
- foreach(DataRow dr in dt.Rows)
|
|
|
|
- {
|
|
|
|
- int UserId = int.Parse(function.CheckInt(dr["UserId"].ToString()));
|
|
|
|
- int ProductType = int.Parse(function.CheckInt(dr["ProductType"].ToString()));
|
|
|
|
- decimal ChangeAmount = decimal.Parse(function.CheckNum(dr["ChangeAmount"].ToString()));
|
|
|
|
- decimal CheckAmount = 0;
|
|
|
|
- DataTable checkdt = OtherMySqlConn.dtable("select sum(SubsidyProfit) from ProfitSubsidyExport2 where MakerCode=(select MakerCode from Users where Id=" + UserId + ") and BrandName=(select Name from KqProducts where Id=" + ProductType + ")");
|
|
|
|
- if(checkdt.Rows.Count > 0)
|
|
|
|
- {
|
|
|
|
- CheckAmount = decimal.Parse(function.CheckNum(checkdt.Rows[0][0].ToString()));
|
|
|
|
- if(ChangeAmount - CheckAmount > 1 && CheckAmount > 0)
|
|
|
|
- {
|
|
|
|
- decimal LastAmount = ChangeAmount - CheckAmount;
|
|
|
|
- function.WriteLog("差异分润:UserId:" + UserId + ";ProductType:" + ProductType + ";ChangeAmount:" + ChangeAmount + ";CheckAmount:" + CheckAmount + ";LastAmount:" + LastAmount + ";", "查找8月多余补贴");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- function.WriteLog("多余分润:UserId:" + UserId + ";ProductType:" + ProductType + ";ChangeAmount:" + ChangeAmount + ";", "查找8月多余补贴");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- function.WriteLog("多余分润:UserId:" + UserId + ";ProductType:" + ProductType + ";ChangeAmount:" + ChangeAmount + ";", "查找8月多余补贴");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- db.Dispose();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- #region 重置开机奖励流量分佣
|
|
|
|
-
|
|
|
|
- public void resetOpenPrize()
|
|
|
|
- {
|
|
|
|
- string doDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
|
|
|
- string flag = function.ReadInstance("/Stat/" + doDate + ".txt");
|
|
|
|
- if (string.IsNullOrEmpty(flag))
|
|
|
|
- {
|
|
|
|
- function.WritePage("/Stat/", doDate + ".txt", DateTime.Now.ToString("HH:mm:ss"));
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- // StatService.Instance.StartEverDay(doDate);
|
|
|
|
- // StatService.Instance.StatMerchantTrade(doDate);
|
|
|
|
- // StatService.Instance.dosomething4(doDate);
|
|
|
|
- // StatService.Instance.ListenFluxRecord(doDate);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- #region 扣8月多余补贴
|
|
|
|
-
|
|
|
|
- public void ReduceMoreSubsidy()
|
|
|
|
- {
|
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,sum(MoreMoney) from SubsidyCheck where Status=0 group by UserId");
|
|
|
|
- foreach(DataRow dr in dt.Rows)
|
|
|
|
- {
|
|
|
|
- int UserId = int.Parse(function.CheckInt(dr["UserId"].ToString()));
|
|
|
|
- decimal MoreMoney = decimal.Parse(function.CheckNum(dr[1].ToString()));
|
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
|
- if (account != null)
|
|
|
|
- {
|
|
|
|
- if(account.BalanceAmount >= MoreMoney)
|
|
|
|
- {
|
|
|
|
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
|
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
|
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
|
- account.BalanceAmount -= MoreMoney;
|
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
|
- db.SaveChanges();
|
|
|
|
- UserAccountRecord accountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
|
- {
|
|
|
|
- CreateDate = DateTime.Now,
|
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
|
- UserId = UserId, //创客
|
|
|
|
- ChangeType = 63, //变动类型
|
|
|
|
- ChangeAmount = MoreMoney, //变更金额
|
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
|
- Remark = "9月多发补贴扣减",
|
|
|
|
- }).Entity;
|
|
|
|
- db.SaveChanges();
|
|
|
|
- OtherMySqlConn.op("update SubsidyCheck set Status=1 where UserId=" + UserId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- db.Dispose();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|