|
|
@@ -574,6 +574,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
TopUserId = int.Parse(ParentNavList[0]);
|
|
|
}
|
|
|
}
|
|
|
+ List<decimal> prizes = new List<decimal>();
|
|
|
decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
|
|
|
if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5 || pos.BrandId == 6)
|
|
|
{
|
|
|
@@ -596,122 +597,125 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
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)
|
|
|
+ }
|
|
|
+ else if(pos.BrandId == 6 && ActPrize == 0)
|
|
|
+ {
|
|
|
+ prizes.Add(50);
|
|
|
+ }
|
|
|
+ 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)
|
|
|
{
|
|
|
- int ChangeType = prize == 40 ? 12 : 0;
|
|
|
- bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.RewardAmount == prize);
|
|
|
- if (!check)
|
|
|
+ Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
|
|
|
+ db.ActiveReward.Add(new ActiveReward()
|
|
|
{
|
|
|
- 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 = 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();
|
|
|
- string IdBrand = GetUserId + "_" + pos.BrandId;
|
|
|
- UserMachineData userData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
- if (userData == null)
|
|
|
+ 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();
|
|
|
+ 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 += prize;
|
|
|
+ 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 += prize;
|
|
|
- account.TotalAmount += prize;
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ }
|
|
|
+ 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()
|
|
|
{
|
|
|
- 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, //变更后余额
|
|
|
+ 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, prize);
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ 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, prize);
|
|
|
+ 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<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);
|
|
|
+ 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);
|
|
|
|
|
|
- //收支明细
|
|
|
- RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
- RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + 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, prize);
|
|
|
+
|
|
|
+ //收支明细
|
|
|
+ RedisDbconn.Instance.AddList("UserAccountRecord:" + GetUserId + ":1:" + monthString, userAccountRecord);
|
|
|
+ RedisDbconn.Instance.AddNumber("UserAccount:" + GetUserId + ":1:" + monthString, prize);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -966,6 +970,17 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
result += "机具所属人:创客编号:" + posUser.MakerCode + ",姓名:" + posUser.RealName + ",手机号:" + posUser.Mobile + "\n";
|
|
|
result += "机器持有人顶级:创客编号:" + posTopUser.MakerCode + ",姓名:" + posTopUser.RealName + ",手机号:" + posTopUser.Mobile + "\n";
|
|
|
result += "机器所属仓库:仓库编号:" + store.StoreNo + ",仓库名称:" + store.StoreName + "\n";
|
|
|
+ if(pos.PreUserId > 0)
|
|
|
+ {
|
|
|
+ Users smallStoreUser = db.Users.FirstOrDefault(m => m.Id == pos.PreUserId) ?? new Users();
|
|
|
+ PreSendStockDetail preSend = db.PreSendStockDetail.FirstOrDefault(m => m.SnId == pos.Id && m.ToUserId == pos.PreUserId && m.Status == 1) ?? new PreSendStockDetail();
|
|
|
+ string preSendDate = preSend.CreateDate == null ? "" : preSend.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ result += "机具所属小分仓:创客编号:" + smallStoreUser.MakerCode + ",姓名:" + smallStoreUser.RealName + ",手机号:" + smallStoreUser.Mobile + ",预发时间:" + preSendDate + "\n";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result += "机具所属小分仓:暂无小分仓\n";
|
|
|
+ }
|
|
|
result += "划拨时间:" + TransferTime + "\n";
|
|
|
result += "绑定状态:" + bindResult + "(绑定时间:" + bindTime + ")\n";
|
|
|
result += "激活状态:" + activeResult + "(激活时间:" + activeTime + ")\n";
|