|
|
@@ -168,7 +168,9 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.data = editData;
|
|
|
|
|
|
Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
+ ViewBag.UserId = users.Id;
|
|
|
ViewBag.RealName = users.RealName;
|
|
|
+ ViewBag.UseAmount = editData.UseAmount;
|
|
|
JsonData SendSnList = new JsonData();
|
|
|
SendSnList = JsonMapper.ToObject(editData.SendSn);//申请数据
|
|
|
List<Dictionary<string, object>> KsProductList = new List<Dictionary<string, object>>();
|
|
|
@@ -203,18 +205,25 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
public string Edit(StoreMachineApply data)
|
|
|
{
|
|
|
Dictionary<string, object> Fields = new Dictionary<string, object>();
|
|
|
-
|
|
|
+ Fields.Add("SendSn", data.SendSn); //发货SN数据
|
|
|
+ JsonData SendSnList = new JsonData();
|
|
|
+ SendSnList = JsonMapper.ToObject(data.SendSn);//申请数据
|
|
|
+ int ApplyNum = 0;
|
|
|
+ for (int i = 0; i < SendSnList.Count; i++)
|
|
|
+ {
|
|
|
+ int num = Convert.ToInt32(SendSnList[i]["ApplyNum"].ToString());
|
|
|
+ ApplyNum += num;
|
|
|
+ }
|
|
|
Fields.Add("BrandId", data.BrandId); //品牌
|
|
|
Fields.Add("ApplyNo", data.ApplyNo); //申请单号
|
|
|
- Fields.Add("ApplyNum", data.ApplyNum); //申请台数
|
|
|
+ Fields.Add("ApplyNum", ApplyNum); //申请台数
|
|
|
Fields.Add("SendNum", data.SendNum); //发货台数
|
|
|
Fields.Add("UseAmount", data.UseAmount); //使用额度
|
|
|
Fields.Add("SendMode", data.SendMode); //发货方式
|
|
|
Fields.Add("ErpCode", data.ErpCode); //快递单号
|
|
|
- Fields.Add("SendSn", data.SendSn); //发货SN数据
|
|
|
Fields.Add("UserId", data.UserId); //创客
|
|
|
|
|
|
- Fields.Add("SeoTitle", data.SeoTitle);
|
|
|
+ Fields.Add("SeoTitle", SysUserName + '-' + SysRealName);
|
|
|
Fields.Add("SeoKeyword", data.SeoKeyword);
|
|
|
Fields.Add("SeoDescription", data.SeoDescription);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
|
|
|
@@ -434,16 +443,33 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
Dictionary<string, object> Fields = new Dictionary<string, object>();
|
|
|
Fields.Add("ApplyNum", data.ApplyNum); //申请数
|
|
|
- Fields.Add("SendNum", data.SendNum); //发货数
|
|
|
+ Fields.Add("SendNum", data.ApplyNum); //发货数
|
|
|
Fields.Add("ErpCode", data.ErpCode); //快递单号
|
|
|
Fields.Add("SendMode", data.SendMode); //发货方式
|
|
|
Fields.Add("SeoKeyword", data.SeoKeyword); //申请描述
|
|
|
- Fields.Add("Status", data.Status);
|
|
|
+ Fields.Add("Status", 1);
|
|
|
AddSysLog(data.Id.ToString(), "StoreMachineApply", "AuditSend");
|
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
|
List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
|
List<SendInfo> sendInfos = new List<SendInfo>();
|
|
|
StoreMachineApply apply = db.StoreMachineApply.FirstOrDefault(m => m.Id == data.Id) ?? new StoreMachineApply();
|
|
|
+ JsonData ApplyList = JsonMapper.ToObject(apply.SendSn);
|
|
|
+ decimal ApplyAmount = 0;
|
|
|
+ decimal Amount = 0;
|
|
|
+ for (int i = 0; i < ApplyList.Count; i++)
|
|
|
+ {
|
|
|
+ int num = Convert.ToInt32(ApplyList[i]["ApplyNum"].ToString());
|
|
|
+ int BrandIds = Convert.ToInt32(ApplyList[i]["BrandId"].ToString());
|
|
|
+ if (BrandIds == 1 || BrandIds == 2 || BrandIds == 4 || BrandIds == 6 || BrandIds == 7 || BrandIds == 8)
|
|
|
+ {
|
|
|
+ ApplyAmount += num * 200;
|
|
|
+ }
|
|
|
+ if (BrandIds == 3 || BrandIds == 5 || BrandIds == 9)
|
|
|
+ {
|
|
|
+ ApplyAmount += num * 300;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Amount = apply.UseAmount - ApplyAmount;
|
|
|
StoreHouse tostore = new StoreHouse();
|
|
|
StoreHouse fromstore = new StoreHouse();
|
|
|
|
|
|
@@ -453,6 +479,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
ExcelData = HttpUtility.UrlDecode(ExcelData);
|
|
|
JsonData list = JsonMapper.ToObject(ExcelData);
|
|
|
+ List<string> PosSnList = new List<string>();
|
|
|
for (int index = 1; index < list.Count; index++)
|
|
|
{
|
|
|
JsonData dr = list[index];
|
|
|
@@ -470,13 +497,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (BrandId == 7) FromStoreId = 1047;
|
|
|
if (BrandId == 8) FromStoreId = 4831;
|
|
|
if (BrandId == 9) FromStoreId = 4832;
|
|
|
- PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
|
|
|
- if (posMachinesTwo == null)
|
|
|
+ if (PosSnList.Contains(SnNo))
|
|
|
{
|
|
|
error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '\n';
|
|
|
}
|
|
|
+ PosSnList.Add(SnNo);
|
|
|
}
|
|
|
- if(!string.IsNullOrEmpty(error))
|
|
|
+ if (!string.IsNullOrEmpty(error))
|
|
|
{
|
|
|
return "Warning|" + error;
|
|
|
}
|
|
|
@@ -596,56 +623,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- //判断发货数和申请数
|
|
|
- if (data.ApplyNum == data.SendNum)
|
|
|
- {
|
|
|
- foreach (var item in sendInfos)
|
|
|
- {
|
|
|
- KqProducts kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == item.BrandId);
|
|
|
- if (kqProducts.Name.Contains("大Pos"))
|
|
|
- {
|
|
|
- var Amount = Convert.ToUInt32(item.Num) * 300;
|
|
|
- apply.UseAmount += Amount;
|
|
|
- }
|
|
|
- if (kqProducts.Name.Contains("电签"))
|
|
|
- {
|
|
|
- var Amount = Convert.ToUInt32(item.Num) * 200;
|
|
|
- apply.UseAmount += Amount;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (data.ApplyNum > data.SendNum)
|
|
|
- {
|
|
|
- JsonData ApplyList = JsonMapper.ToObject(apply.SendSn);
|
|
|
- for (int i = 0; i < ApplyList.Count; i++)
|
|
|
- {
|
|
|
- int Id = Convert.ToInt32(ApplyList[i]["BrandId"].ToString());
|
|
|
- int num = Convert.ToInt32(ApplyList[i]["ApplyNum"].ToString());
|
|
|
- SendInfo item = sendInfos.FirstOrDefault(m => m.BrandId == Id);
|
|
|
- KqProducts kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == Id);
|
|
|
- if (item != null)
|
|
|
- {
|
|
|
- if (kqProducts.Name.Contains("大POS"))
|
|
|
- {
|
|
|
- UserAccount userAccount = db.UserAccount.FirstOrDefault(m => m.UserId == apply.UserId);
|
|
|
- var Amounts = Convert.ToUInt32(item.Num) * 300;
|
|
|
- var Amount = (num - Convert.ToUInt32(item.Num)) * 300;
|
|
|
- // userAccount.FixedAmount += Amount;
|
|
|
- userAccount.ValidAmount += Amount;//可用额度操作
|
|
|
- apply.UseAmount += Amounts;
|
|
|
- }
|
|
|
- if (kqProducts.Name.Contains("电签"))
|
|
|
- {
|
|
|
- UserAccount userAccount = db.UserAccount.FirstOrDefault(m => m.UserId == apply.UserId);
|
|
|
- var Amounts = Convert.ToUInt32(item.Num) * 200;
|
|
|
- var Amount = (num - Convert.ToUInt32(item.Num)) * 200;
|
|
|
- // userAccount.FixedAmount += Amount;
|
|
|
- userAccount.ValidAmount += Amount;//可用额度操作
|
|
|
- apply.UseAmount += Amounts;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
foreach (var item in sendInfos)
|
|
|
{
|
|
|
@@ -660,7 +637,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
OpStoreNum = item.Num, //操作库存数
|
|
|
OpSymbol = "-", //操作符
|
|
|
BeforeTotalNum = storeCH.TotalNum, //操作前总库存数
|
|
|
- AfterTotalNum = storeCH.TotalNum, //操作后总库存数
|
|
|
+ AfterTotalNum = storeCH.TotalNum - item.Num, //操作后总库存数
|
|
|
BeforeLaveNum = storeCH.LaveNum, //操作前剩余库存数
|
|
|
AfterLaveNum = storeCH.LaveNum - item.Num, //操作后剩余库存数
|
|
|
BeforeOutNum = storeCH.OutNum, //操作前出库数
|
|
|
@@ -706,21 +683,16 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
balance.TransRecordNo = ChangeNo2; //交易流水编号
|
|
|
storeSH.TotalNum += item.Num;
|
|
|
storeSH.LaveNum += item.Num;
|
|
|
- storeSH.TotalNum += item.Num;
|
|
|
}
|
|
|
- apply.SeoTitle = SysUserName +'-'+ SysRealName;//添加操作人信息
|
|
|
-
|
|
|
+ apply.SeoTitle = SysUserName + '-' + SysRealName;//添加操作人信息
|
|
|
+ apply.UseAmount = ApplyAmount;
|
|
|
+
|
|
|
db.SaveChanges();
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
|
|
|
|
|
|
- if (data.Status == 1)
|
|
|
- {
|
|
|
- return "success";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return "false";
|
|
|
- }
|
|
|
+ string SendData = "{\"Kind\":\"2\",\"Data\":{\"UserId\":\"" + apply.UserId + "\",\"Amount\":\"" + Amount + "\",\"OperateType\":\"1\"}}";
|
|
|
+ RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
|
|
|
+ return "success";
|
|
|
|
|
|
}
|
|
|
#endregion
|