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 MonthlyGroupPerformanceQueryController : BaseController { // // GET: /MonthlyGroupPerformanceQuery/ ValidationErrors errors = new ValidationErrors(); IQH_PerformanceQuery_Q perfermanceQuery_Q; IQH_MONTHLYSTATEMENT_Q monthlyStatement_Q; public MonthlyGroupPerformanceQueryController(IQH_PerformanceQuery_Q iQH_PerformanceQuery_Q, IQH_MONTHLYSTATEMENT_Q iQH_MONTHLYSTATEMENT_Q) { this.perfermanceQuery_Q = iQH_PerformanceQuery_Q; this.monthlyStatement_Q = iQH_MONTHLYSTATEMENT_Q; } [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", "Export_Click", true); ViewBag.ToolBar = tb; Pager pager = new Pager() { page = 1, rows = 10 }; Table tab = new Table("tablist"); tab.AddHeadCol("GNAME", "", "组别", true); tab.AddHeadCol("DIXING", "", "底薪", true); tab.AddHeadCol("PERFORMANCEAMOUNT", "", "业绩额", true); tab.AddHeadCol("COMMISSIONRATIO", "", "业绩额提成比例", true); tab.AddHeadCol("ORDERCOUNT", "", "单量", true); tab.AddHeadCol("ORDERCOUNTRATIO", "", "单量提成比例", true); tab.AddHeadCol("ALLRATIO", "", "总提成比例", true); tab.AddHeadCol("YULIU", "", "预留金额", true); tab.AddHeadCol("YINGSHOU", "", "应收金额", true); tab.AddHeadCol("TUIKUAN", "", "退款", true); tab.AddHeadCol("SHISHOU", "", "实收金额", true); tab.AddHeadCol("MONTH", "", "结算月份", true); tab.AddHeadRow(); ViewBag.GroupList = tab.GetTable() + Pagination.GetPage(pager, "tablist", "5,8,10,15"); ViewBag.inneruserid = UserId; ViewBag.userGroupId = userGroupId; ViewBag.saleDeptId = saleDeptId; ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId); List monthList = monthlyStatement_Q.GetAllOpYeanAndMonth(); List list = new List(); foreach (decimal result in monthList) { string time = result.ToString().Substring(0, 4) + "-" + result.ToString().Substring(4, 2) + "-01"; list.Add(new SelectListItem { Text = time, Value = time }); } ViewBag.month = list; return View(); } #region 查询 [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_组别业绩报表_月结)] public JsonResult GetHtmlList(Pager pager, string columns) { string groupId = Request.Form["groupId"]; DateTime month = Convert.ToDateTime(Request.Form["opMonth"].ToString() == "null" ? "0001-01-01" : Request.Form["opMonth"]); DateTime monthStart = Convert.ToDateTime(Request.Form["opMonthStart"].ToString() == "null" ? "0001-01-01" : Request.Form["opMonthStart"]); decimal isCollect = Request.Form["HidValue"].GetDecimal(0); try { List list = null; if (isCollect > 0) list = perfermanceQuery_Q.QH_MonthlyGroupPerformanceCollectQuery(ref pager, monthStart, month); else list = perfermanceQuery_Q.QH_MonthlyGroupPerformanceQuery(ref pager, groupId, month); Table tb = new Table(columns, true); tb.gridPager = pager; foreach (QH_BALANCESALEGROUPER model in list) { string groupname = InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(model.INNERUSERID)); tb.AddCol(groupname); tb.AddCol(model.DIXING); tb.AddCol(model.PERFORMANCEAMOUNT); tb.AddCol(model.COMMISSIONRATIO); tb.AddCol(model.ORDERCOUNT); tb.AddCol(model.ORDERCOUNTRATIO); tb.AddCol(model.ORDERCOUNTRATIO); tb.AddCol(model.ALLRATIO); tb.AddCol(model.YULIU); tb.AddCol(model.YINGSHOU); tb.AddCol(model.TUIKUAN); tb.AddCol(model.SHISHOU); tb.AddCol(model.MONTH); tb.AddRow(); } var json = new { totalPages = pager.totalPages, totalRows = pager.totalRows, rowsList = tb.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("QH_MonthlyGroupPerformanceQueryController:" + ex.Message + ex.StackTrace); return JsonHandler.ManageMessage(ex.Message, false); } } #endregion #region 导出 public FileResult Export() { string groupId = Request.QueryString["groupId"]; DateTime month = Convert.ToDateTime(Request.QueryString["opMonth"].ToString() == "null" ? "0001-01-01" : Request.QueryString["opMonth"]); DateTime monthStart = Convert.ToDateTime(Request.QueryString["opMonthStart"].ToString() == "null" ? "0001-01-01" : Request.QueryString["opMonthStart"]); decimal isCollect = Request.QueryString["HidValue"].GetDecimal(0); List list = null; Pager pager = new Pager() { rows = int.MaxValue }; string checkedFilds = PageRequest.GetQueryString("checkedFilds"); string checkedTitle = PageRequest.GetQueryString("checkedTitles"); if (isCollect > 0) list = perfermanceQuery_Q.QH_MonthlyGroupPerformanceCollectQuery(ref pager, monthStart, month); else list = perfermanceQuery_Q.QH_MonthlyGroupPerformanceQuery(ref pager, groupId, month); list.ForEach(p => { if (p.GNAME != "合计") { p.GNAME = InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(p.INNERUSERID)); } }); return File(ExcelHelper.ExportListModelToExcel(list, "期货组别业绩汇总查询(月结)", 60000, checkedFilds, checkedTitle, null), "application/ms-excel", PageRequest.GetDlownLoadName("期货组别业绩汇总查询(月结).xls")); } #endregion } }