|
@@ -206,13 +206,13 @@ namespace MySystem
|
|
|
//充值盟主储备金
|
|
|
OpReserve(db, order, order.UserId, order.TotalPrice, 1);
|
|
|
Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
|
|
|
- OperateReserveBackFor(db, user.ParentUserId, order.TotalPrice);
|
|
|
+ if(pro.ProductId == 27) OperateReserveBackFor(db, user.Id, order.TotalPrice);
|
|
|
}
|
|
|
if (pro.ProductId == 28) //购买小盟主,给上级大盟主返储备金
|
|
|
{
|
|
|
LeaderBack(db, order);
|
|
|
Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
|
|
|
- OperateReserveBackFor(db, user.ParentUserId, order.TotalPrice);
|
|
|
+ OperateReserveBackFor(db, user.Id, order.TotalPrice);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -268,12 +268,16 @@ namespace MySystem
|
|
|
{
|
|
|
if(couponIds.Count > 0)
|
|
|
{
|
|
|
+ UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == user.Id) ?? new UserAccount();
|
|
|
foreach(int couponId in couponIds)
|
|
|
{
|
|
|
PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
|
|
|
if(coupon != null)
|
|
|
{
|
|
|
- coupon.LeaderUserId = user.Id;
|
|
|
+ if(acccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
+ {
|
|
|
+ coupon.LeaderUserId = user.Id;
|
|
|
+ }
|
|
|
coupon.OpId = user.Id;
|
|
|
}
|
|
|
}
|
|
@@ -294,17 +298,20 @@ namespace MySystem
|
|
|
{
|
|
|
if(couponIds.Count > 0)
|
|
|
{
|
|
|
+ UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
|
|
|
foreach(int couponId in couponIds)
|
|
|
{
|
|
|
PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
|
|
|
if(coupon != null)
|
|
|
{
|
|
|
- coupon.LeaderUserId = user.Id;
|
|
|
+ if(acccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
+ {
|
|
|
+ coupon.LeaderUserId = user.Id;
|
|
|
+ }
|
|
|
coupon.OpId = puser.Id;
|
|
|
}
|
|
|
}
|
|
|
db.SaveChanges();
|
|
|
- UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
|
|
|
if(acccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
{
|
|
|
//扣减备用金
|
|
@@ -350,10 +357,11 @@ namespace MySystem
|
|
|
{
|
|
|
if(couponIds.Count > 0)
|
|
|
{
|
|
|
+ UserAccount pacccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
|
|
|
foreach(int couponId in couponIds)
|
|
|
{
|
|
|
PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
|
|
|
- if(coupon != null)
|
|
|
+ if(coupon != null && pacccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
{
|
|
|
coupon.LeaderUserId = puser.Id;
|
|
|
}
|
|
@@ -382,35 +390,39 @@ namespace MySystem
|
|
|
{
|
|
|
//寻找最近储蓄金充足的大盟主及最近运营中心额度大于0的运营中心(含自身)
|
|
|
int PUserId = user.Id;
|
|
|
- bool LeaderFlag = true;
|
|
|
+ int LeaderFlag = 0;
|
|
|
bool OperateFlag = true;
|
|
|
while(PUserId > 0)
|
|
|
{
|
|
|
Users puser = db.Users.FirstOrDefault(m => m.Id == PUserId);
|
|
|
if(puser != null)
|
|
|
{
|
|
|
- if(puser.LeaderLevel == 2 && LeaderFlag == true) //大盟主
|
|
|
+ if(puser.LeaderLevel > 0 && puser.LeaderLevel > LeaderFlag && LeaderFlag < 2) //大盟主
|
|
|
{
|
|
|
if(couponIds.Count > 0)
|
|
|
{
|
|
|
- foreach(int couponId in couponIds)
|
|
|
+ if(puser.LeaderLevel == 2)
|
|
|
{
|
|
|
- PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
|
|
|
- if(coupon != null)
|
|
|
+ UserAccount pacccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
|
|
|
+ foreach(int couponId in couponIds)
|
|
|
{
|
|
|
- coupon.LeaderUserId = puser.Id;
|
|
|
+ PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
|
|
|
+ if(coupon != null && pacccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
+ {
|
|
|
+ coupon.LeaderUserId = puser.Id;
|
|
|
+ }
|
|
|
}
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
- UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
|
|
|
+ UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
|
|
|
if(acccount.LeaderReserve >= 400 * pro.ProductCount)
|
|
|
{
|
|
|
//扣减备用金
|
|
|
- OpReserve(db, order, order.UserId, 400 * pro.ProductCount, 2, 0, "商城购机");
|
|
|
+ OpReserve(db, order, puser.Id, 400 * pro.ProductCount, 2, 0, "商城购机");
|
|
|
//返回到余额
|
|
|
- OpLeaderAccount(db, order, order.UserId, 400, pro.ProductCount);
|
|
|
+ OpLeaderAccount(db, order, puser.Id, 400, pro.ProductCount);
|
|
|
+ LeaderFlag = puser.LeaderLevel;
|
|
|
}
|
|
|
- LeaderFlag = false;
|
|
|
}
|
|
|
}
|
|
|
if(puser.UserType == 1 && OperateFlag == true) //运营中心
|
|
@@ -500,7 +512,7 @@ namespace MySystem
|
|
|
OpAccount(db, order, puser.Id, 100, pro.ProductCount);
|
|
|
buyPrize = true;
|
|
|
}
|
|
|
- if(acccount.LeaderReserve >= 400 * pro.ProductCount && leaderFlag == 0)
|
|
|
+ if(acccount.LeaderReserve >= 400 * pro.ProductCount && puser.LeaderLevel > leaderFlag && leaderFlag < 2)
|
|
|
{
|
|
|
//扣减备用金
|
|
|
OpReserve(db, order, puser.Id, 400 * pro.ProductCount, 2, order.UserId, "购机奖励");
|
|
@@ -611,15 +623,16 @@ namespace MySystem
|
|
|
{
|
|
|
OpReserve(db, order, LeaderUserId, order.TotalPrice, 2, 0, "推荐小盟主");
|
|
|
OpLeaderAccount(db, order, LeaderUserId, order.TotalPrice);
|
|
|
+ LeaderUserId = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- decimal LeaderReserve = account.LeaderReserve;
|
|
|
- OpReserve(db, order, LeaderUserId, LeaderReserve, 2, 0, "推荐小盟主");
|
|
|
- OpLeaderAccount(db, order, LeaderUserId, LeaderReserve);
|
|
|
+ LeaderUserId = user.ParentUserId;
|
|
|
+ // decimal LeaderReserve = account.LeaderReserve;
|
|
|
+ // OpReserve(db, order, LeaderUserId, LeaderReserve, 2, 0, "推荐小盟主");
|
|
|
+ // OpLeaderAccount(db, order, LeaderUserId, LeaderReserve);
|
|
|
}
|
|
|
}
|
|
|
- LeaderUserId = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -895,7 +908,15 @@ namespace MySystem
|
|
|
}
|
|
|
db.Dispose();
|
|
|
}
|
|
|
- public void OperateAmountChange(OpModels.WebCMSEntities db, int UserId, decimal Money, int OperateType, int AmountType, string Remark = "")
|
|
|
+ public void ActReserveBack(int UserId, decimal OpReserve1, decimal OpReserve2, decimal OpReserve3)
|
|
|
+ {
|
|
|
+ OpModels.WebCMSEntities db = new OpModels.WebCMSEntities();
|
|
|
+ if(OpReserve1 > 0) OperateAmountChange(db, UserId, OpReserve1, 1, 1, "机具激活", true);
|
|
|
+ if(OpReserve2 > 0) OperateAmountChange(db, UserId, OpReserve1, 1, 2, "机具激活", true);
|
|
|
+ if(OpReserve3 > 0) OperateAmountChange(db, UserId, OpReserve1, 1, 3, "机具激活", true);
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+ public void OperateAmountChange(OpModels.WebCMSEntities db, int UserId, decimal Money, int OperateType, int AmountType, string Remark = "", bool record = false)
|
|
|
{
|
|
|
OpModels.UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
if (account == null)
|
|
@@ -951,18 +972,21 @@ namespace MySystem
|
|
|
AfterAmount = account.ValidAmount;
|
|
|
}
|
|
|
}
|
|
|
- OpModels.AmountRecord add = db.AmountRecord.Add(new OpModels.AmountRecord()
|
|
|
+ if(record)
|
|
|
{
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- OperateType = OperateType,
|
|
|
- AfterAmount = AfterAmount,
|
|
|
- BeforeAmount = BeforeAmount,
|
|
|
- UseAmount = Money,
|
|
|
- UserId = UserId,
|
|
|
- SeoDescription = Remark,
|
|
|
- Version = AmountType,
|
|
|
- }).Entity;
|
|
|
+ OpModels.AmountRecord add = db.AmountRecord.Add(new OpModels.AmountRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ OperateType = OperateType,
|
|
|
+ AfterAmount = AfterAmount,
|
|
|
+ BeforeAmount = BeforeAmount,
|
|
|
+ UseAmount = Money,
|
|
|
+ UserId = UserId,
|
|
|
+ SeoDescription = Remark,
|
|
|
+ Version = AmountType,
|
|
|
+ }).Entity;
|
|
|
+ }
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
|