From 0e5c4a8e17dcefcc10b2507da61b099be12451d8 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期五, 12 一月 2024 12:52:52 +0800 Subject: [PATCH] 代理合作功能 --- zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciController.cs | 443 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 431 insertions(+), 12 deletions(-) diff --git a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciController.cs b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciController.cs index eca52ff..e9bff1a 100644 --- a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciController.cs +++ b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciController.cs @@ -17,6 +17,8 @@ using zhengcaioa.IService; using CommonToolsCore; using Services; +using Microsoft.Extensions.Configuration; +using Newtonsoft.Json.Linq; namespace zhengcaioa.Controllers.BusinessOrder { @@ -27,14 +29,25 @@ private readonly ILiaotianService _liaotianService; private readonly IOrderBanciService _orderBanciService; private readonly IOrderBanciDtlService _orderBanciDtlService; + private readonly IPltPageService _pltPageService; + private readonly IConfiguration _configuration; + private readonly IHttpClientFactory _clientFactory; + private readonly IExpertService _expertService; - - public OrderBanciController(ILogger<OrderBanciController> logger, ILiaotianService liaotianService, IOrderBanciService orderBanciService, IOrderBanciDtlService orderBanciDtlService) + public OrderBanciController(ILogger<OrderBanciController> logger, ILiaotianService liaotianService, IOrderBanciService orderBanciService, IOrderBanciDtlService orderBanciDtlService + , IPltPageService pltPageService + , IConfiguration configuration + , IHttpClientFactory clientFactory + , IExpertService expertService ) { _logger = logger; _liaotianService = liaotianService; _orderBanciService = orderBanciService; _orderBanciDtlService = orderBanciDtlService; + _pltPageService = pltPageService; + _configuration = configuration; + _clientFactory = clientFactory; + _expertService = expertService; } [CheckLogin] @@ -50,18 +63,34 @@ actionEntity.PageIco = "fa fa-search"; actionEntity.ActionName = "鏌ヨ"; actionlist.Add(actionEntity); - ActionEntity actionEntity1 = new ActionEntity(); - actionEntity1.OpenType = 0; - actionEntity1.ActionUrl = ""; - actionEntity1.ActionFun = "Add"; - actionEntity1.PageIco = "fa fa-plus"; - actionEntity1.ActionName = "鏂板"; - actionlist.Add(actionEntity1); + //ActionEntity actionEntity1 = new ActionEntity(); + //actionEntity1.OpenType = 0; + //actionEntity1.ActionUrl = ""; + //actionEntity1.ActionFun = "Add"; + //actionEntity1.PageIco = "fa fa-plus"; + //actionEntity1.ActionName = "鏂板"; + //actionlist.Add(actionEntity1); + var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanci/Index/"); + var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList(); + + var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList(); + + foreach (var pageEntity in pageEntities1) + { + ActionEntity actionEntity1 = new ActionEntity(); + actionEntity1.OpenType = pageEntity.OpenType; + actionEntity1.ActionUrl = ""; + actionEntity1.ActionFun = pageEntity.PageShortcut; + actionEntity1.PageIco = pageEntity.PageIco; + actionEntity1.ActionName = pageEntity.PageName; + actionlist.Add(actionEntity1); + } ViewData["ActionInfo"] = actionlist; + ViewData["ActionInfo2"] = pageEntities2; - + return View(); @@ -77,7 +106,9 @@ { var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); ViewData["curentuser"] = curentuser; - + var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanci/Index/"); + var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList(); + ViewData["ActionInfo2"] = pageEntities2; OrderBanciDTO dto = new OrderBanciDTO(); if (!String.IsNullOrEmpty(id)) { @@ -111,6 +142,221 @@ ViewData.Model = dto; return View(); + } + + + + //鍚庡彴鐣欏骇 + [CheckLogin] + public async Task<IActionResult> LiuzuoAsync(string id = null) + { + var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); + ViewData["curentuser"] = curentuser; + //var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanci/Index/"); + //var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList(); + //ViewData["ActionInfo2"] = pageEntities2; + + var orderBanciDTO = _orderBanciService.Get(id); + + + if (orderBanciDTO.Hang.HasValue && orderBanciDTO.Lie.HasValue) + { + //鏌ヨ搴т綅淇℃伅 + var orderBanciZuoweiDTOs = _orderBanciService.GetOrderBanciZuoweiList(orderBanciDTO.Id); + + try + { + string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; + string GetTrainingCoursesLockIDSeatId = _configuration.GetSection("GetTrainingCoursesLockIDSeatId").Value; + string url = huiyuanurl + GetTrainingCoursesLockIDSeatId + "?ClassID=" + orderBanciDTO.id; + Uri postUrl2 = new Uri(url); + + string result2 = string.Empty; + + + + var httpClient2 = _clientFactory.CreateClient(); + httpClient2.Timeout = new TimeSpan(0, 0, 10); + var Result2 = await httpClient2.GetAsync(postUrl2); + result2 = Result2.Content.ReadAsStringAsync().Result; + + + _logger.LogInformation("result2:" + result2); + JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); + + if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") + { + List<LockUser> lockUsers = JsonConvert.DeserializeObject<List<LockUser>>(jobjectresult["data"].ToString()); + + + foreach (var orderBanciZuoweiDTO in orderBanciZuoweiDTOs) + { + foreach (var lockUser in lockUsers) + { + if (orderBanciZuoweiDTO.ZuoweiId == lockUser.ID) + { + orderBanciZuoweiDTO.Status = "1"; + break; + } + } + } + + } + } + catch (Exception ex) + { + + } + + var orderBanciZuoweiDTOsret = new List<List<OrderBanciZuoweiDTO>>(); + for (int i = 0; i < orderBanciDTO.Hang; i++) + { + var orderBanciZuoweiDTOs1 = orderBanciZuoweiDTOs.Where(x => x.RowNo == (i + 1)).ToList(); + orderBanciZuoweiDTOsret.Add(orderBanciZuoweiDTOs1); + } + + + //鏌ヨ琚敤鎴烽攣瀹氱殑搴т綅 + orderBanciDTO.orderBanciZuoweiDTOs = orderBanciZuoweiDTOsret; + } + + ViewData.Model = orderBanciDTO; + return View(); + } + + + /// <summary> + /// 淇濆瓨鐣欎綔淇℃伅 + /// </summary> + /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param> + /// <returns></returns> + /// + [CheckLogin] + [HttpPost] + public async Task<IActionResult> SaveLiuzuoAsync(OrderBanciDTO data) + { + + var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); + ViewData["curentuser"] = curentuser; + ResultEntity resultEntity = new ResultEntity(); + resultEntity.Result = true; + var orderBanciZuoweiDTOs = _orderBanciService.GetOrderBanciZuoweiList(data.Id); + + + + + if (data.SeatID!=null&& data.SeatID.Length > 0) + { + //鏌ヨ琚敤鎴烽攣瀹氱殑搴т綅 + try + { + string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; + string GetTrainingCoursesLockIDSeatId = _configuration.GetSection("GetTrainingCoursesLockIDSeatId").Value; + string url = huiyuanurl + GetTrainingCoursesLockIDSeatId + "?ClassID=" + data.Id; + Uri postUrl2 = new Uri(url); + + string result2 = string.Empty; + + + + var httpClient2 = _clientFactory.CreateClient(); + httpClient2.Timeout = new TimeSpan(0, 0, 10); + var Result2 = await httpClient2.GetAsync(postUrl2); + result2 = Result2.Content.ReadAsStringAsync().Result; + + + _logger.LogInformation("result2:" + result2); + JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); + + if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") + { + List<LockUser> lockUsers = JsonConvert.DeserializeObject<List<LockUser>>(jobjectresult["data"].ToString()); + + + foreach (var SeatID in data.SeatID) + { + foreach (var lockUser in lockUsers) + { + if (SeatID == lockUser.ID) + { + resultEntity = new ResultEntity(); + resultEntity.Result = false; + resultEntity.Message = lockUser.Name + "搴т綅宸茬粡琚鎴烽�変腑锛佹棤娉曢鐣�"; + return new JsonResult(resultEntity); + } + } + } + + } + } + catch (Exception ex) + { + + } + + foreach (var seat in data.SeatID) + { + var orderBanciZuoweiDTO = orderBanciZuoweiDTOs.Where(x => x.ZuoweiId == seat).FirstOrDefault(); + if(orderBanciZuoweiDTO.Status == "1") + { + resultEntity = new ResultEntity(); + resultEntity.Result = false; + resultEntity.Message = orderBanciZuoweiDTO.SeatNo +"搴т綅宸茬粡琚鎴烽�変腑锛佹棤娉曢鐣�"; + return new JsonResult(resultEntity); + } + else if (orderBanciZuoweiDTO.Status == "0") + { + orderBanciZuoweiDTO.Status = "2"; + orderBanciZuoweiDTO.Modifier = curentuser.Id; + orderBanciZuoweiDTO.Modifytime = DateTime.Now; + resultEntity = _orderBanciService.saveZuowei(orderBanciZuoweiDTO); + } + } + + var delete = orderBanciZuoweiDTOs.Where(x => !data.SeatID.Contains(x.ZuoweiId)).ToList(); + if (delete != null && delete.Count > 0) + { + foreach (var orderBanciZuoweiDTO in delete) + { + if (orderBanciZuoweiDTO.Status == "2") + { + orderBanciZuoweiDTO.Status = "0"; + orderBanciZuoweiDTO.Modifier = curentuser.Id; + orderBanciZuoweiDTO.Modifytime = DateTime.Now; + resultEntity = _orderBanciService.saveZuowei(orderBanciZuoweiDTO); + } + } + } + + + + } + else + { + foreach (var orderBanciZuoweiDTO in orderBanciZuoweiDTOs) + { + if (orderBanciZuoweiDTO.Status == "2") + { + orderBanciZuoweiDTO.Status = "0"; + orderBanciZuoweiDTO.Modifier = curentuser.Id; + orderBanciZuoweiDTO.Modifytime = DateTime.Now; + resultEntity = _orderBanciService.saveZuowei(orderBanciZuoweiDTO); + } + + } + } + + + + + + + + + + + + return new JsonResult(resultEntity); } @@ -321,7 +567,7 @@ } - public IActionResult GetBanciAll(string id) + public async Task<IActionResult> GetBanciAllAsync(string id) { ReturnMsg<OrderBanciDTO> returnMsg = new ReturnMsg<OrderBanciDTO>(); returnMsg.code = 2; @@ -341,9 +587,83 @@ searchEntity.rows = 1000; searchEntity.OrderBanciId = id; orderBanciDTO.orderBanciDtlDTOs = _orderBanciDtlService.SearchByPaging(searchEntity).DataList; + if(orderBanciDTO.Hang.HasValue && orderBanciDTO.Lie.HasValue) + { + //鏌ヨ搴т綅淇℃伅 + var orderBanciZuoweiDTOs = _orderBanciService.GetOrderBanciZuoweiList(orderBanciDTO.id); + //鏌ヨ琚敤鎴烽攣瀹氱殑搴т綅 + try + { + string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; + string GetTrainingCoursesLockIDSeatId = _configuration.GetSection("GetTrainingCoursesLockIDSeatId").Value; + string url = huiyuanurl + GetTrainingCoursesLockIDSeatId + "?ClassID=" + orderBanciDTO.id; + Uri postUrl2 = new Uri(url); + + string result2 = string.Empty; + + + + var httpClient2 = _clientFactory.CreateClient(); + httpClient2.Timeout = new TimeSpan(0, 0, 10); + var Result2 = await httpClient2.GetAsync(postUrl2); + result2 = Result2.Content.ReadAsStringAsync().Result; + + + _logger.LogInformation("result2:" + result2); + JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); + + if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") + { + List<LockUser> lockUsers = JsonConvert.DeserializeObject<List<LockUser>>(jobjectresult["data"].ToString()); + + + foreach (var orderBanciZuoweiDTO in orderBanciZuoweiDTOs) + { + foreach(var lockUser in lockUsers) + { + if(orderBanciZuoweiDTO.ZuoweiId == lockUser.ID) + { + orderBanciZuoweiDTO.Status = "1"; + break; + } + } + } + + } + } + catch (Exception ex) + { + + } + + + + + + var orderBanciZuoweiDTOsret = new List<List<OrderBanciZuoweiDTO>>(); + for (int i = 0; i < orderBanciDTO.Hang; i++) + { + var orderBanciZuoweiDTOs1 = orderBanciZuoweiDTOs.Where(x => x.RowNo == (i + 1)).ToList(); + orderBanciZuoweiDTOsret.Add(orderBanciZuoweiDTOs1); + } + + + + + + + orderBanciDTO.orderBanciZuoweiDTOs = orderBanciZuoweiDTOsret; + } + + + + + returnMsg.code = 1; returnMsg.count = 1; returnMsg.returnObj = orderBanciDTO; + + } } @@ -393,5 +713,104 @@ } return new JsonResult(returnMsg); } + + + + //鑾峰彇褰撳墠鐨勫煿璁� + public IActionResult GetDangQianBanciList(string id) + { + ReturnMsg<List<BanciFanhui>> returnMsg = new ReturnMsg<List<BanciFanhui>>(); + returnMsg.code = 2; + try + { + + List<OrderBanci> orderBanciDTOs = _orderBanciService.GetDangQianBanciList(id); + List<BanciFanhui> banciFanhuis = new List<BanciFanhui>(); + + if (orderBanciDTOs != null && orderBanciDTOs.Count > 0) + { + foreach (var orderBanciDTO in orderBanciDTOs) + { + BanciFanhui banciFanhui = new BanciFanhui(); + banciFanhui.name = orderBanciDTO.Shijian.HasValue ? orderBanciDTO.Shijian.Value.ToString("yyyy-MM-dd") : ""; + banciFanhui.value = orderBanciDTO.Id; + banciFanhuis.Add(banciFanhui); + } + } + + + returnMsg.code = 1; + returnMsg.count = orderBanciDTOs.Count; + returnMsg.returnObj = banciFanhuis; + + + + + + } + catch (Exception ex) + { + returnMsg.code = 2; + returnMsg.error = "娌℃湁鑾峰彇鍒皌oken"; + returnMsg.count = 0; + + } + return new JsonResult(returnMsg); + } + + + + [CheckLogin] + public IActionResult IndexHezuo() + { + var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); + ViewData["curentuser"] = curentuser; + List<ActionEntity> actionlist = new List<ActionEntity>(); + ActionEntity actionEntity = new ActionEntity(); + actionEntity.OpenType = 0; + actionEntity.ActionUrl = ""; + actionEntity.ActionFun = "Search"; + actionEntity.PageIco = "fa fa-search"; + actionEntity.ActionName = "鏌ヨ"; + actionlist.Add(actionEntity); + //ActionEntity actionEntity1 = new ActionEntity(); + //actionEntity1.OpenType = 0; + //actionEntity1.ActionUrl = ""; + //actionEntity1.ActionFun = "Add"; + //actionEntity1.PageIco = "fa fa-plus"; + //actionEntity1.ActionName = "鏂板"; + //actionlist.Add(actionEntity1); + //var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanci/Index/"); + //var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList(); + + //var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList(); + + //foreach (var pageEntity in pageEntities1) + //{ + // ActionEntity actionEntity1 = new ActionEntity(); + // actionEntity1.OpenType = pageEntity.OpenType; + // actionEntity1.ActionUrl = ""; + // actionEntity1.ActionFun = pageEntity.PageShortcut; + // actionEntity1.PageIco = pageEntity.PageIco; + // actionEntity1.ActionName = pageEntity.PageName; + // actionlist.Add(actionEntity1); + //} + ViewData["ActionInfo"] = actionlist; + //ViewData["ActionInfo2"] = pageEntities2; + + + + + + return View(); + + } + + + public IActionResult GetListHezuo(ExpertDTOSearch search) + { + //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); + return new JsonResult(_expertService.SearchByPaging(search)); + } } } -- Gitblit v1.9.1