|
|
@@ -48,12 +48,13 @@ namespace MySystem.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
- // 推荐王奖励
|
|
|
+ // 推荐王奖励666 // TODO:待完善
|
|
|
public string InvitePrize666(string month)
|
|
|
{
|
|
|
DateTime start = DateTime.Parse(month + "-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);
|
|
|
@@ -63,27 +64,73 @@ namespace MySystem.Controllers
|
|
|
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)
|
|
|
{
|
|
|
- decimal tradeAmt = 0; //机具总交易额
|
|
|
- int actPosCount = 0; //激活机具数量
|
|
|
- //查询当前创客所属机具
|
|
|
- var posList = db.PosMachinesTwo.Select(m => new { m.ActivationState, m.ActivationTime, m.BuyUserId, m.BindMerchantId }).Where(m => m.BuyUserId == uid && m.ActivationState == 1 && m.ActivationTime >= start && m.ActivationTime < end).ToList();
|
|
|
- if(posList.Count > 0)
|
|
|
+ int ActCount = 0;
|
|
|
+ List<Users> users = db.Users.Where(m => m.ParentUserId == uid && m.AuthFlag == 1 && m.AuthDate >= start).ToList();
|
|
|
+ foreach(Users user in users)
|
|
|
{
|
|
|
- actPosCount = posList.Count;
|
|
|
- foreach(var pos in posList)
|
|
|
+ int BeforeActCount = db.PosMachinesTwo.Count(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime < start);
|
|
|
+ if(BeforeActCount == 0)
|
|
|
{
|
|
|
- //查询机具交易额
|
|
|
- bool checkTrade = db.PosMerchantTradeSummay.Any(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth);
|
|
|
- if(checkTrade)
|
|
|
+ decimal tradeAmt = 0; //机具总交易额
|
|
|
+ int actPosCount = 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)
|
|
|
{
|
|
|
- tradeAmt = db.PosMerchantTradeSummay.Where(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
|
|
|
+ actPosCount = posList.Count;
|
|
|
+ foreach(var pos in posList)
|
|
|
+ {
|
|
|
+ //查询机具交易额
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ decimal AvgTradeAmount = tradeAmt / actPosCount;
|
|
|
+ if(AvgTradeAmount >= 30000 && actPosCount >= 3)
|
|
|
+ {
|
|
|
+ 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>";
|
|
|
+ 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);
|
|
|
+ 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();
|
|
|
- return "";
|
|
|
+ return html;
|
|
|
}
|
|
|
|
|
|
// 创客达标返600
|