| | |
| | | using CommonToolsCore; |
| | | using Services; |
| | | using System.Transactions; |
| | | using System.IdentityModel.Tokens.Jwt; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Newtonsoft.Json.Linq; |
| | | using System.Net.Http.Headers; |
| | | |
| | | namespace zhengcaioa.Controllers.BusinessOrder |
| | | { |
| | | [CheckLogin] |
| | | |
| | | public class CooperOrderController : Controller |
| | | { |
| | | private readonly ILogger<CooperOrderController> _logger; |
| | |
| | | private readonly IFiBookService _fiBookService; |
| | | private readonly IFiServiceService _fiServiceService; |
| | | private readonly IFiMemberService _fiMemberService; |
| | | private readonly IConfiguration _configuration; |
| | | private readonly IHttpClientFactory _clientFactory; |
| | | |
| | | |
| | | public CooperOrderController(ILogger<CooperOrderController> logger, ILiaotianService liaotianService, IUserService userService, ICooperOrderService cooperOrderService |
| | | , ICooperatecustomCustomerService cooperatecustomCustomerService, IProjectService projectService, IPltPageService pltPageService, IFiBookService fiBookService |
| | | , IFiServiceService fiServiceService, IFiMemberService fiMemberService) |
| | | , IFiServiceService fiServiceService, IFiMemberService fiMemberService |
| | | , IConfiguration configuration |
| | | , IHttpClientFactory clientFactory) |
| | | { |
| | | _logger = logger; |
| | | _liaotianService = liaotianService; |
| | |
| | | _fiBookService = fiBookService; |
| | | _fiServiceService = fiServiceService; |
| | | _fiMemberService = fiMemberService; |
| | | _configuration = configuration; |
| | | _clientFactory = clientFactory; |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Index() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetList(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | | ViewData["curentuser"] = curentuser; |
| | | search.Creater = curentuser.Id; |
| | | //search.Creater = curentuser.Id; |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult ShouliList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListshouli(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult ChedanList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListchedan(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult WangongList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListwangong(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult SonghuoList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListsonghuo(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult HuifangList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListHuifang(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult PingjiaList() |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListPingjia(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult GetListYouhui(CooperOrderDTOSearch search) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | | return new JsonResult(_cooperOrderService.SearchByPaging(search)); |
| | | } |
| | | [CheckLogin] |
| | | public IActionResult Edit(string id = null, string ShouliStatus = "1") |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | /// <param name="data">岗位实体类对象</param> |
| | | /// <returns></returns> |
| | | /// |
| | | [CheckLogin] |
| | | [HttpPost] |
| | | public IActionResult Save(CooperOrderDTO data) |
| | | public async Task<IActionResult> SaveAsync(CooperOrderDTO data) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | using (TransactionScope scope = new TransactionScope()) |
| | | { |
| | | //using (TransactionScope scope = new TransactionScope()) |
| | | //{ |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | | ViewData["curentuser"] = curentuser; |
| | | data.RecStatus = "A"; |
| | |
| | | data.Creater = curentuser.Id; |
| | | data.Createtime = DateTime.Now; |
| | | data.XdTime = data.Createtime; |
| | | |
| | | if (data.OrderType == "03" || data.OrderType == "07" || (data.OrderType == "02" && (data.OrderType1 == "代拟投诉书" || data.OrderType1 == "代拟质疑函"))) |
| | | { |
| | | var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(data.Khdw); |
| | | if (cooperatecustomCustomerDTO != null && !string.IsNullOrEmpty(cooperatecustomCustomerDTO.HuiyuanId)) |
| | | { |
| | | string huiyuanurl = _configuration.GetSection("huiyuanurl").Value; |
| | | string SetCaseOrder = _configuration.GetSection("SetCaseOrder").Value; |
| | | |
| | | Uri postUrl2 = new Uri(huiyuanurl + SetCaseOrder); |
| | | |
| | | JObject questions2 = new JObject(); |
| | | questions2.Add("UserID", cooperatecustomCustomerDTO.HuiyuanId); |
| | | if (data.OrderType == "03") |
| | | { |
| | | questions2.Add("CaseType", 0); |
| | | } |
| | | else if (data.OrderType == "07") |
| | | { |
| | | questions2.Add("CaseType", 1); |
| | | } |
| | | else if (data.OrderType == "07") |
| | | { |
| | | questions2.Add("CaseType", 1); |
| | | } |
| | | else if (data.OrderType == "02" && (data.OrderType1 == "代拟投诉书" || data.OrderType1 == "代拟质疑函")) |
| | | { |
| | | questions2.Add("CaseType", 2); |
| | | } |
| | | |
| | | questions2.Add("count", Decimal.ToInt32(data.OrderNum.Value) ); |
| | | |
| | | string requestJson2 = questions2.ToString(); |
| | | string result2 = string.Empty; |
| | | |
| | | using (HttpContent httpContent = new StringContent(requestJson2)) |
| | | { |
| | | httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
| | | |
| | | var httpClient2 = _clientFactory.CreateClient(); |
| | | httpClient2.Timeout = new TimeSpan(0, 0, 10); |
| | | var Result2 = await httpClient2.PostAsync(postUrl2, httpContent); |
| | | result2 = Result2.Content.ReadAsStringAsync().Result; |
| | | } |
| | | |
| | | _logger.LogInformation("result2:" + result2); |
| | | JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2); |
| | | |
| | | if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1") |
| | | { |
| | | resultEntity.Result = true; |
| | | } |
| | | else |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "写入会员订单失败"; |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | data.ShouliStatus = "1"; |
| | | data.Modifier = curentuser.Id; |
| | | data.Modifytime = DateTime.Now; |
| | | |
| | | resultEntity = _cooperOrderService.save(data); |
| | | scope.Complete(); |
| | | } |
| | | // scope.Complete(); |
| | | //} |
| | | |
| | | |
| | | return new JsonResult(resultEntity); |
| | |
| | | /// <param name="info">实体</param> |
| | | /// <returns></returns> |
| | | /// |
| | | [CheckLogin] |
| | | public IActionResult Nullify(string Id = "") |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | /// <param name="data">岗位实体类对象</param> |
| | | /// <returns></returns> |
| | | /// |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Shouli(string id) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | /// <param name="data">岗位实体类对象</param> |
| | | /// <returns></returns> |
| | | /// |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Wangong(string id) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Chedan(string id = null) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | |
| | | return View(); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult chedantuihuan(decimal Price, string Chedanid) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Huifang(string id = null) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | |
| | | return View(); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Huifangtuihuan(CooperOrderDTO dto) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | |
| | | /// <param name="data">岗位实体类对象</param> |
| | | /// <returns></returns> |
| | | /// |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Songhuo(string id) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Songhuotuihuan(CooperOrderDTO dto) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Pingjia(string id = null) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | |
| | | return View(); |
| | | } |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Pingjiatuihuan(string PingjiaStatus, string Pingjiaid) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult Print(string id = null) |
| | | { |
| | | var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); |
| | |
| | | return View(); |
| | | } |
| | | |
| | | |
| | | [CheckLogin] |
| | | public IActionResult printList(CooperOrderDTOSearch search) |
| | | { |
| | | //JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver()); |
| | |
| | | return result; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //提问 |
| | | public IActionResult GetHuiYuanOrder([FromBody]CooperOrderDTOSearch search) |
| | | { |
| | | ReturnMsg<List<UserOrders>> returnMsg = new ReturnMsg<List<UserOrders>>(); |
| | | returnMsg.code = 2; |
| | | try |
| | | { |
| | | string userid = ""; |
| | | var headers = Request.Headers; |
| | | if (headers != null) |
| | | { |
| | | //string SecurityKey = _configuration.GetSection("SecurityKey").Value; |
| | | var keyId = headers["Authorization"].FirstOrDefault(); |
| | | if (string.IsNullOrEmpty("keyId")) |
| | | { |
| | | returnMsg.code = 2; |
| | | returnMsg.error = "没有获取到token"; |
| | | returnMsg.count = 0; |
| | | |
| | | return new JsonResult(returnMsg); |
| | | } |
| | | |
| | | |
| | | JwtSecurityToken jwt = null; |
| | | var handler = new JwtSecurityTokenHandler(); |
| | | var key1 = keyId.Replace("Bearer", "").Trim(); |
| | | jwt = handler.ReadJwtToken(key1); |
| | | System.Security.Claims.Claim sss = jwt.Claims.Where(x => x.Type == "id").FirstOrDefault(); |
| | | userid = sss.Value; |
| | | |
| | | } |
| | | //LZhuanjiahuidumDTOSearch searchEntity = new LZhuanjiahuidumDTOSearch(); |
| | | //searchEntity.Userid = userid; |
| | | ////searchEntity.HuidaStatus = "A"; |
| | | //searchEntity.page = 1; |
| | | //searchEntity.rows = 1000; |
| | | search.HuiyuanId = userid; |
| | | ResultDataEntity<CooperOrderDTO> resultDataEntity = _cooperOrderService.SearchByPaging(search); |
| | | List<CooperOrderDTO> cooperOrderDTOs = resultDataEntity.DataList; |
| | | List<UserOrders> userOrders = new List<UserOrders>(); |
| | | //封装订单 |
| | | foreach (var cooperOrderDTO in cooperOrderDTOs) |
| | | { |
| | | UserOrders userOrder = new UserOrders(); |
| | | userOrder.order_goods = new List<usercart_items>(); |
| | | usercart_items usercart_Item = new usercart_items(); |
| | | |
| | | userOrder.order_type = "offline"; |
| | | userOrder.order_no = cooperOrderDTO.OrderNo; |
| | | userOrder.accept_name = cooperOrderDTO.Shr; |
| | | userOrder.mobile = cooperOrderDTO.ShrTel; |
| | | userOrder.address = cooperOrderDTO.ShrAddress; |
| | | userOrder.order_amount = cooperOrderDTO.Money.HasValue ? cooperOrderDTO.Money.Value: 0; |
| | | userOrder.statusChs = cooperOrderDTO.ShouliStatusName; |
| | | userOrder.add_time = cooperOrderDTO.Createtime; |
| | | |
| | | usercart_Item.sell_price = cooperOrderDTO.Price.HasValue ? cooperOrderDTO.Price.Value : 0; |
| | | usercart_Item.quantity = cooperOrderDTO.OrderNum.HasValue ? decimal.ToInt32(cooperOrderDTO.OrderNum.Value) : 0; |
| | | usercart_Item.name = cooperOrderDTO.OrderTypeName + "-" + cooperOrderDTO.OrderType1Name + (string.IsNullOrEmpty(cooperOrderDTO.OrderType2)?"": "-"+cooperOrderDTO.OrderType2); |
| | | |
| | | |
| | | |
| | | userOrder.order_goods.Add(usercart_Item); |
| | | userOrders.Add(userOrder); |
| | | } |
| | | returnMsg.code = 1; |
| | | returnMsg.returnObj = userOrders; |
| | | returnMsg.count = resultDataEntity.DataList.Count; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | returnMsg.code = 2; |
| | | returnMsg.error = "没有获取到token"; |
| | | returnMsg.count = 0; |
| | | |
| | | } |
| | | return new JsonResult(returnMsg); |
| | | } |
| | | |
| | | } |
| | | } |