Procházet zdrojové kódy

wifi交易分存量和增量

lcl před 1 rokem
rodič
revize
3d41377586

+ 100 - 0
AppStart/Helper/SycnSpServer/SycnSpTradeWifiService.cs

@@ -131,6 +131,14 @@ namespace MySystem
                                 {
                                     StartMonth = StartMonth.AddMonths(1);
                                     StatTrade(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                                    if (pos.BindingTime < DateTime.Now.AddMonths(-9))
+                                    {
+                                        StatTradeBefore(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                                    }
+                                    else
+                                    {
+                                        StatTradeAfter(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                                    }
                                 }
                             }
 
@@ -222,5 +230,97 @@ namespace MySystem
                 }
             }
         }
+
+        public void StatTradeBefore(PxcModels.WebCMSEntities db, int UserId, int BrandId, string TradeMonth, decimal TradeAmount)
+        {
+            PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new PxcModels.Users();
+            string ParentNav = user.ParentNav;
+            string TradeDate = TradeMonth + "01";
+            ParentNav += "," + UserId + ",";
+
+            PxcModels.TradeDaySummaryBefore selfStat = db.TradeDaySummaryBefore.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "self");
+            if (selfStat == null)
+            {
+                selfStat = db.TradeDaySummaryBefore.Add(new PxcModels.TradeDaySummaryBefore()
+                {
+                    UserId = UserId,
+                    TradeMonth = TradeMonth,
+                    TradeDate = TradeDate,
+                    BrandId = BrandId,
+                    SeoTitle = "self",
+                }).Entity;
+                db.SaveChanges();
+            }
+            selfStat.HelpDirectTradeAmt += TradeAmount;
+            if (!string.IsNullOrEmpty(ParentNav))
+            {
+                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                foreach (string NavUserIdString in ParentNavList)
+                {
+                    int NavUserId = int.Parse(NavUserIdString);
+                    PxcModels.TradeDaySummaryBefore teamStat = db.TradeDaySummaryBefore.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "team");
+                    if (teamStat == null)
+                    {
+                        teamStat = db.TradeDaySummaryBefore.Add(new PxcModels.TradeDaySummaryBefore()
+                        {
+                            UserId = NavUserId,
+                            TradeMonth = TradeMonth,
+                            TradeDate = TradeDate,
+                            BrandId = BrandId,
+                            SeoTitle = "team",
+                        }).Entity;
+                        db.SaveChanges();
+                    }
+                    teamStat.HelpNonDirectTradeAmt += TradeAmount;
+                    db.SaveChanges();
+                }
+            }
+        }
+
+        public void StatTradeAfter(PxcModels.WebCMSEntities db, int UserId, int BrandId, string TradeMonth, decimal TradeAmount)
+        {
+            PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new PxcModels.Users();
+            string ParentNav = user.ParentNav;
+            string TradeDate = TradeMonth + "01";
+            ParentNav += "," + UserId + ",";
+
+            PxcModels.TradeDaySummaryAfter selfStat = db.TradeDaySummaryAfter.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "self");
+            if (selfStat == null)
+            {
+                selfStat = db.TradeDaySummaryAfter.Add(new PxcModels.TradeDaySummaryAfter()
+                {
+                    UserId = UserId,
+                    TradeMonth = TradeMonth,
+                    TradeDate = TradeDate,
+                    BrandId = BrandId,
+                    SeoTitle = "self",
+                }).Entity;
+                db.SaveChanges();
+            }
+            selfStat.HelpDirectTradeAmt += TradeAmount;
+            if (!string.IsNullOrEmpty(ParentNav))
+            {
+                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                foreach (string NavUserIdString in ParentNavList)
+                {
+                    int NavUserId = int.Parse(NavUserIdString);
+                    PxcModels.TradeDaySummaryAfter teamStat = db.TradeDaySummaryAfter.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "team");
+                    if (teamStat == null)
+                    {
+                        teamStat = db.TradeDaySummaryAfter.Add(new PxcModels.TradeDaySummaryAfter()
+                        {
+                            UserId = NavUserId,
+                            TradeMonth = TradeMonth,
+                            TradeDate = TradeDate,
+                            BrandId = BrandId,
+                            SeoTitle = "team",
+                        }).Entity;
+                        db.SaveChanges();
+                    }
+                    teamStat.HelpNonDirectTradeAmt += TradeAmount;
+                    db.SaveChanges();
+                }
+            }
+        }
     }
 }