|
|
@@ -1569,6 +1569,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
string[] idlist = StoreIds.Split(new char[] { ',' });
|
|
|
var totalAmount = 0;
|
|
|
+ decimal deposit = 0;
|
|
|
+ var userIds = "";
|
|
|
foreach (var item in idlist)
|
|
|
{
|
|
|
int StoreId = int.Parse(item);
|
|
|
@@ -1585,12 +1587,17 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
amount = 150;
|
|
|
}
|
|
|
+ if (!userIds.Contains(storeInfo.UserId + ","))
|
|
|
+ {
|
|
|
+ userIds += storeInfo.UserId + ",";
|
|
|
+ deposit += storeInfo.Deposit;
|
|
|
+ }
|
|
|
tamount = amount * posCount;//扣减运营中心该品牌机具额度
|
|
|
totalAmount += tamount;//关联分仓打标记运营中心所需额度
|
|
|
}
|
|
|
ViewBag.RightInfo = RightInfo;
|
|
|
ViewBag.right = right;
|
|
|
- ViewBag.totalAmount = "关联分仓机具需要额度:" + totalAmount;
|
|
|
+ ViewBag.totalAmount = "关联分仓机具需要额度:" + totalAmount + "\n" + "关联分仓获得押金:" + deposit;
|
|
|
|
|
|
return View();
|
|
|
}
|
|
|
@@ -1648,10 +1655,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
userIds += storeInfo.UserId + ",";
|
|
|
deposit += storeInfo.Deposit;//增加分仓押金
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- deposit = storeInfo.Deposit;//增加分仓押金
|
|
|
- }
|
|
|
tamount += amount * posCount;//扣减运营中心该品牌机具额度
|
|
|
pCount += posCount;//添加总机具数
|
|
|
}
|
|
|
@@ -1661,7 +1664,11 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
return "Warning|" + error;
|
|
|
}
|
|
|
var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
|
|
|
- if (userAmount.ValidAmount + deposit - tamount >= 0)
|
|
|
+ decimal TotalAmount = userAmount.ValidAmount + userAmount.TotalAmt + userAmount.ValidForGetAmount;//旧的总金额
|
|
|
+ userAmount.ValidAmount += deposit;
|
|
|
+ opdb.SaveChanges();
|
|
|
+ decimal toAmount = userAmount.ValidAmount + userAmount.TotalAmt + userAmount.ValidForGetAmount;//新的总金额
|
|
|
+ if (toAmount - tamount >= 0)
|
|
|
{
|
|
|
foreach (var item in idlist)
|
|
|
{
|
|
|
@@ -1672,12 +1679,45 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0).ToList();
|
|
|
var posCount = pos.Count();
|
|
|
+ var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == int.Parse(storeInfo.BrandId));
|
|
|
+ if (brandInfo.Name.Contains("电签"))
|
|
|
+ {
|
|
|
+ amount = 100;
|
|
|
+ }
|
|
|
+ if (brandInfo.Name.Contains("大POS"))
|
|
|
+ {
|
|
|
+ amount = 150;
|
|
|
+ }
|
|
|
if (IsOk == "1")
|
|
|
{
|
|
|
foreach (var items in pos)
|
|
|
{
|
|
|
var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == items.Id) ?? new PosMachinesTwo();
|
|
|
posInfo.OpId = sysAdmin.UserId;
|
|
|
+ if (userAmount.ValidAmount - amount >= 0)
|
|
|
+ {
|
|
|
+ posInfo.OpReserveKind = 3;//标记为关联分仓额度
|
|
|
+ userAmount.ValidAmount -= amount;
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (userAmount.TotalAmt - amount >= 0)
|
|
|
+ {
|
|
|
+ posInfo.OpReserveKind = 1;//标记为未使用额度
|
|
|
+ userAmount.TotalAmt -= amount;
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (userAmount.ValidForGetAmount - amount >= 0)
|
|
|
+ {
|
|
|
+ posInfo.OpReserveKind = 2;//标记为可提现额度
|
|
|
+ userAmount.ValidForGetAmount -= amount;
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
sysAdmin.TotalMachineCount += posCount;//添加总机具数
|
|
|
@@ -1727,8 +1767,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
SeoDescription = "关联分仓",
|
|
|
OperateType = 1,
|
|
|
UseAmount = deposit - tamount,
|
|
|
- BeforeAmount = userAmount.ValidAmount,
|
|
|
- AfterAmount = userAmount.ValidAmount + deposit - tamount,
|
|
|
+ BeforeAmount = TotalAmount,
|
|
|
+ AfterAmount = TotalAmount + deposit- tamount,
|
|
|
}).Entity;
|
|
|
}
|
|
|
if (deposit < tamount)
|
|
|
@@ -1740,19 +1780,21 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
SeoDescription = "关联分仓",
|
|
|
OperateType = 2,
|
|
|
UseAmount = tamount - deposit,
|
|
|
- BeforeAmount = userAmount.ValidAmount,
|
|
|
- AfterAmount = userAmount.ValidAmount + deposit - tamount,
|
|
|
+ BeforeAmount = TotalAmount,
|
|
|
+ AfterAmount = TotalAmount + deposit - tamount,
|
|
|
}).Entity;
|
|
|
}
|
|
|
- userAmount.ValidAmount -= tamount;//扣减关联分仓机具占用额度
|
|
|
- userAmount.ValidAmount += deposit;//增加关联分仓押金
|
|
|
+ // userAmount.ValidAmount -= tamount;//扣减关联分仓机具占用额度
|
|
|
+ // userAmount.ValidAmount += deposit;//增加关联分仓押金
|
|
|
opdb.SaveChanges();
|
|
|
}
|
|
|
- sysAdmin.StoreCount += pCount;//添加关联分仓数
|
|
|
+ sysAdmin.StoreCount += idlist.Count();//添加关联分仓数
|
|
|
opdb.SaveChanges();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ userAmount.ValidAmount -= deposit;
|
|
|
+ opdb.SaveChanges();
|
|
|
return "运营中心额度不足";
|
|
|
}
|
|
|
}
|
|
|
@@ -1769,7 +1811,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
UserForMakerCode userFor = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
|
|
|
OpModels.UserAccount account = opdb.UserAccount.FirstOrDefault(m => m.Id == userFor.UserId) ?? new OpModels.UserAccount();
|
|
|
- return account.ValidAmount.ToString("f2");
|
|
|
+ decimal TotalAmount = account.ValidAmount + account.TotalAmt + account.ValidForGetAmount;
|
|
|
+ return TotalAmount.ToString("f2");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
@@ -1808,17 +1851,12 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
userIds += storeInfo.UserId + ",";
|
|
|
deposit += storeInfo.Deposit;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- deposit = storeInfo.Deposit;
|
|
|
- }
|
|
|
tamount = amount * posCount;//增加运营中心该品牌机具额度
|
|
|
totalAmount += tamount;//取消关联分仓打标记运营中心所需额度
|
|
|
}
|
|
|
- // totalAmount -= deposit;
|
|
|
ViewBag.RightInfo = RightInfo;
|
|
|
ViewBag.right = right;
|
|
|
- ViewBag.totalAmount = "取消关联机具获得额度:" + totalAmount;
|
|
|
+ ViewBag.totalAmount = "取消关联机具获得额度:" + totalAmount + "\n" + "取消关联分仓扣除押金:" + deposit;
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
@@ -1841,6 +1879,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (userForMakerCode.UserId > 0)
|
|
|
{
|
|
|
var sysAdmin = opdb.SysAdmin.FirstOrDefault(m => m.UserId == userForMakerCode.UserId);
|
|
|
+ var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
|
|
|
+ decimal TotalAmount = userAmount.ValidAmount + userAmount.TotalAmt + userAmount.ValidForGetAmount;
|
|
|
Fields.Add("OpId", 0);
|
|
|
if (sysAdmin.Id > 0)
|
|
|
{
|
|
|
@@ -1876,25 +1916,45 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
userIds += store.UserId + ",";
|
|
|
deposit += store.Deposit;//增加分仓押金
|
|
|
}
|
|
|
- else
|
|
|
+ foreach (var items in pos)
|
|
|
{
|
|
|
- deposit = store.Deposit;//增加分仓押金
|
|
|
+ var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == items.Id) ?? new PosMachinesTwo();
|
|
|
+ if (posInfo.OpReserveKind == 3)
|
|
|
+ {
|
|
|
+ userAmount.ValidAmount += amount;//标记为关联分仓额度
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ if (posInfo.OpReserveKind == 1)
|
|
|
+ {
|
|
|
+ userAmount.TotalAmt += amount;//标记为未使用额度
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ if (posInfo.OpReserveKind == 2)
|
|
|
+ {
|
|
|
+ userAmount.ValidForGetAmount += amount;//标记为可提现额度
|
|
|
+ opdb.SaveChanges();
|
|
|
+ }
|
|
|
+ posInfo.OpReserveKind = 0;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
tamount += amount * posCount;//扣减运营中心该品牌机具额度
|
|
|
pCount += posCount;//添加总机具数
|
|
|
}
|
|
|
}
|
|
|
+ //扣减押金
|
|
|
+ userAmount.ValidAmount -= deposit;
|
|
|
+ opdb.SaveChanges();
|
|
|
if (!string.IsNullOrEmpty(error))
|
|
|
{
|
|
|
return "Warning|" + error;
|
|
|
}
|
|
|
- var userAmount = opdb.UserAccount.FirstOrDefault(m => m.Sort == sysAdmin.Id) ?? new OpModels.UserAccount();
|
|
|
- if (userAmount.ValidAmount - deposit + tamount >= 0)
|
|
|
+ if (TotalAmount - deposit >= 0)
|
|
|
{
|
|
|
foreach (var item in idlist)
|
|
|
{
|
|
|
int StoreId = int.Parse(item);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreHouse", Fields, StoreId);
|
|
|
+ db.SaveChanges();
|
|
|
var store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId && m.StoreKind != 2);
|
|
|
var pos = db.PosMachinesTwo.Where(m => m.StoreId == StoreId && m.UserId == 0 && m.BuyUserId == 0 && m.PreUserId == 0 && m.OpId == sysAdmin.UserId).ToList();
|
|
|
foreach (var items in pos)
|
|
|
@@ -1913,7 +1973,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
}
|
|
|
userAmount.ValidAmount -= deposit;//扣减关联分仓押金
|
|
|
- userAmount.ValidAmount += tamount;//添加关联仓库机占用额度
|
|
|
+ // userAmount.ValidAmount += tamount;//添加关联仓库机占用额度
|
|
|
+
|
|
|
sysAdmin.StoreCount -= idlist.Count();//减少关联分仓数
|
|
|
sysAdmin.TotalMachineCount -= pCount;//减少关联分仓机具数
|
|
|
if (deposit > tamount)
|
|
|
@@ -1925,8 +1986,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
SeoDescription = "取消关联分仓",
|
|
|
OperateType = 2,
|
|
|
UseAmount = deposit - tamount,
|
|
|
- BeforeAmount = userAmount.ValidAmount,
|
|
|
- AfterAmount = userAmount.ValidAmount - deposit + tamount,
|
|
|
+ BeforeAmount = TotalAmount,
|
|
|
+ AfterAmount = TotalAmount - deposit + tamount,
|
|
|
}).Entity;
|
|
|
}
|
|
|
if (deposit < tamount)
|
|
|
@@ -1938,8 +1999,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
SeoDescription = "取消关联分仓",
|
|
|
OperateType = 1,
|
|
|
UseAmount = tamount - deposit,
|
|
|
- BeforeAmount = userAmount.ValidAmount,
|
|
|
- AfterAmount = userAmount.ValidAmount - deposit + tamount,
|
|
|
+ BeforeAmount = TotalAmount,
|
|
|
+ AfterAmount = TotalAmount - deposit + tamount,
|
|
|
}).Entity;
|
|
|
}
|
|
|
opdb.SaveChanges();
|