|
@@ -334,7 +334,7 @@ namespace MySystem
|
|
{
|
|
{
|
|
// while(true)
|
|
// while(true)
|
|
// {
|
|
// {
|
|
- // if(DateTime.Now.Day == 1 && DateTime.Now.Hour > 0)
|
|
|
|
|
|
+ // if(DateTime.Now.Day == 1 && DateTime.Now.Hour > 2 && DateTime.Now.Hour < 5)
|
|
// {
|
|
// {
|
|
DoProfit();
|
|
DoProfit();
|
|
// Thread.Sleep(600000);
|
|
// Thread.Sleep(600000);
|
|
@@ -349,7 +349,13 @@ namespace MySystem
|
|
//分润算法
|
|
//分润算法
|
|
public void DoProfit()
|
|
public void DoProfit()
|
|
{
|
|
{
|
|
- string TradeMonth = DateTime.Now.ToString("yyyyMM");
|
|
|
|
|
|
+ string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
|
|
+ string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + ".txt");
|
|
|
|
+ if(!string.IsNullOrEmpty(check))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ function.WritePage("/ProfitFlag/", TradeMonth + ".txt", DateTime.Now.ToString());
|
|
KxsMainModels.WebCMSEntities kxsdb = new KxsMainModels.WebCMSEntities();
|
|
KxsMainModels.WebCMSEntities kxsdb = new KxsMainModels.WebCMSEntities();
|
|
WebCMSEntities dbnew = new WebCMSEntities();
|
|
WebCMSEntities dbnew = new WebCMSEntities();
|
|
DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount) from UserAmountSummary where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId", MysqlConn.SqlConnStr);
|
|
DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount) from UserAmountSummary where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId", MysqlConn.SqlConnStr);
|
|
@@ -708,6 +714,7 @@ namespace MySystem
|
|
#region 分润算法
|
|
#region 分润算法
|
|
public List<ProfitResult> StartProft(decimal TotalAmount, int LevelKindId, List<ProfitUsers> users, bool IsActive = true)
|
|
public List<ProfitResult> StartProft(decimal TotalAmount, int LevelKindId, List<ProfitUsers> users, bool IsActive = true)
|
|
{
|
|
{
|
|
|
|
+ function.WriteLog("\n\nTotalAmount:" + TotalAmount + ";", "来客吧分润日志");
|
|
string Month = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
string Month = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
List<UserLevelSet> levels = db.UserLevelSet.ToList();
|
|
List<UserLevelSet> levels = db.UserLevelSet.ToList();
|
|
@@ -718,6 +725,13 @@ namespace MySystem
|
|
int maxLevel = obj.MaxLevel; //最大等级
|
|
int maxLevel = obj.MaxLevel; //最大等级
|
|
int maxFloor = obj.MaxFloor; //最大层级
|
|
int maxFloor = obj.MaxFloor; //最大层级
|
|
decimal diffLevelProfit = 0; //等级级差
|
|
decimal diffLevelProfit = 0; //等级级差
|
|
|
|
+ ProfitObjectLevels maxlevel = db.ProfitObjectLevels.FirstOrDefault(m => m.Id == 9) ?? new ProfitObjectLevels(); //获取最高等级参数
|
|
|
|
+ decimal maxPercent = IsActive ? maxlevel.DebitPercents : maxlevel.Percents;
|
|
|
|
+ function.WriteLog("maxPercent:" + maxPercent + ";", "来客吧分润日志");
|
|
|
|
+ decimal maxLevelProfit = TotalAmount * maxPercent;
|
|
|
|
+ function.WriteLog("maxLevelProfit:" + maxLevelProfit + ";", "来客吧分润日志");
|
|
|
|
+ maxLevelProfit = PublicFunction.NumberFormat(maxLevelProfit);
|
|
|
|
+ function.WriteLog("maxLevelProfit:" + maxLevelProfit + ";", "来客吧分润日志");
|
|
// decimal diffDiviProfit = 0; //分红级差
|
|
// decimal diffDiviProfit = 0; //分红级差
|
|
int curLevel = 0; //当前层级的会员等级
|
|
int curLevel = 0; //当前层级的会员等级
|
|
for (int curFloor = 1; curFloor <= users.Count; curFloor++)
|
|
for (int curFloor = 1; curFloor <= users.Count; curFloor++)
|
|
@@ -730,7 +744,7 @@ namespace MySystem
|
|
SubUser selfUser = GetUser(user.UserId, Month) ?? new SubUser();
|
|
SubUser selfUser = GetUser(user.UserId, Month) ?? new SubUser();
|
|
int UserLevel = selfUser.PreUserLevel > selfUser.UserLevel ? selfUser.PreUserLevel : selfUser.UserLevel; //当前会员等级
|
|
int UserLevel = selfUser.PreUserLevel > selfUser.UserLevel ? selfUser.PreUserLevel : selfUser.UserLevel; //当前会员等级
|
|
//判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
//判断当前创客是否有直推的激活机具,并且在活动时间内
|
|
- if (UserLevel == maxLevel && UserLevel == curLevel)
|
|
|
|
|
|
+ if (curLevel == maxLevel)
|
|
{
|
|
{
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -742,9 +756,12 @@ namespace MySystem
|
|
decimal getLevelProfit = 0; //等级分润
|
|
decimal getLevelProfit = 0; //等级分润
|
|
UserProfitSet profitSet = new UserProfitSet();
|
|
UserProfitSet profitSet = new UserProfitSet();
|
|
decimal profitPercent = IsActive ? objlevel.DebitPercents : objlevel.Percents;
|
|
decimal profitPercent = IsActive ? objlevel.DebitPercents : objlevel.Percents;
|
|
|
|
+ function.WriteLog("money:" + UserLevel + ":" + profitPercent + ";", "来客吧分润日志");
|
|
if (profitPercent > 0)
|
|
if (profitPercent > 0)
|
|
{
|
|
{
|
|
- getLevelProfit += TotalAmount * profitPercent;
|
|
|
|
|
|
+ decimal profitTmp = TotalAmount * profitPercent;
|
|
|
|
+ getLevelProfit += profitTmp;
|
|
|
|
+ function.WriteLog("money:" + UserLevel + ":" + profitTmp + ";", "来客吧分润日志");
|
|
}
|
|
}
|
|
decimal money = getLevelProfit;
|
|
decimal money = getLevelProfit;
|
|
getLevelProfit -= diffLevelProfit;
|
|
getLevelProfit -= diffLevelProfit;
|
|
@@ -758,16 +775,20 @@ namespace MySystem
|
|
{
|
|
{
|
|
UserId = user.UserId,
|
|
UserId = user.UserId,
|
|
UserNav = user.UserNav,
|
|
UserNav = user.UserNav,
|
|
- Money = getLevelProfit,
|
|
|
|
|
|
+ Money = PublicFunction.NumberFormat(getLevelProfit),
|
|
ProfitRate = profitSet.ProfitRate,
|
|
ProfitRate = profitSet.ProfitRate,
|
|
ProfitPercent = profitSet.ProfitPercent,
|
|
ProfitPercent = profitSet.ProfitPercent,
|
|
AddOrSubRate = profitSet.AddOrSubRate,
|
|
AddOrSubRate = profitSet.AddOrSubRate,
|
|
ProfitRateBase = profitSet.ProfitRateBase,
|
|
ProfitRateBase = profitSet.ProfitRateBase,
|
|
});
|
|
});
|
|
|
|
+ function.WriteLog("money:" + UserLevel + ":" + PublicFunction.NumberFormat(getLevelProfit) + ";", "来客吧分润日志");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- curLevel = UserLevel;
|
|
|
|
|
|
+ if(curLevel < UserLevel)
|
|
|
|
+ {
|
|
|
|
+ curLevel = UserLevel;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
db.Dispose();
|
|
db.Dispose();
|