|
@@ -140,7 +140,7 @@ namespace MySystem
|
|
|
Name = Name.Split('_')[1];
|
|
|
}
|
|
|
}
|
|
|
- PxcModels.Users user = db.Users.FirstOrDefault(m => m.Mobile.StartsWith(BeforeNum) && m.Mobile.EndsWith(AfterNum) && m.RealName == Name && m.AuthFlag == 1 && m.MerchantType == 0);
|
|
|
+ PxcModels.Users user = db.Users.FirstOrDefault(m => m.Mobile.StartsWith(BeforeNum) && m.Mobile.EndsWith(AfterNum) && m.RealName == Name && m.AuthFlag == 1 && m.MerchantType == 0 && m.CreateDate >= yesterday && m.CreateDate < today);
|
|
|
if (user != null)
|
|
|
{
|
|
|
user.MerchantType = 1;
|
|
@@ -269,144 +269,145 @@ namespace MySystem
|
|
|
// {
|
|
|
// otherInfo.PrizeFlag1 = 1;
|
|
|
// db.SaveChanges();
|
|
|
- string ParentNav = "";
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
- if (user != null)
|
|
|
+ string ParentNav = "";
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
+ if (user != null)
|
|
|
+ {
|
|
|
+ int GetUserId = user.Id;
|
|
|
+ ParentNav = user.ParentNav;
|
|
|
+ int TopUserId = 0;
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
|
{
|
|
|
- int GetUserId = user.Id;
|
|
|
- ParentNav = user.ParentNav;
|
|
|
- int TopUserId = 0;
|
|
|
- if (!string.IsNullOrEmpty(ParentNav))
|
|
|
- {
|
|
|
- TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
- }
|
|
|
- decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
|
- if (pos.BrandId == 1 || pos.BrandId == 3)
|
|
|
- {
|
|
|
- ActPrize = ActPrize / 100;
|
|
|
- }
|
|
|
- if (ActPrize > 0)
|
|
|
+ TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
+ }
|
|
|
+ decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
|
+ if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5)
|
|
|
+ {
|
|
|
+ ActPrize = ActPrize / 100;
|
|
|
+ }
|
|
|
+ if (ActPrize > 0)
|
|
|
+ {
|
|
|
+ bool check = db.ActiveReward.Any(m => m.KqMerNo == merchant.KqMerNo);
|
|
|
+ if (!check)
|
|
|
{
|
|
|
- bool check = db.ActiveReward.Any(m => m.KqMerNo == merchant.KqMerNo);
|
|
|
- if (!check)
|
|
|
+ if (ActPrize == 99)
|
|
|
{
|
|
|
- if (ActPrize == 99)
|
|
|
- {
|
|
|
- ActPrize = 100;
|
|
|
- }
|
|
|
- else if (ActPrize == 199)
|
|
|
- {
|
|
|
- ActPrize = 200;
|
|
|
- }
|
|
|
- else if (ActPrize == 299)
|
|
|
- {
|
|
|
- ActPrize = 300;
|
|
|
- }
|
|
|
- Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? 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;
|
|
|
+ }
|
|
|
+ Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? 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)
|
|
|
+ {
|
|
|
+ userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
{
|
|
|
- userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
- {
|
|
|
- IdBrand = IdBrand,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- userData.ActProfit += ActPrize;
|
|
|
+ IdBrand = IdBrand,
|
|
|
+ }).Entity;
|
|
|
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 += ActPrize;
|
|
|
- account.TotalAmount += ActPrize;
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ }
|
|
|
+ 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()
|
|
|
{
|
|
|
- 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, //变更后余额
|
|
|
+ Id = GetUserId,
|
|
|
+ UserId = GetUserId,
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
- 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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
|
|
|
- // 激活奖励详情
|
|
|
- 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<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);
|
|
|
|
|
|
- //收支明细
|
|
|
- RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
- RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, 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, ActPrize);
|
|
|
+
|
|
|
+ //收支明细
|
|
|
+ RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
+ RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, ActPrize);
|
|
|
+ RedisDbconn.Instance.Clear("UserAccount:Income:" + GetUserId + ":" + monthString);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
// }
|
|
|
}
|
|
|
}
|