239 lines
9.2 KiB
C#
239 lines
9.2 KiB
C#
using CRM.Core.DTO;
|
|
using Newtonsoft.Json;
|
|
using Ninject;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.Common.Layui;
|
|
using WX.CRM.Common.StockHelper;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.Model.DTO;
|
|
using WX.CRM.Model.Enum;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.WeiXin
|
|
{
|
|
public class OutComplaintController : BaseController
|
|
{
|
|
|
|
[Inject]
|
|
public IBAS_SALESDEPARTMENT_Q _bas_salesdepartment { get; set; }
|
|
|
|
public ICACHE_Q _cache { get; set; }
|
|
|
|
public readonly string webapi = "";
|
|
|
|
|
|
|
|
public OutComplaintController(ICACHE_Q cache)
|
|
{
|
|
_cache = cache;
|
|
webapi = _cache.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
}
|
|
|
|
public ActionResult ComplaintTab()
|
|
{
|
|
|
|
return View();
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public ActionResult Index()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.外诉处理列表, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
tool.AddOtherButton("Other1", "处理回复", "icon-detail", "Deal_Click", true);
|
|
tool.AddOtherButton("Other2", "查看回复", "icon-detail", "Detail_Click", true);
|
|
tool.AddOtherButton("Other3", "导出", "icon-detail", "Export_Click", true);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
//List<WX.CRM.Model.Entity.BAS_SALESDEPARTMENT> list = _bas_salesdepartment.GetList();
|
|
var deptList = _cache.GetList_BusinessLines().ToList();
|
|
|
|
ViewBag.deptList = deptList;
|
|
ViewBag.eid = Eid;
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public JsonResult GetHtmlList(Laypage pager, OutComplaintRequest dto)
|
|
{
|
|
var layUidata = new LayuiData<OutComplaintResponse>();
|
|
try
|
|
{
|
|
var data = GetList(pager, dto);
|
|
|
|
layUidata.msg = "数据加载成功";
|
|
layUidata.code = 0;
|
|
layUidata.data = data.data.Data.ToList();
|
|
layUidata.count = data.data.Total;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
|
}
|
|
return Json(layUidata);
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public ActionResult Edit(int id)
|
|
{
|
|
var model = new OutComplaintReplyDto();
|
|
|
|
var url = $"{webapi}/api/OutComplaint/Restore";
|
|
var para = $"id={id}";
|
|
var result = Utility.GetData(url, para, Encoding.UTF8);
|
|
var data = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<OutComplaintReplyDto>>(result);
|
|
if (data.code == 0 && data.data != null)
|
|
model = data.data;
|
|
|
|
ViewBag.id = id;
|
|
ViewBag.eid = Eid;
|
|
ViewBag.userName = UserName;
|
|
ViewBag.File_Server = _cache.GetValue_Parameter("File_Server");
|
|
return View(model);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public JsonResult EditSubmit(CreateOutComplaintRestoreDto dto)
|
|
{
|
|
var url = $"{webapi}/api/OutComplaint/Restore";
|
|
dto.RestoreType = 1;
|
|
var result = Utility.PostAjaxData(url, dto.ToJson(), Encoding.UTF8);
|
|
var data = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<bool>>(result);
|
|
|
|
retMsg ret = new retMsg();
|
|
if(data.code == 0 && data.data)
|
|
ret = new retMsg() { result = true, retcode = 200, retmsg = "创建成功!" };
|
|
else
|
|
ret = new retMsg() { result = false, retcode = 200, retmsg = "创建失败!" };
|
|
|
|
|
|
return Json(ret);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public ActionResult Detail(int id)
|
|
{
|
|
var model = new OutComplaintReplyDto();
|
|
|
|
var url = $"{webapi}/api/OutComplaint/Restore";
|
|
var para = $"id={id}";
|
|
var result = Utility.GetData(url, para, Encoding.UTF8);
|
|
var data = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<OutComplaintReplyDto>>(result);
|
|
|
|
if (data.code == 0 && data.data != null)
|
|
model = data.data;
|
|
|
|
return View(model);
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_外诉处理列表)]
|
|
public ActionResult Export(OutComplaintRequest dto)
|
|
{
|
|
var data = GetList(new Laypage { page = 1,limit = 100000}, dto);
|
|
|
|
if(data.code == 0)
|
|
{
|
|
string checkedFilds = PageRequest.GetQueryString("checkedFilds").Replace("[]", "");
|
|
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
|
|
return File(ExcelHelper.ExportListModelToExcel<OutComplaintResponse>(data.data.Data.ToList(), "外诉处理列表", 10000, checkedFilds, checkedTitles, DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("外诉处理列表.xls"));
|
|
}
|
|
|
|
return Json(new { message = "数据获取错误!" }, JsonRequestBehavior.AllowGet);
|
|
|
|
|
|
}
|
|
|
|
private string DataFormart(string key, object value)
|
|
{
|
|
string formartValue = string.Empty;
|
|
switch (key)
|
|
{
|
|
case "reasonList":
|
|
case "orderList":
|
|
case "priceList":
|
|
formartValue = string.Join("\n", Utility.ToObject<List<string>>(Utility.ToJson(value)));
|
|
break;
|
|
default: formartValue = string.Format("{0}", value); break;
|
|
}
|
|
return formartValue;
|
|
}
|
|
|
|
private WX.CRM.Common.Employee.ApiResult<PageResult<OutComplaintResponse>> GetList(Laypage pager, OutComplaintRequest dto)
|
|
{
|
|
try
|
|
{
|
|
string eids = null;
|
|
var innerUserIds = new List<decimal>();
|
|
var ug = _cache.GetList_InnerUserGroup();
|
|
if (dto.txt_userId.HasValue)
|
|
{
|
|
innerUserIds.Add(dto.txt_userId.Value);
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(dto.txt_groupIds))
|
|
{
|
|
var users = ug.Where(x => x.GID == decimal.Parse(dto.txt_groupIds)).ToList();
|
|
if (users != null && users.Any())
|
|
innerUserIds.AddRange(users.Select(x => x.INNERUSERID).ToList());
|
|
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(dto.txt_deptId))
|
|
{
|
|
var users = ug.Where(x => x.DEPTID == decimal.Parse(dto.txt_deptId)).ToList();
|
|
if (users != null && users.Any())
|
|
innerUserIds.AddRange(users.Select(x => x.INNERUSERID).ToList());
|
|
}
|
|
|
|
if (innerUserIds.Count > 0)
|
|
eids = string.Join(",", new BAS_INNERUSER_BL().GetInnerUserByGroup(innerUserIds.ToArray()).Select(p => p.EID));
|
|
|
|
var deptIds = _cache.GetList_BusinessLines().ToList();
|
|
var showDeptIds = string.Join(",", deptIds.Select(x => x.BUSINESSID));
|
|
|
|
var url = $"{webapi}/api/OutComplaint/page";
|
|
var para = $"Deptid={dto.Deptid}&Channel={dto.Channel}&Orderid={dto.Orderid}" +
|
|
$"&Reason={dto.Reason}&Resid={dto.Resid}&CreaetOrUpdateUser={dto.CreaetOrUpdateUser}" +
|
|
$"&BusinessStatus={dto.BusinessStatus}&Cname={dto.Cname}&ComplaintId={dto.ComplaintId}" +
|
|
$"&DateType={dto.DateType}&DueStatus={dto.DueStatus}&Eid={dto.Eid}&showDeptIds={showDeptIds}" +
|
|
$"&OutComplaintChannel={dto.OutComplaintChannel}&OutComplaintStatus={dto.OutComplaintStatus}" +
|
|
$"&DateFrom={dto.DateFrom}&DateTo={dto.DateTo}&Eids={eids}&PageIndex={pager.page}&PageSize={pager.limit}";
|
|
|
|
var result = Utility.GetData(url, para, Encoding.UTF8);
|
|
var data = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<PageResult<OutComplaintResponse>>>(result);
|
|
|
|
if (data.code == 0 && data.data != null && data.data.Data != null)
|
|
{
|
|
foreach (var item in data.data.Data)
|
|
{
|
|
var uid = InnerUserHelper.Instance.GetUserIdByEid(item.eid);
|
|
if (uid > 1)
|
|
item.groupname = InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(uid));
|
|
}
|
|
}
|
|
return data;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
throw new Exception(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
} |