ComplianceServer/oldcode/WEB/Controllers/QH/QHCommissionRuleController.cs

202 lines
9.2 KiB
C#

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 QHCommissionRuleController : BaseController
{
#region
private readonly IQH_COMMISSIONAPPLY_Q _commissionApplyBiz;
ValidationErrors errors = new ValidationErrors();
public QHCommissionRuleController(IQH_COMMISSIONAPPLY_Q commissionApplyBiz)
{
this._commissionApplyBiz = commissionApplyBiz;
}
[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-export", "ExportAllPage_Click", true);
tool.AddOtherButton("Other2", "历史导出", "icon-export", "ExportAllPage_His_Click", true);
ViewBag.ToolBar = tool;
Pager pager = new Pager() { order = "pkid", page = 1, rows = 10 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHeadCol("USERACCOUNT", "", "交易商代吗");
tab.AddHeadCol("mainSalesEid", "", "主经纪人");
tab.AddHeadCol("THEDATE", "", "日期");
tab.AddHeadCol("customerRate", "", "客户佣金比例");
tab.AddHeadCol("userEid", "", "分成工号");
tab.AddHeadCol("COMMISSTIONRATIO", "", "分成比例");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "5,8,10,15");
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
return View();
}
#region
[AuthorizeRedirect(Roles = InitRights.CONST_期货佣金规则明细查询)]
public JsonResult GetHtmlCommissionRuleList(Pager pager, string columns)
{
try
{
string txtTradeCode = Request["txtTradeCode"];
string txtEid = Request["txtEid"];
string txtAssignEid = Request["txtAssignEid"];
string sdCTime = Request["sdCTime"];
string edCTime = Request["edCTime"];
string groupId = Request["groupId"];
decimal userId = Request["userId"].GetDecimal(0);
decimal isHis = Request["isHis"].GetDecimal(0);
int? _userEid = null;
int? _txtAssignEid = null;
DateTime? ctime1 = null;
DateTime? ctime2 = null;
if (!string.IsNullOrEmpty(txtEid))
_userEid = int.Parse(txtEid);
if (!string.IsNullOrEmpty(txtAssignEid))
_txtAssignEid = int.Parse(txtAssignEid);
if (!string.IsNullOrEmpty(sdCTime))
ctime1 = DateTime.Parse(sdCTime);
if (!string.IsNullOrEmpty(edCTime))
ctime2 = DateTime.Parse(edCTime);
List<QH_COMMISSIONRULE_APPLY_VIEW> lis = new List<QH_COMMISSIONRULE_APPLY_VIEW>();
if (isHis > 0)
lis = _commissionApplyBiz.GetCommissionRuleHisList(ref pager, txtTradeCode, _userEid, _txtAssignEid, ctime1, ctime2, userId, groupId);
else
lis = _commissionApplyBiz.GetCommissionRuleList(ref pager, txtTradeCode, _userEid, _txtAssignEid, ctime1, ctime2, userId, groupId);
Table table = new Table(columns, true);
table.gridPager = pager;
foreach (var model in lis)
{
table.AddCol(model.USERACCOUNT);
table.AddCol(InnerUserHelper.Instance.EidAndName(InnerUserHelper.Instance.GetUserIdByEid(model.mainSalesEid)));
table.AddCol(model.THEDATE.ToUnityString(1));
table.AddCol(model.customerRate);
table.AddCol(InnerUserHelper.Instance.EidAndName(InnerUserHelper.Instance.GetUserIdByEid(model.userEid)));
table.AddCol(model.COMMISSTIONRATIO.ToString() + "%");
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error("Gjs_CommissionRuleController:" + ex.Message + ex.StackTrace);
return JsonHandler.ManageMessage(ex.Message, false);
}
}
#endregion
#region
[AuthorizeToolBar(InitRights.CONST_期货佣金规则明细查询, InitToolBar.CONST_Other1)]
public FileResult Export()
{
string txtTradeCode = Request.Params["txtTradeCode"];
string txtEid = Request.Params["txtEid"];
string txtAssignEid = Request.Params["txtAssignEid"];
string sdCTime = Request.Params["sdCTime"];
string edCTime = Request.Params["edCTime"];
string groupId = Request.Params["groupId"];
decimal userId = Request.Params["userId"].GetDecimal(0);
int? _userEid = null;
int? _txtAssignEid = null;
DateTime? ctime1 = null;
DateTime? ctime2 = null;
if (!string.IsNullOrEmpty(txtEid))
_userEid = int.Parse(txtEid);
if (!string.IsNullOrEmpty(txtAssignEid))
_txtAssignEid = int.Parse(txtAssignEid);
if (!string.IsNullOrEmpty(sdCTime))
ctime1 = DateTime.Parse(sdCTime);
if (!string.IsNullOrEmpty(edCTime))
ctime2 = DateTime.Parse(edCTime);
Pager pager = new Pager() { rows = int.MaxValue, page = 1 };
string checkedFilds = PageRequest.GetQueryString("checkedFilds");
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
var list = _commissionApplyBiz.GetCommissionRuleList(ref pager, txtTradeCode, _userEid, _txtAssignEid, ctime1, ctime2, userId, groupId);
return File(ExcelHelper.ExportListModelToExcel<QH_COMMISSIONRULE_APPLY_VIEW>(list, "佣金规则明细", 60000, checkedFilds, checkedTitles, DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("佣金规则明细.xls"));
}
[AuthorizeToolBar(InitRights.CONST_期货佣金规则明细查询, InitToolBar.CONST_Other2)]
public FileResult ExportHis()
{
string txtTradeCode = Request.Params["txtTradeCode"];
string txtEid = Request.Params["txtEid"];
string txtAssignEid = Request.Params["txtAssignEid"];
string sdCTime = Request.Params["sdCTime"];
string edCTime = Request.Params["edCTime"];
string groupId = Request.Params["groupId"];
decimal userId = Request.Params["userId"].GetDecimal(0);
int? _userEid = null;
int? _txtAssignEid = null;
DateTime? ctime1 = null;
DateTime? ctime2 = null;
if (!string.IsNullOrEmpty(txtEid))
_userEid = int.Parse(txtEid);
if (!string.IsNullOrEmpty(txtAssignEid))
_txtAssignEid = int.Parse(txtAssignEid);
if (!string.IsNullOrEmpty(sdCTime))
ctime1 = DateTime.Parse(sdCTime);
if (!string.IsNullOrEmpty(edCTime))
ctime2 = DateTime.Parse(edCTime);
Pager pager = new Pager() { rows = int.MaxValue, page = 1 };
string checkedFilds = PageRequest.GetQueryString("checkedFilds");
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
var list = _commissionApplyBiz.GetCommissionRuleHisList(ref pager, txtTradeCode, _userEid, _txtAssignEid, ctime1, ctime2, userId, groupId);
return File(ExcelHelper.ExportListModelToExcel<QH_COMMISSIONRULE_APPLY_VIEW>(list, "佣金规则明细_历史", 60000, checkedFilds, checkedTitles, DataFormart), "application/ms-excel", PageRequest.GetDlownLoadName("佣金规则明细_历史.xls"));
}
public string DataFormart(string key, object value)
{
string formartValue = string.Empty;
switch (key)
{
case "mainSalesEid":
formartValue = InnerUserHelper.Instance.EidAndName(InnerUserHelper.Instance.GetUserIdByEid(Convert.ToDecimal(value)));
break;
case "userEid":
formartValue = InnerUserHelper.Instance.EidAndName(InnerUserHelper.Instance.GetUserIdByEid(Convert.ToDecimal(value)));
break;
default: formartValue = string.Format("{0}", value); break;
}
return formartValue;
}
#endregion
#endregion
}
}