username@email.com
2024-07-08 c6c6761506785691ef44e7e232c45e1b4b16f7fa
zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs
@@ -47,6 +47,7 @@
        private readonly IFiOrderrecievemoneyService _fiOrderrecievemoneyService;
        private readonly IFiAccountService _fiAccountService;
        private readonly IFiAccountRecordService _iFiAccountRecordService;
        private readonly ISysAttachmentService _sysAttachmentService;
        public CooperOrderController(ILogger<CooperOrderController> logger, ILiaotianService liaotianService, IUserService userService, ICooperOrderService cooperOrderService
@@ -60,6 +61,7 @@
            , IFiOrderrecievemoneyService fiOrderrecievemoneyService
            , IFiAccountService fiAccountService
            , IFiAccountRecordService iFiAccountRecordService
             , ISysAttachmentService sysAttachmentService
            )
        {
            _logger = logger;
@@ -80,6 +82,7 @@
            _fiOrderrecievemoneyService = fiOrderrecievemoneyService;
            _fiAccountService = fiAccountService;
            _iFiAccountRecordService = iFiAccountRecordService;
            _sysAttachmentService = sysAttachmentService;
        }
        [CheckLogin]
@@ -88,34 +91,62 @@
            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);
            //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);
            ActionEntity actionEntity3 = new ActionEntity();
            actionEntity3.OpenType = 0;
            actionEntity3.ActionUrl = "";
            actionEntity3.ActionFun = "Print";
            actionEntity3.PageIco = "fa fa-print";
            actionEntity3.ActionName = "打印";
            actionlist.Add(actionEntity3);
            //ActionEntity actionEntity3 = new ActionEntity();
            //actionEntity3.OpenType = 0;
            //actionEntity3.ActionUrl = "";
            //actionEntity3.ActionFun = "Print";
            //actionEntity3.PageIco = "fa fa-print";
            //actionEntity3.ActionName = "打印";
            //actionlist.Add(actionEntity3);
            ViewData["ActionInfo"] = actionlist;
            //ViewData["ActionInfo"] = actionlist;
            List<PageEntity> pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/CooperOrder/Index/");
            ViewBag.pageEntities = pageEntities;
            var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
            if (pageEntities1.Count(x => x.PageShortcut == "Search") <= 0)
            {
                ActionEntity actionEntity = new ActionEntity();
                actionEntity.OpenType = 0;
                actionEntity.ActionUrl = "";
                actionEntity.ActionFun = "Search";
                actionEntity.PageIco = "fa fa-search";
                actionEntity.ActionName = "查询";
                actionlist.Add(actionEntity);
                ViewData["Creater"] = curentuser.Id;
            }
            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;
            ViewBag.OrderType = _liaotianService.GetSYScode("CooperVisit", "jtype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.users = _userService.GetList().Where(x => x.IsYwjl == "A").Select(x => new { code = x.Id, label = x.UserName }).ToList();
@@ -415,118 +446,239 @@
            return new JsonResult(_cooperOrderService.SearchByPaging(search));
        }
        [CheckLogin]
        public IActionResult Edit(string id = null, string ShouliStatus = "1")
        public IActionResult Edit(string id = null, string ShouliStatus = "1",string dingdantype = "0")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/CooperOrder/Index/");
            var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
            ViewData["ActionInfo2"] = pageEntities2;
            CooperOrderDTO dto = new CooperOrderDTO();
            if (!String.IsNullOrEmpty(id))
            if(dingdantype == "0")
            {
                dto = _cooperOrderService.Get(id);
                ViewBag.ShouliStatus = ShouliStatus;
                //ViewBag.YouHuiList = _askService.GetAskYouHuiList(dto.Khdw, dto.OrderType);
                //质疑函
                List<TChallengeletterDTO> challengeletterDTOs  = _cooperOrderService.GetListChallengeletter(id);
                TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                if (challengeletterDTOs!=null&& challengeletterDTOs.Count > 0)
                if (!String.IsNullOrEmpty(id))
                {
                    challengeletterDTO = challengeletterDTOs[0];
                    if (challengeletterDTO.DocumentsDate.HasValue)
                    dto = _cooperOrderService.Get(id);
                    ViewBag.ShouliStatus = ShouliStatus;
                    //ViewBag.YouHuiList = _askService.GetAskYouHuiList(dto.Khdw, dto.OrderType);
                    //质疑函
                    List<TChallengeletterDTO> challengeletterDTOs = _cooperOrderService.GetListChallengeletter(id);
                    TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                    if (challengeletterDTOs != null && challengeletterDTOs.Count > 0)
                    {
                        challengeletterDTO.DocumentsDateName = challengeletterDTO.DocumentsDate.Value.ToString("yyyy-MM-dd");
                        challengeletterDTO = challengeletterDTOs[0];
                        if (challengeletterDTO.DocumentsDate.HasValue)
                        {
                            challengeletterDTO.DocumentsDateName = challengeletterDTO.DocumentsDate.Value.ToString("yyyy-MM-dd");
                        }
                        List<TChallengeItemDTO> challengeItemDTOs = _cooperOrderService.GetListChallengeItem(challengeletterDTO.Id);
                        if (challengeItemDTOs.Count > 0)
                            challengeletterDTO.challengeItemDTOs = challengeItemDTOs;
                        else
                            challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                        List<TComplaintShouquandaibiaoDTO> complaintShouquandaibiaoDTOs = _cooperOrderService.GetListComplaintShouquandaibiao(challengeletterDTO.Id);
                        if (complaintShouquandaibiaoDTOs.Count > 0)
                            challengeletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                        else
                            challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                    }
                    List<TChallengeItemDTO> challengeItemDTOs = _cooperOrderService.GetListChallengeItem(challengeletterDTO.Id);
                    if(challengeItemDTOs.Count>0)
                        challengeletterDTO.challengeItemDTOs = challengeItemDTOs;
                    else
                    {
                        challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                    List<TComplaintShouquandaibiaoDTO> complaintShouquandaibiaoDTOs = _cooperOrderService.GetListComplaintShouquandaibiao(challengeletterDTO.Id);
                    if (complaintShouquandaibiaoDTOs.Count > 0)
                        challengeletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                    else
                        challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                }
                else
                {
                    challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                    challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                }
                ViewBag.challengeletterDTO = challengeletterDTO;
                //投诉书
                List<TComplaintletterDTO> complaintletterDTOs = _cooperOrderService.GetListComplaintletter(id);
                TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                if (complaintletterDTOs != null && complaintletterDTOs.Count > 0)
                {
                    complaintletterDTO = complaintletterDTOs[0];
                    if (complaintletterDTO.NoticeDate.HasValue)
                    {
                        complaintletterDTO.NoticeDateName = complaintletterDTO.NoticeDate.Value.ToString("yyyy-MM-dd");
                    }
                    if (complaintletterDTO.ResultnoticeDate.HasValue)
                    ViewBag.challengeletterDTO = challengeletterDTO;
                    //投诉书
                    List<TComplaintletterDTO> complaintletterDTOs = _cooperOrderService.GetListComplaintletter(id);
                    TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                    if (complaintletterDTOs != null && complaintletterDTOs.Count > 0)
                    {
                        complaintletterDTO.ResultnoticeDateName = complaintletterDTO.ResultnoticeDate.Value.ToString("yyyy-MM-dd");
                    }
                        complaintletterDTO = complaintletterDTOs[0];
                    List<TComplaintItemDTO> complaintItemDTOs = _cooperOrderService.GetListComplaintItem(complaintletterDTO.Id);
                    if (complaintItemDTOs.Count > 0)
                        complaintletterDTO.complaintItemDTOs = complaintItemDTOs;
                        if (complaintletterDTO.NoticeDate.HasValue)
                        {
                            complaintletterDTO.NoticeDateName = complaintletterDTO.NoticeDate.Value.ToString("yyyy-MM-dd");
                        }
                        if (complaintletterDTO.ResultnoticeDate.HasValue)
                        {
                            complaintletterDTO.ResultnoticeDateName = complaintletterDTO.ResultnoticeDate.Value.ToString("yyyy-MM-dd");
                        }
                        List<TComplaintItemDTO> complaintItemDTOs = _cooperOrderService.GetListComplaintItem(complaintletterDTO.Id);
                        if (complaintItemDTOs.Count > 0)
                            complaintletterDTO.complaintItemDTOs = complaintItemDTOs;
                        else
                            complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                        List<TComplaintRespondentDTO> complaintRespondentDTOs = _cooperOrderService.GetListComplaintRespondent(complaintletterDTO.Id);
                        if (complaintRespondentDTOs.Count > 0)
                            complaintletterDTO.complaintRespondentDTOs = complaintRespondentDTOs;
                        else
                            complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                        List<TComplaintShouquandaibiaoDTO> complaintShouquandaibiaoDTOs = _cooperOrderService.GetListComplaintShouquandaibiao(complaintletterDTO.Id);
                        if (complaintShouquandaibiaoDTOs.Count > 0)
                            complaintletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                        else
                            complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                        List<TComplaintGongyingshangDTO> complaintGongyingshangDTOs = _cooperOrderService.GetListComplaintGongyingshang(complaintletterDTO.Id);
                        if (complaintGongyingshangDTOs.Count > 0)
                            complaintletterDTO.complaintGongyingshangDTOs = complaintGongyingshangDTOs;
                        else
                            complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                    }
                    else
                    {
                        complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                    List<TComplaintRespondentDTO> complaintRespondentDTOs = _cooperOrderService.GetListComplaintRespondent(complaintletterDTO.Id);
                    if (complaintRespondentDTOs.Count > 0)
                        complaintletterDTO.complaintRespondentDTOs = complaintRespondentDTOs;
                    else
                        complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                    List<TComplaintShouquandaibiaoDTO> complaintShouquandaibiaoDTOs = _cooperOrderService.GetListComplaintShouquandaibiao(complaintletterDTO.Id);
                    if (complaintShouquandaibiaoDTOs.Count > 0)
                        complaintletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                    else
                        complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                    List<TComplaintGongyingshangDTO> complaintGongyingshangDTOs = _cooperOrderService.GetListComplaintGongyingshang(complaintletterDTO.Id);
                    if (complaintGongyingshangDTOs.Count > 0)
                        complaintletterDTO.complaintGongyingshangDTOs = complaintGongyingshangDTOs;
                    else
                        complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                    }
                    ViewBag.complaintletterDTO = complaintletterDTO;
                }
                else
                {
                    dto.XdTime = DateTime.Now;
                    dto.OrderNum = 1;
                    ViewBag.ShouliStatus = "1";
                    dto.OrderNo = _cooperOrderService.GetOrderNo();
                    //ViewBag.YouHuiList = new List<AdmAskYouHuiDTO>();
                    //质疑函
                    TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                    challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                    challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                    ViewBag.challengeletterDTO = challengeletterDTO;
                    //投诉书
                    TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                    complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                    complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                    complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                    complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                    complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>() /*{ new TComplaintGongyingshangDTO() }*/;
                    ViewBag.complaintletterDTO = complaintletterDTO;
                }
                ViewBag.complaintletterDTO = complaintletterDTO;
            }
            else
            else if (dingdantype == "1")
            {
                dto.XdTime = DateTime.Now;
                dto.OrderNum = 1;
                ViewBag.ShouliStatus = "1";
                dto.OrderNo = _cooperOrderService.GetOrderNo();
                //ViewBag.YouHuiList = new List<AdmAskYouHuiDTO>();
                dto = _cooperOrderService.Get(id);
                ViewBag.ShouliStatus = ShouliStatus;
                //质疑函
                TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                ViewBag.challengeletterDTO = challengeletterDTO;
                //投诉书
                TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO()};
                complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>() /*{ new TComplaintGongyingshangDTO() }*/;
                ViewBag.complaintletterDTO = complaintletterDTO;
                complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                //complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                List<TChallengeletterDTO> challengeletterDTOs = _cooperOrderService.GetListChallengeletter(id);
                if (challengeletterDTOs != null && challengeletterDTOs.Count > 0)
                {
                    complaintletterDTO.TsrName = challengeletterDTOs[0].GysName;
                    complaintletterDTO.TsrAddress = challengeletterDTOs[0].GysAddress;
                    complaintletterDTO.TsrPostcode = challengeletterDTOs[0].GysPostcode;
                    complaintletterDTO.TsrCorporation = challengeletterDTOs[0].GysContacts;
                    complaintletterDTO.TsrPhone = challengeletterDTOs[0].GysPhone;
                    complaintletterDTO.XmName = challengeletterDTOs[0].XmName;
                    complaintletterDTO.XmCode = challengeletterDTOs[0].XmCode;
                    complaintletterDTO.XmPackage = challengeletterDTOs[0].XmPackage;
                    complaintletterDTO.PurchaserName = challengeletterDTOs[0].PurchaserName;
                    //complaintletterDTO.Agency = challengeletterDTOs[0].PurchaserName;
                    complaintletterDTO.ChallengeDateName = challengeletterDTOs[0].DocumentsDate.HasValue ? challengeletterDTOs[0].DocumentsDate.Value.ToString("yyyy-MM-dd") : "";
                    complaintletterDTO.RequestInfo = challengeletterDTOs[0].RequestInfo;
                    complaintletterDTO.Questioned = challengeletterDTOs[0].PurchaserName;
                    List<TComplaintShouquandaibiaoDTO> complaintShouquandaibiaoDTOs = _cooperOrderService.GetListComplaintShouquandaibiao(challengeletterDTOs[0].Id);
                    if (complaintShouquandaibiaoDTOs.Count > 0)
                        complaintletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                    else
                        complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                }
                    ViewBag.complaintletterDTO = complaintletterDTO;
                dto.Id = "";
                dto.OrderType = "02";
                dto.OrderType1 = "代拟投诉书";
                //dto.OrderType2 = "";
            }
            else if (dingdantype == "2")
            {
                dto = _cooperOrderService.Get(id);
                ViewBag.ShouliStatus = ShouliStatus;
                dto.Id = "";
                dto.OrderType = "08";
                dto.OrderType1 = "复议诉讼";
                dto.OrderType2 = "";
                //质疑函
                TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                ViewBag.challengeletterDTO = challengeletterDTO;
                //投诉书
                TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                ViewBag.complaintletterDTO = complaintletterDTO;
            }
            else if (dingdantype == "3")
            {
                dto = _cooperOrderService.Get(id);
                ViewBag.ShouliStatus = ShouliStatus;
                dto.Id = "";
                //质疑函
                TChallengeletterDTO challengeletterDTO = new TChallengeletterDTO();
                challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                ViewBag.challengeletterDTO = challengeletterDTO;
                //投诉书
                TComplaintletterDTO complaintletterDTO = new TComplaintletterDTO();
                complaintletterDTO.complaintItemDTOs = new List<TComplaintItemDTO>() { new TComplaintItemDTO() };
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                ViewBag.complaintletterDTO = complaintletterDTO;
            }
            ViewBag.request_info = _liaotianService.GetSYScode("t_challengeletter", "request_info");//质疑请求
            ViewBag.question = _liaotianService.GetSYScode("t_challenge_items", "question"); //   质疑事项
            ViewBag.law = _liaotianService.GetSYScode("t_complaint_items", "law");//法律依据
@@ -1017,7 +1169,13 @@
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            using (TransactionScope scope = new TransactionScope())
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
          new TransactionOptions
          {
              IsolationLevel = IsolationLevel.ReadCommitted,
              Timeout = TransactionManager.MaximumTimeout
          }
          ))
            {
                CooperOrderDTO dto = _cooperOrderService.Get(id);
@@ -1084,6 +1242,59 @@
                }
                if(dto.Money<=0 && dto.OrderType == "05")
                {
                var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(dto.Khdw);
                var fiMemberDTO = _fiMemberService.Get(dto.OrderType1);
                //开通会员
                string huiyuanurl = _configuration.GetSection("huiyuanurl").Value;
                string OAWriteChangeAsync = _configuration.GetSection("OAWriteChangeAsync").Value;
                Uri postUrl2 = new Uri(huiyuanurl + OAWriteChangeAsync);
                JObject questions2 = new JObject();
                questions2.Add("UserID", cooperatecustomCustomerDTO.HuiyuanId);
                questions2.Add("PhoneNumber", cooperatecustomCustomerDTO.Tel);
                questions2.Add("VIPName", fiMemberDTO.MemberType);
                questions2.Add("FromName", "OA");
                questions2.Add("UserName", cooperatecustomCustomerDTO.Name);
                string requestJson2 = questions2.ToString();
                    string result2 = string.Empty;
                    using (HttpContent httpContent = new StringContent(requestJson2))
                    {
                        httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                        using (HttpClient httpClient = new HttpClient())
                        {
                            httpClient.Timeout = new TimeSpan(0, 0, 10);
                            HttpResponseMessage responseMessage = httpClient.PostAsync(postUrl2, httpContent).Result;
                            result2 = responseMessage.Content.ReadAsStringAsync().Result;
                        }
                    }
                    _logger.LogInformation("result2:" + result2);
                    JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2);
                    if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1")
                    {
                        cooperatecustomCustomerDTO.HuiyuanId = jobjectresult["UserID"].ToString();
                        _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
                        resultEntity.Result = true;
                    }
                    else
                    {
                        resultEntity.Result = false;
                        resultEntity.Message = "写入会员权限失败";
                        return new JsonResult(resultEntity);
                    }
                }
                dto.Shoulier = curentuser.Id;
                dto.Shoulitime = DateTime.Now;
@@ -1113,9 +1324,10 @@
            //dto.Id = id;
            dto.Wangonger = curentuser.Id;
            dto.Wangongtime = DateTime.Now;
            dto.WangongStatus = "A";
            dto.ShouliStatus = "4";
            ResultEntity resultEntity = _cooperOrderService.save(dto);
            ResultEntity resultEntity = _cooperOrderService.Wangong(dto);
            return new JsonResult(resultEntity);
        }
@@ -1126,23 +1338,25 @@
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            var cooperOrderDTO = _cooperOrderService.Get(id);
            ViewData["Chedanid"] = id;
            ViewData["Money"] = cooperOrderDTO.Money.Value.ToString();
            return View();
        }
        [CheckLogin]
        public IActionResult chedantuihuan(string Chedanid, decimal Price=0)
        public IActionResult chedantuihuan(string Chedanid, decimal Price=0,string Chedanyuany="")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            using (TransactionScope scope = new TransactionScope())
            {
                CooperOrderDTO dto = _cooperOrderService.Get(Chedanid);
                if (dto.ShouliStatus != "2")
                {
@@ -1199,15 +1413,18 @@
                dto.ChedanStatus = "A";
                dto.Chedan = Price;
                dto.ShouliStatus = "0";
                if (!string.IsNullOrWhiteSpace(Chedanyuany))
                    dto.Remark += "    " + Chedanyuany;
                resultEntity = _cooperOrderService.chedan(dto);
                var fiAccountRecordDTOs = _iFiAccountRecordService.GetList("订单收款"+dto.OrderNo);
                if (fiAccountRecordDTOs!= null && fiAccountRecordDTOs.Count > 0)
                var fiAccountRecordDTOs = _iFiAccountRecordService.GetList("订单收款"+dto.OrderNo, dto.OrderNo);
                if ( Price>0 && fiAccountRecordDTOs != null && fiAccountRecordDTOs.Count > 0)
                {
                    foreach (var fiAccountRecordDTO in fiAccountRecordDTOs)
                    {
                    var sysCodeDtls = _liaotianService.GetSYScode("CooperVisit", "jtype");
                    //foreach (var fiAccountRecordDTO in fiAccountRecordDTOs)
                    //{
                        CooperatecustomCustomerDTO cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(dto.Khdw);
                        FiAccountRecordDTO data1 = new FiAccountRecordDTO();
                        data1.RecStatus = "A";
@@ -1215,13 +1432,28 @@
                        data1.Createtime = DateTime.Now;
                        data1.Modifier = curentuser.Id;
                        data1.Modifytime = DateTime.Now;
                        data1.SubjectId = fiAccountRecordDTO.SubjectId;
                        data1.SubjectId = fiAccountRecordDTOs[0].SubjectId;
                        data1.AccountId = fiAccountRecordDTO.AccountId;
                        data1.Money = fiAccountRecordDTO.Money;
                        data1.AccountId = fiAccountRecordDTOs[0].AccountId;
                        data1.Money = Price;
                        data1.PaymentUnit = cooperatecustomCustomerDTO.Name;
                        data1.OperationalMatters = "订单撤单" + dto.OrderNo;
                        var ssss = sysCodeDtls.Where(x => x.CodeSn == dto.OrderType).FirstOrDefault();
                        if (ssss!=null)
                        {
                            dto.OrderTypeName = ssss.Comments;
                        }
                        var book = _fiBookService.Get(dto.OrderType1);
                        var member = _fiMemberService.Get(dto.OrderType1);
                        if (book != null)
                        {
                            dto.OrderType1 = book.BookName;
                        }
                        if (member != null)
                        {
                            dto.OrderType1 = member.MemberType;
                        }
                        data1.OperationalMatters = dto.OrderTypeName + dto.OrderType1 + dto.OrderType2 + " 订单撤单退款"  ;
                        data1.Remark =  dto.OrderNo;
                        FiAccountDTO firmAccount = _fiAccountService.Get(data1.AccountId);
@@ -1232,13 +1464,13 @@
                        firmAccount.AllExpenses = (firmAccount.AllExpenses ?? 0) + fiAccountRecordDTO.Money;
                        firmAccount.Balance = (firmAccount.Balance ?? 0) - fiAccountRecordDTO.Money;
                        firmAccount.AllIncome = (firmAccount.AllIncome ?? 0) - Price;
                        firmAccount.Balance = (firmAccount.Balance ?? 0) - Price;
                        data1.AccountMoney = firmAccount.Balance;
                        resultEntity = _iFiAccountRecordService.save(data1);
                        resultEntity = _fiAccountService.save(firmAccount);
                    }
                    //}
                }
                scope.Complete();
            }
@@ -1537,7 +1769,7 @@
                {
                    //string SecurityKey = _configuration.GetSection("SecurityKey").Value;
                    var keyId = headers["Authorization"].FirstOrDefault();
                    if (string.IsNullOrEmpty("keyId"))
                    if (string.IsNullOrEmpty(keyId))
                    {
                        returnMsg.code = 2;
                        returnMsg.error = "没有获取到token";
@@ -1658,7 +1890,9 @@
            actionlist.Add(actionEntity);
            ViewData["ActionInfo"] = actionlist;
            var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/CooperOrder/selectWenshu");
            var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
            ViewData["ActionInfo2"] = pageEntities2;
            ViewBag.Wenshuleixing = _liaotianService.GetSYScode("t_challengeletter", "Wenshuleixing").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.status = _liaotianService.GetSYScode("t_challengeletter", "status").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
@@ -1669,7 +1903,7 @@
        public IActionResult EditZhiyihan(string id = null)
        public IActionResult EditZhiyihan(string id = null, string ReturnID = null)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
@@ -1679,7 +1913,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //质疑函
@@ -1699,9 +1933,29 @@
                    foreach (var challengeItemDTO in challengeletterDTO.challengeItemDTOs)
                    {
                      var sysCodeDtls2 =  sysCodeDtls1.Where(x => x.Classify1 == challengeItemDTO.Question).ToList();
                        if (!string.IsNullOrEmpty(challengeItemDTO.Law))
                        if (!string.IsNullOrEmpty(challengeItemDTO.Law) || !string.IsNullOrEmpty(ReturnID))
                        {
                            sysCodeDtls2 = sysCodeDtls2.Where(x => challengeItemDTO.Law.Split(',').Contains(x.Comments)).ToList();
                            var law = "";
                            if (!string.IsNullOrEmpty(challengeItemDTO.Law))
                            {
                                law = challengeItemDTO.Law;
                                if (!string.IsNullOrEmpty(ReturnID))
                                {
                                    law += "," + ReturnID;
                                }
                            }
                            else
                            {
                                law = ReturnID;
                            }
                            if (!string.IsNullOrEmpty(law))
                            {
                                sysCodeDtls2 = sysCodeDtls2.Where(x => law.Split(',').Contains(x.CodeSn)).ToList();
                            }
                        }
                        challengeItemDTO.sysCodeDtls = sysCodeDtls2;
                    }
@@ -1720,6 +1974,13 @@
                    challengeletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                else
                    challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                List<TChallengeRequestInfoDTO> challengeRequestInfoDTOs = _cooperOrderService.GetListChallengeRequestInfo(challengeletterDTO.Id);
                if (challengeRequestInfoDTOs.Count > 0)
                    challengeletterDTO.challengeRequestInfoDTOs = challengeRequestInfoDTOs;
                else
                    challengeletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() { new TChallengeRequestInfoDTO() };
            }
            else
            {
@@ -1728,6 +1989,7 @@
                challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { challengeItemDTO };
                challengeletterDTO.challengeItemDTOs[0].sysCodeDtls = new List<SysCodeDtl>() { new SysCodeDtl() };
                challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                challengeletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() { new TChallengeRequestInfoDTO() };
            }
            //ViewBag.challengeletterDTO = challengeletterDTO;
@@ -1740,7 +2002,10 @@
            ViewBag.law = sysCodeDtls1;//法律依据
            if (!challengeletterDTO.PrintNum.HasValue)
            {
                challengeletterDTO.PrintNum = 1;
            }
            ViewData.Model = challengeletterDTO;
@@ -1780,7 +2045,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls1.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //if (sysCodeDtl != null)
@@ -1789,6 +2054,7 @@
            //}
            resultEntity.Message = no;
            resultEntity.Remark = challengeItemId;
            resultEntity.Remark2 = id;
            resultEntity.DataList = sysCodeDtls;
            return new JsonResult(resultEntity);
@@ -1805,7 +2071,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //质疑函
@@ -2108,6 +2374,7 @@
                            var challengeItemDTO = new TChallengeItemDTO();
                            challengeItemDTO.ChallengeId = challengeletterDTO.Id;
                            challengeItemDTO.Question = data.Question[i];
                            challengeItemDTO.Questionname = data.Questionname[i];
                            challengeItemDTO.Evidential = data.Evidential[i];
                            challengeItemDTO.Law = Law;
                            //challengeItemDTO.Lawcoment = data.Lawcoment[i];
@@ -2117,6 +2384,26 @@
                       
                    }
                }
                resultEntity = _cooperOrderService.deleteChallengeRequestInfo(challengeletterDTO.Id);
                if (data.RequestInfos != null && data.RequestInfos.Length > 0)
                {
                    for (int i = 0; i < data.RequestInfos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(data.RequestInfos[i]))
                        {
                            var challengeRequestInfoDTO = new TChallengeRequestInfoDTO();
                            challengeRequestInfoDTO.ChallengeId = challengeletterDTO.Id;
                            challengeRequestInfoDTO.RequestInfo = data.RequestInfos[i];
                            challengeRequestInfoDTO.RequestInfoname = data.RequestInfoname[i];
                            resultEntity = _cooperOrderService.saveChallengeRequestInfo(challengeRequestInfoDTO);
                        }
                    }
                }
                scope.Complete();
            }
@@ -2135,7 +2422,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //质疑函
            List<TChallengeletterDTO> challengeletterDTOs = _cooperOrderService.GetListChallengeletter(id);
@@ -2156,7 +2443,7 @@
                        var sysCodeDtls2 = sysCodeDtls1.Where(x => x.Classify1 == challengeItemDTO.Question).ToList();
                        if (!string.IsNullOrEmpty(challengeItemDTO.Law))
                        {
                            sysCodeDtls2 = sysCodeDtls2.Where(x => challengeItemDTO.Law.Split(',').Contains(x.Comments)).ToList();
                            sysCodeDtls2 = sysCodeDtls2.Where(x => challengeItemDTO.Law.Split(',').Contains(x.CodeSn)).OrderBy(x=>x.Classify3).ToList();
                        }
                        challengeItemDTO.sysCodeDtls = sysCodeDtls2;
                    }
@@ -2174,12 +2461,21 @@
                    challengeletterDTO.complaintShouquandaibiaoDTOs = complaintShouquandaibiaoDTOs;
                else
                    challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() /*{ new TComplaintShouquandaibiaoDTO() }*/;
                List<TChallengeRequestInfoDTO> challengeRequestInfoDTOs = _cooperOrderService.GetListChallengeRequestInfo(challengeletterDTO.Id);
                if (challengeRequestInfoDTOs.Count > 0)
                    challengeletterDTO.challengeRequestInfoDTOs = challengeRequestInfoDTOs;
                else
                    challengeletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() /*{ new TChallengeRequestInfoDTO() }*/;
            }
            else
            {
                challengeletterDTO.challengeItemDTOs = new List<TChallengeItemDTO>() { new TChallengeItemDTO() };
                challengeletterDTO.challengeItemDTOs[0].sysCodeDtls = new List<SysCodeDtl>() { new SysCodeDtl() };
                challengeletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() /*{ new TComplaintShouquandaibiaoDTO() }*/;
                challengeletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() /*{ new TChallengeRequestInfoDTO() }*/;
            }
            //ViewBag.challengeletterDTO = challengeletterDTO;
@@ -2200,15 +2496,58 @@
            //ViewBag.law = sysCodeDtls1;//法律依据
            var cooperOrderDTO = _cooperOrderService.Get(id);
            var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(cooperOrderDTO.Khdw);
            if (cooperatecustomCustomerDTO.Name.IndexOf("股份有限公司") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "董事长";
            }
            else if (cooperatecustomCustomerDTO.Name.IndexOf("有限公司") >= 0 || cooperatecustomCustomerDTO.Name.IndexOf("有限责任公司") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "执行董事";
            }
            else if (cooperatecustomCustomerDTO.Name.IndexOf("协会") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "会长";
            }
            else
            {
                cooperatecustomCustomerDTO.Zhiwu = "总经理";
            }
            ResultDataEntity<SysAttachmentDTO> resultsyinyezhizhao = new ResultDataEntity<SysAttachmentDTO>();
            SysAttachmentDTOSearch searchEntity = new SysAttachmentDTOSearch();
            searchEntity.page = 1;
            searchEntity.rows = 1000;
            searchEntity.AttObj = "Cooperyinyezhizhao";
            searchEntity.AttObjid = cooperOrderDTO.Khdw;
            resultsyinyezhizhao = _sysAttachmentService.SearchByPaging(searchEntity);
            ViewBag.yinyezhizhao = resultsyinyezhizhao;
            ResultDataEntity<SysAttachmentDTO> resultshenfenzheng = new ResultDataEntity<SysAttachmentDTO>();
            SysAttachmentDTOSearch searchEntity1 = new SysAttachmentDTOSearch();
            searchEntity1.page = 1;
            searchEntity1.rows = 1000;
            searchEntity1.AttObj = "Cooperashenfenzheng";
            searchEntity1.AttObjid = cooperOrderDTO.Khdw;
            resultshenfenzheng = _sysAttachmentService.SearchByPaging(searchEntity1);
            ViewBag.shenfenzheng = resultshenfenzheng;
            ViewBag.cooperatecustomCustomerDTO = cooperatecustomCustomerDTO;
            ViewData.Model = challengeletterDTO;
            return View();
        }
        public IActionResult EditTousushu(string id = null)
        public IActionResult EditTousushu(string id = null, string ReturnID = null)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
@@ -2219,7 +2558,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //投诉书
            List<TComplaintletterDTO> complaintletterDTOs = _cooperOrderService.GetListComplaintletter(id);
@@ -2255,10 +2594,33 @@
                    foreach (var complaintItemDTO in complaintletterDTO.complaintItemDTOs)
                    {
                        var sysCodeDtls2 = sysCodeDtls1.Where(x => x.Classify1 == complaintItemDTO.Question).ToList();
                        if (!string.IsNullOrEmpty(complaintItemDTO.Law))
                        if (!string.IsNullOrEmpty(complaintItemDTO.Law) || !string.IsNullOrEmpty(ReturnID))
                        {
                            sysCodeDtls2 = sysCodeDtls2.Where(x => complaintItemDTO.Law.Split(',').Contains(x.Comments)).ToList();
                            var law = "";
                            if (!string.IsNullOrEmpty(complaintItemDTO.Law))
                            {
                                law = complaintItemDTO.Law;
                                if (!string.IsNullOrEmpty(ReturnID))
                                {
                                    law += "," + ReturnID;
                                }
                            }
                            else
                            {
                                law = ReturnID;
                            }
                            if (!string.IsNullOrEmpty(law))
                            {
                                sysCodeDtls2 = sysCodeDtls2.Where(x => law.Split(',').Contains(x.CodeSn)).ToList();
                            }
                        }
                        complaintItemDTO.sysCodeDtls = sysCodeDtls2;
                    }
                }
@@ -2283,6 +2645,12 @@
                else
                    complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                List<TChallengeRequestInfoDTO> challengeRequestInfoDTOs = _cooperOrderService.GetListChallengeRequestInfo(complaintletterDTO.Id);
                if (challengeRequestInfoDTOs.Count > 0)
                    complaintletterDTO.challengeRequestInfoDTOs = challengeRequestInfoDTOs;
                else
                    complaintletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() { new TChallengeRequestInfoDTO() };
                List<TComplaintGongyingshangDTO> complaintGongyingshangDTOs = _cooperOrderService.GetListComplaintGongyingshang(complaintletterDTO.Id);
                if (complaintGongyingshangDTOs.Count > 0)
                    complaintletterDTO.complaintGongyingshangDTOs = complaintGongyingshangDTOs;
@@ -2299,10 +2667,11 @@
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>()/* { new TComplaintGongyingshangDTO() }*/;
                complaintletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() { new TChallengeRequestInfoDTO() };
            }
            //判断是否有质疑函
            if (complaintletterDTO.Status != 2)
            if (complaintletterDTO.Status != 2 && string.IsNullOrEmpty(complaintletterDTO.complaintItemDTOs[0].Question))
            {
                CooperOrderDTO cooperOrderDTO = _cooperOrderService.Get(complaintletterDTO.OrderId);
                List<TChallengeletterDTO> challengeletterDTOs = _cooperOrderService.GetListChallengelettertousu(cooperOrderDTO.Khdw, complaintletterDTO.XmCode);
@@ -2319,6 +2688,11 @@
                        complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() { new TComplaintShouquandaibiaoDTO() };
                    complaintletterDTO.challengeRequestInfoDTOs = _cooperOrderService.GetListChallengeRequestInfo(challengeletterDTO.Id);
                    if (complaintletterDTO.challengeRequestInfoDTOs.Count == 0)
                        complaintletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() { new TChallengeRequestInfoDTO() };
                    List<TChallengeItemDTO> challengeItemDTOs = _cooperOrderService.GetListChallengeItem(challengeletterDTO.Id);
                    if (challengeItemDTOs.Count > 0)
                    {
@@ -2329,6 +2703,7 @@
                            complaintItemDTO.Id = challengeItemDTO.Id;
                            complaintItemDTO.ComplaintId = challengeItemDTO.ChallengeId;
                            complaintItemDTO.Question = challengeItemDTO.Question;
                            complaintItemDTO.Questionname = challengeItemDTO.Questionname;
                            complaintItemDTO.Evidential = challengeItemDTO.Evidential;
                            complaintItemDTO.Law = challengeItemDTO.Law;
                            complaintItemDTO.Lawcoment = challengeItemDTO.Lawcoment;
@@ -2364,6 +2739,10 @@
            ViewBag.ChallengeletterChosen = _cooperOrderService.GetListChallengeletterChosen().Where(x => x.Createtime >= DateTime.Now.AddMonths(-2)).ToList(); ;
            if (!complaintletterDTO.PrintNum.HasValue)
            {
                complaintletterDTO.PrintNum = 1;
            }
            ViewData.Model = complaintletterDTO;
            return View();
        }
@@ -2583,6 +2962,7 @@
                            var complaintItemDTO = new TComplaintItemDTO();
                            complaintItemDTO.ComplaintId = complaintletterDTO.Id;
                            complaintItemDTO.Question = data.Question[i];
                            complaintItemDTO.Questionname = data.Questionname[i];
                            complaintItemDTO.Evidential = data.Evidential[i];
                            complaintItemDTO.Law = Law;
                            //complaintItemDTO.Lawcoment = data.Lawcoment[i];
@@ -2592,6 +2972,26 @@
                    }
                }
                resultEntity = _cooperOrderService.deleteChallengeRequestInfo(complaintletterDTO.Id);
                if (data.RequestInfos != null && data.RequestInfos.Length > 0)
                {
                    for (int i = 0; i < data.RequestInfos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(data.RequestInfos[i]))
                        {
                            var challengeRequestInfoDTO = new TChallengeRequestInfoDTO();
                            challengeRequestInfoDTO.ChallengeId = complaintletterDTO.Id;
                            challengeRequestInfoDTO.RequestInfo = data.RequestInfos[i];
                            challengeRequestInfoDTO.RequestInfoname = data.RequestInfoname[i];
                            resultEntity = _cooperOrderService.saveChallengeRequestInfo(challengeRequestInfoDTO);
                        }
                    }
                }
                scope.Complete();
            }
@@ -2611,7 +3011,7 @@
            {
                var sysCodeDtl1 = sysCodeDtls.Where(x => x.CodeSn == sysCodeDtl.Comments).FirstOrDefault();
                if (sysCodeDtl1 != null)
                    sysCodeDtl.CodeSn = sysCodeDtl1.Comments;
                    sysCodeDtl.Classify3 = sysCodeDtl1.Comments;
            }
            //投诉书
            List<TComplaintletterDTO> complaintletterDTOs = _cooperOrderService.GetListComplaintletter(id);
@@ -2649,7 +3049,7 @@
                        var sysCodeDtls2 = sysCodeDtls1.Where(x => x.Classify1 == complaintItemDTO.Question).ToList();
                        if (!string.IsNullOrEmpty(complaintItemDTO.Law))
                        {
                            sysCodeDtls2 = sysCodeDtls2.Where(x => complaintItemDTO.Law.Split(',').Contains(x.Comments)).ToList();
                            sysCodeDtls2 = sysCodeDtls2.Where(x => complaintItemDTO.Law.Split(',').Contains(x.CodeSn)).OrderBy(x => x.Classify3).ToList();
                        }
                        complaintItemDTO.sysCodeDtls = sysCodeDtls2;
                    }
@@ -2674,6 +3074,12 @@
                else
                    complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>() /*{ new TComplaintShouquandaibiaoDTO() }*/;
                List<TChallengeRequestInfoDTO> challengeRequestInfoDTOs = _cooperOrderService.GetListChallengeRequestInfo(complaintletterDTO.Id);
                if (challengeRequestInfoDTOs.Count > 0)
                    complaintletterDTO.challengeRequestInfoDTOs = challengeRequestInfoDTOs;
                else
                    complaintletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() /*{ new TChallengeRequestInfoDTO() }*/;
                List<TComplaintGongyingshangDTO> complaintGongyingshangDTOs = _cooperOrderService.GetListComplaintGongyingshang(complaintletterDTO.Id);
                if (complaintGongyingshangDTOs.Count > 0)
                    complaintletterDTO.complaintGongyingshangDTOs = complaintGongyingshangDTOs;
@@ -2688,7 +3094,7 @@
                complaintletterDTO.complaintRespondentDTOs = new List<TComplaintRespondentDTO>() { new TComplaintRespondentDTO() };
                complaintletterDTO.complaintShouquandaibiaoDTOs = new List<TComplaintShouquandaibiaoDTO>()/* { new TComplaintShouquandaibiaoDTO() }*/;
                complaintletterDTO.complaintGongyingshangDTOs = new List<TComplaintGongyingshangDTO>() /*{ new TComplaintGongyingshangDTO() }*/;
                complaintletterDTO.challengeRequestInfoDTOs = new List<TChallengeRequestInfoDTO>() /*{ new TChallengeRequestInfoDTO() }*/;
            }
@@ -2727,14 +3133,67 @@
                        complaintletterDTO.SqdbId += challengeItemDTO.QuestionName+";";
                    }
                }
            }
            else
            {
                complaintletterDTO.SqdbId = "";
                if (complaintletterDTO.complaintItemDTOs != null && complaintletterDTO.complaintItemDTOs.Count > 0)
                {
                    foreach (var complaintItemDTO in complaintletterDTO.complaintItemDTOs)
                    {
                        complaintletterDTO.SqdbId += complaintItemDTO.QuestionName ;
                    }
                }
            }
            var cooperOrderDTO = _cooperOrderService.Get(id);
            var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(cooperOrderDTO.Khdw);
            if (cooperatecustomCustomerDTO.Name.IndexOf("股份有限公司") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "董事长";
            }
            else if (cooperatecustomCustomerDTO.Name.IndexOf("有限公司") >= 0 || cooperatecustomCustomerDTO.Name.IndexOf("有限责任公司") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "执行董事";
            }
            else if (cooperatecustomCustomerDTO.Name.IndexOf("协会") >= 0)
            {
                cooperatecustomCustomerDTO.Zhiwu = "会长";
            }
            else
            {
                cooperatecustomCustomerDTO.Zhiwu = "总经理";
            }
            ResultDataEntity<SysAttachmentDTO> resultsyinyezhizhao = new ResultDataEntity<SysAttachmentDTO>();
            SysAttachmentDTOSearch searchEntity = new SysAttachmentDTOSearch();
            searchEntity.page = 1;
            searchEntity.rows = 1000;
            searchEntity.AttObj = "Cooperyinyezhizhao";
            searchEntity.AttObjid = cooperOrderDTO.Khdw;
            resultsyinyezhizhao = _sysAttachmentService.SearchByPaging(searchEntity);
            ViewBag.yinyezhizhao = resultsyinyezhizhao;
            ResultDataEntity<SysAttachmentDTO> resultshenfenzheng = new ResultDataEntity<SysAttachmentDTO>();
            SysAttachmentDTOSearch searchEntity1 = new SysAttachmentDTOSearch();
            searchEntity1.page = 1;
            searchEntity1.rows = 1000;
            searchEntity1.AttObj = "Cooperashenfenzheng";
            searchEntity1.AttObjid = cooperOrderDTO.Khdw;
            resultshenfenzheng = _sysAttachmentService.SearchByPaging(searchEntity1);
            ViewBag.shenfenzheng = resultshenfenzheng;
            ViewBag.cooperatecustomCustomerDTO = cooperatecustomCustomerDTO;
            ViewData.Model = complaintletterDTO;