|
|
@@ -51,21 +51,22 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// 分仓机具申请记录列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public JsonResult IndexData(StoreMachineApply data, string BrandIdSelect, string UserIdRealName, string UserIdMakerCode, int page = 1, int limit = 30)
|
|
|
+ public JsonResult IndexData(StoreMachineApply data, string UserIdRealName, string UserIdMakerCode, string CreateDateData, int page = 1, int limit = 30)
|
|
|
{
|
|
|
|
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
|
|
|
|
- Fields.Add("CreateDate", "3"); //时间
|
|
|
Fields.Add("ApplyNo", "1"); //申请单号
|
|
|
Fields.Add("SendMode", "1"); //发货方式
|
|
|
|
|
|
|
|
|
string condition = " and Status>-1";
|
|
|
- //品牌
|
|
|
- if (!string.IsNullOrEmpty(BrandIdSelect))
|
|
|
+ if (!string.IsNullOrEmpty(CreateDateData))
|
|
|
{
|
|
|
- condition += " and BrandId=" + BrandIdSelect;
|
|
|
+ string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
|
|
|
+ string start = datelist[0];
|
|
|
+ string end = datelist[1];
|
|
|
+ condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
|
|
|
}
|
|
|
//创客真实姓名
|
|
|
if (!string.IsNullOrEmpty(UserIdRealName))
|
|
|
@@ -85,7 +86,10 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
//品牌
|
|
|
dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
|
|
|
- dic["StatusName"] = dic["Status"].ToString() == "1" ? "正常" : "关闭";
|
|
|
+ int Status = int.Parse(dic["Status"].ToString());
|
|
|
+ if (Status == 0) dic["StatusName"] = "待配货";
|
|
|
+ if (Status == 1) dic["StatusName"] = "已发货";
|
|
|
+ if (Status == 2) dic["StatusName"] = "已驳回";
|
|
|
//创客
|
|
|
int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
|
|
|
Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
@@ -160,9 +164,30 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.RightInfo = RightInfo;
|
|
|
ViewBag.right = right;
|
|
|
|
|
|
-
|
|
|
StoreMachineApply editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
|
|
|
ViewBag.data = editData;
|
|
|
+
|
|
|
+ Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
+ ViewBag.RealName = users.RealName;
|
|
|
+ JsonData SendSnList = new JsonData();
|
|
|
+ SendSnList = JsonMapper.ToObject(editData.SendSn);//申请数据
|
|
|
+ List<Dictionary<string, object>> KsProductList = new List<Dictionary<string, object>>();
|
|
|
+ for (int i = 0; i < SendSnList.Count; i++)
|
|
|
+ {
|
|
|
+ int BrandId = Convert.ToInt32(SendSnList[i]["BrandId"].ToString());
|
|
|
+ int Num = Convert.ToInt32(SendSnList[i]["ApplyNum"].ToString());
|
|
|
+ List<KqProducts> products = db.KqProducts.Where(m => m.Id == BrandId).ToList();
|
|
|
+ foreach (KqProducts product in products)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> item = new Dictionary<string, object>();
|
|
|
+ item.Add("BrandId", BrandId); //商品Id
|
|
|
+ item.Add("Name", product.Name); //商品名称
|
|
|
+ item.Add("Num", Num); //商品数量
|
|
|
+ KsProductList.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ViewBag.KsProductList = KsProductList;
|
|
|
+
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
@@ -262,7 +287,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
int id = int.Parse(subid);
|
|
|
Dictionary<string, object> Fields = new Dictionary<string, object>();
|
|
|
- Fields.Add("Status", 0);
|
|
|
+ Fields.Add("Status", 2);
|
|
|
new AdminContent(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
|
|
|
}
|
|
|
db.SaveChanges();
|
|
|
@@ -381,5 +406,324 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+
|
|
|
+ #region 审核发货
|
|
|
+
|
|
|
+ public IActionResult AuditSend(string right, int Id = 0)
|
|
|
+ {
|
|
|
+ ViewBag.RightInfo = RightInfo;
|
|
|
+ ViewBag.right = right;
|
|
|
+
|
|
|
+
|
|
|
+ StoreMachineApply editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
|
|
|
+ ViewBag.data = editData;
|
|
|
+
|
|
|
+ Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
+ ViewBag.MakerCode = users.MakerCode;
|
|
|
+ ViewBag.RealName = users.RealName;
|
|
|
+
|
|
|
+ return View();
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 审核发货
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public string AuditSend(StoreMachineApply data, string ExcelData)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> Fields = new Dictionary<string, object>();
|
|
|
+ Fields.Add("ApplyNum", data.ApplyNum); //申请数
|
|
|
+ Fields.Add("SendNum", data.SendNum); //发货数
|
|
|
+ Fields.Add("ErpCode", data.ErpCode); //快递单号
|
|
|
+ Fields.Add("SendMode", data.SendMode); //发货方式
|
|
|
+ Fields.Add("SeoKeyword", data.SeoKeyword); //申请描述
|
|
|
+ Fields.Add("Status", data.Status);
|
|
|
+ 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();
|
|
|
+ StoreHouse tostore = new StoreHouse();
|
|
|
+ StoreHouse fromstore = new StoreHouse();
|
|
|
+
|
|
|
+ var BrandId = 0;
|
|
|
+ var FromStoreId = 0;
|
|
|
+ string error = "";
|
|
|
+
|
|
|
+ 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 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() : "";
|
|
|
+ string BatchNo = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
|
|
|
+ string OutNote = itemJson.Contains("\"D\"") ? dr["D"].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;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ apply.SeoDescription = function.CheckString(SnNo) + ',';
|
|
|
+
|
|
|
+ fromstore = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId);
|
|
|
+ tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString());
|
|
|
+
|
|
|
+ MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
|
|
|
+ PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
|
|
|
+ if (machine.Id > 0)
|
|
|
+ {
|
|
|
+ StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ Sort = data.Id,//库存变动关联申请记录表
|
|
|
+ StoreId = FromStoreId, //出货仓库
|
|
|
+ BrandId = BrandId, //产品类型
|
|
|
+ ProductName = RelationClass.GetKqProductBrandInfo(BrandId), //产品名称
|
|
|
+ BizBatchNo = BatchNo, //业务批次号
|
|
|
+ TransType = 1, //交易类型
|
|
|
+ SnNo = SnNo, //SN编号
|
|
|
+ StockOpDirect = 1, //库存操作方向
|
|
|
+ SnStatus = 1, //SN状态
|
|
|
+ DeviceVendor = machine.DeviceName, //设备厂商
|
|
|
+ DeviceModel = machine.DeviceKind, //设备型号
|
|
|
+ DeviceType = machine.DeviceType, //设备类型
|
|
|
+ FromUserId = fromstore.UserId, //出货人
|
|
|
+ FromDate = DateTime.Now, //出库时间
|
|
|
+ FromRemark = OutNote, //出库备注
|
|
|
+ ToUserId = tostore.UserId, //收货人
|
|
|
+ ToStoreId = fromstore.Id, //退货收货仓库
|
|
|
+ SourceStoreId = machine.SourceStoreId, //源仓库编号
|
|
|
+ BrandType = machine.DeviceType, //品牌类型
|
|
|
+ }).Entity;
|
|
|
+
|
|
|
+ string ChangeNo = "CS";
|
|
|
+ int StoreStockChangeId = stockchange.Id;
|
|
|
+ string StoreStockChangeIdString = StoreStockChangeId.ToString();
|
|
|
+ for (int j = 0; j < 18 - StoreStockChangeId.ToString().Length; j++)
|
|
|
+ {
|
|
|
+ StoreStockChangeIdString = "0" + StoreStockChangeIdString;
|
|
|
+ }
|
|
|
+ ChangeNo += StoreStockChangeIdString;
|
|
|
+ stockchange.ChangeNo = ChangeNo; //交易流水编号
|
|
|
+ machine.StoreId = tostore.Id;
|
|
|
+
|
|
|
+ db.StoreChangeHistory.Add(new StoreChangeHistory()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UserId = fromstore.UserId, //创客
|
|
|
+ BrandId = BrandId, //产品类型
|
|
|
+ ChangeRecordNo = ChangeNo, //变更记录单号
|
|
|
+ BizBatchNo = BatchNo, //业务批次号
|
|
|
+ TransType = 1, //交易类型
|
|
|
+ SnNo = SnNo, //SN编号
|
|
|
+ SnType = machine.PosSnType, //SN机具类型
|
|
|
+ StockOpDirect = 1, //库存操作方向
|
|
|
+ DeviceVendor = machine.DeviceName, //设备厂商
|
|
|
+ DeviceModel = machine.DeviceKind, //设备型号
|
|
|
+ DeviceType = machine.DeviceType, //设备类型
|
|
|
+ FromUserId = fromstore.UserId, //出货创客
|
|
|
+ FromDate = DateTime.Now, //出库时间
|
|
|
+ FromRemark = OutNote, //出库备注
|
|
|
+ SourceStoreId = machine.SourceStoreId, //源仓库
|
|
|
+ StoreId = fromstore.Id, //仓库
|
|
|
+ ToUserId = tostore.UserId,//收货创客
|
|
|
+ });
|
|
|
+
|
|
|
+ //修改机具所属仓库
|
|
|
+ machine.StoreId = tostore.Id;
|
|
|
+ machine.UpdateDate = DateTime.Now;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return "总仓无该机具";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //判断发货数和申请数
|
|
|
+ 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;
|
|
|
+ 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;
|
|
|
+ apply.UseAmount += Amounts;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in sendInfos)
|
|
|
+ {
|
|
|
+ //出货仓库数据调整
|
|
|
+ StoreHouse storeCH = db.StoreHouse.FirstOrDefault(m => m.Id == item.FromStoreId) ?? new StoreHouse();
|
|
|
+ StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ StoreId = storeCH.Id, //仓库
|
|
|
+ TransType = 1, //交易类型
|
|
|
+ BrandId = BrandId, //产品类型
|
|
|
+ OpStoreNum = item.Num, //操作库存数
|
|
|
+ OpSymbol = "-", //操作符
|
|
|
+ BeforeTotalNum = storeCH.TotalNum, //操作前总库存数
|
|
|
+ AfterTotalNum = storeCH.TotalNum, //操作后总库存数
|
|
|
+ BeforeLaveNum = storeCH.LaveNum, //操作前剩余库存数
|
|
|
+ AfterLaveNum = storeCH.LaveNum - item.Num, //操作后剩余库存数
|
|
|
+ BeforeOutNum = storeCH.OutNum, //操作前出库数
|
|
|
+ AfterOutNum = storeCH.OutNum + item.Num, //操作后出库数
|
|
|
+ }).Entity;
|
|
|
+ string ChangeNo1 = "CS";
|
|
|
+ int StoreStockChangeId1 = balance.Id;
|
|
|
+ string StoreStockChangeId1String = StoreStockChangeId1.ToString();
|
|
|
+ for (int i = 0; i < 18 - StoreStockChangeId1.ToString().Length; i++)
|
|
|
+ {
|
|
|
+ StoreStockChangeId1String = "0" + StoreStockChangeId1String;
|
|
|
+ }
|
|
|
+ ChangeNo1 += StoreStockChangeId1String;
|
|
|
+ balance.TransRecordNo = ChangeNo1; //交易流水编号
|
|
|
+ storeCH.LaveNum -= item.Num;
|
|
|
+ storeCH.OutNum += item.Num;
|
|
|
+
|
|
|
+ //收货仓库数据调整
|
|
|
+ StoreHouse storeSH = db.StoreHouse.FirstOrDefault(m => m.Id == item.ToStoreId) ?? new StoreHouse();
|
|
|
+ balance = db.StoreBalance.Add(new StoreBalance()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ StoreId = storeSH.Id, //仓库
|
|
|
+ TransType = 0, //交易类型
|
|
|
+ BrandId = BrandId, //产品类型
|
|
|
+ OpStoreNum = item.Num, //操作库存数
|
|
|
+ OpSymbol = "+", //操作符
|
|
|
+ BeforeTotalNum = storeSH.TotalNum, //操作前总库存数
|
|
|
+ AfterTotalNum = storeSH.TotalNum + item.Num, //操作后总库存数
|
|
|
+ BeforeLaveNum = storeSH.LaveNum, //操作前剩余库存数
|
|
|
+ AfterLaveNum = storeSH.LaveNum + item.Num, //操作后剩余库存数
|
|
|
+ BeforeOutNum = storeSH.OutNum, //操作前出库数
|
|
|
+ AfterOutNum = storeSH.OutNum, //操作后出库数
|
|
|
+ }).Entity;
|
|
|
+ string ChangeNo2 = "CS";
|
|
|
+ int StoreStockChangeId2 = balance.Id;
|
|
|
+ string StoreStockChangeId2String = StoreStockChangeId2.ToString();
|
|
|
+ for (int i = 0; i < 18 - StoreStockChangeId2.ToString().Length; i++)
|
|
|
+ {
|
|
|
+ StoreStockChangeId2String = "0" + StoreStockChangeId2String;
|
|
|
+ }
|
|
|
+ ChangeNo2 += StoreStockChangeId2String;
|
|
|
+ balance.TransRecordNo = ChangeNo2; //交易流水编号
|
|
|
+ storeSH.TotalNum += item.Num;
|
|
|
+ storeSH.LaveNum += item.Num;
|
|
|
+ storeSH.TotalNum += item.Num;
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
|
|
|
+
|
|
|
+ if (data.Status == 1)
|
|
|
+ {
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return "false";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //发货信息实体类
|
|
|
+ private class SendInfo
|
|
|
+ {
|
|
|
+ public int FromStoreId { get; set; }
|
|
|
+ public int ToStoreId { get; set; }
|
|
|
+ public int BrandId { get; set; }
|
|
|
+ public int Num { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|