|
|
@@ -212,7 +212,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0)
|
|
|
{
|
|
|
- pos.IsPurchase = 0;
|
|
|
+ // pos.IsPurchase = 0;
|
|
|
pos.ActivationState = 1;
|
|
|
pos.ActivationTime = DateTime.Now;
|
|
|
PosMerchantInfo mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
|
@@ -242,7 +242,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
pos.BuyUserId = user.Id;
|
|
|
if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0 && pos.BindingTime > DateTime.Now.AddDays(-30))
|
|
|
{
|
|
|
- pos.IsPurchase = 0;
|
|
|
+ // pos.IsPurchase = 0;
|
|
|
pos.ActivationState = 1;
|
|
|
pos.ActivationTime = DateTime.Now;
|
|
|
}
|
|
|
@@ -414,13 +414,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
if (pos.CreditTrade < 1000)
|
|
|
{
|
|
|
- pos.IsPurchase = 99;
|
|
|
+ // pos.IsPurchase = 99;
|
|
|
db.SaveChanges();
|
|
|
return "该机具贷记卡累计交易不足1000";
|
|
|
}
|
|
|
if (pos.CreditTrade >= 1000 && pos.ActivationState == 0)
|
|
|
{
|
|
|
- pos.IsPurchase = 0;
|
|
|
+ // pos.IsPurchase = 0;
|
|
|
pos.ActivationState = 1;
|
|
|
pos.ActivationTime = DateTime.Now;
|
|
|
PosMerchantInfo mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
|
@@ -448,13 +448,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
pos.UserId = user.Id;
|
|
|
pos.BuyUserId = user.Id;
|
|
|
- if (pos.CreditTrade < 1000)
|
|
|
+ // if (pos.CreditTrade < 1000)
|
|
|
+ // {
|
|
|
+ // pos.IsPurchase = 99;
|
|
|
+ // }
|
|
|
+ if (pos.CreditTrade >= 1000 && pos.ActivationState == 0)
|
|
|
{
|
|
|
- pos.IsPurchase = 99;
|
|
|
- }
|
|
|
- else if (pos.CreditTrade >= 1000 && pos.ActivationState == 0)
|
|
|
- {
|
|
|
- pos.IsPurchase = 0;
|
|
|
+ // pos.IsPurchase = 0;
|
|
|
pos.ActivationState = 1;
|
|
|
pos.ActivationTime = DateTime.Now;
|
|
|
}
|
|
|
@@ -561,10 +561,18 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
int GetUserId = user.Id;
|
|
|
ParentNav = user.ParentNav;
|
|
|
- int TopUserId = 0;
|
|
|
+ int TopUserId = 1;
|
|
|
if (!string.IsNullOrEmpty(ParentNav))
|
|
|
{
|
|
|
- TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
+ string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
+ if (ParentNavList.Length > 1)
|
|
|
+ {
|
|
|
+ TopUserId = int.Parse(ParentNavList[1]);
|
|
|
+ }
|
|
|
+ else if (ParentNavList.Length == 1)
|
|
|
+ {
|
|
|
+ TopUserId = int.Parse(ParentNavList[0]);
|
|
|
+ }
|
|
|
}
|
|
|
decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
|
if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5 || pos.BrandId == 6)
|
|
|
@@ -573,127 +581,137 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
if (ActPrize > 0)
|
|
|
{
|
|
|
- bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.RewardAmount != 40);
|
|
|
- if (!check)
|
|
|
+ if (ActPrize == 99)
|
|
|
{
|
|
|
- if (ActPrize == 99)
|
|
|
- {
|
|
|
- ActPrize = 100;
|
|
|
- }
|
|
|
- else if (ActPrize == 199)
|
|
|
- {
|
|
|
- ActPrize = 200;
|
|
|
- }
|
|
|
- else if (ActPrize == 299)
|
|
|
- {
|
|
|
- ActPrize = 300;
|
|
|
- }
|
|
|
- else if (ActPrize == 249)
|
|
|
- {
|
|
|
- ActPrize = 260;
|
|
|
- }
|
|
|
- Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
|
|
|
- db.ActiveReward.Add(new ActiveReward()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- UserId = GetUserId, //创客
|
|
|
- MerchantId = pos.BindMerchantId, //商户
|
|
|
- StandardDate = pos.ActivationTime, //达标日期
|
|
|
- RewardAmount = ActPrize, //奖励金额
|
|
|
- BrandId = pos.BrandId, //品牌
|
|
|
- UserNav = ParentNav, //创客父级
|
|
|
- DirectBuddyNo = merchant.UserId, //商户直属创客
|
|
|
- KqMerNo = merchant.KqMerNo, //渠道商户编号
|
|
|
- KqSnNo = pos.PosSn, //渠道SN号
|
|
|
- SnType = pos.PosSnType, //机具类型
|
|
|
- SnApplyUserId = pos.BuyUserId, //机具申请创客
|
|
|
- ActType = 0, //激活类型
|
|
|
- SnStoreId = pos.StoreId, //SN仓库
|
|
|
- RewardTips = "激活奖励", //奖励描述
|
|
|
- Remark = "激活奖励", //备注
|
|
|
- ActDate = pos.ActivationTime, //激活时间
|
|
|
- TopUserId = TopUserId, //顶级创客
|
|
|
- SeoTitle = machineUser.RealName,
|
|
|
- });
|
|
|
- db.SaveChanges();
|
|
|
- string IdBrand = GetUserId + "_" + pos.BrandId;
|
|
|
- UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
- if (userData == null)
|
|
|
+ ActPrize = 100;
|
|
|
+ }
|
|
|
+ else if (ActPrize == 199)
|
|
|
+ {
|
|
|
+ ActPrize = 200;
|
|
|
+ }
|
|
|
+ else if (ActPrize == 299)
|
|
|
+ {
|
|
|
+ ActPrize = 300;
|
|
|
+ }
|
|
|
+ else if (ActPrize == 249)
|
|
|
+ {
|
|
|
+ ActPrize = 260;
|
|
|
+ }
|
|
|
+ List<decimal> prizes = new List<decimal>();
|
|
|
+ prizes.Add(ActPrize);
|
|
|
+ if (pos.BrandId == 6 && pos.ActivationState == 1 && pos.CreditTrade >= 10000 && pos.BindingTime > DateTime.Now.AddDays(-60))
|
|
|
+ {
|
|
|
+ prizes.Add(40);
|
|
|
+ }
|
|
|
+ foreach(decimal prize in prizes)
|
|
|
+ {
|
|
|
+ int ChangeType = prize == 40 ? 12 : 0;
|
|
|
+ bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.RewardAmount == prize);
|
|
|
+ if (!check)
|
|
|
{
|
|
|
- userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
+ Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
|
|
|
+ db.ActiveReward.Add(new ActiveReward()
|
|
|
{
|
|
|
- IdBrand = IdBrand,
|
|
|
- }).Entity;
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ UserId = GetUserId, //创客
|
|
|
+ MerchantId = pos.BindMerchantId, //商户
|
|
|
+ StandardDate = pos.ActivationTime, //达标日期
|
|
|
+ RewardAmount = prize, //奖励金额
|
|
|
+ BrandId = pos.BrandId, //品牌
|
|
|
+ UserNav = ParentNav, //创客父级
|
|
|
+ DirectBuddyNo = merchant.UserId, //商户直属创客
|
|
|
+ KqMerNo = merchant.KqMerNo, //渠道商户编号
|
|
|
+ KqSnNo = pos.PosSn, //渠道SN号
|
|
|
+ SnType = pos.PosSnType, //机具类型
|
|
|
+ SnApplyUserId = pos.BuyUserId, //机具申请创客
|
|
|
+ ActType = 0, //激活类型
|
|
|
+ SnStoreId = pos.StoreId, //SN仓库
|
|
|
+ RewardTips = "激活奖励", //奖励描述
|
|
|
+ Remark = "激活奖励", //备注
|
|
|
+ ActDate = pos.ActivationTime, //激活时间
|
|
|
+ TopUserId = TopUserId, //顶级创客
|
|
|
+ SeoTitle = machineUser.RealName,
|
|
|
+ });
|
|
|
db.SaveChanges();
|
|
|
- }
|
|
|
- userData.ActProfit += ActPrize;
|
|
|
- db.SaveChanges();
|
|
|
- RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
|
|
|
- if (account == null)
|
|
|
- {
|
|
|
- account = db.UserAccount.Add(new UserAccount()
|
|
|
+ string IdBrand = GetUserId + "_" + pos.BrandId;
|
|
|
+ UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
+ if (userData == null)
|
|
|
{
|
|
|
- Id = GetUserId,
|
|
|
- UserId = GetUserId,
|
|
|
+ userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
+ {
|
|
|
+ IdBrand = IdBrand,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ userData.ActProfit += prize;
|
|
|
+ db.SaveChanges();
|
|
|
+ RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
+ {
|
|
|
+ Id = GetUserId,
|
|
|
+ UserId = GetUserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
+ decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
+ decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
+ account.BalanceAmount += prize;
|
|
|
+ account.TotalAmount += prize;
|
|
|
+ decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
+ decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
+ decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
+ UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ UserId = GetUserId, //创客
|
|
|
+ ChangeType = ChangeType, //变动类型
|
|
|
+ ProductType = pos.BrandId, //产品类型
|
|
|
+ ChangeAmount = prize, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
- }
|
|
|
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
- account.BalanceAmount += ActPrize;
|
|
|
- account.TotalAmount += ActPrize;
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- UserId = GetUserId, //创客
|
|
|
- ChangeType = 0, //变动类型
|
|
|
- ProductType = pos.BrandId, //产品类型
|
|
|
- ChangeAmount = ActPrize, //变更金额
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- RedisDbconn.Instance.Set("UserAccount:" + GetUserId, account);
|
|
|
+ RedisDbconn.Instance.Set("UserAccount:" + GetUserId, account);
|
|
|
|
|
|
- string dateString = pos.ActivationTime.Value.ToString("yyyyMMdd");
|
|
|
- string monthString = pos.ActivationTime.Value.ToString("yyyyMM");
|
|
|
- // 激活奖励列表
|
|
|
- List<string> dates = RedisDbconn.Instance.GetList<string>("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId);
|
|
|
- if (!dates.Contains(dateString))
|
|
|
- {
|
|
|
- RedisDbconn.Instance.AddList("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId, dateString);
|
|
|
- }
|
|
|
- RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + dateString, ActPrize);
|
|
|
+ string dateString = pos.ActivationTime.Value.ToString("yyyyMMdd");
|
|
|
+ string monthString = pos.ActivationTime.Value.ToString("yyyyMM");
|
|
|
+ // 激活奖励列表
|
|
|
+ List<string> dates = RedisDbconn.Instance.GetList<string>("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId);
|
|
|
+ if (!dates.Contains(dateString))
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("ActiveRewardDay:" + GetUserId + ":" + pos.BrandId, dateString);
|
|
|
+ }
|
|
|
+ RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + dateString, prize);
|
|
|
|
|
|
- List<string> months = RedisDbconn.Instance.GetList<string>("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId);
|
|
|
- if (!months.Contains(monthString))
|
|
|
- {
|
|
|
- RedisDbconn.Instance.AddList("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId, monthString);
|
|
|
- }
|
|
|
- RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + monthString, ActPrize);
|
|
|
+ List<string> months = RedisDbconn.Instance.GetList<string>("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId);
|
|
|
+ if (!months.Contains(monthString))
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId, monthString);
|
|
|
+ }
|
|
|
+ RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + monthString, prize);
|
|
|
|
|
|
- // 激活奖励详情
|
|
|
- List<int> actPrizeList = RedisDbconn.Instance.GetList<int>("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString);
|
|
|
- if (!actPrizeList.Contains(pos.BindMerchantId))
|
|
|
- {
|
|
|
- RedisDbconn.Instance.AddList("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString, pos.BindMerchantId);
|
|
|
- }
|
|
|
- RedisDbconn.Instance.AddNumber("ActiveRewardAmt:mer:" + pos.BindMerchantId + ":" + pos.BrandId + ":" + dateString, ActPrize);
|
|
|
+ // 激活奖励详情
|
|
|
+ List<int> actPrizeList = RedisDbconn.Instance.GetList<int>("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString);
|
|
|
+ if (!actPrizeList.Contains(pos.BindMerchantId))
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("ActiveRewardDetail:" + GetUserId + ":" + pos.BrandId + ":" + dateString, pos.BindMerchantId);
|
|
|
+ }
|
|
|
+ RedisDbconn.Instance.AddNumber("ActiveRewardAmt:mer:" + pos.BindMerchantId + ":" + pos.BrandId + ":" + dateString, prize);
|
|
|
|
|
|
- //收支明细
|
|
|
- RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
- RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, ActPrize);
|
|
|
+ //收支明细
|
|
|
+ RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
+ RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, prize);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|