using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.IdentityModel.Tokens.Jwt;
|
using System.Linq;
|
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
using System.Transactions;
|
using zhengcaioa.IService;
|
using zhengcaioa.Models;
|
|
namespace zhengcaioa.Controllers
|
{
|
public class APIController : Controller
|
{
|
|
private readonly ILogger<UserController> _logger;
|
private readonly IUserService _userService;
|
private readonly IHrDeptService _hrDeptService;
|
private readonly IHrPositionService _hrPositionService;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IPltJiatingchengyuanService _pltJiatingchengyuanService;
|
private readonly ISysAttachmentService _sysAttachmentService;
|
private readonly IPltRoleService _pltRoleService;
|
private readonly IPltPageService _pltPageService;
|
private readonly ICooperatecustomCustomerService _cooperatecustomCustomerService;
|
private readonly IIntentionCustomerService _intentionCustomerService;
|
private readonly ICooperVisitService _cooperVisitService;
|
private readonly IIntentionVisitService _intentionVisitService;
|
private readonly IExpertService _expertService;
|
|
public APIController(ILogger<UserController> logger, IUserService userService, IHrDeptService hrDeptService, IHrPositionService hrPositionService, ILiaotianService liaotianService, IPltJiatingchengyuanService pltJiatingchengyuanService, ISysAttachmentService sysAttachmentService
|
, IPltRoleService pltRoleService
|
, IPltPageService pltPageService
|
, ICooperatecustomCustomerService cooperatecustomCustomerService
|
, IIntentionCustomerService intentionCustomerService
|
, ICooperVisitService cooperVisitService
|
, IIntentionVisitService intentionVisitService
|
, IExpertService expertService)
|
{
|
_logger = logger;
|
_userService = userService;
|
_hrDeptService = hrDeptService;
|
_hrPositionService = hrPositionService;
|
_liaotianService = liaotianService;
|
_pltJiatingchengyuanService = pltJiatingchengyuanService;
|
_sysAttachmentService = sysAttachmentService;
|
_pltRoleService = pltRoleService;
|
_pltPageService = pltPageService;
|
_cooperatecustomCustomerService = cooperatecustomCustomerService;
|
_intentionCustomerService = intentionCustomerService;
|
_cooperVisitService = cooperVisitService;
|
_intentionVisitService = intentionVisitService;
|
_expertService = expertService;
|
}
|
|
|
//获取某个客户经理的所有客户
|
|
// 分页,查询条件 客户名称 客户类型
|
|
// 客户意向 查询 客户类型 查询
|
|
//填写客户意向
|
//申请下行流量包
|
|
|
//获取客户类型
|
public IActionResult GetKhlx()
|
{
|
ReturnMsg<List<SysCodeDtl>> returnMsg = new ReturnMsg<List<SysCodeDtl>>();
|
returnMsg.code = 2;
|
try
|
{
|
string userid = "";
|
string usersn = "";//客户经理登录名
|
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;
|
System.Security.Claims.Claim ssss = jwt.Claims.Where(x => x.Type == "sub").FirstOrDefault();
|
usersn = ssss.Value;
|
}
|
|
var aaaaa = _liaotianService.GetSYScode("CooperatecustomCustomer", "khlx");
|
returnMsg.code = 1;
|
returnMsg.returnObj = aaaaa;
|
returnMsg.count = aaaaa.Count;
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
|
//获取客户成交意向
|
public IActionResult GetCjyx()
|
{
|
ReturnMsg<List<SysCodeDtl>> returnMsg = new ReturnMsg<List<SysCodeDtl>>();
|
returnMsg.code = 2;
|
try
|
{
|
string userid = "";
|
string usersn = "";//客户经理登录名
|
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;
|
System.Security.Claims.Claim ssss = jwt.Claims.Where(x => x.Type == "sub").FirstOrDefault();
|
usersn = ssss.Value;
|
}
|
|
var aaaaa = _liaotianService.GetSYScode("CooperVisit", "yx");
|
returnMsg.code = 1;
|
returnMsg.returnObj = aaaaa;
|
returnMsg.count = aaaaa.Count;
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
|
//获取客户经理客户
|
public IActionResult GetCustomer([FromBody]CooperatecustomCustomerDTOSearch search)
|
{
|
ReturnMsg<List<CooperatecustomCustomerDTO>> returnMsg = new ReturnMsg<List<CooperatecustomCustomerDTO>>();
|
returnMsg.code = 2;
|
try
|
{
|
string userid = "";
|
string usersn = "";//客户经理登录名
|
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;
|
System.Security.Claims.Claim ssss = jwt.Claims.Where(x => x.Type == "sub").FirstOrDefault();
|
usersn = ssss.Value;
|
}
|
|
var aaaaa = _userService.GetList().Where(x=>x.UserSn == usersn).FirstOrDefault();
|
if (aaaaa == null)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有找到客户经理";
|
returnMsg.count = 0;
|
|
return new JsonResult(returnMsg);
|
}
|
search.Ywjl = aaaaa.Id;
|
//search.page = 1;
|
//search.rows = 20;
|
var resultDataEntity = _cooperatecustomCustomerService.SearchByPagingAll(search);
|
|
|
|
|
returnMsg.code = 1;
|
returnMsg.returnObj = resultDataEntity.DataList;
|
returnMsg.count = resultDataEntity.DataList.Count;
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
//修改客户客户类型
|
public IActionResult UpdateKhlx([FromBody] CooperatecustomCustomerDTO dTO)
|
{
|
ReturnMsg<CooperatecustomCustomerDTO> returnMsg = new ReturnMsg<CooperatecustomCustomerDTO>();
|
returnMsg.code = 2;
|
try
|
{
|
string userid = "";
|
string usersn = "";//客户经理登录名
|
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;
|
System.Security.Claims.Claim ssss = jwt.Claims.Where(x => x.Type == "sub").FirstOrDefault();
|
usersn = ssss.Value;
|
}
|
var aaaaa = _userService.GetList().Where(x => x.UserSn == usersn).FirstOrDefault();
|
if (aaaaa == null)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有找到客户经理";
|
returnMsg.count = 0;
|
|
return new JsonResult(returnMsg);
|
}
|
dTO.Modifier = aaaaa.Id;
|
dTO.Modifytime = DateTime.Now;
|
var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(dTO.Id);
|
if (!string.IsNullOrEmpty(cooperatecustomCustomerDTO.Id))
|
{
|
var resultDataEntity = _cooperatecustomCustomerService.saveKhlx(dTO);
|
}
|
else
|
{
|
var intentionCustomerDTO = _intentionCustomerService.Get(dTO.Id);
|
if (!string.IsNullOrEmpty(intentionCustomerDTO.Id))
|
{
|
var resultDataEntity = _intentionCustomerService.saveKhlx(dTO);
|
}
|
}
|
|
|
returnMsg.code = 1;
|
returnMsg.returnObj = dTO;
|
returnMsg.count = 1;
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
|
|
|
//修改客户成交意向
|
public IActionResult UpdateCjyx([FromBody] CooperVisitDTO dTO)
|
{
|
ReturnMsg<CooperVisitDTO> returnMsg = new ReturnMsg<CooperVisitDTO>();
|
returnMsg.code = 2;
|
try
|
{
|
string userid = "";
|
string usersn = "";//客户经理登录名
|
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;
|
System.Security.Claims.Claim ssss = jwt.Claims.Where(x => x.Type == "sub").FirstOrDefault();
|
usersn = ssss.Value;
|
}
|
|
var aaaaa = _userService.GetList().Where(x => x.UserSn == usersn).FirstOrDefault();
|
if (aaaaa == null)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有找到客户经理";
|
returnMsg.count = 0;
|
|
return new JsonResult(returnMsg);
|
}
|
var cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(dTO.Viscustomer);
|
if (!string.IsNullOrEmpty(cooperatecustomCustomerDTO.Id))
|
{
|
dTO.VisType = "05";
|
if(string.IsNullOrEmpty(dTO.Jtype))
|
dTO.Jtype = "10";
|
if (string.IsNullOrEmpty(dTO.Talk))
|
dTO.Talk = "成交意向";
|
if (string.IsNullOrEmpty(dTO.Khfk))
|
dTO.Khfk = "成交意向";
|
if (string.IsNullOrEmpty(dTO.Jy))
|
dTO.Jy = "02";
|
if (string.IsNullOrEmpty(dTO.Jdr))
|
dTO.Jdr = "无";
|
if (string.IsNullOrEmpty(dTO.Zw))
|
dTO.Zw = "08";
|
|
//dTO.Vistime = DateTime.Now;
|
dTO.Modifier = aaaaa.Id;
|
dTO.Modifytime = DateTime.Now;
|
dTO.Creater = aaaaa.Id;
|
dTO.Modifytime = dTO.Modifytime;
|
var resultDataEntity = _cooperVisitService.save(dTO);
|
}
|
else
|
{
|
var intentionCustomerDTO = _intentionCustomerService.Get(dTO.Viscustomer);
|
if (!string.IsNullOrEmpty(intentionCustomerDTO.Id))
|
{
|
var intentionVisitDTO = new IntentionVisitDTO();
|
|
intentionVisitDTO.VisType = "05";
|
if (string.IsNullOrEmpty(dTO.Jtype))
|
intentionVisitDTO.Jtype = "10";
|
else
|
intentionVisitDTO.Jtype = dTO.Jtype;
|
if (string.IsNullOrEmpty(dTO.Talk))
|
intentionVisitDTO.Talk = "成交意向";
|
else
|
intentionVisitDTO.Talk = dTO.Talk;
|
if (string.IsNullOrEmpty(dTO.Khfk))
|
intentionVisitDTO.Khfk = "成交意向";
|
else
|
intentionVisitDTO.Khfk = dTO.Khfk;
|
if (string.IsNullOrEmpty(dTO.Jy))
|
intentionVisitDTO.Jy = "02";
|
else
|
intentionVisitDTO.Jy = dTO.Jy;
|
if (string.IsNullOrEmpty(dTO.Jdr))
|
dTO.Jdr = "无";
|
else
|
intentionVisitDTO.Jdr = dTO.Jdr;
|
if (string.IsNullOrEmpty(dTO.Zw))
|
dTO.Zw = "08";
|
else
|
intentionVisitDTO.Zw = dTO.Zw;
|
|
//intentionVisitDTO.Vistime = DateTime.Now;
|
intentionVisitDTO.Viscustomer = dTO.Viscustomer;
|
intentionVisitDTO.Yx = dTO.Yx;
|
intentionVisitDTO.Modifier = aaaaa.Id;
|
intentionVisitDTO.Modifytime = DateTime.Now;
|
intentionVisitDTO.Creater = aaaaa.Id;
|
intentionVisitDTO.Modifytime = intentionVisitDTO.Modifytime;
|
var resultDataEntity = _intentionVisitService.save(intentionVisitDTO);
|
}
|
}
|
|
|
|
returnMsg.code = 1;
|
returnMsg.returnObj = dTO;
|
returnMsg.count = 1;
|
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
|
|
|
|
|
//代理合作申请
|
public IActionResult SaveDlhz([FromBody] ExpertDTO dTO)
|
{
|
ReturnMsg<ExpertDTO> returnMsg = new ReturnMsg<ExpertDTO>();
|
returnMsg.code = 2;
|
try
|
{
|
|
|
|
dTO.InfoSource = "";
|
dTO.ExpertType = "";
|
dTO.RecStatus = "A";
|
dTO.Modifier = "1";
|
dTO.Modifytime = DateTime.Now;
|
dTO.Creater = "1";
|
dTO.Createtime = dTO.Modifytime;
|
var resultDataEntity = _expertService.savehezuo(dTO);
|
|
|
|
if (resultDataEntity.Result)
|
{
|
returnMsg.code = 1;
|
returnMsg.returnObj = dTO;
|
returnMsg.count = 1;
|
}
|
else
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "保存失败";
|
returnMsg.count = 0;
|
}
|
|
|
|
|
|
}
|
catch (Exception ex)
|
{
|
returnMsg.code = 2;
|
returnMsg.error = "没有获取到token";
|
returnMsg.count = 0;
|
|
}
|
return new JsonResult(returnMsg);
|
}
|
}
|
}
|