|
|
@@ -1,116 +1,116 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Data;
|
|
|
-using MySystem.PxcModels;
|
|
|
-using Library;
|
|
|
-using LitJson;
|
|
|
+// using System;
|
|
|
+// using System.Collections.Generic;
|
|
|
+// using System.Linq;
|
|
|
+// using System.Data;
|
|
|
+// using MySystem.PxcModels;
|
|
|
+// using Library;
|
|
|
+// using LitJson;
|
|
|
|
|
|
-namespace MySystem
|
|
|
-{
|
|
|
- public class RecommandKingHelper
|
|
|
- {
|
|
|
- public readonly static RecommandKingHelper Instance = new RecommandKingHelper();
|
|
|
- private RecommandKingHelper()
|
|
|
- { }
|
|
|
+// namespace MySystem
|
|
|
+// {
|
|
|
+// public class RecommandKingHelper
|
|
|
+// {
|
|
|
+// public readonly static RecommandKingHelper Instance = new RecommandKingHelper();
|
|
|
+// private RecommandKingHelper()
|
|
|
+// { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public void Recommend2()
|
|
|
- {
|
|
|
- DateTime start = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01 00:00:00");
|
|
|
- DateTime end = start.AddMonths(1);
|
|
|
- string TradeMonth = start.ToString("yyyyMM");
|
|
|
- List<RecommendPriceList> userdic = new List<RecommendPriceList>();
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
- //判断当月是否下单
|
|
|
- bool checkOrder = db.Orders.Any(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66);
|
|
|
- if(checkOrder)
|
|
|
- {
|
|
|
- //统计当月下单名单
|
|
|
- List<int> uids = db.Orders.Where(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66).ToList().Select(m => m.UserId).Distinct().ToList();
|
|
|
- foreach(int uid in uids)
|
|
|
- {
|
|
|
- int ActCount = 0;
|
|
|
- List<Users> users = db.Users.Where(m => m.ParentUserId == uid && m.AuthFlag == 1).ToList();
|
|
|
- foreach(Users user in users)
|
|
|
- {
|
|
|
- int BeforeActCount = db.PosMachinesTwo.Count(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime < start);
|
|
|
- if(BeforeActCount == 0)
|
|
|
- {
|
|
|
- //查询当前创客所属机具
|
|
|
- var posList = db.PosMachinesTwo.Select(m => new { m.ActivationState, m.ActivationTime, m.BuyUserId, m.BindMerchantId }).Where(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime >= start && m.ActivationTime < end).ToList();
|
|
|
- if(posList.Count > 0 || (user.AuthDate >= start && user.AuthDate < end))
|
|
|
- {
|
|
|
- int actPosCount = 0; //激活机具数量
|
|
|
- foreach(var pos in posList)
|
|
|
- {
|
|
|
- decimal tradeAmt = 0; //机具总交易额
|
|
|
- //查询机具交易额
|
|
|
- bool checkTrade = db.PosMerchantTradeSummay.Any(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth);
|
|
|
- if(checkTrade)
|
|
|
- {
|
|
|
- tradeAmt += db.PosMerchantTradeSummay.Where(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
|
|
|
- }
|
|
|
- if(tradeAmt >= 30000)
|
|
|
- {
|
|
|
- actPosCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if(actPosCount >= 2)
|
|
|
- {
|
|
|
- ActCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- RecommendPriceList item = userdic.FirstOrDefault(m => m.UserId == uid);
|
|
|
- if(item != null)
|
|
|
- {
|
|
|
- item.ActCount += ActCount;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- userdic.Add(new RecommendPriceList()
|
|
|
- {
|
|
|
- UserId = uid,
|
|
|
- ActCount = ActCount,
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- string html = "<table>";
|
|
|
- html += "<tr>";
|
|
|
- html += "<td>创客编号</td>";
|
|
|
- html += "<td>创客姓名</td>";
|
|
|
- html += "<td>推荐总数</td>";
|
|
|
- html += "<td>成功推荐数</td>";
|
|
|
- html += "<td>是否达标</td>";
|
|
|
- html += "</tr>";
|
|
|
- foreach(RecommendPriceList item in userdic)
|
|
|
- {
|
|
|
- string status = "未达标";
|
|
|
- if(item.ActCount >= 6)
|
|
|
- {
|
|
|
- status = "已达标";
|
|
|
- }
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == item.UserId) ?? new Users();
|
|
|
- int subCount = db.Users.Count(m => m.ParentUserId == item.UserId && m.AuthFlag == 1 && m.AuthDate >= start && m.AuthDate < end);
|
|
|
- html += "<tr>";
|
|
|
- html += "<td>" + user.MakerCode + "</td>"; //创客编号
|
|
|
- html += "<td>" + user.RealName + "</td>"; //创客姓名
|
|
|
- html += "<td>" + subCount + "</td>"; //推荐总数
|
|
|
- html += "<td>" + item.ActCount + "</td>"; //成功推荐数
|
|
|
- html += "<td>" + status + "</td>"; //是否达标
|
|
|
- html += "</tr>";
|
|
|
- }
|
|
|
- html += "</table>";
|
|
|
- db.Dispose();
|
|
|
- function.WritePage("/wwwroot/EveryMonthExcel/" + DateTime.Now.AddMonths(-1).ToString("yyyyMM") + "/", "Recommend.html", html);
|
|
|
- }
|
|
|
+// public void Recommend2()
|
|
|
+// {
|
|
|
+// DateTime start = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01 00:00:00");
|
|
|
+// DateTime end = start.AddMonths(1);
|
|
|
+// string TradeMonth = start.ToString("yyyyMM");
|
|
|
+// List<RecommendPriceList> userdic = new List<RecommendPriceList>();
|
|
|
+// WebCMSEntities db = new WebCMSEntities();
|
|
|
+// //判断当月是否下单
|
|
|
+// bool checkOrder = db.Orders.Any(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66);
|
|
|
+// if(checkOrder)
|
|
|
+// {
|
|
|
+// //统计当月下单名单
|
|
|
+// List<int> uids = db.Orders.Where(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66).ToList().Select(m => m.UserId).Distinct().ToList();
|
|
|
+// foreach(int uid in uids)
|
|
|
+// {
|
|
|
+// int ActCount = 0;
|
|
|
+// List<Users> users = db.Users.Where(m => m.ParentUserId == uid && m.AuthFlag == 1).ToList();
|
|
|
+// foreach(Users user in users)
|
|
|
+// {
|
|
|
+// int BeforeActCount = db.PosMachinesTwo.Count(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime < start);
|
|
|
+// if(BeforeActCount == 0)
|
|
|
+// {
|
|
|
+// //查询当前创客所属机具
|
|
|
+// var posList = db.PosMachinesTwo.Select(m => new { m.ActivationState, m.ActivationTime, m.BuyUserId, m.BindMerchantId }).Where(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime >= start && m.ActivationTime < end).ToList();
|
|
|
+// if(posList.Count > 0 || (user.AuthDate >= start && user.AuthDate < end))
|
|
|
+// {
|
|
|
+// int actPosCount = 0; //激活机具数量
|
|
|
+// foreach(var pos in posList)
|
|
|
+// {
|
|
|
+// decimal tradeAmt = 0; //机具总交易额
|
|
|
+// //查询机具交易额
|
|
|
+// bool checkTrade = db.PosMerchantTradeSummay.Any(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth);
|
|
|
+// if(checkTrade)
|
|
|
+// {
|
|
|
+// tradeAmt += db.PosMerchantTradeSummay.Where(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
|
|
|
+// }
|
|
|
+// if(tradeAmt >= 30000)
|
|
|
+// {
|
|
|
+// actPosCount += 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(actPosCount >= 2)
|
|
|
+// {
|
|
|
+// ActCount += 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// RecommendPriceList item = userdic.FirstOrDefault(m => m.UserId == uid);
|
|
|
+// if(item != null)
|
|
|
+// {
|
|
|
+// item.ActCount += ActCount;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// userdic.Add(new RecommendPriceList()
|
|
|
+// {
|
|
|
+// UserId = uid,
|
|
|
+// ActCount = ActCount,
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// string html = "<table>";
|
|
|
+// html += "<tr>";
|
|
|
+// html += "<td>创客编号</td>";
|
|
|
+// html += "<td>创客姓名</td>";
|
|
|
+// html += "<td>推荐总数</td>";
|
|
|
+// html += "<td>成功推荐数</td>";
|
|
|
+// html += "<td>是否达标</td>";
|
|
|
+// html += "</tr>";
|
|
|
+// foreach(RecommendPriceList item in userdic)
|
|
|
+// {
|
|
|
+// string status = "未达标";
|
|
|
+// if(item.ActCount >= 6)
|
|
|
+// {
|
|
|
+// status = "已达标";
|
|
|
+// }
|
|
|
+// Users user = db.Users.FirstOrDefault(m => m.Id == item.UserId) ?? new Users();
|
|
|
+// int subCount = db.Users.Count(m => m.ParentUserId == item.UserId && m.AuthFlag == 1 && m.AuthDate >= start && m.AuthDate < end);
|
|
|
+// html += "<tr>";
|
|
|
+// html += "<td>" + user.MakerCode + "</td>"; //创客编号
|
|
|
+// html += "<td>" + user.RealName + "</td>"; //创客姓名
|
|
|
+// html += "<td>" + subCount + "</td>"; //推荐总数
|
|
|
+// html += "<td>" + item.ActCount + "</td>"; //成功推荐数
|
|
|
+// html += "<td>" + status + "</td>"; //是否达标
|
|
|
+// html += "</tr>";
|
|
|
+// }
|
|
|
+// html += "</table>";
|
|
|
+// db.Dispose();
|
|
|
+// function.WritePage("/wwwroot/EveryMonthExcel/" + DateTime.Now.AddMonths(-1).ToString("yyyyMM") + "/", "Recommend.html", html);
|
|
|
+// }
|
|
|
|
|
|
- #endregion
|
|
|
+// #endregion
|
|
|
|
|
|
- }
|
|
|
-}
|
|
|
+// }
|
|
|
+// }
|