|
@@ -37,20 +37,20 @@ namespace MySystem.Areas.Api.Controllers.v1.pos
|
|
|
public AppResultJson AddDo(string value)
|
|
|
{
|
|
|
JsonData data = JsonMapper.ToObject(value);
|
|
|
- int ToUserId = int.Parse(function.CheckInt(data["ToUserId"].ToString())); //目标创客
|
|
|
+ string ToMakerCode = data["ToMakerCode"].ToString(); //目标创客
|
|
|
int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
|
|
|
string SnIds = data["SnIds"].ToString(); //码牌列表返回的Id集合
|
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
|
- bool checkUser = kxsdb.Users.Any(m => m.Id == ToUserId);
|
|
|
- if (!checkUser)
|
|
|
+ KxsMainModels.UserForMakerCode checkUser = kxsdb.UserForMakerCode.FirstOrDefault(m => m.MakerCode == ToMakerCode);
|
|
|
+ if (checkUser == null)
|
|
|
{
|
|
|
return new AppResultJson() { Status = "-1", Info = "请输入正确的创客编号", Data = Obj };
|
|
|
}
|
|
|
KxsMainModels.Users user = kxsdb.Users.FirstOrDefault(m => m.Id == UserId) ?? new KxsMainModels.Users();
|
|
|
- KxsMainModels.Users touser = kxsdb.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new KxsMainModels.Users();
|
|
|
+ KxsMainModels.Users touser = kxsdb.Users.FirstOrDefault(m => m.Id == checkUser.UserId) ?? new KxsMainModels.Users();
|
|
|
if (!ToUserIds.Contains(UserId))
|
|
|
{
|
|
|
- if (!function.CheckNull(touser.ParentNav).Contains("," + UserId + ",") || function.CheckNull(user.ParentNav).Contains("," + ToUserId + ","))
|
|
|
+ if (!function.CheckNull(touser.ParentNav).Contains("," + UserId + ",") || function.CheckNull(user.ParentNav).Contains("," + touser.Id + ","))
|
|
|
{
|
|
|
return new AppResultJson() { Status = "-1", Info = "划拨对象不在您的权限范围", Data = Obj };
|
|
|
}
|
|
@@ -71,12 +71,12 @@ namespace MySystem.Areas.Api.Controllers.v1.pos
|
|
|
{
|
|
|
CreateDate = DateTime.Now,
|
|
|
OrderNo = ChangeRecordNo,
|
|
|
- ToUserId = ToUserId,
|
|
|
+ ToUserId = touser.Id,
|
|
|
FromUserId = UserId,
|
|
|
PosCouponId = SnIdNum,
|
|
|
}).Entity;
|
|
|
- pos.BuyUserId = ToUserId;
|
|
|
- pos.UserId = ToUserId;
|
|
|
+ pos.BuyUserId = touser.Id;
|
|
|
+ pos.UserId = touser.Id;
|
|
|
maindb.SaveChanges();
|
|
|
}
|
|
|
int SnCount = SnIdList.Length;
|
|
@@ -98,12 +98,12 @@ namespace MySystem.Areas.Api.Controllers.v1.pos
|
|
|
int AfterTotal = forUser.TotalNum;
|
|
|
int AfterStock = forUser.StockNum;
|
|
|
maindb.SaveChanges();
|
|
|
- PosCouponForUser forToUser = maindb.PosCouponForUser.FirstOrDefault(m => m.Id == ToUserId);
|
|
|
+ PosCouponForUser forToUser = maindb.PosCouponForUser.FirstOrDefault(m => m.Id == touser.Id);
|
|
|
if (forToUser == null)
|
|
|
{
|
|
|
forToUser = maindb.PosCouponForUser.Add(new PosCouponForUser()
|
|
|
{
|
|
|
- Id = ToUserId,
|
|
|
+ Id = touser.Id,
|
|
|
}).Entity;
|
|
|
maindb.SaveChanges();
|
|
|
}
|
|
@@ -127,7 +127,7 @@ namespace MySystem.Areas.Api.Controllers.v1.pos
|
|
|
BeforeStock = BeforeStock,
|
|
|
OrderNo = ChangeRecordNo,
|
|
|
ToUserId = UserId,
|
|
|
- FromUserId = ToUserId,
|
|
|
+ FromUserId = touser.Id,
|
|
|
}).Entity;
|
|
|
maindb.SaveChanges();
|
|
|
}
|