|
|
@@ -284,8 +284,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// <returns></returns>
|
|
|
public string Cancel(int Id)
|
|
|
{
|
|
|
- AddSysLog(Id, "StoreMachineApply", "cancel");
|
|
|
- AddSysLog(Id, "Orders", "cancel");
|
|
|
StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id);
|
|
|
Orders order = db.Orders.FirstOrDefault(m => m.Id == storeMachineApply.OrderId);
|
|
|
if (storeMachineApply != null && order != null)
|
|
|
@@ -295,104 +293,9 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
db.Orders.Remove(order);
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
+ AddSysLog(Id, "StoreMachineApply", "cancel");
|
|
|
+ AddSysLog(Id, "Orders", "cancel");
|
|
|
return "success";
|
|
|
- // if (storeMachineApply != null)
|
|
|
- // {
|
|
|
- // Orders order = db.Orders.FirstOrDefault(m => m.Id == storeMachineApply.OrderId);
|
|
|
- // if (order != null)
|
|
|
- // {
|
|
|
- // string SwapSnExpand = storeMachineApply.SwapSnExpand;
|
|
|
- // if (!string.IsNullOrEmpty(SwapSnExpand))
|
|
|
- // {
|
|
|
- // string[] list = SwapSnExpand.TrimEnd('\n').Split('\n');
|
|
|
- // if (storeMachineApply.Sort > 0)
|
|
|
- // {
|
|
|
- // int Kind = storeMachineApply.Sort - 1;
|
|
|
- // string ChangeRecordNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
- // int CouponCount = 0;
|
|
|
- // foreach (string sub in list)
|
|
|
- // {
|
|
|
- // PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.ExchangeCode == sub && m.UserId == order.UserId && m.IsUse == 1);
|
|
|
- // if (coupon != null)
|
|
|
- // {
|
|
|
- // coupon.IsUse = 0;
|
|
|
- // coupon.IsLock = 0;
|
|
|
- // coupon.UseDate = DateTime.Parse("1900-01-01");
|
|
|
- // PosCouponRecord query = db.PosCouponRecord.Add(new PosCouponRecord()
|
|
|
- // {
|
|
|
- // QueryCount = Kind,
|
|
|
- // CreateDate = DateTime.Now,
|
|
|
- // ChangeKind = 1,
|
|
|
- // OrderNo = ChangeRecordNo,
|
|
|
- // ToUserId = order.UserId,
|
|
|
- // FromUserId = order.UserId,
|
|
|
- // PosCouponId = coupon.Id,
|
|
|
- // }).Entity;
|
|
|
- // CouponCount += 1;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (CouponCount > 0)
|
|
|
- // {
|
|
|
- // PosCouponForUser forUser = db.PosCouponForUser.FirstOrDefault(m => m.Id == order.UserId);
|
|
|
- // if (forUser == null)
|
|
|
- // {
|
|
|
- // forUser = db.PosCouponForUser.Add(new PosCouponForUser()
|
|
|
- // {
|
|
|
- // Id = order.UserId,
|
|
|
- // }).Entity;
|
|
|
- // db.SaveChanges();
|
|
|
- // }
|
|
|
- // int BeforeOut = forUser.OutNum;
|
|
|
- // int BeforeTotal = forUser.TotalNum;
|
|
|
- // int BeforeStock = forUser.StockNum;
|
|
|
- // forUser.StockNum += CouponCount;
|
|
|
- // int AfterOut = forUser.OutNum;
|
|
|
- // int AfterTotal = forUser.TotalNum;
|
|
|
- // int AfterStock = forUser.StockNum;
|
|
|
- // PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
|
|
|
- // {
|
|
|
- // QueryCount = Kind,
|
|
|
- // CreateDate = DateTime.Now,
|
|
|
- // ChangeKind = 1,
|
|
|
- // ChangeCount = CouponCount,
|
|
|
- // AfterOut = AfterOut,
|
|
|
- // AfterTotal = AfterTotal,
|
|
|
- // AfterStock = AfterStock,
|
|
|
- // BeforeOut = BeforeOut,
|
|
|
- // BeforeTotal = BeforeTotal,
|
|
|
- // BeforeStock = BeforeStock,
|
|
|
- // OrderNo = ChangeRecordNo,
|
|
|
- // ToUserId = order.UserId,
|
|
|
- // FromUserId = order.UserId,
|
|
|
- // }).Entity;
|
|
|
- // }
|
|
|
- // function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(storeMachineApply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
|
|
|
- // db.StoreMachineApply.Remove(storeMachineApply);
|
|
|
- // db.Orders.Remove(order);
|
|
|
- // db.SaveChanges();
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // foreach (string sub in list)
|
|
|
- // {
|
|
|
- // string SourcePosSn = sub.Split(':')[0];
|
|
|
- // MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SourcePosSn) ?? new MachineForSnNo();
|
|
|
- // PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forSnNo.SnId);
|
|
|
- // if (pos != null)
|
|
|
- // {
|
|
|
- // function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(storeMachineApply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
|
|
|
- // pos.IsPurchase = 0;
|
|
|
- // RedisDbconn.Instance.Clear("PosMachinesTwo:" + pos.Id);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // db.StoreMachineApply.Remove(storeMachineApply);
|
|
|
- // db.Orders.Remove(order);
|
|
|
- // db.SaveChanges();
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return "success";
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
@@ -457,7 +360,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region 导入数据
|
|
|
+ #region 导入数据
|
|
|
|
|
|
public IActionResult Import(string right, string ExcelKind)
|
|
|
{
|
|
|
@@ -471,12 +374,34 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="ExcelData"></param>
|
|
|
[HttpPost]
|
|
|
- public string ImportPost(string ExcelPath, int Kind = 0)
|
|
|
+ public string ImportPost(string ExcelData)
|
|
|
{
|
|
|
- // RedisDbconn.Instance.AddList("ExcelImport", ExcelPath + "#cut#" + Kind);
|
|
|
- string key = function.MD5_16(Guid.NewGuid().ToString());
|
|
|
- RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key);
|
|
|
- return "success|" + key;
|
|
|
+ // // RedisDbconn.Instance.AddList("ExcelImport", ExcelPath + "#cut#" + Kind);
|
|
|
+ // string key = function.MD5_16(Guid.NewGuid().ToString());
|
|
|
+ // RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key);
|
|
|
+ // return "success|" + key;
|
|
|
+ ExcelData = HttpUtility.UrlDecode(ExcelData);
|
|
|
+ JsonData list = JsonMapper.ToObject(ExcelData);
|
|
|
+ for (int i = 1; i < list.Count; i++)
|
|
|
+ {
|
|
|
+ JsonData dr = list[i];
|
|
|
+ // string SwapSnExpand = dr[0].ToString();
|
|
|
+ var temp = dr[0].ToString();
|
|
|
+ temp = temp.Substring(1);
|
|
|
+ temp = temp.Substring(0, temp.Length - 1);
|
|
|
+ var SwapSnExpand = temp.Split(",,");
|
|
|
+ // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.MakerCode == MakerCode);
|
|
|
+ // if (UserCode != null)
|
|
|
+ // {
|
|
|
+ // Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
|
|
|
+ // if (User != null)
|
|
|
+ // {
|
|
|
+ // User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ return "success";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -625,8 +550,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
StoreHouse storeHouse = db.StoreHouse.FirstOrDefault(m => m.Id == editData.StoreId) ?? new StoreHouse();
|
|
|
- ViewBag.MakerCode=users.MakerCode;
|
|
|
- ViewBag.RealName=users.RealName;
|
|
|
+ ViewBag.MakerCode = users.MakerCode;
|
|
|
+ ViewBag.RealName = users.RealName;
|
|
|
|
|
|
return View();
|
|
|
}
|
|
|
@@ -648,6 +573,35 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
StoreMachineApply apply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id) ?? new StoreMachineApply();
|
|
|
StoreHouse tostore = db.StoreHouse.FirstOrDefault(m=>m.Id == apply.StoreId) ?? new StoreHouse();
|
|
|
int BrandId = apply.BrandId.Value;
|
|
|
+ var FromStoreId = 0;
|
|
|
+ if (BrandId==1)
|
|
|
+ {
|
|
|
+ FromStoreId=7;
|
|
|
+ }
|
|
|
+ else if (BrandId==2)
|
|
|
+ {
|
|
|
+ FromStoreId=721;
|
|
|
+ }
|
|
|
+ else if (BrandId==3)
|
|
|
+ {
|
|
|
+ FromStoreId=697;
|
|
|
+ }
|
|
|
+ else if (BrandId==4)
|
|
|
+ {
|
|
|
+ FromStoreId=774;
|
|
|
+ }
|
|
|
+ else if (BrandId==5)
|
|
|
+ {
|
|
|
+ FromStoreId=775;
|
|
|
+ }
|
|
|
+ else if (BrandId==6)
|
|
|
+ {
|
|
|
+ FromStoreId=871;
|
|
|
+ }
|
|
|
+ else if (BrandId==7)
|
|
|
+ {
|
|
|
+ FromStoreId=0;
|
|
|
+ }
|
|
|
ExcelData = HttpUtility.UrlDecode(ExcelData);
|
|
|
JsonData list = JsonMapper.ToObject(ExcelData);
|
|
|
Dictionary<string, int> storeData = new Dictionary<string, int>();
|
|
|
@@ -659,6 +613,11 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
|
|
|
string BatchNo = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
|
|
|
string OutNote = itemJson.Contains("\"C\"") ? dr["B"].ToString() : "";
|
|
|
+ StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id);
|
|
|
+ if (storeMachineApply != null)
|
|
|
+ {
|
|
|
+ storeMachineApply.SwapSnExpand = function.CheckString(SnNo)+',';
|
|
|
+ }
|
|
|
MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
|
|
|
PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.StoreId != apply.StoreId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
|
|
|
if (machine.Id > 0)
|
|
|
@@ -666,7 +625,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
|
|
|
{
|
|
|
CreateDate = DateTime.Now,
|
|
|
- StoreId = 7, //出货仓库
|
|
|
+ StoreId = FromStoreId, //出货仓库
|
|
|
BrandId = BrandId, //产品类型
|
|
|
ProductName = RelationClass.GetKqProductBrandInfo(BrandId), //产品名称
|
|
|
BizBatchNo = BatchNo, //业务批次号
|
|
|
@@ -742,7 +701,9 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
}
|
|
|
- int StoreId = 7;
|
|
|
+ db.SaveChanges();
|
|
|
+
|
|
|
+ int StoreId = FromStoreId;
|
|
|
int OpStoreNum = list.Count - 1;
|
|
|
StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
|
|
|
@@ -813,7 +774,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
#endregion
|
|
|
|
|
|
}
|