using Ninject;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using System.Xml.Serialization;
using WX.CRM.BLL.Util;
using WX.CRM.Common;
using WX.CRM.Common.Layui;
using WX.CRM.IBLL.Base;
using WX.CRM.IBLL.Res;
using WX.CRM.Model.crmModel;
using WX.CRM.Model.DTO;
using WX.CRM.Model.Entity;
using WX.CRM.Model.Enum;
using WX.CRM.Model.MAP;
using WX.CRM.Model.QueryMap;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Res
{
public class ActivityController : BaseController
{
private IRES_ACTIVITY_Q activityBiz_Q;
private IRES_ACTIVITY activityBiz;
private IRES_RESOURCETYPE_Q resourceTypeBiz_Q;
private IRES_ACTIVITY_EXPORTLOG activity_exportLog;
private IRES_ACTIVITY_EXPORTLOG_Q activity_exportLog_Q;
private IRES_IMPORTRES_Q importQ;
private IRES_IMPORTRES import;
private static readonly object sync = new object();
[Inject]
public IBAS_INNERGROUP_Q _INNERGROUP_Q { get; set; }
[Inject]
public IBAS_INNERUSER_Q inneruserBiz_Q { get; set; }
[Inject]
public IBAS_INNERUSERGROUP_Q inneruserGroupBiz_Q { get; set; }
[Inject]
public IBAS_COMPANY_Q companyBl { get; set; }
[Inject]
public IRES_DISTRIBUTE dISTRIBUTE_Q { get; set; }
[Inject]
public IRES_DISTRIBUTE_DETAIL _DISTRIBUTE_DETAIL { get; set; }
[Inject]
public CACHE_BL cache_BL { get; set; }
[Inject]
public IRES_ResRecycleRecord resRecycle_BL { get; set; }
[Inject]
public IRES_CUSTOMERDETAIL _res_customerdetail { get; set; }
[Inject]
public IBAS_SALESDEPARTMENT_Q bas_SalesDepartment_BL { get; set; }
private ValidationErrors errors = new ValidationErrors();
public ActivityController(
IRES_ACTIVITY_Q _activityBiz_Q,
IRES_ACTIVITY _activityBiz,
IRES_RESOURCETYPE_Q _resourceTypeBiz_Q,
IRES_ACTIVITY_EXPORTLOG _activity_exportLog,
IRES_ACTIVITY_EXPORTLOG_Q _activity_exportLog_Q,
IRES_IMPORTRES_Q _importQ,
IRES_IMPORTRES _import
)
{
this.activityBiz_Q = _activityBiz_Q;
this.activityBiz = _activityBiz;
this.resourceTypeBiz_Q = _resourceTypeBiz_Q;
this.activity_exportLog = _activity_exportLog;
this.activity_exportLog_Q = _activity_exportLog_Q;
this.importQ = _importQ;
this.import = _import;
}
#region 资源统计及输出
///
/// 资源统计及输出
///
///
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public ActionResult ActivityStOrEx()
{
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.资源统计及输出, userRightId);
tool.AllowButton(toolbtn);
//tool.AllowButton("Other1", "Other2", "Other3");
tool.AddOtherButton("Other1", "导出资源", "icon-excel", "Export_Res_Click", true);
tool.AddOtherButton("Other2", "续导出", "icon-excel", "Continued_Click", true);
tool.AddOtherButton("Other3", "筛选导出", "icon-excel", "Advanced_Search_Click", true);
tool.AddOtherButton("Other4", "资源分配", "icon-details", "Distbute_Click", true);
tool.AddOtherButton("Other5", "资源统计导出", "icon-excel", "ResourceCountExport_Click", true);
tool.AddOtherButton("Other6", "查看明细", "icon-details", "List_Click", true);
ViewBag.ToolBar = tool;
//移动(3g)推广table
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab.AddHiddenHeadCol("ActivityId", "ActivityId");
tab.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab.AddHeadCol("", "25px", " ");
tab.AddHeadCol("TypeName", "30%", "资源类型");
tab.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab.AddHeadCol("strategyname", "", "分配策略");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable();
//策划table
string tableId1 = "tablist1";
Table tab1 = new Table(tableId1);
tab1.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab1.AddHiddenHeadCol("ActivityId", "ActivityId");
tab1.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab1.AddHeadCol("", "25px", " ");
tab1.AddHeadCol("TypeName", "30%", "资源类型");
tab1.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab1.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab1.AddHeadCol("strategyname", "", "分配策略");
tab1.AddHeadRow();
ViewBag.gridTable1 = tab1.GetTable();
//pc推广table2
string tableId2 = "tablist2";
Table tab2 = new Table(tableId2);
tab2.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab2.AddHiddenHeadCol("ActivityId", "ActivityId");
tab2.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
// tab2.AddHeadCol("", "25px", " ");
tab2.AddHeadCol("TypeName", "30%", "资源类型");
tab2.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab2.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab2.AddHeadCol("strategyname", "", "分配策略");
tab2.AddHeadRow();
ViewBag.gridTable2 = tab2.GetTable();
//table3 注册
string tableId3 = "tablist3";
Table tab3 = new Table(tableId3);
tab3.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab3.AddHiddenHeadCol("ActivityId", "ActivityId");
tab3.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab3.AddHeadCol("", "25px", " ");
tab3.AddHeadCol("TypeName", "30%", "资源类型");
tab3.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab3.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab3.AddHeadCol("strategyname", "", "分配策略");
tab3.AddHeadRow();
ViewBag.gridTable3 = tab3.GetTable();
//table4 其他
string tableId4 = "tablist4";
Table tab4 = new Table(tableId4);
tab4.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab4.AddHiddenHeadCol("ActivityId", "ActivityId");
tab4.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab4.AddHeadCol("", "25px", " ");
tab4.AddHeadCol("TypeName", "40%", "资源类型");
tab4.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab4.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab4.AddHeadCol("strategyname", "", "分配策略");
tab4.AddHeadRow();
ViewBag.gridTable4 = tab4.GetTable();
//table5 PC手机号注册资源统计
string tableId5 = "tablist5";
Table tab5 = new Table(tableId5);
tab5.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab5.AddHiddenHeadCol("ActivityId", "ActivityId");
tab5.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab5.AddHeadCol("", "25px", " ");
tab5.AddHeadCol("TypeName", "40%", "资源类型");
tab5.AddHeadCol("ActivityCountByTime", "10%", "每日新增资源(不受上面时间筛选影响)");
tab5.AddHeadCol("ActivityCountByCurDay", "15%", "资源合计");
tab5.AddHeadCol("strategyname", "", "分配策略");
tab5.AddHeadRow();
ViewBag.gridTable5 = tab5.GetTable();
return View();
}
#region 3g移动端
[HttpPost]
///
/// 按照条件获取数据
///
///
///
///
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlList3g(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
//var restypeCode = IsSanBu();
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 1, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 1, restypeCode: restypeCode);
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table = new Table(columns, true);
//推广资源
var groupList = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//推广资源table
foreach (var group in groupList)
{
table.AddHiddenCol(group.First().ResTypeId);
table.AddHiddenCol("");
table.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table.AddCol(" ");
table.AddCol(style1, "", group.Key);
table.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table.AddRow();
foreach (var model in group)
{
table.AddHiddenCol(model.ResTypeId);
table.AddHiddenCol(model.ActivityId);
table.AddHiddenCol(model.ActivityCountByTime);
table.AddCol("");
table.AddCol(style2, "", model.ActivityName);
table.AddCol(style2, "", model.ActivityCountByCurDay);
table.AddCol(style2, "", model.ActivityCountByTime);
table.AddCol(style3, "", "");
table.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table.GetRows()//推广
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 3g移动端
#region 策划
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlListch(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
//var restypeCode = IsSanBu();
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 0, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 0, UserId, HasRole());
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table1 = new Table(columns, true);
//策划资源
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//策划资源table
foreach (var group in groupList1)
{
table1.AddHiddenCol(group.First().ResTypeId);
table1.AddHiddenCol("");
table1.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table1.AddCol(" ");
table1.AddCol(style1, "", group.Key);
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table1.AddRow();
foreach (var model in group)
{
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(model.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style2, "", model.ActivityName);
table1.AddCol(style2, "", model.ActivityCountByCurDay);
table1.AddCol(style2, "", model.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table1.GetRows()//策划
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 策划
#region pc端
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlListpc(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
//var restypeCode = IsSanBu();
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 2, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 2, restypeCode: restypeCode);
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table = new Table(columns, true);
//pc推广资源
var groupList = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//推广资源table
foreach (var group in groupList)
{
table.AddHiddenCol(group.First().ResTypeId);
table.AddHiddenCol("");
table.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
// table.AddCol(" ");
table.AddCol(style1, "", group.Key);
table.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table.AddRow();
foreach (var model in group)
{
table.AddHiddenCol(model.ResTypeId);
table.AddHiddenCol(model.ActivityId);
table.AddHiddenCol(model.ActivityCountByTime);
// table.AddCol("");
table.AddCol(style2, "", model.ActivityName);
table.AddCol(style2, "", model.ActivityCountByCurDay);
table.AddCol(style2, "", model.ActivityCountByTime);
table.AddCol(style3, "", "");
table.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion pc端
#region 注册
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlListappzc(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 3, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 3);
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo);
Table table1 = new Table(columns, true);
//策划资源
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//策划资源table
foreach (var group in groupList1)
{
table1.AddHiddenCol(group.First().ResTypeId);
table1.AddHiddenCol("");
table1.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table1.AddCol(" ");
table1.AddCol(style1, "", group.Key);
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table1.AddRow();
foreach (var model in group)
{
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(model.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style2, "", model.ActivityName);
table1.AddCol(style2, "", model.ActivityCountByCurDay);
table1.AddCol(style2, "", model.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table1.GetRows()//策划
};
return Json(json, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlListpczc(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
if (System.Configuration.ConfigurationManager.AppSettings["ResHasWword"] != null && System.Configuration.ConfigurationManager.AppSettings["ResHasWword"].ToString() == "true")
{
return GetStaHtmlListpczcHasWord(columns, sTime, eTime, ResTypeId, ActivityId, hasMemo, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount);
}
var restypeCode = IsSanBu();
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 5, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 5, restypeCode: restypeCode);
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table1 = new Table(columns, true);
//策划资源
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//策划资源table
foreach (var group in groupList1)
{
table1.AddHiddenCol(group.First().ResTypeId);
table1.AddHiddenCol("");
table1.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table1.AddCol(" ");
table1.AddCol(style1, "", group.Key);
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table1.AddRow();
foreach (var model in group)
{
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(model.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style2, "", model.ActivityName);
table1.AddCol(style2, "", model.ActivityCountByCurDay);
table1.AddCol(style2, "", model.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table1.GetRows()//策划
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 注册
public JsonResult GetStaHtmlListpczcHasWord(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
//var restypeCode = IsSanBu();
IList list;
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
list = activityBiz_Q.GetList_Activity(sTime, eTime, 5, UserId, HasRole());
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table1 = new Table(columns, true);
//策划资源
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style5 = "text-align:left;padding-left:50px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//策划资源table
foreach (var group in groupList1)
{
table1.AddHiddenCol(group.First().ResTypeId);
table1.AddHiddenCol("");
table1.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table1.AddCol(" ");
table1.AddCol(style1, "", group.Key);
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table1.AddRow();
if (group.First().ResTypeId == 1201906702)
{
List ActivityIds = new List();
foreach (var model in group)
{
if (ActivityIds.Contains(model.ActivityId))
continue;
ActivityIds.Add(model.ActivityId);
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(group.Where(i => i.ActivityId == model.ActivityId).Sum(m => m.ActivityCountByTime));
table1.AddCol("");
table1.AddCol(style1, "", " " + model.ActivityName);
table1.AddCol(style2, "", "共:" + group.Where(i => i.ActivityId == model.ActivityId).Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style2, "", "共:" + group.Where(i => i.ActivityId == model.ActivityId).Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
foreach (var item in group)
{
if (item.ActivityId == model.ActivityId)
{
table1.AddHiddenCol(item.ActivityId);
table1.AddHiddenCol(item.kword);
table1.AddHiddenCol(item.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style5, "", item.kword);
table1.AddCol(style5, "", item.ActivityCountByCurDay);
table1.AddCol(style5, "", item.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + item.ActivityName + "'");
}
}
}
}
else
{
foreach (var model in group)
{
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(model.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style2, "", model.ActivityName);
table1.AddCol(style2, "", model.ActivityCountByCurDay);
table1.AddCol(style2, "", model.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
}
var json = new
{
rowsList = table1.GetRows()//策划
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#region 其他
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult GetStaHtmlListqt(string columns, DateTime sTime, DateTime eTime, int? ResTypeId, int? ActivityId, bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
//var restypeCode = IsSanBu();
IList list = activityBiz_Q.GetList_Activity(sTime, eTime, 4, UserId, HasRole());
//if (ResTypeId == null && hasMemo == null && hasRegisterSoftware == null && hasOpenFuturesAccount == null && hasOpenSilverAccount == null) //非高级查询
// list = activityBiz_Q.GetList_Activity(sTime, eTime, 4, restypeCode: restypeCode);
//else
// list = activityBiz_Q.GetList_Activity(sTime, eTime, ResTypeId, ActivityId, hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo, restypeCode);
Table table1 = new Table(columns, true);
//策划资源
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
//策划资源table
foreach (var group in groupList1)
{
table1.AddHiddenCol(group.First().ResTypeId);
table1.AddHiddenCol("");
table1.AddHiddenCol(group.Sum(m => m.ActivityCountByTime));
table1.AddCol(" ");
table1.AddCol(style1, "", group.Key);
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByCurDay));
table1.AddCol(style1, "", "合计:" + group.Sum(m => m.ActivityCountByTime));
table1.AddCol(style3, "", string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")");
table1.AddRow();
foreach (var model in group)
{
table1.AddHiddenCol(model.ResTypeId);
table1.AddHiddenCol(model.ActivityId);
table1.AddHiddenCol(model.ActivityCountByTime);
table1.AddCol("");
table1.AddCol(style2, "", model.ActivityName);
table1.AddCol(style2, "", model.ActivityCountByCurDay);
table1.AddCol(style2, "", model.ActivityCountByTime);
table1.AddCol(style3, "", "");
table1.AddRow("style='display:none' typeName='" + group.Key + "'");
}
}
var json = new
{
rowsList = table1.GetRows()//策划
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 其他
#endregion 资源统计及输出
#region 查看明细
[HttpGet]
public ActionResult List()
{
return View();
}
[HttpPost]
public JsonResult List(decimal? resTypeId, decimal? activityId, DateTime? sTime, DateTime? eTime)
{
//var pager = new Pager() { page = 1, rows = int.MaxValue };
var list = activityBiz_Q.GetResList(resTypeId, activityId, sTime, eTime);
foreach (var item in list)
{
if (!string.IsNullOrEmpty(item.ExtXml))
{
try
{
var xml = Deserialize(item.ExtXml);
item.ExtXml = xml.CNAME;
}
catch (Exception ex)
{
}
}
}
var data = new LayuiData()
{
msg = "数据加载成功!",
count = 0,
code = 0,
data = list
};
return Json(data, JsonRequestBehavior.AllowGet);
}
///
/// XML反序列化为对象
///
/// 对象类型
/// xml字符串
///
public static T Deserialize(string xml)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
StringReader stringReader = new StringReader(xml);
return (T)xmlSerializer.Deserialize(stringReader);
}
#endregion 查看明细
#region 资源导出
///
/// 资源导出
///
///
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other1)]
public FileResult ResourceExport()
{
decimal ResTypeId = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
decimal ActivityId = 0;
if (Request.QueryString["ActivityId"] != "")
ActivityId = Convert.ToDecimal(Request.QueryString["ActivityId"]);
string stime = Request.QueryString["stime"];
string etime = Request.QueryString["etime"];
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源导出" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
//List list = activityBiz_Q.GetListExport_Activity(ResTypeId, ActivityId, DateTime.Parse(stime), DateTime.Parse(etime)) as List;
List list = activityBiz_Q.GetList_Activity_export(ResTypeId, ActivityId, DateTime.Parse(stime), DateTime.Parse(etime), UserId, HasRole()) as List;
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(list, "资源列表", 50000, null);
return File(strem, contentType, downloadName);
}
#endregion 资源导出
#region 续导出
///
/// 续导出页面
///
///
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other2)]
public ActionResult ContinuedExport()
{
string ResTypeId = Request.QueryString["ResTypeId"];
string ActivityId = Request.QueryString["ActivityId"];
string name = string.Empty;
decimal id = 0;
short sourceType = 0;
if (ActivityId.Trim() != "")
{
id = Convert.ToDecimal(ActivityId);
sourceType = 1;
WX.CRM.Model.Entity.RES_ACTIVITY acmodel = activityBiz_Q.GetModel(id);
if (acmodel != null)
name = acmodel.ACTIVITYNAME;
}
else
{
id = Convert.ToDecimal(ResTypeId);
WX.CRM.Model.Entity.RES_RESOURCETYPE tpmodel = resourceTypeBiz_Q.GetModel(id);
if (tpmodel != null)
name = tpmodel.TYPENAME;
}
WX.CRM.Model.Entity.RES_ACTIVITY_EXPORTLOG model = activity_exportLog_Q.GetModel(id, sourceType);
if (model == null)
{
model = new WX.CRM.Model.Entity.RES_ACTIVITY_EXPORTLOG();
model.CTIME = Convert.ToDateTime("2000-01-01");
model.SOURCETYPE = sourceType;
model.SOURCEID = id;
}
ViewBag.sourceName = name;
return View(model);
}
///
/// 续导出 excle
///
///
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other2)]
public FileResult ContinuedResourceExport()
{
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源续导出" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
decimal ResTypeId = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
decimal ActivityId = 0;
if (Request.QueryString["ActivityId"] != "")
ActivityId = Convert.ToDecimal(Request.QueryString["ActivityId"]);
string stime = Request.QueryString["stime"];
string etime = Request.QueryString["etime"];
//List list = activityBiz_Q.GetListExport_Activity(ResTypeId, ActivityId, DateTime.Parse(stime), DateTime.Parse(etime)) as List;
List list = activityBiz_Q.GetList_Activity_export(ResTypeId, ActivityId, DateTime.Parse(stime), DateTime.Parse(etime), UserId, HasRole()) as List;
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(list, "资源列表", 50000, null);
//创建续导出的记录
WX.CRM.Model.Entity.RES_ACTIVITY_EXPORTLOG model = new WX.CRM.Model.Entity.RES_ACTIVITY_EXPORTLOG();
model.CREATEUSER = UserId;
model.CTIME = DateTime.Now;
if (string.IsNullOrEmpty(Request.QueryString["ActivityId"]))
{
model.SOURCEID = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
model.SOURCETYPE = 0;//0资源类型、1活动
}
else
{
model.SOURCEID = Convert.ToDecimal(Request.QueryString["ActivityId"]);
model.SOURCETYPE = 1;//0资源类型、1活动
}
activity_exportLog.Create(ref errors, model);
return File(strem, contentType, downloadName);
}
#endregion 续导出
#region 资源统计数导出
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other5)]
public FileResult ResourceCountExport()
{
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源统计数导出.xls");
decimal ResTypeId = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
DateTime stime = Request.QueryString["stime"].GetDateTime() ?? DateTime.Now;
DateTime etime = Request.QueryString["etime"].GetDateTime() ?? DateTime.Now;
int Attribute = Request["attribute"].GetInt(5);
string checkedTitles = "资源类型,每日新增资源(不受上面时间筛选影响),资源合计,分配策略";
string checkedFilds = "[ActivityName][ActivityCountByCurDay][ActivityCountByTime][StrategyName]";
var restypeCode = IsSanBu();
IList list = null;
if (Attribute == 5 && System.Configuration.ConfigurationManager.AppSettings["ResHasWword"] != null && System.Configuration.ConfigurationManager.AppSettings["ResHasWword"].ToString() == "true")
{
list = activityBiz_Q.GetList_Activity(stime, etime, Attribute, UserId, HasRole());
}
else
{
list = activityBiz_Q.GetList_Activity(stime, etime, Attribute, UserId, HasRole());
}
var groupList1 = from q in list
group q by q.TypeName into g
select g;
string style1 = "text-align:left;padding-left:10px;";
string style2 = "text-align:left;padding-left:30px;";
string style3 = "text-align:left;padding-left:10px;color:red;font-weight:bold";
var exportList = new List();
//策划资源table
foreach (var group in groupList1)
{
GroupByActivity_Export item = new GroupByActivity_Export()
{
ActivityName = group.Key,
ActivityCountByCurDay = "合计:" + group.Sum(m => m.ActivityCountByCurDay).ToString(),
ActivityCountByTime = "合计:" + group.Sum(m => m.ActivityCountByTime).ToString(),
StrategyName = string.IsNullOrWhiteSpace(group.First().strategyname) ? "" : group.First().strategyname + "(" + group.First().strategymemo + ")"
};
exportList.Add(item);
if (group.First().ResTypeId == 1201906702)
{
List ActivityIds = new List();
foreach (var model in group)
{
if (ActivityIds.Contains(model.ActivityId))
continue;
ActivityIds.Add(model.ActivityId);
GroupByActivity_Export item3 = new GroupByActivity_Export()
{
ActivityName = " |--" + model.ActivityName,
ActivityCountByCurDay = "共:" + group.Where(i => i.ActivityId == model.ActivityId).Sum(m => m.ActivityCountByCurDay),
ActivityCountByTime = "共:" + group.Where(i => i.ActivityId == model.ActivityId).Sum(m => m.ActivityCountByTime),
StrategyName = group.Key
};
exportList.Add(item3);
foreach (var item2 in group)
{
if (item2.ActivityId == model.ActivityId)
{
GroupByActivity_Export item4 = new GroupByActivity_Export()
{
ActivityName = " |--" + item2.kword,
ActivityCountByCurDay = item2.ActivityCountByCurDay.ToString(),
ActivityCountByTime = item2.ActivityCountByTime.ToString(),
StrategyName = item2.ActivityName
};
exportList.Add(item4);
}
}
}
}
else
{
foreach (var model in group)
{
GroupByActivity_Export item2 = new GroupByActivity_Export()
{
ActivityName = " |--" + model.ActivityName,
ActivityCountByCurDay = model.ActivityCountByCurDay.ToString(),
ActivityCountByTime = model.ActivityCountByTime.ToString(),
StrategyName = ""
};
exportList.Add(item2);
}
}
}
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(exportList, "资源统计数", 50000, checkedFilds, checkedTitles, null);
return File(strem, contentType, downloadName);
}
#endregion 资源统计数导出
#region 高级导出
///
/// 高级导出
///
///
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other3)]
public ActionResult AdvancedExport()
{
//table
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHiddenHeadCol("ResTypeId", "ResTypeId");
tab.AddHiddenHeadCol("ActivityId", "ActivityId");
tab.AddHiddenHeadCol("RESTOTAL", "RESTOTAL");
tab.AddHeadCol("", "25px", " ");
tab.AddHeadCol("TypeName", "20%", "资源类型");
tab.AddHeadCol("ActivityCountByTime", "20%", "每日新增资源(不受上面时间筛选影响)");
tab.AddHeadCol("ActivityCountByCurDay", "", "资源合计");
tab.AddHeadCol("StrategyName", "", "分配策略");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable();
return View();
}
///
/// 高级导出excle
///
///
public FileResult AdvancedResourceExport(bool? hasMemo, bool? hasRegisterSoftware, bool? hasOpenFuturesAccount, bool? hasOpenSilverAccount)
{
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源高级导出" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
decimal ResTypeId = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
decimal ActivityId = 0;
if (Request.QueryString["ActivityId"] != "")
ActivityId = Convert.ToDecimal(Request.QueryString["ActivityId"]);
string stime = Request.QueryString["stime"];
string etime = Request.QueryString["etime"];
List list = activityBiz_Q.GetListExport_Activity(ResTypeId, ActivityId, DateTime.Parse(stime), DateTime.Parse(etime), hasRegisterSoftware, hasOpenFuturesAccount, hasOpenSilverAccount, hasMemo) as List;
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(list, "资源列表", 50000, null);
return File(strem, contentType, downloadName);
}
#endregion 高级导出
#region 筛选导出
[AuthorizeToolBar(InitRights.CONST_资源统计及输出, InitToolBar.CONST_Other3)]
public FileResult DistbuteDataExport()
{
decimal ResTypeId = Convert.ToDecimal(Request.QueryString["ResTypeId"]);
decimal ActivityId = 0;
if (Request.QueryString["ActivityId"] != "")
ActivityId = Convert.ToDecimal(Request.QueryString["ActivityId"]);
DateTime? stime = Request.QueryString["stime"].GetDateTime();
DateTime? etime = Request.QueryString["etime"].GetDateTime();
string choices = Request.QueryString["choices"];
string excludeWeixinRes = Request.QueryString["excludeWeixinRes"];
string excludeOrderRes = Request.QueryString["excludeOrderRes"];
string excludeSpecialMemo = Request.QueryString["excludeSpecialMemo"];
DateTime? Memostime = Request.QueryString["Memostime"].GetDateTime();
DateTime? Memoetime = Request.QueryString["Memoetime"].GetDateTime();
int count = 0;
decimal importId = 0;
if (Memoetime != null)
Memoetime = Memoetime.Value.AddDays(1);
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源导出" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
List list = activityBiz_Q.GetList_DistributeActivity_export(ResTypeId, ActivityId, stime, etime, choices, Memostime, Memoetime, excludeWeixinRes, excludeOrderRes, excludeSpecialMemo) as List;
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(list, "资源列表", 50000, null);
return File(strem, contentType, downloadName);
}
#endregion 筛选导出
#region 资源分配
#region 修改后 资源分配
public ActionResult Strategy()
{
ViewBag.projectType = cache_BL.GetValue_Parameter(Model.Enum.Parameter.Sys_ProjectType);
return View();
}
[HttpPost]
public JsonResult DistbuteDataQueryAndInsert(decimal ResTypeId, decimal? ActivityId, DateTime? stime, DateTime? etime)
{
try
{
int count = 0;
decimal importId = 0;
//lock (sync)
{
dISTRIBUTE_Q.DistbuteDataQueryAndInsert(ResTypeId, ActivityId ?? 0, stime, etime, UserId, HasRole(), ref count, ref importId);
}
LogHelper.Info("资源分配日志:工号:" + Eid.ToString() + ",进行了分配资源:" + count.ToString());
if (count >= 0)
return Json(new { Success = true, DataCount = count, ImportId = importId }, JsonRequestBehavior.AllowGet);
else
return Json(new { Success = false, DataCount = count, ImportId = importId }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error("ActivityController_DistbuteDataQueryAndInsert:" + ex.StackTrace + ";" + ex.Message);
return Json(new { Success = false, Message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
public ActionResult Distbute(decimal ImportId, int DataCount)
{
var resTypeId = Request["ResTypeId"].GetDecimal(0);
var glist = _INNERGROUP_Q.GetList().OrderBy(p => p.SORT).ToList();
var ulist = inneruserBiz_Q.GetList();
var uglist = inneruserGroupBiz_Q.GetList();
var roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
if (roleCodes.Contains("[BMZG]") && !roleCodes.Contains("[ZJZL]"))
{
glist = glist.Where(m => m.SALEDEPTID == saleDeptId).ToList();
}
var ug = from t1 in uglist
join t2 in ulist on t1.INNERUSERID equals t2.PKID
join t3 in glist on t1.GID equals t3.GID
where t2.ISDISMISS == 0
select new { PKID = t2.PKID, UNAME = t2.UNAME, map_GID = t1.GID, DEPTID = t3.SALEDEPTID };
if (roleCodes.Contains("[BMZG]") && !roleCodes.Contains("[ZJZL]"))
{
ug = ug.Where(p => p.DEPTID == saleDeptId);
}
var ugView = from t1 in ug select new BAS_INNERUSER() { PKID = t1.PKID, UNAME = t1.UNAME, map_GID = t1.map_GID };
ViewData["ULIST"] = ugView;
ViewData["GLIST"] = glist;
ViewData["TOTAL"] = DataCount;
return View();
}
///
/// 长沙使用
///
///
///
///
public ActionResult Distbute2(decimal ImportId, int DataCount)
{
var glist = _INNERGROUP_Q.GetList();
var ulist = inneruserBiz_Q.GetList();
ViewData["GLIST"] = glist;
var uglist = inneruserGroupBiz_Q.GetList();
var ug = from t1 in uglist
join t2 in ulist on t1.INNERUSERID equals t2.PKID
where t2.ISDISMISS == 0
select new BAS_INNERUSER() { PKID = t2.PKID, UNAME = t2.UNAME, map_GID = t1.GID };
ViewData["ULIST"] = ug;
ViewData["TOTAL"] = DataCount;
return View();
}
[HttpPost]
public JsonResult DistbuteSubmit(string distbuteData, decimal ImportId, decimal ResTypeId, decimal? ActivityId)
{
try
{
List list_DISTRIBUTE_DETAIL = new List();//_uploadtable.ToList();
RES_DISTRIBUTE model = new RES_DISTRIBUTE
{
PICI = "IM" + DateTime.Now.ToString("yyMMddHHmmss"),
RESTYPEID = ResTypeId,
ACTIVITYID = ActivityId ?? 0,
CREATEUSER = UserId,
CTIME = DateTime.Now,
DISLEADER = UserId.ToString(),
SALESREMARK = "",
REMARK = ""
};
bool rst = true;
rst &= dISTRIBUTE_Q.Create(ref errors, model);
if (distbuteData != null)
{
//List list = importQ.GetResImportIdList(ImportId);
List list = importQ.GetExpResImportIdList(ImportId);
if (list.Any())
{
int resindex = 0;
var disarray = distbuteData.Split(',');
foreach (string disitem in disarray)
{
var disitemarr = disitem.Split(':');
if (disitemarr.Length != 2)
continue;
int num = Convert.ToInt32(string.IsNullOrEmpty(disitemarr[1]) ? "0" : disitemarr[1]);
while (num-- > 0)
{
if (resindex >= list.Count)
{
return Json(new { Success = false, Message = "资源不足,分配失败!" }, JsonRequestBehavior.AllowGet);
}
var detail = new RES_DISTRIBUTE_DETAIL
{
RESID = list[resindex++].IMPORTDATA,
SALESID = Convert.ToDecimal(disitemarr[0]),
DISTRIBUTEID = model.PKID,
CTIME = DateTime.Now
};
list_DISTRIBUTE_DETAIL.Add(detail);
}
}
rst &= _DISTRIBUTE_DETAIL.BatchAdd(ref errors, list_DISTRIBUTE_DETAIL);
try
{
import.BatchRemove(ImportId);
}
catch (Exception exx)
{
LogHelper.Error("删除导入的数据失败" + exx.ToString());
}
}
else
{
return Json(new { Success = false, Message = "找不到数据,请重试!" + errors }, JsonRequestBehavior.AllowGet);
}
LogHelper.Info("资源分配日志:工号:" + Eid.ToString() + ",提交了分配资源:" + list.Count.ToString());
}
if (rst)
return Json(new { Success = true, Message = "分配成功" }, JsonRequestBehavior.AllowGet);
else
{
LogHelper.Error("分配失败:" + errors);
return Json(new { Success = false, Message = "分配失败" + errors }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
LogHelper.Error("ActivityController/DistbuteSubmit" + ex);
return Json(new { Success = false, Message = "分配失败" }, JsonRequestBehavior.AllowGet);
}
}
[HttpPost]
public JsonResult ClearDistribute(decimal ImportId)
{
try
{
import.BatchRemove(ImportId);
return Json(new { Success = true, Message = "分配成功" }, JsonRequestBehavior.AllowGet);
}
catch (Exception exx)
{
LogHelper.Error("删除导入的数据失败" + exx.ToString());
return Json(new { Success = false, Message = "分配失败" }, JsonRequestBehavior.AllowGet);
}
}
///
/// 长沙使用
///
///
///
///
///
///
[HttpPost]
public JsonResult DistbuteSubmit2(string distbuteData, decimal ImportId, decimal ResTypeId, decimal? ActivityId)
{
try
{
var list_DISTRIBUTE_DETAIL = new List();//_uploadtable.ToList();
var dis = new Dictionary();
var model = new RES_DISTRIBUTE
{
PICI = "IM" + DateTime.Now.ToString("yyMMddHHmmss"),
RESTYPEID = ResTypeId,
ACTIVITYID = ActivityId ?? 0,
CREATEUSER = UserId,
CTIME = DateTime.Now,
DISLEADER = UserId.ToString(),
SALESREMARK = "",
REMARK = ""
};
var rst = true;
rst &= dISTRIBUTE_Q.Create(ref errors, model);
if (distbuteData != null)
{
List list = importQ.GetExpResImportIdList(ImportId);
int resindex = 0;
var disarray = distbuteData.Split(',');
foreach (string disitem in disarray)
{
var disitemarr = disitem.Split(':');
if (disitemarr.Length != 3)
continue;
int num = Convert.ToInt32(string.IsNullOrEmpty(disitemarr[1]) ? "0" : disitemarr[1]);
while (num-- > 0)
{
if (resindex >= list.Count)
{
return Json(new { Success = false, Message = "资源不足,分配失败!" }, JsonRequestBehavior.AllowGet);
}
var detail = new RES_DISTRIBUTE_DETAIL();
detail.RESID = list[resindex++].IMPORTDATA;
detail.SALESID = Convert.ToDecimal(disitemarr[0]);
detail.DISTRIBUTEID = model.PKID;
detail.CTIME = DateTime.Now;
list_DISTRIBUTE_DETAIL.Add(detail);
dis.Add(detail.RESID, disitemarr[2]);
}
}
rst &= _DISTRIBUTE_DETAIL.BatchAdd(ref errors, list_DISTRIBUTE_DETAIL);
_res_customerdetail.UpdateCategoryDic(dis);
}
if (rst)
return Json(new { Success = true, Message = "分配成功" }, JsonRequestBehavior.AllowGet);
else
{
LogHelper.Error("分配失败:" + errors);
return Json(new { Success = false, Message = "分配失败" + errors }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
LogHelper.Error("ActivityController/DistbuteSubmit" + ex);
return Json(new { Success = false, Message = "分配失败" }, JsonRequestBehavior.AllowGet);
}
}
public ActionResult DistbuteDisMiss(string resid, bool? isZhuguan, string groupId, decimal? userId, string HidRESOURCETAG, decimal? HidResourceId)
{
HidResourceId = HidResourceId.HasValue ? HidResourceId.Value : 0;
Pager pager = new Pager() { page = 1, rows = int.MaxValue };
var roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
var list = dISTRIBUTE_Q.GetDistbuteRes(ref pager, resid, userId, groupId, HidRESOURCETAG, HidResourceId.Value);
var glist = _INNERGROUP_Q.GetList();
if (roleCodes.Contains("[BMZG]"))
{
glist = glist.Where(m => m.SALEDEPTID == saleDeptId).ToList();
}
else if (!(roleCodes.Contains("[ZJZL]") || roleCodes.Contains("[GLY]")))
{
glist = glist.Where(m => userOnGroupId.Contains(m.GID)).ToList();
}
var ulist = inneruserBiz_Q.GetList();
ViewData["GLIST"] = glist;
var uglist = inneruserGroupBiz_Q.GetList();
var ug = from t1 in uglist
join t2 in ulist on t1.INNERUSERID equals t2.PKID
join t3 in glist on t1.GID equals t3.GID
where t2.ISDISMISS == 0
select new { PKID = t2.PKID, UNAME = t2.UNAME, map_GID = t1.GID, DEPTID = t3.SALEDEPTID };
if (roleCodes.Contains("[BMZG]"))
{
ug = ug.Where(p => p.DEPTID == saleDeptId);
}
else if (!(roleCodes.Contains("[ZJZL]") || roleCodes.Contains("[GLY]")))
{
ug = ug.Where(m => userOnGroupId.Contains(m.map_GID.Value)).ToList();
}
var ugView = from t1 in ug select new BAS_INNERUSER() { PKID = t1.PKID, UNAME = t1.UNAME, map_GID = t1.map_GID };
ViewData["ULIST"] = ugView;
ViewData["TOTAL"] = pager.totalRows;
return View();
}
public ActionResult DistbuteDisMissSubmit(string distbuteData, string resid, bool? isZhuguan, string groupId, decimal? userId, string HidRESOURCETAG, decimal? HidResourceId)
{
try
{
HidResourceId = HidResourceId.HasValue ? HidResourceId.Value : 0;
Pager pager = new Pager() { page = 1, rows = int.MaxValue };
var list_DISTRIBUTE_DETAIL = new List();
var removeDic = new List();
var updateDic = new List();
var resTypeId = cache_BL.GetValue_Parameter("RecycleResTypeId");
if (string.IsNullOrEmpty(resTypeId))
{
return Json(new { Success = false, Message = "回收类型ID为空,请联系管理员配置" }, JsonRequestBehavior.AllowGet);
}
var model = new RES_DISTRIBUTE
{
PICI = "IM" + DateTime.Now.ToString("yyMMddHHmmss"),
RESTYPEID = decimal.Parse(resTypeId),
ACTIVITYID = 0,
CREATEUSER = UserId,
CTIME = DateTime.Now,
DISLEADER = UserId.ToString(),
SALESREMARK = "",
REMARK = ""
};
bool rst = true;
rst &= dISTRIBUTE_Q.Create(ref errors, model);
if (distbuteData != null)
{
var list = dISTRIBUTE_Q.GetDistbuteRes(ref pager, resid, userId, groupId, HidRESOURCETAG, HidResourceId.Value);
int resindex = 0;
var disarray = distbuteData.Split(',');
foreach (string disitem in disarray)
{
var disitemarr = disitem.Split(':');
if (disitemarr.Length != 2)
continue;
int num = Convert.ToInt32(string.IsNullOrEmpty(disitemarr[1]) ? "0" : disitemarr[1]);
while (num-- > 0)
{
if (resindex >= list.Count)
{
return Json(new { Success = false, Message = "资源不足,分配失败!" }, JsonRequestBehavior.AllowGet);
}
var detail = new RES_DISTRIBUTE_DETAIL
{
RESID = list[resindex].resid,
SALESID = Convert.ToDecimal(disitemarr[0]),
DISTRIBUTEID = model.PKID,
CTIME = DateTime.Now
};
list_DISTRIBUTE_DETAIL.Add(detail);
removeDic.Add(list[resindex].logid);
updateDic.Add(list[resindex].resid);
resindex++;
}
}
rst &= _DISTRIBUTE_DETAIL.BatchAdd(ref errors, list_DISTRIBUTE_DETAIL);
_DISTRIBUTE_DETAIL.BatchRemove(removeDic);
_DISTRIBUTE_DETAIL.BatchUpdate(updateDic);
}
if (rst)
return Json(new { Success = true, Message = "分配成功" }, JsonRequestBehavior.AllowGet);
else
{
LogHelper.Error("分配失败:" + errors);
return Json(new { Success = false, Message = "分配失败" + errors }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
LogHelper.Error("ActivityController/DistbuteDisMissSubmit" + ex);
return Json(new { Success = false, Message = "分配失败" }, JsonRequestBehavior.AllowGet);
}
}
#endregion 修改后 资源分配
#region 手工分配回收
[HttpGet]
public ActionResult ChangeDistbuteRes()
{
ToolBar tool = new ToolBar();
tool.AllowButton("Other2");
tool.AddOtherButton("Other2", "资源分配", "icon-details", "AllocateRes_Click", true);
ViewBag.ToolBar = tool;
//table
Pager pager = new Pager() { page = 1, rows = 50 };
string tableId = "tablist";
Table tab = new Table(tableId);
//tab.isCheckbox = true;
tab.AddHiddenHeadCol("PKID", "PKID");
tab.AddHeadCol("ResId", "15%", "客户ID");
tab.AddHeadCol("INNERUSERID", "", "员工");
tab.AddHeadCol("TypeName", "", "资源类型");
tab.AddHeadCol("ActivityName", "", "活动名称");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "50,100");
List lis = new List();
var rlis = resourceTypeBiz_Q.GetList();
lis.Add(new SelectListItem() { Value = "0", Text = "-请选择-" });
foreach (var obj in rlis)
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
var category = cache_BL.GetList_SubComType(ComType.CustomerCategory).Select(item => new SelectListItem() { Text = item.SUBTYPENAME, Value = item.SUBTYPENAME }).ToList();
category.Insert(0, new SelectListItem() { Text = "全部", Value = string.Empty });
category.Insert(1, new SelectListItem() { Text = "未知", Value = "unknown" });
ViewData["ResourctType1"] = lis;
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
return View();
}
[HttpPost]
public JsonResult ChangeDistbuteRes(Pager pager, string columns, string groupId, decimal? userId, string resId)
{
string resourcetag = Request.Form["HidRESOURCETAG"];
decimal resourcetypeid = Request.Form["HidResourceId"].GetDecimal(0);
var list = dISTRIBUTE_Q.GetDistbuteRes(ref pager, resId, userId, groupId, resourcetag, resourcetypeid);
Table table = new Table(columns, true);
table.gridPager = pager;
//table.isCheckbox = true;
foreach (var model in list)
{
table.AddHiddenCol(model.logid);
var linkUrl = string.Format("{2}"
, "客户详细"
, "/Csvr/CustomerInfo/CustomerDetail?resid=" + model.resid
, model.resid);
table.AddCol(linkUrl);
table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(model.salesid));
table.AddCol(model.typename);
table.AddCol(model.activityname);
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public ActionResult DisbuteResCount()
{
ToolBar tool = new ToolBar();
tool.AllowButton("Other2");
tool.AddOtherButton("Other2", "资源分配", "icon-details", "AllocateRes_Click", true);
ViewBag.ToolBar = tool;
//table
Pager pager = new Pager() { page = 1, rows = 50 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHeadCol("salesid", "", "员工");
tab.AddHeadCol("typename", "", "资源类型");
tab.AddHeadCol("activityname", "", "活动名称");
tab.AddHeadCol("c", "", "数量");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "50,100");
List lis = new List();
var rlis = resourceTypeBiz_Q.GetList();
lis.Add(new SelectListItem() { Value = "0", Text = "-请选择-" });
foreach (var obj in rlis)
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
ViewData["ResourctType1"] = lis;
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
return View();
}
[HttpPost]
public JsonResult DisbuteResCount(Pager pager, string columns, string groupId, decimal? userId, DateTime sTime, DateTime eTime, decimal? HidResourceId, decimal? HidACTIVITYID)
{
var list = dISTRIBUTE_Q.GetDistbuteResCount(ref pager, userId, groupId, sTime, eTime, HidResourceId, HidACTIVITYID);
Table table = new Table(columns, true);
table.gridPager = pager;
foreach (var model in list)
{
table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(model.salesid));
table.AddCol(model.typename);
table.AddCol(model.activityname);
table.AddCol(model.c);
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public FileResult DisbuteResCountExport(string groupId, decimal? userId, DateTime sTime, DateTime eTime, decimal? HidResourceId, decimal? HidACTIVITYID)
{
var pager = new Pager
{
page = 1,
rows = int.MaxValue
};
string contentType = "application/ms-excel";
string downloadName = PageRequest.GetDlownLoadName("资源分配统计导出" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
var list = dISTRIBUTE_Q.GetDistbuteResCount(ref pager, userId, groupId, sTime, eTime, HidResourceId, HidACTIVITYID);
var data = from q in list
select new { 员工 = InnerUserHelper.Instance.GetEidAndTrueName(q.salesid), 资源类型 = q.typename, 活动名称 = q.activityname, 数量 = q.c };
System.IO.Stream strem = ExcelHelper.ExportListModelToExcel(data.ToList(), "资源分配统计导出", 50000, null);
return File(strem, contentType, downloadName);
}
#endregion 手工分配回收
#endregion 资源分配
#region 资源回收
[HttpGet]
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public ActionResult ResRecycle()
{
List lis = new List();
var rlis = resourceTypeBiz_Q.GetList();
lis.Add(new SelectListItem() { Value = "0", Text = "-请选择-" });
foreach (var obj in rlis)
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
ViewData["ResourctType1"] = lis;
ViewData["ResourctType2"] = lis;
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_资源统计及输出)]
public JsonResult ResRecycle(string groupId, decimal? userId, DateTime? sTime, DateTime? eTime, decimal? HidResourceId, decimal? HidACTIVITYID, decimal? hasNum, decimal? hasOrder, decimal? hasRecord, decimal? hasMemo, decimal? tranResTypeId, decimal? tranResActivityId, string tranResTag, decimal? num)
{
try
{
dISTRIBUTE_Q.ExecDistbuteRecycle(userId, groupId, sTime, eTime, HidResourceId, HidACTIVITYID, hasNum, hasOrder, hasRecord, hasMemo, tranResTypeId, tranResActivityId, tranResTag, companyId, num);
return Json(new { ret = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error("回收资源出错:" + ex.ToString());
return Json(new { ret = false }, JsonRequestBehavior.AllowGet);
}
}
public JsonResult ResRecycleCount(string groupId, decimal? userId, DateTime? sTime, DateTime? eTime, decimal? HidResourceId, decimal? HidACTIVITYID, decimal? hasNum, decimal? hasOrder, decimal? hasRecord, decimal? hasMemo)
{
try
{
Pager pager = new Pager() { page = 1, rows = int.MaxValue };
var list = dISTRIBUTE_Q.GetDistbuteResCount(ref pager, userId, groupId, sTime, eTime, HidResourceId, HidACTIVITYID, hasNum, hasOrder, hasRecord, hasMemo);
return Json(new { ret = true, count = list.Sum(p => p.c) / 2 }, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
return Json(new { ret = false, count = 0 }, JsonRequestBehavior.AllowGet);
}
}
#endregion 资源回收
#region 首页
[AuthorizeRedirect(Roles = InitRights.CONST_资源活动管理)]
public ActionResult Index()
{
//ToolBar
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.资源活动管理, userRightId);
tool.AllowButton(toolbtn);
//tool.AllowButton("Create", "Edit", "Details", "Delete");
ViewBag.ToolBar = tool;
//table
Pager pager = new Pager() { page = 1, rows = 20, sort = "desc" };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHeadCol("ACTIVITYID", "8%", "活动ID");
tab.AddHeadCol("ACTIVITYNAME", "15%", "活动名称", true);
tab.AddHeadCol("ACTIVITYCODE", "8%", "活动编码", true);
tab.AddHeadCol("RESOURCETAG", "15%", "活动标签", true);
tab.AddHeadCol("ACTIVITYADDR", "14%", "活动地址");
tab.AddHeadCol("RESTYPEID", "15%", "资源类型", true);
tab.AddHeadCol("CTIME", "10%", "创建时间", true);
tab.AddHeadCol("MEMO", "", "备注");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20");
return View();
}
#endregion 首页
#region 列表
[HttpPost]
///
/// 按照条件获取数据
///
///
///
///
[AuthorizeRedirect(Roles = InitRights.CONST_资源活动管理)]
public JsonResult GetHtmlList(Pager pager, string columns)
{
string activityName = Request.Form["activityName"];
string activityCode = Request.Form["activityCode"];
string resourceTag = Request.Form["resourceTag"];
string resTypeName = Request.Form["resTypeName"];
string stime = Request.Form["stime"];
string etime = Request.Form["etime"];
List list = activityBiz_Q.GetList(ref pager, activityName, activityCode, resourceTag, resTypeName, stime, etime);
Table tab = new Table(columns, true);
tab.gridPager = pager;
foreach (WX.CRM.Model.Entity.RES_ACTIVITY_EXTEND model in list)
{
tab.AddCol(model.res_ACTIVITY.ACTIVITYID);
tab.AddCol(model.res_ACTIVITY.ACTIVITYNAME);
tab.AddCol(model.res_ACTIVITY.ACTIVITYCODE);
tab.AddCol(model.res_ACTIVITY.RESOURCETAG);
tab.AddCol(model.res_ACTIVITY.ACTIVITYADDR);
tab.AddCol(model.TYPEName);
tab.AddCol(model.res_ACTIVITY.CTIME);
tab.AddCol(model.res_ACTIVITY.MEMO);
tab.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = tab.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 列表
#region 详细
[AuthorizeToolBar(InitRights.CONST_资源活动管理, InitToolBar.CONST_Details)]
public ActionResult Details(string id)
{
WX.CRM.Model.Entity.RES_ACTIVITY model = null;
if (id != null)
model = activityBiz_Q.GetModel(Convert.ToDecimal(id));
else
model = new WX.CRM.Model.Entity.RES_ACTIVITY();
return View(model);
}
#endregion 详细
#region 编辑
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_资源活动管理, InitToolBar.CONST_Edit)]
public ActionResult Edit(string id)
{
WX.CRM.Model.Entity.RES_ACTIVITY model = null;
if (id == null)
{
model = new WX.CRM.Model.Entity.RES_ACTIVITY();
// 数据初始化
}
else
model = activityBiz_Q.GetModel(Convert.ToDecimal(id));
List type = resourceTypeBiz_Q.GetList();
ViewBag.typeList = type;
return View(model);
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_资源活动管理, InitToolBar.CONST_Edit)]
public JsonResult Edit(WX.CRM.Model.Entity.RES_ACTIVITY model)
{
//标签去空格
model.RESOURCETAG = model.RESOURCETAG.Trim();
if (!ModelState.IsValid)
{
return JsonHandler.ValidateFailMessage();
}
if (model.ACTIVITYID == 0)
{
model.CREATEUSER = UserId;
bool result = activityBiz.Create(ref errors, model);
return JsonHandler.InsertMessage(errors, result);
}
else
{
model.UPDATEUSER = UserId;
bool result = activityBiz.Update(ref errors, model);
return JsonHandler.UpdateMessage(errors, result);
}
}
#endregion 编辑
#region 删除
///
/// 删除数据
///
///
///
[AuthorizeToolBar(InitRights.CONST_资源活动管理, InitToolBar.CONST_Delete)]
public JsonResult Delete(string id)
{
if (string.IsNullOrWhiteSpace(id))
{
return JsonHandler.ManageMessage("删除失败", false);
}
bool result = activityBiz.Delete(ref errors, Convert.ToDecimal(id));
return JsonHandler.DeleteMessage(errors, result);
}
#endregion 删除
#region 客户资料业的活动信息
#region 活动信息
public ActionResult ActivityList(string ResId)
{
ViewBag.resid = ResId;
return View();
}
public JsonResult ActivityListHtml(string ResId)
{
Table tab = new Table("", true);
if (!string.IsNullOrEmpty(ResId))
{
var list = activityBiz_Q.GetMonthActivityByresid(ResId);
var deptList = cache_BL.GetDeptNameMapList();
foreach (var model in list)
{
tab.AddCol(model.ResId);
tab.AddCol(PhoneHelper.FormatPhoneUserName(model.UserName));
if (model.deptid.HasValue && model.deptid > 0)
{
var dept = deptList.FirstOrDefault(n => n.id == model.deptid);
if (dept == null)
{
tab.AddCol("");
}
else
{
tab.AddCol(dept.title);
}
}
else
{
tab.AddCol("");
}
tab.AddCol(model.ActivityName);
tab.AddCol(model.TypeName);
tab.AddCol(model.DataType);
tab.AddCol(model.ExtXml);
tab.AddCol(model.ApplyTime);
tab.AddRow();
}
}
var json = new
{
rowsList = tab.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 活动信息
#region 更多活动信息
public ActionResult ActivityListmore(string ResId)
{
//table
Pager pager = new Pager() { page = 1, rows = 10 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHeadCol("resid", "10%", "客户ID");
tab.AddHeadCol("username", "10%", "用户名");
tab.AddHeadCol("deptname", "10%", "事业部");
tab.AddHeadCol("activityname", "10%", "活动名称");
tab.AddHeadCol("typename", "10%", "资源类型");
tab.AddHeadCol("datatype", "10%", "数据类型");
tab.AddHeadCol("extxml", "", "活动备注");
tab.AddHeadCol("applytime", "10%", "申请时间");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "5,8,10,15");
ViewBag.resid = ResId;
return View();
}
public JsonResult ActivityListmoreHtml(Pager pager, string columns)
{
string stime = Request.Form["stime"];
string etime = Request.Form["etime"];
string ResId = Request.QueryString["ResId"];
Table tab = new Table("", true);
var deptList = cache_BL.GetDeptNameMapList();
if (!string.IsNullOrEmpty(ResId))
{
var list = activityBiz_Q.GetActivityInfoMoreList(ref pager, ResId, stime, etime);
foreach (var model in list)
{
tab.AddCol(model.ResId);
tab.AddCol(PhoneHelper.FormatPhoneUserName(model.UserName));
if (model.deptid.HasValue && model.deptid > 0)
{
var dept = deptList.FirstOrDefault(n => n.id == model.deptid);
if (dept == null)
{
tab.AddCol("");
}
else
{
tab.AddCol(dept.title);
}
}
else
{
tab.AddCol("");
}
tab.AddCol(model.ActivityName);
tab.AddCol(model.TypeName);
tab.AddCol(model.DataType);
tab.AddCol(model.ExtXml);
tab.AddCol(model.ApplyTime);
tab.AddRow();
}
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = tab.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 更多活动信息
#endregion 客户资料业的活动信息
#region 我的新单活动资源池
[AuthorizeRedirect(Roles = InitRights.CONST_我的新单活动资源池)]
public ActionResult MyActivityRes()
{
var resourceType = Request["resourcetype"];
//table
Pager pager = new Pager() { page = 1, rows = 10 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHeadCol("DeptName", "", "事业部");
tab.AddHeadCol("ResourceTypeName", "", "资源类型");
tab.AddHeadCol("ActivityName", "", "活动名称");
tab.AddHeadCol("ActivityRemark", "", "活动备注");
tab.AddHeadCol("CTime", "", "时间");
tab.AddHeadCol("ResId", "", "客户ID");
tab.AddHeadCol("CName", "", "客户姓名");
tab.AddHeadCol("ISBOUND", "", "加好友");
tab.AddHeadCol("FollowInfo", "", "跟进情况");
tab.AddHeadCol("FollowTime", "", "跟进时间");
tab.AddHeadCol("Group", "", "销售组");
tab.AddHeadCol("User", "", "归属客服");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20,50");
List lis = new List();
var rlis = resourceTypeBiz_Q.GetList();
lis.Add(new SelectListItem() { Value = "", Text = "-请选择-" });
foreach (var obj in rlis)
{
if (!string.IsNullOrEmpty(resourceType))
{
decimal resourceTypeId = 0;
decimal.TryParse(resourceType, out resourceTypeId);
if (resourceTypeId == obj.RESTYPEID)
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME, Selected = true });
}
else
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
}
else
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
}
ViewData["ResourctType1"] = lis;
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
var category = cache_BL.GetList_SubComType(ComType.CustomerCategory).Select(item => new SelectListItem() { Text = item.SUBTYPENAME, Value = item.SUBTYPENAME }).ToList();
category.Insert(0, new SelectListItem() { Text = string.Empty, Value = string.Empty });
ViewBag.category = category;
var deptList = cache_BL.GetList_BusinessLines().ToList();
ViewBag.deptList = deptList;
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_我的新单活动资源池)]
public JsonResult GetMyActiviryResList(Pager pager, string columns, QueryUserComboDto usercomboDto, string resid, decimal? HidResourceId, string HidRESOURCETAG, string activityName, string activityRemark, DateTime? cTime1, DateTime? cTime2, decimal? eid, int? deptlineId)
{
if (!string.IsNullOrWhiteSpace(resid))
resid = resid.Trim();
if (eid.HasValue)
{
eid = InnerUserHelper.Instance.GetUserIdByEid(eid.Value);
}
var list = activityBiz_Q.GetMyActiviryResList(ref pager, usercomboDto, resid, HidResourceId, HidRESOURCETAG, activityName, activityRemark, cTime1, cTime2, eid, deptlineId);
Table table = new Table(columns, true);
table.gridPager = pager;
foreach (var model in list)
{
table.AddCol(model.DeptName);
table.AddCol(model.ResourceTypeName);
table.AddCol(model.ActivityName);
table.AddCol(model.ActivityRemark);
table.AddCol(model.CTime);
var a = string.Format("{2}", "客户详细", "/Csvr/CustomerInfo/CustomerDetail?resid=" + model.ResId, model.ResId);
table.AddCol(a);
table.AddCol(model.CName);
table.AddCol(model.IsBound);
table.AddCol(model.FollowInfo);
table.AddCol(model.FollowTime);
table.AddCol(InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(model.InnerUserId)));
table.AddCol(InnerUserHelper.Instance.EidAndName(model.InnerUserId));
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion 我的新单活动资源池
#region
public ActionResult LookNotice(decimal type, DateTime? sdate)
{
resRecycle_BL.UpadteNoticeLookStatus(UserId, type);
if (type == 1)
return Redirect("/Res/Activity/ActivityStOrEx?sdate=" + (sdate.HasValue ? string.Format("{0:yyyy-MM-dd}", sdate) : ""));
return View();
}
#endregion
private decimal? IsSanBu()
{
var roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
if (!(roleCodes.Contains("[GLY]") || roleCodes.Contains("[ZJZL]") || roleCodes.Contains("[ZJ]") || roleCodes.Contains("[CKZY]")))
{
if (roleCodes.Contains("[BMZG]"))
return saleDeptId;
else
return 0;
}
return null;
}
private int HasRole()
{
var roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
if (roleCodes.Contains("[GLY]") || roleCodes.Contains("[ZJZL]") || roleCodes.Contains("[ZJ]") || roleCodes.Contains("[CKZY]"))
{
return 1;
}
return 0;
}
#region 新单资源列表
[AuthorizeRedirect(Roles = InitRights.CONST_新单活动资源池)]
public ActionResult ResActivityIndex()
{
//ToolBar
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.新单活动资源池, userRightId);
tool.AllowButton(toolbtn);
tool.AddOtherButton("Other1", "资源分配", "icon-detail", "AllocateRes_Click", true);
ViewBag.ToolBar = tool;
List lis = new List();
var rlis = resourceTypeBiz_Q.GetList();
lis.Add(new SelectListItem() { Value = "0", Text = "-请选择-" });
foreach (var obj in rlis)
{
lis.Add(new SelectListItem() { Value = string.Format("{0}", obj.RESTYPEID), Text = obj.TYPENAME });
}
ViewBag.ResourceType = lis;
var deptList = cache_BL.GetList_BusinessLines().ToList();
ViewBag.deptList = deptList;
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_新单活动资源池)]
public JsonResult GetResActivityHtmlList(Laypage pager, ActiveQueryModel dto)
{
var layUidata = new LayuiData();
try
{
List list = activityBiz_Q.GetResModels(pager, dto);
foreach (var item in list)
{
item.gname = InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(item.InnerUserId));
item.eidInfo = InnerUserHelper.Instance.EidAndName(item.InnerUserId);
}
layUidata.msg = "数据加载成功";
layUidata.code = 0;
layUidata.data = list;
layUidata.count = pager.count;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
layUidata.SetFail(1, "出现错误!" + ex.Message);
}
return Json(layUidata);
}
#endregion
}
}