|
@@ -1000,65 +1000,98 @@ namespace MySystem.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ //补推荐奖励
|
|
|
|
+ public string AddDirectPrice(int oid = 0)
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ List<int> uids = new List<int>(); //领取过的下单创客
|
|
|
|
+ IQueryable<Orders> orders = db.Orders.Where(m => m.Status > 1 && m.UserId > 1 && m.TotalPrice % 600 == 0 && m.Sort == 0);
|
|
|
|
+ if(oid > 0)
|
|
|
|
+ {
|
|
|
|
+ orders = orders.Where(m => m.Id == oid);
|
|
|
|
+ }
|
|
|
|
+ foreach (Orders order in orders.ToList())
|
|
|
|
+ {
|
|
|
|
+ if(!uids.Contains(order.UserId))
|
|
|
|
+ {
|
|
|
|
+ bool checkPrize = db.UserAccountRecord.Any(m => m.QueryCount == oid && m.ChangeType == 112);
|
|
|
|
+ if(checkPrize)
|
|
|
|
+ {
|
|
|
|
+ uids.Add(order.UserId);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == oid) ?? new OrderProduct();
|
|
|
|
+ if (pro.ProductId == 10 || pro.ProductId == 11)
|
|
|
|
+ {
|
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
|
|
|
|
+ if (user != null)
|
|
|
|
+ {
|
|
|
|
+ bool directPrize = false; //直推奖标记
|
|
|
|
+ int ParentUserId = user.ParentUserId;
|
|
|
|
+ List<int> proids = new List<int>();
|
|
|
|
+ proids.Add(10);
|
|
|
|
+ proids.Add(11);
|
|
|
|
+ while (ParentUserId > 0)
|
|
|
|
+ {
|
|
|
|
+ Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
|
|
|
|
+ int machineCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.PosSnType == 0); //判断是否拥有3台购买机
|
|
|
|
+ int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
|
+ int couponCount = db.PosCoupons.Count(m => m.UserId == ParentUserId && m.IsUse == 0); //判断是否拥有3张券
|
|
|
|
+ if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
|
|
|
|
+ {
|
|
|
|
+ function.WriteLog("满足条件", "推荐下单奖励监控日志");
|
|
|
|
+ if (puser.LeaderLevel == 0) // 非盟主直推奖励,每个创客第一次下单,上级可得
|
|
|
|
+ {
|
|
|
|
+ List<int> oids = new List<int>();
|
|
|
|
+ var orderpros = db.OrderProduct.Select(m => new { m.OrderId, m.UserId, m.ProductId }).Where(m => m.UserId == order.UserId && proids.Contains(m.ProductId)).ToList();
|
|
|
|
+ foreach (var orderpro in orderpros)
|
|
|
|
+ {
|
|
|
|
+ oids.Add(orderpro.OrderId);
|
|
|
|
+ }
|
|
|
|
+ bool check = db.Orders.Any(m => oids.Contains(m.Id) && m.Status > 0);
|
|
|
|
+ if (check)
|
|
|
|
+ {
|
|
|
|
+ // AlipayPayBack2Service.Instance.DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
|
|
|
|
+ function.WriteLog(order.Id + "," + ParentUserId + "," + pro.ProductCount, "没发的推荐奖励");
|
|
|
|
+ directPrize = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // 盟主直推奖励,可以每次下单获得
|
|
|
|
+ // AlipayPayBack2Service.Instance.DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
|
|
|
|
+ function.WriteLog(order.Id + "," + ParentUserId + "," + pro.ProductCount + "--盟主", "没发的推荐奖励");
|
|
|
|
+ directPrize = true;
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
- //重置交易额,重置分润(直营)
|
|
|
|
- // /home/resetProfit?uid=120687&m=2022-06&bid=1
|
|
|
|
- // public string resetProfit(int uid, string m, int bid)
|
|
|
|
- // {
|
|
|
|
- // string result = "";
|
|
|
|
- // OtherMySqlConn.connstr = "server=47.109.31.237;port=3306;user=KxsMainServer2;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer2;charset=utf8;";
|
|
|
|
- // DateTime start = DateTime.Parse(m + "-01 00:00:00");
|
|
|
|
- // DateTime end = start.AddMonths(1);
|
|
|
|
- // decimal ProfitAmt = 0;
|
|
|
|
- // while(start < end)
|
|
|
|
- // {
|
|
|
|
- // DateTime endDay = start.AddDays(1);
|
|
|
|
- // DataTable dt = OtherMySqlConn.dtable("select sum(HelpDirectTradeAmt) as HelpDirectTradeAmt,sum(NotHelpDirectTradeAmt) as NotHelpDirectTradeAmt from TradeDaySummary where UserId=" + uid + " and TradeDate='" + start.ToString("yyyyMMdd") + "' and SeoTitle='self' and BrandId=" + bid);
|
|
|
|
- // if(dt.Rows.Count > 0)
|
|
|
|
- // {
|
|
|
|
- // decimal HelpDirectTradeAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["HelpDirectTradeAmt"].ToString()));
|
|
|
|
- // decimal NotHelpDirectTradeAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["NotHelpDirectTradeAmt"].ToString()));
|
|
|
|
- // result += "扶持期:" + HelpDirectTradeAmt + ",稳定期:" + NotHelpDirectTradeAmt + ";\n";
|
|
|
|
- // dt = OtherMySqlConn.dtable("select sum(if(MerHelpFlag=1,TradeAmount,0)) as HelpAmt,sum(if(MerHelpFlag=0,TradeAmount,0)) as NotHelpAmt from TradeRecord where CreateDate>='" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and CreateDate<'" + endDay.ToString("yyyy-MM-dd HH:mm:ss") + "' and UserId=" + uid + " and BrandId=" + bid);
|
|
|
|
- // if(dt.Rows.Count > 0)
|
|
|
|
- // {
|
|
|
|
- // decimal HelpAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["HelpAmt"].ToString()));
|
|
|
|
- // decimal NotHelpAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["NotHelpAmt"].ToString()));
|
|
|
|
- // result += "update TradeDaySummary set HelpDirectTradeAmt=" + HelpAmt + ",NotHelpDirectTradeAmt=" + NotHelpAmt + " where UserId=" + uid + " and TradeDate='" + start.ToString("yyyyMMdd") + "' and SeoTitle='self' and BrandId=" + bid + ";\n\n";
|
|
|
|
- // dt = OtherMySqlConn.dtable("select UserLevel from Users where Id=" + uid + "");
|
|
|
|
- // if(dt.Rows.Count > 0)
|
|
|
|
- // {
|
|
|
|
- // int UserLevel = int.Parse(function.CheckInt(dt.Rows[0]["UserLevel"].ToString()));
|
|
|
|
- // dt = OtherMySqlConn.dtable("select Rank from UserRankWhite where Id=" + uid + "");
|
|
|
|
- // if(dt.Rows.Count > 0)
|
|
|
|
- // {
|
|
|
|
- // UserLevel = int.Parse(function.CheckInt(dt.Rows[0]["Rank"].ToString()));
|
|
|
|
- // }
|
|
|
|
- // int LevelKindId = ProfitHelperV2.Instance.GetLevelKindId(bid, 1, 1);
|
|
|
|
- // ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel) ?? new ProfitObjectLevels();
|
|
|
|
- // ProfitAmt += HelpAmt * objlevel.Percents;
|
|
|
|
- // LevelKindId = ProfitHelperV2.Instance.GetLevelKindId(bid, 0, 1);
|
|
|
|
- // objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel) ?? new ProfitObjectLevels();
|
|
|
|
- // ProfitAmt += NotHelpAmt * objlevel.Percents;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // start = start.AddDays(1);
|
|
|
|
- // }
|
|
|
|
- // DataTable dt2 = OtherMySqlConn.dtable("select Id,ProfitAmount from ProfitRecord where UserId=" + uid + " and SeoTitle='" + m.Replace("-", "") + "' and DirectFlag=1 and BrandId=" + bid);
|
|
|
|
- // if(dt2.Rows.Count > 0)
|
|
|
|
- // {
|
|
|
|
- // int Id = int.Parse(function.CheckInt(dt2.Rows[0]["Id"].ToString()));
|
|
|
|
- // decimal ProfitAmount = decimal.Parse(function.CheckNum(dt2.Rows[0]["ProfitAmount"].ToString()));
|
|
|
|
- // result += "当前分润:" + ProfitAmount + ";\n";
|
|
|
|
- // if(ProfitAmount != ProfitAmt)
|
|
|
|
- // {
|
|
|
|
- // result += "update ProfitRecord set ProfitAmount=" + ProfitAmt + " where UserId=" + uid + " and SeoTitle='" + m.Replace("-", "") + "' and DirectFlag=1 and BrandId=" + bid + ";\n";
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // OtherMySqlConn.connstr = "";
|
|
|
|
- // return result;
|
|
|
|
- // }
|
|
|
|
|
|
+ //推荐下单上级获得30天的机具循环天数
|
|
|
|
+ var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null).ToList();
|
|
|
|
+ foreach (var subPos in posList)
|
|
|
|
+ {
|
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
|
|
|
|
+ if (pos != null)
|
|
|
|
+ {
|
|
|
|
+ pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ if(directPrize)
|
|
|
|
+ {
|
|
|
|
+ ParentUserId = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ParentUserId = puser.ParentUserId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "ok";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|