|
@@ -37,12 +37,12 @@ namespace MySystem
|
|
|
public void Recommend()
|
|
|
{
|
|
|
string today = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
- string checkFlag = function.ReadInstance("/RecommandKing/" + today + ".txt");
|
|
|
- if(!string.IsNullOrEmpty(checkFlag))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- function.WritePage("/RecommandKing/", today + ".txt", DateTime.Now.ToString());
|
|
|
+ // string checkFlag = function.ReadInstance("/RecommandKing/" + today + ".txt");
|
|
|
+ // if(!string.IsNullOrEmpty(checkFlag))
|
|
|
+ // {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // function.WritePage("/RecommandKing/", today + ".txt", DateTime.Now.ToString());
|
|
|
List<int> Historys = new List<int>();
|
|
|
Historys.Add(565);
|
|
|
Historys.Add(139473);
|
|
@@ -68,119 +68,115 @@ namespace MySystem
|
|
|
Dictionary<int, decimal> PreMonthAmt = GetTradeAmtList(PreTradeMonth);
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
ReadModels.WebCMSEntities readdb = new ReadModels.WebCMSEntities();
|
|
|
+ MpMainModels.WebCMSEntities mpdb = new MpMainModels.WebCMSEntities();
|
|
|
+ MpMainModels2.WebCMSEntities mpdb2 = new MpMainModels2.WebCMSEntities();
|
|
|
//统计当月下单名单
|
|
|
- List<int> uids = readdb.Orders.Where(m => m.PayDate >= check && m.Status > 0 && m.Sort == 0 && m.UserId > 1 && ProductIds.Contains(m.ProductId)).ToList().Select(m => m.UserId).Distinct().ToList();
|
|
|
- foreach(int uid in uids)
|
|
|
+ // List<int> checkIds = readdb.Users.Where(m => (m.ParentNav.Contains(",609,") || m.Id == 609) && m.AuthFlag == 1).ToList().Select(m => m.Id).ToList();
|
|
|
+ // List<int> uids = readdb.Orders.Where(m => m.PayDate >= check && m.Status > 0 && m.Sort == 0 && m.UserId > 1 && checkIds.Contains(m.UserId) && ProductIds.Contains(m.ProductId)).ToList().Select(m => m.UserId).Distinct().ToList();
|
|
|
+ // foreach(int uid in uids)
|
|
|
+ // {
|
|
|
+ // Users user = db.Users.FirstOrDefault(m => m.Id == uid);
|
|
|
+ // if(user != null)
|
|
|
+ // {
|
|
|
+ // if(!users.Any(m => m.UserId == user.Id))
|
|
|
+ // {
|
|
|
+ // users.Add(new RecommandKingItem()
|
|
|
+ // {
|
|
|
+ // UserId = user.Id,
|
|
|
+ // ParentUserId = user.ParentUserId,
|
|
|
+ // ParentNav = user.ParentNav,
|
|
|
+ // PreAmount = PreMonthAmt.ContainsKey(user.Id) ? PreMonthAmt[user.Id] : 0,
|
|
|
+ // Level = user.ParentNav.Replace(",,", ",").Trim(',').Split(',').Length + 1,
|
|
|
+ // Kind = 1,
|
|
|
+ // Op = false,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // string[] ParentIds = user.ParentNav.Replace(",,", ",").Trim(',').Split(',');
|
|
|
+ // foreach(string ParentId in ParentIds)
|
|
|
+ // {
|
|
|
+ // int ParentUserId = int.Parse(ParentId);
|
|
|
+ // Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId && m.Id > 1);
|
|
|
+ // if(puser != null)
|
|
|
+ // {
|
|
|
+ // if(!users.Any(m => m.UserId == puser.Id))
|
|
|
+ // {
|
|
|
+ // users.Add(new RecommandKingItem()
|
|
|
+ // {
|
|
|
+ // UserId = puser.Id,
|
|
|
+ // ParentUserId = puser.ParentUserId,
|
|
|
+ // ParentNav = puser.ParentNav,
|
|
|
+ // PreAmount = PreMonthAmt.ContainsKey(puser.Id) ? PreMonthAmt[puser.Id] : 0,
|
|
|
+ // Level = puser.ParentNav.Replace(",,", ",").Trim(',').Split(',').Length + 1,
|
|
|
+ // Kind = 2,
|
|
|
+ // Op = false,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // foreach(RecommandKingItem user in users)
|
|
|
+ // {
|
|
|
+ // if(user.Kind == 1)
|
|
|
+ // {
|
|
|
+ // int uid = user.UserId;
|
|
|
+ // int ActCount = 0;
|
|
|
+ // if(ActCount == 0)
|
|
|
+ // {
|
|
|
+ // if(readdb.UserTradeMonthSummary.Any(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team"))
|
|
|
+ // {
|
|
|
+ // ActCount += readdb.UserTradeMonthSummary.Where(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team").Sum(m => m.ActiveBuddyMerStatus);
|
|
|
+ // if(readdb.UserSimActSummary.Any(m => m.UserId == uid && m.Kind == 1))
|
|
|
+ // {
|
|
|
+ // ActCount -= readdb.UserSimActSummary.Where(m => m.UserId == uid && m.Kind == 1).Sum(m => m.ActCount); //减去注销的用户
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if(ActCount == 0)
|
|
|
+ // {
|
|
|
+ // ActCount += mpdb.MerchantDepositOrder.Count(m => m.UserId == uid && m.CreateDate >= start && m.CreateDate < end && m.Status > 0 && m.UserId == uid);
|
|
|
+ // }
|
|
|
+ // if(ActCount == 0)
|
|
|
+ // {
|
|
|
+ // ActCount += mpdb2.MerchantDepositOrder.Count(m => m.UserId == uid && m.CreateDate >= start && m.CreateDate < end && m.Status > 0 && m.UserId == uid);
|
|
|
+ // }
|
|
|
+ // if(ActCount > 0)
|
|
|
+ // {
|
|
|
+ // user.Op = true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // RedisDbconn.Instance.AddList("userstmp2024", user);
|
|
|
+ // }
|
|
|
+ users = RedisDbconn.Instance.GetList<RecommandKingItem>("userstmp2024", 1, 99999999);
|
|
|
+ users = users.OrderBy(m => m.Level).ToList();
|
|
|
+ foreach(RecommandKingItem user in users)
|
|
|
+ {
|
|
|
+ string UserIdStr = "," + user.UserId + ",";
|
|
|
+ int Count = users.Count(m => m.ParentNav.Contains(UserIdStr) && m.Op);
|
|
|
+ user.ActCount = Count;
|
|
|
+ user.ChkActCount = Count;
|
|
|
+ }
|
|
|
+ foreach(RecommandKingItem user in users)
|
|
|
{
|
|
|
- int ActCount = 0;
|
|
|
- if(ActCount == 0)
|
|
|
+ string UserIdStr = "," + user.UserId + ",";
|
|
|
+ if(users.Any(m => m.ParentNav.Contains(UserIdStr) && (m.ChkActCount >= 50 || m.PreAmount >= 30000000)))
|
|
|
{
|
|
|
- if(readdb.UserTradeMonthSummary.Any(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team"))
|
|
|
+ List<RecommandKingItem> subs = users.Where(m => m.ParentUserId == user.UserId).ToList();
|
|
|
+ foreach(RecommandKingItem sub in subs)
|
|
|
{
|
|
|
- ActCount += readdb.UserTradeMonthSummary.Where(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team").Sum(m => m.ActiveBuddyMerStatus);
|
|
|
- if(readdb.UserSimActSummary.Any(m => m.UserId == uid && m.Kind == 1))
|
|
|
+ string subUserIdStr = "," + sub.UserId + ",";
|
|
|
+ if(sub.ChkActCount >= 50 || sub.PreAmount >= 30000000 || Historys.Contains(sub.UserId))
|
|
|
{
|
|
|
- ActCount -= readdb.UserSimActSummary.Where(m => m.UserId == uid && m.Kind == 1).Sum(m => m.ActCount); //减去注销的用户
|
|
|
+ user.ActCount -= sub.ChkActCount;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- if(ActCount == 0)
|
|
|
- {
|
|
|
- MpMainModels.WebCMSEntities mpdb = new MpMainModels.WebCMSEntities();
|
|
|
- ActCount += mpdb.MerchantDepositOrder.Count(m => m.UserId == uid && m.CreateDate >= start && m.CreateDate < end && m.Status > 0 && m.UserId == uid);
|
|
|
- mpdb.Dispose();
|
|
|
- }
|
|
|
- if(ActCount == 0)
|
|
|
- {
|
|
|
- MpMainModels2.WebCMSEntities mpdb = new MpMainModels2.WebCMSEntities();
|
|
|
- ActCount += mpdb.MerchantDepositOrder.Count(m => m.UserId == uid && m.CreateDate >= start && m.CreateDate < end && m.Status > 0 && m.UserId == uid);
|
|
|
- mpdb.Dispose();
|
|
|
- }
|
|
|
- if(ActCount > 0)
|
|
|
- {
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == uid);
|
|
|
- if(user != null)
|
|
|
- {
|
|
|
- if(!users.Any(m => m.UserId == user.Id))
|
|
|
+ else if(users.Any(m => m.ParentNav.Contains(subUserIdStr) && (m.ChkActCount >= 50 || m.PreAmount >= 30000000)))
|
|
|
{
|
|
|
- users.Add(new RecommandKingItem()
|
|
|
- {
|
|
|
- UserId = user.Id,
|
|
|
- ParentUserId = user.ParentUserId,
|
|
|
- ParentNav = user.ParentNav,
|
|
|
- PreAmount = PreMonthAmt.ContainsKey(user.Id) ? PreMonthAmt[user.Id] : 0,
|
|
|
- Level = user.ParentNav.Replace(",,", ",").Trim(',').Split(',').Length + 1
|
|
|
- });
|
|
|
+ RecommandKingItem tar = users.Where(m => m.ParentNav.Contains(subUserIdStr) && (m.ChkActCount >= 50 || m.PreAmount >= 30000000)).OrderBy(m => m.Level).FirstOrDefault();
|
|
|
+ user.ActCount -= tar.ChkActCount;
|
|
|
}
|
|
|
-
|
|
|
- // string ParentNav = user.ParentNav;
|
|
|
- // if(!string.IsNullOrEmpty(ParentNav))
|
|
|
- // {
|
|
|
- // string[] ParentNavList = ParentNav.Replace(",,", ",").Trim(',').Split(',');
|
|
|
- // Array.Reverse(ParentNavList);
|
|
|
- // bool PassFlag = true;
|
|
|
- // foreach(string UserIdString in ParentNavList)
|
|
|
- // {
|
|
|
- // int UserId = int.Parse(UserIdString);
|
|
|
- // //判断是否历史达标创客
|
|
|
- // if(PassFlag)
|
|
|
- // {
|
|
|
- // if(db.RecommendDirectUser.Any(m => m.UserId == UserId && m.TradeMonth != TradeMonth && m.QueryCount >= 50) || Historys.Contains(UserId))
|
|
|
- // {
|
|
|
- // PassFlag = false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if(PassFlag)
|
|
|
- // {
|
|
|
- // if(db.RecommendDirectUser.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.QueryCount >= 50))
|
|
|
- // {
|
|
|
- // PassFlag = false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if(PassFlag)
|
|
|
- // {
|
|
|
- // RecommendDirectUser item = db.RecommendDirectUser.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
- // if(item == null)
|
|
|
- // {
|
|
|
- // item = db.RecommendDirectUser.Add(new RecommendDirectUser()
|
|
|
- // {
|
|
|
- // UserId = UserId,
|
|
|
- // TradeMonth = TradeMonth,
|
|
|
- // }).Entity;
|
|
|
- // db.SaveChanges();
|
|
|
- // }
|
|
|
- // item.QueryCount += 1;
|
|
|
- // db.SaveChanges();
|
|
|
- // }
|
|
|
- // //判断上月交易额是否满3000W
|
|
|
- // if(PassFlag)
|
|
|
- // {
|
|
|
- // if(GetTradeAmt(UserId, PreTradeMonth) >= 30000000)
|
|
|
- // {
|
|
|
- // PassFlag = false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- users = users.OrderByDescending(m => m.Level).ToList();
|
|
|
- List<RecommandKingItem> users2 = users.OrderBy(m => m.Level).ToList();
|
|
|
- foreach(RecommandKingItem user in users)
|
|
|
- {
|
|
|
- string UserIdStr = "," + user.UserId + ",";
|
|
|
- RecommandKingItem lookSub = users2.FirstOrDefault(m => m.ParentNav.Contains(UserIdStr) && (m.ActCount >= 50 || m.PreAmount >= 30000000));
|
|
|
- if(lookSub != null)
|
|
|
- {
|
|
|
- string ParentNav = lookSub.ParentNav + "," + lookSub.UserId + ",";
|
|
|
- user.ActCount = users.Count(m => m.ParentNav.Contains(UserIdStr) && !m.ParentNav.StartsWith(ParentNav) && m.UserId != lookSub.UserId && m.ActCount < 50 && m.PreAmount < 30000000);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- user.ActCount = users.Count(m => m.ParentNav.Contains(UserIdStr) && m.ActCount < 50 && m.PreAmount < 30000000);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
int num = 0;
|
|
|
foreach(RecommandKingItem user in users)
|
|
@@ -204,6 +200,8 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
db.Dispose();
|
|
|
readdb.Dispose();
|
|
|
+ mpdb.Dispose();
|
|
|
+ mpdb2.Dispose();
|
|
|
}
|
|
|
|
|
|
public decimal GetTradeAmt(int UserId, string TradeMonth)
|