Просмотр исходного кода

调整后台分仓机具申请-审核发货逻辑

lichunlei 4 лет назад
Родитель
Сommit
3f29645707
1 измененных файлов с 45 добавлено и 184 удалено
  1. 45 184
      Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

+ 45 - 184
Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

@@ -452,11 +452,35 @@ namespace MySystem.Areas.Admin.Controllers
 
             ExcelData = HttpUtility.UrlDecode(ExcelData);
             JsonData list = JsonMapper.ToObject(ExcelData);
+            for (int index = 1; index < list.Count; index++)
+            {
+                JsonData dr = list[index];
+                string itemJson = dr.ToJson();
+                string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                BrandId = Convert.ToInt32(Brand);
+                if (BrandId == 1) FromStoreId = 7;
+                if (BrandId == 2) FromStoreId = 721;
+                if (BrandId == 3) FromStoreId = 697;
+                if (BrandId == 4) FromStoreId = 774;
+                if (BrandId == 5) FromStoreId = 775;
+                if (BrandId == 6) FromStoreId = 871;
+                if (BrandId == 7) FromStoreId = 1047;
+                PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
+                if (posMachinesTwo == null)
+                {
+                    error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
+                }
+            }
+            if(!string.IsNullOrEmpty(error))
+            {
+                return "Warning" + error;
+            }
             Dictionary<string, int> storeData = new Dictionary<string, int>();
             Dictionary<string, int> toStoreData = new Dictionary<string, int>();
-            for (int i = 1; i < list.Count; i++)
+            for (int index = 1; index < list.Count; index++)
             {
-                JsonData dr = list[i];
+                JsonData dr = list[index];
                 string itemJson = dr.ToJson();
                 string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
                 string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
@@ -466,190 +490,29 @@ namespace MySystem.Areas.Admin.Controllers
                 BrandId = Convert.ToInt32(Brand);
                 // PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
 
-
-
-                if (BrandId == 1)
-                {
-                    FromStoreId = 7;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
-                }
-                else if (BrandId == 2)
-                {
-                    FromStoreId = 721;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
-                }
-                else if (BrandId == 3)
-                {
-                    FromStoreId = 697;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
-                }
-                else if (BrandId == 4)
-                {
-                    FromStoreId = 774;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
-                }
-                else if (BrandId == 5)
-                {
-                    FromStoreId = 775;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
-                }
-                else if (BrandId == 6)
+                if (BrandId == 1) FromStoreId = 7;
+                if (BrandId == 2) FromStoreId = 721;
+                if (BrandId == 3) FromStoreId = 697;
+                if (BrandId == 4) FromStoreId = 774;
+                if (BrandId == 5) FromStoreId = 775;
+                if (BrandId == 6) FromStoreId = 871;
+                if (BrandId == 7) FromStoreId = 1047;
+                tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
+                SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
+                if (item == null)
                 {
-                    FromStoreId = 871;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
+                    SendInfo row = new SendInfo()
                     {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
+                        FromStoreId = FromStoreId,
+                        ToStoreId = tostore.Id,
+                        BrandId = BrandId,
+                        Num = 1
+                    };
+                    sendInfos.Add(row);
                 }
-                else if (BrandId == 7)
+                else
                 {
-                    FromStoreId = 1047;
-                    PosMachinesTwo posMachinesTwo = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo && m.StoreId == FromStoreId);
-                    if (posMachinesTwo == null)
-                    {
-                        error += "以下操作失败" + SnNo + ',' + "该机具重复发货" + '|' + '\n';
-                    }
-                    tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
-                    SendInfo item = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
-                    if (item == null)
-                    {
-                        SendInfo row = new SendInfo()
-                        {
-                            FromStoreId = FromStoreId,
-                            ToStoreId = tostore.Id,
-                            BrandId = BrandId,
-                            Num = 1
-                        };
-                        sendInfos.Add(row);
-                    }
-                    else
-                    {
-                        item.Num += 1;
-                    }
+                    item.Num += 1;
                 }
 
                 apply.SeoDescription = function.CheckString(SnNo) + ',';
@@ -723,9 +586,7 @@ namespace MySystem.Areas.Admin.Controllers
                     machine.UpdateDate = DateTime.Now;
                 }
 
-                return "Warning" + error;
             }
-
             //判断发货数和申请数
             if (data.ApplyNum == data.SendNum)
             {