|
|
@@ -941,9 +941,15 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
prizes.Add(50);
|
|
|
}
|
|
|
+ //9月1日-9月30日立刷机具刷5000激活时额外奖励30元立刷活动奖
|
|
|
+ else if (pos.BrandId == 6 && pos.CreditTrade >= 5000M && pos.ActivationTime >= DateTime.Parse("2023-08-31 00:00:00") && pos.ActivationTime < DateTime.Parse("2023-10-01 00:00:00"))
|
|
|
+ {
|
|
|
+ prizes.Add(30);
|
|
|
+ }
|
|
|
foreach (decimal prize in prizes)
|
|
|
{
|
|
|
int ChangeType = prize == 40 ? 12 : 0;
|
|
|
+ if (prize == 30) ChangeType = 133;
|
|
|
bool check = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.RewardAmount == prize);
|
|
|
if (!check)
|
|
|
{
|
|
|
@@ -1144,7 +1150,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
#region 取消商户代理
|
|
|
|
|
|
public IActionResult CancelMerAgent(string right)
|
|
|
@@ -1240,7 +1245,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
#region 查看SP原始数据日志
|
|
|
|
|
|
public IActionResult SeeSpLog(string right)
|
|
|
@@ -3327,155 +3331,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId);
|
|
|
if (user != null)
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(user.ParentNav))
|
|
|
- {
|
|
|
- decimal Prize = 20;
|
|
|
- List<string> PrizeFlag = new List<string>();
|
|
|
- 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.BuyUserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台兑换机
|
|
|
- int ActiveCount = db.PosMachinesTwo.Count(m => m.BuyUserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
- int couponCount = db.PosCoupons.Count(m => m.UserId == puser.Id && m.IsUse == 0); //判断是否拥有3张券
|
|
|
- if (machineCount + ActiveCount + couponCount >= 3)
|
|
|
- {
|
|
|
- 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.BuyUserId) ?? new Users();
|
|
|
- OpenRewardDetail detail = db.OpenRewardDetail.Add(new OpenRewardDetail()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- TradeMonth = DateTime.Now.ToString("yyyyMM"), //交易月
|
|
|
- TradeDate = pos.ActivationTime, //达标日期
|
|
|
- UserId = puser.Id, //创客
|
|
|
- BrandId = pos.BrandId, //品牌
|
|
|
- ProductName = RelationClass.GetKqProductBrandInfo(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 = DateTime.Now.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();
|
|
|
- //账户入库
|
|
|
- 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()
|
|
|
- {
|
|
|
- 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 = DateTime.Now.ToString("yyyyMMdd");
|
|
|
- string monthString = DateTime.Now.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 = 0;
|
|
|
- PrizeFlag.Add(Prize.ToString("f0"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- string result = "";
|
|
|
- if (string.IsNullOrEmpty(result))
|
|
|
- {
|
|
|
- return "发放成功";
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
+ RedisDbconn.Instance.AddList("OpenRewardQueue", Id.ToString());
|
|
|
+ return "操作成功,请稍后查询";
|
|
|
}
|
|
|
db.Dispose();
|
|
|
return "操作失败";
|