using System; using System.Collections.Generic; using System.Web.Mvc; using WX.CRM.Common; using WX.CRM.IBLL.QH; using WX.CRM.Model.Entity; using WX.CRM.WebHelper; namespace WX.CRM.WEB.Controllers.QH { public class MonthlyUserPerformanceQueryController : BaseController { ValidationErrors errors = new ValidationErrors(); IQH_PerformanceQuery_Q perfermanceQuery_Q; public MonthlyUserPerformanceQueryController(IQH_PerformanceQuery_Q _perfermanceQuery_Q) { this.perfermanceQuery_Q = _perfermanceQuery_Q; } #region 首页 [AuthorizeRedirect(Roles = InitRights.CONST_期货员工业绩汇总查询_月结)] public ActionResult Index() { ToolBar tb = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.期货员工业绩汇总查询_月结, userRightId); tb.AllowButton(toolbtn); tb.AddOtherButton("Other1", "导出", "icon-export", "ExportAllPage_Click1", true); ViewBag.ToolBar = tb; Pager gp = new Pager() { page = 1, rows = 10 }; Table tab = new Table("tablist"); tab.AddHeadCol("GNAME", "", "组别", true); tab.AddHeadCol("ISDISMISS", "", "在(离)职"); tab.AddHeadCol("EID", "", "工号"); tab.AddHeadCol("UNAME", "", "姓名"); tab.AddHeadCol("DIXING", "", "底薪"); tab.AddHeadCol("PERFORMANCEAMOUNT", "", "业绩额"); tab.AddHeadCol("COMMISSIONRATIO", "", "业绩额提成比例(%)", true); tab.AddHeadCol("ORDERCOUNT", "", "单量", true); tab.AddHeadCol("ORDERCOUNTRATIO", "", "单量提成比例(%)", true); tab.AddHeadCol("ALLRATIO", "", "总提成比例(%)", true); tab.AddHeadCol("YINGSHOU", "", "应收金额", true); tab.AddHeadCol("YULIU", "", "预留金额", true); tab.AddHeadCol("FANHUAN", "", "当月返还额", true); tab.AddHeadCol("TUIKUAN", "", "退款", true); tab.AddHeadCol("SHISHOU", "", "实收", true); tab.AddHeadCol("TOUSU", "", "投诉次数", true); tab.AddHeadCol("CHUFA", "", "处罚次数", true); tab.AddHeadCol("CHUQIN", "", "出勤率", true); tab.AddHeadCol("ALLPERFORMANCEAMOUNT", "", "本月提成金额", true); tab.AddHeadCol("WORKDAY", "", "实际工作天数", true); tab.AddHeadCol("DEDUCTIONS", "", "扣款", true); tab.AddHeadCol("REWARD", "", "全勤", true); tab.AddHeadRow(); ViewBag.GroupList = tab.GetTable() + Pagination.GetPage(gp, "tablist", "5,8,10,15"); ViewBag.inneruserid = UserId; ViewBag.userGroupId = userGroupId; ViewBag.saleDeptId = saleDeptId; ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId); //List monList = new List(); //List list = monthlyStatement_Q.GetAllOpYeanAndMonth(); //foreach(var result in list) //{ // monList.Add(new SelectListItem() { Text = result.ToString(), Value = result.ToString() }); //} //ViewBag.monList = monList; return View(); } #endregion #region 查询 [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_期货员工业绩汇总查询_月结)] public JsonResult GetHtmlList(Pager pg, string columns) { decimal saleEid = Request.Form["SaleEid"].GetDecimal(0); string groupId = Request.Form["groupId"]; decimal inneruserid = Request.Form["userId"].GetDecimal(0); decimal isdismiss = Request.Form["isDismiss"].GetDecimal(0); string checkResult = Request.Form["SumIsZero"]; string month = Request.Form["opMonth"]; try { List list = perfermanceQuery_Q.QH_MonthlyUserPerformanceQuery(ref pg, saleEid, isdismiss, groupId, inneruserid, "", month); Table tb = new Table(columns, true); tb.gridPager = pg; foreach (QH_BALANCESALEUSER model in list) { if (!string.IsNullOrEmpty(model.GNAME)) tb.AddCol(model.GNAME != "合计" ? InnerUserHelper.Instance.GetGroupName(model.GID) : model.GNAME); else tb.AddCol(""); //tb.AddCol(model.GROUPNAME); if (model.ISDISMISS.HasValue) tb.AddCol(model.ISDISMISS.Value == 0 ? "在职" : "离职"); else tb.AddCol(model.ISDISMISS); tb.AddCol(model.EID); tb.AddCol(model.UNAME); tb.AddCol(model.DIXING); tb.AddCol(model.PERFORMANCEAMOUNT); tb.AddCol(model.COMMISSIONRATIO); tb.AddCol(model.ORDERCOUNT); tb.AddCol(model.ORDERCOUNTRATIO); tb.AddCol(model.ALLRATIO); tb.AddCol(model.YINGSHOU); tb.AddCol(model.YULIU); tb.AddCol(model.FANHUAN); tb.AddCol(model.TUIKUAN); tb.AddCol(model.SHISHOU); tb.AddCol(model.TOUSU); tb.AddCol(model.CHUFA); tb.AddCol(model.CHUQIN); tb.AddCol(model.ALLPERFORMANCEAMOUNT); tb.AddCol(model.WORKDAY); tb.AddCol(model.DEDUCTIONS); tb.AddCol(model.REWARD); tb.AddRow(); } var json = new { totalPages = pg.totalPages, totalRows = pg.totalRows, rowsList = tb.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("QH_MonthlyUserPerformanceQueryController:" + ex.Message + ex.StackTrace); return JsonHandler.ManageMessage(ex.Message, false); } } #endregion #region 导出 public FileResult Export() { decimal saleEid = Request["SaleEid"].GetDecimal(0); string groupId = Request["groupId"]; decimal inneruserid = Request["userId"].GetDecimal(0); decimal isdismiss = Request["isDismiss"].GetDecimal(0); string checkResult = Request["SumIsZero"]; string month = Request["opMonth"]; List list = new List(); Pager pager = new Pager() { page = 1, rows = int.MaxValue }; string checkedFilds = PageRequest.GetQueryString("checkedFilds"); string checkedTitle = PageRequest.GetQueryString("checkedTitles"); list = perfermanceQuery_Q.QH_MonthlyUserPerformanceQuery(ref pager, saleEid, isdismiss, groupId, inneruserid, "", month); foreach (var item in list) { if (!string.IsNullOrEmpty(item.GNAME)) item.GNAME = item.GNAME != "合计" ? InnerUserHelper.Instance.GetGroupName(item.GID) : item.GNAME; else item.GNAME = ""; } return File(ExcelHelper.ExportListModelToExcel(list, "员工业绩汇总查询(月结)", 60000, checkedFilds, checkedTitle, null), "application/ms-excel", PageRequest.GetDlownLoadName("员工业绩汇总查询(月结).xls")); } #endregion } }