|
@@ -20,6 +20,7 @@ namespace MySystem
|
|
|
public void Recommend2()
|
|
|
{
|
|
|
DateTime check = DateTime.Parse("2023-10-01 00:00:00");
|
|
|
+ DateTime start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
|
|
|
string TradeMonth = DateTime.Now.ToString("yyyyMM");
|
|
|
List<int> ProductIds = new List<int>();
|
|
|
ProductIds.Add(10);
|
|
@@ -36,8 +37,55 @@ namespace MySystem
|
|
|
List<int> uids = db.Orders.Where(m => m.PayDate >= check && m.Status > 0 && m.Sort == 0 && ProductIds.Contains(m.ProductId)).ToList().Select(m => m.UserId).Distinct().ToList();
|
|
|
foreach(int uid in uids)
|
|
|
{
|
|
|
-
|
|
|
+ int ActCount = 0;
|
|
|
+ if(ActCount == 0)
|
|
|
+ {
|
|
|
+ if(db.UserTradeMonthSummary.Any(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team" && m.BrandId != 14))
|
|
|
+ {
|
|
|
+ ActCount += db.UserTradeMonthSummary.Where(m => m.UserId == uid && m.TradeMonth == TradeMonth && m.SeoTitle == "team" && m.BrandId != 14).Sum(m => m.ActiveBuddyMerStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ActCount == 0)
|
|
|
+ {
|
|
|
+ MpMainModels.WebCMSEntities mpdb = new MpMainModels.WebCMSEntities();
|
|
|
+ ActCount += mpdb.MerchantDepositOrder.Count(m => m.UserId == uid && m.CreateDate >= start && 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.Status > 0 && m.UserId == uid);
|
|
|
+ mpdb.Dispose();
|
|
|
+ }
|
|
|
+ if(ActCount > 0)
|
|
|
+ {
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == uid);
|
|
|
+ if(user != null)
|
|
|
+ {
|
|
|
+ string ParentNav = user.ParentNav;
|
|
|
+ if(!string.IsNullOrEmpty(ParentNav))
|
|
|
+ {
|
|
|
+ string[] ParentNavList = ParentNav.Replace(",,", ",").Trim(',').Split(',');
|
|
|
+ foreach(string UserIdString in ParentNavList)
|
|
|
+ {
|
|
|
+ int UserId = int.Parse(UserIdString);
|
|
|
+ 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.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
}
|