using System; using System.Linq; using System.Web.Mvc; using WX.CRM.Common; using WX.CRM.IBLL.Wx; using WX.CRM.WebHelper; namespace WX.CRM.WEB.Controllers.WeiXin { public class MessageCount2Controller : BaseController { private IWX_MESSAGE _message; public MessageCount2Controller(IWX_MESSAGE message) { _message = message; } [HttpGet] [AuthorizeRedirect(Roles = InitRights.CONST_微信聊天信息统计)] public ActionResult Index() { ToolBar tb = new ToolBar(); ViewBag.ToolBar = tb; Pager pager = new Pager() { page = 1, rows = int.MaxValue }; Table tab = new Table("tablist"); tab.AddHeadCol("Groupname", "", "组别"); tab.AddHeadCol("SALESEID", "", "工号"); tab.AddHeadCol("UNAME", "", "姓名"); tab.AddHeadCol("username", "", "微信用户名"); tab.AddHeadCol("alias", "", "微信号"); var x = 6; tab.AddHeadCol("qfc", "", "群发次数", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); x++; tab.AddHeadCol("qf", "", "群发数量", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); x++; tab.AddHeadCol("fs", "", "发送量", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); x++; tab.AddHeadCol("js", "", "接收量", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); x++; tab.AddHeadCol("kfs", "", "沟通客户数", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); x++; tab.AddHeadCol("yxkfs", "", "有效沟通客户数", "sortTable('tablist'," + x + ",'float');", "cursor:pointer"); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead(); 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 Index(string columns, string groupId, string userId, DateTime sTime, DateTime eTime) { Table table = new Table(columns, true); var list = _message.GetMessageCount2(groupId, userId, sTime, eTime); foreach (var item in list) { table.AddCol(item.GName); table.AddCol(item.Eid); table.AddCol(item.UName); table.AddCol(item.username); table.AddCol(item.alias); table.AddCol(item.qfc); table.AddCol(item.qf); table.AddCol(item.fs); table.AddCol(item.js); table.AddCol(item.kfs); table.AddCol(item.yxkfs); table.AddRow(); } if (list.Count > 0) { table.AddCol("合计:"); table.AddCol(""); table.AddCol(""); table.AddCol(""); table.AddCol(""); table.AddCol(list.Sum(p => p.qfc)); table.AddCol(list.Sum(p => p.qf)); table.AddCol(list.Sum(p => p.fs)); table.AddCol(list.Sum(p => p.js)); table.AddCol(list.Sum(p => p.kfs)); table.AddCol(list.Sum(p => p.yxkfs)); table.AddFootRow(); } var json = new { rowsList = table.GetRows(), foot = table.GetFoot() }; return Json(json, JsonRequestBehavior.AllowGet); } } }