|
@@ -287,159 +287,330 @@ namespace MySystem
|
|
}
|
|
}
|
|
foreach (PosMachinesTwo pos in posList.ToList())
|
|
foreach (PosMachinesTwo pos in posList.ToList())
|
|
{
|
|
{
|
|
|
|
+ // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
|
|
PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
if (merchant != null)
|
|
if (merchant != null)
|
|
{
|
|
{
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
|
- // if (user != null)
|
|
|
|
|
|
+ // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag1 == 0);
|
|
|
|
+ // if (otherInfo != null)
|
|
// {
|
|
// {
|
|
- // if (user.MerchantType == 1)
|
|
|
|
- // {
|
|
|
|
- // user = db.Users.FirstOrDefault(m => m.Id == user.ParentUserId);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- string ParentNav = "";
|
|
|
|
- if (user != null)
|
|
|
|
- {
|
|
|
|
- int GetUserId = user.Id;
|
|
|
|
- ParentNav = user.ParentNav;
|
|
|
|
- int TopUserId = 0;
|
|
|
|
- if (!string.IsNullOrEmpty(ParentNav))
|
|
|
|
|
|
+ // otherInfo.PrizeFlag1 = 1;
|
|
|
|
+ // db.SaveChanges();
|
|
|
|
+ string ParentNav = "";
|
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
|
+ if (user != null)
|
|
{
|
|
{
|
|
- TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
|
- }
|
|
|
|
- decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
|
|
- if (pos.BrandId == 1)
|
|
|
|
- {
|
|
|
|
- ActPrize = ActPrize / 100;
|
|
|
|
- }
|
|
|
|
- if (ActPrize > 0)
|
|
|
|
- {
|
|
|
|
- bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn);
|
|
|
|
- if (!check)
|
|
|
|
|
|
+ int GetUserId = user.Id;
|
|
|
|
+ ParentNav = user.ParentNav;
|
|
|
|
+ int TopUserId = 0;
|
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
{
|
|
{
|
|
- 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)
|
|
|
|
|
|
+ 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)
|
|
|
|
+ {
|
|
|
|
+ bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn);
|
|
|
|
+ if (!check)
|
|
{
|
|
{
|
|
- userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
|
|
|
+ if (ActPrize == 99)
|
|
{
|
|
{
|
|
- IdBrand = IdBrand,
|
|
|
|
- }).Entity;
|
|
|
|
|
|
+ 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();
|
|
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 += 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()
|
|
|
|
+ {
|
|
|
|
+ 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()
|
|
|
|
+ {
|
|
|
|
+ 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;
|
|
}).Entity;
|
|
db.SaveChanges();
|
|
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);
|
|
|
|
+
|
|
|
|
+ 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<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);
|
|
}
|
|
}
|
|
- 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()
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.Dispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //根据商户信息发放激活奖励
|
|
|
|
+ public void dosomething32(int merid = 0)
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ DateTime yesterday = DateTime.Now.AddHours(-3);
|
|
|
|
+ DateTime today = DateTime.Now;
|
|
|
|
+ IQueryable<PosMerchantInfo> merList = db.PosMerchantInfo.Where(m => m.ActiveStatus == 1 && !string.IsNullOrEmpty(m.SeoKeyword));
|
|
|
|
+ if (merid > 0)
|
|
|
|
+ {
|
|
|
|
+ merList = merList.Where(m => m.Id == merid);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ merList = merList.Where(m => m.MerStandardDate >= yesterday && m.MerStandardDate < today);
|
|
|
|
+ }
|
|
|
|
+ foreach (PosMerchantInfo merchant in merList.ToList())
|
|
|
|
+ {
|
|
|
|
+ // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
|
|
|
|
+ // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag1 == 0);
|
|
|
|
+ // if (otherInfo != null)
|
|
|
|
+ // {
|
|
|
|
+ // otherInfo.PrizeFlag1 = 1;
|
|
|
|
+ // db.SaveChanges();
|
|
|
|
+ MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.MerchantNo) ?? new MachineForMerNo();
|
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forMerNo.SnId) ?? new PosMachinesTwo();
|
|
|
|
+ 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))
|
|
|
|
+ {
|
|
|
|
+ TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
|
+ }
|
|
|
|
+ decimal ActPrize = decimal.Parse(function.CheckNum(merchant.SeoKeyword));
|
|
|
|
+ if (pos.BrandId == 1 || pos.BrandId == 3)
|
|
|
|
+ {
|
|
|
|
+ ActPrize = ActPrize / 100;
|
|
|
|
+ }
|
|
|
|
+ if (ActPrize > 0)
|
|
|
|
+ {
|
|
|
|
+ bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn);
|
|
|
|
+ if (!check)
|
|
|
|
+ {
|
|
|
|
+ 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)
|
|
|
|
+ {
|
|
|
|
+ userData = db.UserMachineData.Add(new UserMachineData()
|
|
{
|
|
{
|
|
- 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, //变更后余额
|
|
|
|
|
|
+ IdBrand = IdBrand,
|
|
}).Entity;
|
|
}).Entity;
|
|
db.SaveChanges();
|
|
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);
|
|
|
|
-
|
|
|
|
- List<string> months = RedisDbconn.Instance.GetList<string>("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId);
|
|
|
|
- if (!months.Contains(monthString))
|
|
|
|
|
|
+ }
|
|
|
|
+ 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()
|
|
{
|
|
{
|
|
- RedisDbconn.Instance.AddList("ActiveRewardMonth:" + GetUserId + ":" + pos.BrandId, monthString);
|
|
|
|
- }
|
|
|
|
- RedisDbconn.Instance.AddNumber("ActiveRewardAmt:" + GetUserId + ":" + pos.BrandId + ":" + monthString, ActPrize);
|
|
|
|
|
|
+ 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()
|
|
|
|
+ {
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
db.Dispose();
|
|
db.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//3. 前一天的激活记录,根据创客类型,如果是商户型创客,则开机奖励的起始人从此人上级计算。如果不是,则从此人开始计算
|
|
//3. 前一天的激活记录,根据创客类型,如果是商户型创客,则开机奖励的起始人从此人上级计算。如果不是,则从此人开始计算
|
|
public void dosomething4(string date)
|
|
public void dosomething4(string date)
|
|
{
|
|
{
|
|
@@ -454,163 +625,341 @@ namespace MySystem
|
|
decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
if (ActPrize > 0)
|
|
if (ActPrize > 0)
|
|
{
|
|
{
|
|
|
|
+ // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
|
|
PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
|
|
if (merchant != null)
|
|
if (merchant != null)
|
|
{
|
|
{
|
|
- // 从机具所属人上级开始分开机奖励
|
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
|
- // Users user = db.Users.FirstOrDefault(m => m.Id == merchant.UserId);
|
|
|
|
- // if (user != null)
|
|
|
|
|
|
+ // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag2 == 0);
|
|
|
|
+ // if (otherInfo != null)
|
|
// {
|
|
// {
|
|
- // if (user.MerchantType == 1)
|
|
|
|
- // {
|
|
|
|
- // user = db.Users.FirstOrDefault(m => m.Id == user.ParentUserId);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- if (user != null)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrEmpty(user.ParentNav))
|
|
|
|
|
|
+ // otherInfo.PrizeFlag2 = 1;
|
|
|
|
+ // db.SaveChanges();
|
|
|
|
+ // 从机具所属人上级开始分开机奖励
|
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
|
+ if (user != null)
|
|
{
|
|
{
|
|
- decimal Prize = 20;
|
|
|
|
- string[] ParentNavs = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
- for (int i = ParentNavs.Length - 1; i >= 0; i--)
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(user.ParentNav))
|
|
{
|
|
{
|
|
- int UserId = int.Parse(ParentNavs[i]);
|
|
|
|
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1);
|
|
|
|
- if (puser != null && Prize > 0)
|
|
|
|
|
|
+ decimal Prize = 20;
|
|
|
|
+ string[] ParentNavs = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
+ for (int i = ParentNavs.Length - 1; i >= 0; i--)
|
|
{
|
|
{
|
|
- int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
|
|
|
|
- if (machineCount >= 3)
|
|
|
|
|
|
+ int UserId = int.Parse(ParentNavs[i]);
|
|
|
|
+ Users puser = db.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1);
|
|
|
|
+ if (puser != null && Prize > 0)
|
|
{
|
|
{
|
|
- int pTopUserId = 0;
|
|
|
|
- if (!string.IsNullOrEmpty(puser.ParentNav))
|
|
|
|
- {
|
|
|
|
- pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
|
- }
|
|
|
|
- Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
|
|
|
|
- OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
|
|
|
|
- {
|
|
|
|
- CreateDate = DateTime.Now,
|
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
|
- TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
- TradeDate = yesterday, //达标日期
|
|
|
|
- UserId = puser.Id, //创客
|
|
|
|
- BrandId = pos.BrandId, //品牌
|
|
|
|
- ProductName = RelationClass.GetKqProductsInfo(pos.BrandId), //产品名称
|
|
|
|
- MerchantId = pos.BindMerchantId, //商户
|
|
|
|
- DirectUserId = merchant.UserId, //商户直属人
|
|
|
|
- SnNo = pos.PosSn, //SN号
|
|
|
|
- MerNo = merchant.KqMerNo, //渠道商户号
|
|
|
|
- SnType = pos.PosSnType, //机具类型
|
|
|
|
- StandardDate = pos.ActivationTime, //商户的激活日期
|
|
|
|
- SnStoreId = pos.StoreId, //SN仓库
|
|
|
|
- MerBuddyType = puser.MerchantType, //商户创客类型
|
|
|
|
- RewardType = 1, //奖励类型 1-开机直接奖励,2-开机间接奖励
|
|
|
|
- RewardTips = "开机奖励", //奖励描述
|
|
|
|
- CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
- DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
- CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
- RewardDesc = "开机奖励", //奖励描述
|
|
|
|
- TopUserId = pTopUserId, //顶级创客
|
|
|
|
- SeoTitle = machineUser.RealName,
|
|
|
|
- }).Entity;
|
|
|
|
- db.OpenReward.Add(new OpenReward()
|
|
|
|
|
|
+ int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
|
|
|
|
+ int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
|
+ int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
|
|
|
|
+ int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
|
|
|
|
+ if (machineCount >= 3 || ActiveCount >= 3 || BigCount >= 2 || BigActiveCount >= 2)
|
|
{
|
|
{
|
|
- CreateDate = DateTime.Now,
|
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
|
- TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
- TradeDate = DateTime.Now, //达标日期
|
|
|
|
- UserId = puser.Id, //创客
|
|
|
|
- BrandId = pos.BrandId, //品牌
|
|
|
|
- RewardType = 2, //奖励类型
|
|
|
|
- CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
- DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
- CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
- RewardDesc = "开机奖励", //奖励描述
|
|
|
|
- TopUserId = pTopUserId, //顶级创客
|
|
|
|
- });
|
|
|
|
- string IdBrand = puser.Id + "_" + pos.BrandId;
|
|
|
|
- UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
|
- if (userData == null)
|
|
|
|
- {
|
|
|
|
- userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
|
|
|
+ int pTopUserId = 0;
|
|
|
|
+ if (!string.IsNullOrEmpty(puser.ParentNav))
|
|
|
|
+ {
|
|
|
|
+ pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
|
+ }
|
|
|
|
+ Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
|
|
|
|
+ OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
|
|
{
|
|
{
|
|
- IdBrand = IdBrand,
|
|
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
+ TradeDate = yesterday, //达标日期
|
|
|
|
+ UserId = puser.Id, //创客
|
|
|
|
+ BrandId = pos.BrandId, //品牌
|
|
|
|
+ ProductName = RelationClass.GetKqProductsInfo(pos.BrandId), //产品名称
|
|
|
|
+ MerchantId = pos.BindMerchantId, //商户
|
|
|
|
+ DirectUserId = merchant.UserId, //商户直属人
|
|
|
|
+ SnNo = pos.PosSn, //SN号
|
|
|
|
+ MerNo = merchant.KqMerNo, //渠道商户号
|
|
|
|
+ SnType = pos.PosSnType, //机具类型
|
|
|
|
+ StandardDate = pos.ActivationTime, //商户的激活日期
|
|
|
|
+ SnStoreId = pos.StoreId, //SN仓库
|
|
|
|
+ MerBuddyType = puser.MerchantType, //商户创客类型
|
|
|
|
+ RewardType = 1, //奖励类型 1-开机直接奖励,2-开机间接奖励
|
|
|
|
+ RewardTips = "开机奖励", //奖励描述
|
|
|
|
+ CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
+ DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
+ CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
+ RewardDesc = "开机奖励", //奖励描述
|
|
|
|
+ TopUserId = pTopUserId, //顶级创客
|
|
|
|
+ SeoTitle = machineUser.RealName,
|
|
}).Entity;
|
|
}).Entity;
|
|
|
|
+ db.OpenReward.Add(new OpenReward()
|
|
|
|
+ {
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
+ TradeDate = DateTime.Now, //达标日期
|
|
|
|
+ UserId = puser.Id, //创客
|
|
|
|
+ BrandId = pos.BrandId, //品牌
|
|
|
|
+ RewardType = 2, //奖励类型
|
|
|
|
+ CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
+ DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
+ CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
+ RewardDesc = "开机奖励", //奖励描述
|
|
|
|
+ TopUserId = pTopUserId, //顶级创客
|
|
|
|
+ });
|
|
|
|
+ string IdBrand = puser.Id + "_" + pos.BrandId;
|
|
|
|
+ UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
|
+ if (userData == null)
|
|
|
|
+ {
|
|
|
|
+ userData = db.UserMachineData.Add(new UserMachineData()
|
|
|
|
+ {
|
|
|
|
+ IdBrand = IdBrand,
|
|
|
|
+ }).Entity;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ userData.OpenProfit += Prize;
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
- }
|
|
|
|
- userData.OpenProfit += Prize;
|
|
|
|
- db.SaveChanges();
|
|
|
|
- RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
|
|
|
|
- //账户入库
|
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
|
|
|
|
- if (account == null)
|
|
|
|
- {
|
|
|
|
- account = db.UserAccount.Add(new UserAccount()
|
|
|
|
|
|
+ RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
|
|
|
|
+ //账户入库
|
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
|
|
|
|
+ if (account == null)
|
|
|
|
+ {
|
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
|
+ {
|
|
|
|
+ Id = puser.Id,
|
|
|
|
+ UserId = puser.Id,
|
|
|
|
+ }).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()
|
|
{
|
|
{
|
|
- Id = puser.Id,
|
|
|
|
- UserId = puser.Id,
|
|
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ UserId = puser.Id, //创客
|
|
|
|
+ ChangeType = 50, //变动类型
|
|
|
|
+ ProductType = pos.BrandId, //产品类型
|
|
|
|
+ ChangeAmount = Prize, //变更金额
|
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
}).Entity;
|
|
}).Entity;
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
|
|
+ RedisDbconn.Instance.Set("UserAccount:" + puser.Id, account);
|
|
|
|
+
|
|
|
|
+ string dateString = yesterday.ToString("yyyyMMdd");
|
|
|
|
+ string monthString = yesterday.ToString("yyyyMM");
|
|
|
|
+ // 开机奖励列表
|
|
|
|
+ List<string> dates = RedisDbconn.Instance.GetList<string>("OpenRewardDay:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
+ if (!dates.Contains(dateString))
|
|
|
|
+ {
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardDay:" + puser.Id + ":" + pos.BrandId, dateString);
|
|
|
|
+ }
|
|
|
|
+ RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + dateString, Prize);
|
|
|
|
+
|
|
|
|
+ List<string> months = RedisDbconn.Instance.GetList<string>("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
+ if (!months.Contains(monthString))
|
|
|
|
+ {
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId, monthString);
|
|
|
|
+ }
|
|
|
|
+ RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + monthString, Prize);
|
|
|
|
+
|
|
|
|
+ // 开机奖励详情
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardDetail:" + puser.Id + ":" + pos.BrandId + ":" + dateString, detail);
|
|
|
|
+
|
|
|
|
+ //收支明细
|
|
|
|
+ RedisDbconn.Instance.AddList("UserAccountRecord:" + puser.Id + ":1:" + monthString, userAccountRecord);
|
|
|
|
+ RedisDbconn.Instance.AddNumber("UserAccount:" + puser.Id + ":1:" + monthString, Prize);
|
|
|
|
+
|
|
|
|
+ Prize -= 10;
|
|
}
|
|
}
|
|
- //收支明细入库
|
|
|
|
- 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()
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db.Dispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void dosomething42(string date)
|
|
|
|
+ {
|
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
|
+ DateTime yesterday = DateTime.Parse(date + " 00:00:00");
|
|
|
|
+ DateTime today = DateTime.Parse(DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
|
|
|
|
+ List<PosMerchantInfo> merList = db.PosMerchantInfo.Where(m => m.ActiveStatus == 1 && m.MerStandardDate >= yesterday && m.MerStandardDate < today && !string.IsNullOrEmpty(m.SeoKeyword) && m.SeoKeyword != "0").ToList();
|
|
|
|
+ foreach (PosMerchantInfo merchant in merList)
|
|
|
|
+ {
|
|
|
|
+ MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.MerchantNo) ?? new MachineForMerNo();
|
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forMerNo.SnId) ?? new PosMachinesTwo();
|
|
|
|
+ if (pos.ActivationTime > DateTime.Now.AddDays(-20) && pos.CreditTrade >= 1000)
|
|
|
|
+ {
|
|
|
|
+ decimal ActPrize = decimal.Parse(function.CheckNum(merchant.SeoKeyword));
|
|
|
|
+ if (ActPrize > 0)
|
|
|
|
+ {
|
|
|
|
+ // PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId && !string.IsNullOrEmpty(m.MerIdcardNo));
|
|
|
|
+ // PosMerchantOtherInfo otherInfo = db.PosMerchantOtherInfo.FirstOrDefault(m => m.CertId == merchant.MerIdcardNo && m.PrizeFlag2 == 0);
|
|
|
|
+ // if (otherInfo != null)
|
|
|
|
+ // {
|
|
|
|
+ // otherInfo.PrizeFlag2 = 1;
|
|
|
|
+ // db.SaveChanges();
|
|
|
|
+ // 从机具所属人上级开始分开机奖励
|
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId);
|
|
|
|
+ if (user != null)
|
|
|
|
+ {
|
|
|
|
+ if (!string.IsNullOrEmpty(user.ParentNav))
|
|
|
|
+ {
|
|
|
|
+ decimal Prize = 20;
|
|
|
|
+ string[] ParentNavs = user.ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
|
+ for (int i = ParentNavs.Length - 1; i >= 0; i--)
|
|
|
|
+ {
|
|
|
|
+ int UserId = int.Parse(ParentNavs[i]);
|
|
|
|
+ Users puser = db.Users.FirstOrDefault(m => m.Id == UserId && m.AuthFlag == 1);
|
|
|
|
+ if (puser != null && Prize > 0)
|
|
|
|
+ {
|
|
|
|
+ int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
|
|
|
|
+ int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
|
+ int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
|
|
|
|
+ int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
|
|
|
|
+ if (machineCount >= 3 || ActiveCount >= 3 || BigCount >= 2 || BigActiveCount >= 2)
|
|
|
|
+ {
|
|
|
|
+ int pTopUserId = 0;
|
|
|
|
+ if (!string.IsNullOrEmpty(puser.ParentNav))
|
|
|
|
+ {
|
|
|
|
+ pTopUserId = int.Parse(puser.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
|
+ }
|
|
|
|
+ Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new Users();
|
|
|
|
+ OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
|
|
|
|
+ {
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
+ TradeDate = yesterday, //达标日期
|
|
|
|
+ UserId = puser.Id, //创客
|
|
|
|
+ BrandId = pos.BrandId, //品牌
|
|
|
|
+ ProductName = RelationClass.GetKqProductsInfo(pos.BrandId), //产品名称
|
|
|
|
+ MerchantId = pos.BindMerchantId, //商户
|
|
|
|
+ DirectUserId = merchant.UserId, //商户直属人
|
|
|
|
+ SnNo = pos.PosSn, //SN号
|
|
|
|
+ MerNo = merchant.KqMerNo, //渠道商户号
|
|
|
|
+ SnType = pos.PosSnType, //机具类型
|
|
|
|
+ StandardDate = pos.ActivationTime, //商户的激活日期
|
|
|
|
+ SnStoreId = pos.StoreId, //SN仓库
|
|
|
|
+ MerBuddyType = puser.MerchantType, //商户创客类型
|
|
|
|
+ RewardType = 1, //奖励类型 1-开机直接奖励,2-开机间接奖励
|
|
|
|
+ RewardTips = "开机奖励", //奖励描述
|
|
|
|
+ CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
+ DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
+ CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
+ RewardDesc = "开机奖励", //奖励描述
|
|
|
|
+ TopUserId = pTopUserId, //顶级创客
|
|
|
|
+ SeoTitle = machineUser.RealName,
|
|
|
|
+ }).Entity;
|
|
|
|
+ db.OpenReward.Add(new OpenReward()
|
|
|
|
+ {
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
|
+ TradeMonth = yesterday.ToString("yyyyMM"), //交易月
|
|
|
|
+ TradeDate = DateTime.Now, //达标日期
|
|
|
|
+ UserId = puser.Id, //创客
|
|
|
|
+ BrandId = pos.BrandId, //品牌
|
|
|
|
+ RewardType = 2, //奖励类型
|
|
|
|
+ CreditTradeAmt = pos.CreditTrade, //贷记卡交易总金额
|
|
|
|
+ DebitTradeAmt = pos.DebitCardTrade, //借记卡交易总金额
|
|
|
|
+ CreditRewardAmount = Prize, //贷记卡交易奖励金额
|
|
|
|
+ RewardDesc = "开机奖励", //奖励描述
|
|
|
|
+ TopUserId = pTopUserId, //顶级创客
|
|
|
|
+ });
|
|
|
|
+ string IdBrand = puser.Id + "_" + pos.BrandId;
|
|
|
|
+ UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
|
+ if (userData == null)
|
|
|
|
+ {
|
|
|
|
+ userData = db.UserMachineData.Add(new UserMachineData()
|
|
{
|
|
{
|
|
- CreateDate = DateTime.Now,
|
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
|
- UserId = puser.Id, //创客
|
|
|
|
- ChangeType = 50, //变动类型
|
|
|
|
- ProductType = pos.BrandId, //产品类型
|
|
|
|
- ChangeAmount = Prize, //变更金额
|
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
|
|
|
+ IdBrand = IdBrand,
|
|
}).Entity;
|
|
}).Entity;
|
|
db.SaveChanges();
|
|
db.SaveChanges();
|
|
- RedisDbconn.Instance.Set("UserAccount:" + puser.Id, account);
|
|
|
|
-
|
|
|
|
- string dateString = yesterday.ToString("yyyyMMdd");
|
|
|
|
- string monthString = yesterday.ToString("yyyyMM");
|
|
|
|
- // 开机奖励列表
|
|
|
|
- List<string> dates = RedisDbconn.Instance.GetList<string>("OpenRewardDay:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
- if (!dates.Contains(dateString))
|
|
|
|
|
|
+ }
|
|
|
|
+ userData.OpenProfit += Prize;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ RedisDbconn.Instance.Set("UserMachineData:" + IdBrand, userData);
|
|
|
|
+ //账户入库
|
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id);
|
|
|
|
+ if (account == null)
|
|
|
|
+ {
|
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
{
|
|
{
|
|
- RedisDbconn.Instance.AddList("OpenRewardDay:" + puser.Id + ":" + pos.BrandId, dateString);
|
|
|
|
- }
|
|
|
|
- RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + dateString, Prize);
|
|
|
|
|
|
+ Id = puser.Id,
|
|
|
|
+ UserId = puser.Id,
|
|
|
|
+ }).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 = puser.Id, //创客
|
|
|
|
+ ChangeType = 50, //变动类型
|
|
|
|
+ ProductType = pos.BrandId, //产品类型
|
|
|
|
+ ChangeAmount = Prize, //变更金额
|
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
|
+ }).Entity;
|
|
|
|
+ db.SaveChanges();
|
|
|
|
+ RedisDbconn.Instance.Set("UserAccount:" + puser.Id, account);
|
|
|
|
+
|
|
|
|
+ string dateString = yesterday.ToString("yyyyMMdd");
|
|
|
|
+ string monthString = yesterday.ToString("yyyyMM");
|
|
|
|
+ // 开机奖励列表
|
|
|
|
+ List<string> dates = RedisDbconn.Instance.GetList<string>("OpenRewardDay:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
+ if (!dates.Contains(dateString))
|
|
|
|
+ {
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardDay:" + puser.Id + ":" + pos.BrandId, dateString);
|
|
|
|
+ }
|
|
|
|
+ RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + dateString, Prize);
|
|
|
|
|
|
- List<string> months = RedisDbconn.Instance.GetList<string>("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
- if (!months.Contains(monthString))
|
|
|
|
- {
|
|
|
|
- RedisDbconn.Instance.AddList("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId, monthString);
|
|
|
|
- }
|
|
|
|
- RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + monthString, Prize);
|
|
|
|
|
|
+ List<string> months = RedisDbconn.Instance.GetList<string>("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId);
|
|
|
|
+ if (!months.Contains(monthString))
|
|
|
|
+ {
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardMonth:" + puser.Id + ":" + pos.BrandId, monthString);
|
|
|
|
+ }
|
|
|
|
+ RedisDbconn.Instance.AddNumber("OpenRewardAmt:" + puser.Id + ":" + pos.BrandId + ":" + monthString, Prize);
|
|
|
|
|
|
- // 开机奖励详情
|
|
|
|
- RedisDbconn.Instance.AddList("OpenRewardDetail:" + puser.Id + ":" + pos.BrandId + ":" + dateString, detail);
|
|
|
|
|
|
+ // 开机奖励详情
|
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardDetail:" + puser.Id + ":" + pos.BrandId + ":" + dateString, detail);
|
|
|
|
|
|
- //收支明细
|
|
|
|
- RedisDbconn.Instance.AddList("UserAccountRecord:" + puser.Id + ":1:" + monthString, userAccountRecord);
|
|
|
|
- RedisDbconn.Instance.AddNumber("UserAccount:" + puser.Id + ":1:" + monthString, Prize);
|
|
|
|
|
|
+ //收支明细
|
|
|
|
+ RedisDbconn.Instance.AddList("UserAccountRecord:" + puser.Id + ":1:" + monthString, userAccountRecord);
|
|
|
|
+ RedisDbconn.Instance.AddNumber("UserAccount:" + puser.Id + ":1:" + monthString, Prize);
|
|
|
|
|
|
- Prize -= 10;
|
|
|
|
- }
|
|
|
|
|
|
+ Prize -= 10;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|