|
@@ -6,6 +6,7 @@ using System.Linq;
|
|
|
using System.Data;
|
|
|
using System.Threading;
|
|
|
using MySystem.PxcModels;
|
|
|
+using Microsoft.EntityFrameworkCore.Internal;
|
|
|
|
|
|
namespace MySystem
|
|
|
{
|
|
@@ -793,8 +794,6 @@ namespace MySystem
|
|
|
ChkBrandIds.Add(24);
|
|
|
ChkBrandIds.Add(25);
|
|
|
ChkBrandIds.Add(26);
|
|
|
- ChkBrandIds.Add(12);
|
|
|
- ChkBrandIds.Add(13);
|
|
|
if(string.IsNullOrEmpty(MerNo) && !ChkBrandIds.Contains(pos.BrandId))
|
|
|
{
|
|
|
// MerNo = "n" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
@@ -822,84 +821,89 @@ namespace MySystem
|
|
|
}
|
|
|
if (!check && !check1)
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + ":" + pos.PosSn, "实时处理激活奖励");
|
|
|
- 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 = MerNo, //渠道商户编号
|
|
|
- KqSnNo = pos.PosSn, //渠道SN号
|
|
|
- SnType = pos.PosSnType, //机具类型
|
|
|
- SnApplyUserId = pos.BuyUserId, //机具申请创客
|
|
|
- ActType = ActType, //激活类型
|
|
|
- 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)
|
|
|
+ doActiveRewardFunc(db, merchant, pos, GetUserId, ParentNav, TopUserId, ActPrize, ChangeType, ActType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void doActiveRewardFunc(WebCMSEntities db, PosMerchantInfo merchant, PosMachinesTwo pos, int GetUserId, string ParentNav, int TopUserId, decimal ActPrize, int ChangeType = 0, int ActType = 0)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + ":" + pos.PosSn, "实时处理激活奖励");
|
|
|
+ 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 = ActType, //激活类型
|
|
|
+ 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();
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
|
|
|
- if (account == null)
|
|
|
+ }
|
|
|
+ userData.ActProfit += ActPrize;
|
|
|
+ db.SaveChanges();
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == GetUserId);
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
{
|
|
|
- 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 = ChangeType, //变动类型
|
|
|
- ProductType = pos.BrandId, //产品类型
|
|
|
- ChangeAmount = ActPrize, //变更金额
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
- QueryCount = pos.Id, //机具Id
|
|
|
- Kind = 3
|
|
|
+ Id = GetUserId,
|
|
|
+ UserId = GetUserId,
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
-
|
|
|
- //发送APP推送消息
|
|
|
- Utils.Instance.PrizePush(GetUserId, 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 = ChangeType, //变动类型
|
|
|
+ ProductType = pos.BrandId, //产品类型
|
|
|
+ ChangeAmount = ActPrize, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
+ QueryCount = pos.Id, //机具Id
|
|
|
+ Kind = 3
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+
|
|
|
+ //发送APP推送消息
|
|
|
+ Utils.Instance.PrizePush(GetUserId, ActPrize);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3356,7 +3360,10 @@ namespace MySystem
|
|
|
TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
|
|
|
}
|
|
|
function.WriteLog("发放给:" + GetUserId, "服务费奖励发放日志");
|
|
|
- doActiveReward(db, merchant, pos, GetUserId, user.ParentNav, TopUserId, ActPrize, 0, 1);
|
|
|
+ if(!db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.ActType == 1))
|
|
|
+ {
|
|
|
+ doActiveRewardFunc(db, merchant, pos, GetUserId, user.ParentNav, TopUserId, ActPrize, 0, 1);
|
|
|
+ }
|
|
|
function.WriteLog("已发放", "服务费奖励发放日志");
|
|
|
}
|
|
|
}
|