316 lines
11 KiB
C#
316 lines
11 KiB
C#
using Ninject;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.Common.Layui;
|
|
using WX.CRM.IBLL.Res;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.Model.MAP;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Res
|
|
{
|
|
public class SalesRuleController : BaseController
|
|
{
|
|
[Inject]
|
|
public ICACHE_Q _cache { get; set; }
|
|
[Inject]
|
|
public IRES_SALES_RULE _salesRule { get; set; }
|
|
[Inject]
|
|
public IRES_SALESGROUP_Q _salesGroup { get; set; }
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_客服分配规则列表)]
|
|
public ActionResult Index()
|
|
{
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.客服分配规则列表, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
tool.AddOtherButton("Other1", "编辑状态", "icon-detail", "Set_Click", true);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
//table
|
|
Pager pager = new Pager() { page = 1, rows = 100 };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId)
|
|
{
|
|
isCheckbox = true
|
|
};
|
|
tab.AddHeadCol("SID", "", "规则组ID");
|
|
tab.AddHeadCol("SGNAME", "", "规则组");
|
|
tab.AddHeadCol("GNAME", "", "组别");
|
|
tab.AddHeadCol("EID", "", "工号");
|
|
tab.AddHeadCol("UNAME", "", "姓名");
|
|
tab.AddHiddenHeadCol("LEVEL", "档位");
|
|
tab.AddHeadCol("LEVELNAME", "", "档位");
|
|
tab.AddHeadCol("NUM", "", "数量");
|
|
tab.AddHeadCol("ISLIMIT", "", "数量限制");
|
|
tab.AddHeadCol("ISVALID", "", "是否上线");
|
|
tab.AddHeadRow();
|
|
|
|
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "100,200,500,1000");
|
|
|
|
var salesGroup = _cache.GetValue_Parameter("SaleGroup");
|
|
|
|
var salesGroupList = new List<SaleGroupView>();
|
|
if (!string.IsNullOrWhiteSpace(salesGroup))
|
|
{
|
|
salesGroupList = salesGroup.ToObject<List<SaleGroupView>>();
|
|
}
|
|
|
|
ViewBag.SalesGroup = salesGroupList;
|
|
|
|
var level = _cache.GetValue_Parameter("SaleLevel");
|
|
|
|
var levelList = new List<ResSalesLevelView>();
|
|
if (!string.IsNullOrWhiteSpace(level))
|
|
{
|
|
levelList = level.ToObject<List<ResSalesLevelView>>();
|
|
}
|
|
|
|
ViewBag.Level = levelList;
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Index(string columns, Pager pager, QueryUserComboDto usercomboDto, int? level, int? sgid, int? isvalid)
|
|
{
|
|
var list = _salesRule.GetResSalesRule(ref pager, usercomboDto, level, sgid, isvalid);
|
|
|
|
Table table = new Table(columns, true)
|
|
{
|
|
isCheckbox = true,
|
|
gridPager = pager
|
|
};
|
|
foreach (var model in list)
|
|
{
|
|
table.AddCol(model.SID);
|
|
table.AddCol(model.SGNAME);
|
|
table.AddCol(model.GNAME);
|
|
table.AddCol(model.EID);
|
|
table.AddCol(model.UNAME);
|
|
table.AddHiddenCol(model.LEVEL);
|
|
table.AddCol(model.LEVELNAME);
|
|
table.AddCol(model.NUM);
|
|
if (model.ISLIMIT == "是")
|
|
{
|
|
table.AddCol("color:green", "", model.ISLIMIT);
|
|
}
|
|
else
|
|
{
|
|
table.AddCol(model.ISLIMIT);
|
|
}
|
|
if (model.ISVALID == "是")
|
|
{
|
|
table.AddCol("color:green", "", model.ISVALID);
|
|
}
|
|
else
|
|
{
|
|
table.AddCol(model.ISVALID);
|
|
}
|
|
|
|
table.AddRow();
|
|
}
|
|
|
|
var json = new
|
|
{
|
|
totalPages = pager.totalPages,
|
|
totalRows = pager.totalRows,
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult List()
|
|
{
|
|
var level = _cache.GetValue_Parameter("SaleLevel");
|
|
|
|
ViewBag.Level = level.ToObject<List<ResSalesLevelView>>();
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult List(QueryUserComboDto usercomboDto, int? level, int? sgid, int? isvalid)
|
|
{
|
|
var pager = new Pager() { page = 1, rows = int.MaxValue };
|
|
|
|
var list = _salesRule.GetResSalesRule(ref pager, usercomboDto, level, sgid, isvalid);
|
|
|
|
var data = new LayuiData<ResSalesRuleListView>()
|
|
{
|
|
msg = "数据加载成功!",
|
|
count = 0,
|
|
code = 0,
|
|
data = list
|
|
};
|
|
return Json(data, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public ActionResult Add()
|
|
{
|
|
var salesGroup = _cache.GetValue_Parameter("SaleGroup");
|
|
|
|
var salesGroupList = new List<SaleGroupView>();
|
|
if (!string.IsNullOrWhiteSpace(salesGroup))
|
|
{
|
|
salesGroupList = salesGroup.ToObject<List<SaleGroupView>>();
|
|
}
|
|
|
|
ViewBag.SalesGroup = salesGroupList;
|
|
|
|
var level = _cache.GetValue_Parameter("SaleLevel");
|
|
|
|
var levelList = new List<ResSalesLevelView>();
|
|
if (!string.IsNullOrWhiteSpace(level))
|
|
{
|
|
levelList = level.ToObject<List<ResSalesLevelView>>();
|
|
}
|
|
|
|
ViewBag.Level = levelList;
|
|
|
|
var isMoreGroup = _cache.GetValue_Parameter("IsMoreGroup");
|
|
ViewBag.IsMoreGroup = isMoreGroup;
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult notSet(QueryUserComboDto usercomboDto, int? sgid)
|
|
{
|
|
var list = _salesRule.GetResSalesUnRule(usercomboDto, sgid);
|
|
|
|
var data = new LayuiData<ResSaleUnRuleListView>()
|
|
{
|
|
msg = "数据加载成功!",
|
|
count = 0,
|
|
code = 0,
|
|
data = list
|
|
};
|
|
return Json(data, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Add(string eids, int level, int sgid, int islimit)
|
|
{
|
|
try
|
|
{
|
|
//LogHelper.Info("eids:" + eids + "--level:" + level.ToString());
|
|
var arr = eids.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select<string, int>(x => Convert.ToInt32(x)).ToArray();
|
|
//LogHelper.Info("eids:" + string.Join(",", eids) + "--level:" + level.ToString());
|
|
var result = _salesRule.Batch(arr, level, sgid, islimit);
|
|
if (result)
|
|
{
|
|
return Json(new { result = true }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
else
|
|
{
|
|
return Json(new { result = false }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
return Json(new { result = false }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
|
|
public JsonResult Update(string eids, int? level, int? islimit, int? isvalid)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = _salesRule.Update(eids, level, islimit, isvalid);
|
|
if (result)
|
|
{
|
|
return Json(new { result = true }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
else
|
|
{
|
|
return Json(new { result = false }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
return Json(new { result = false }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult Assign()
|
|
{
|
|
var tab = new Table("tablist");
|
|
tab.AddHeadCol("rname", "", "规则组");
|
|
tab.AddHeadCol("eid", "", "工号");
|
|
tab.AddHeadCol("uname", "", "姓名");
|
|
tab.AddHeadCol("gname", "", "组别");
|
|
tab.AddHeadCol("total", "", "实际分配资源数");
|
|
tab.AddHeadCol("isnew", "", "新资源");
|
|
tab.AddHeadCol("isold", "", "老资源");
|
|
tab.AddHeadCol("allocations", "", "当前分配权重数");
|
|
tab.AddHeadCol("quantity", "", "当天实际分配权重数");
|
|
tab.AddHeadCol("todayallocations", "", "当天分配资源量");
|
|
tab.AddHeadCol("tgquantity", "", "推广资源量");
|
|
tab.AddHeadRow();
|
|
|
|
ViewBag.gridTable = tab.GetHead();
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Assign(string columns, QueryUserComboDto usercomboDto)
|
|
{
|
|
var tab = new Table(columns, true);
|
|
|
|
var list = _salesRule.GetAssignLists(usercomboDto);
|
|
|
|
if (list != null)
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
tab.AddCol(item.rname);
|
|
tab.AddCol(item.eid);
|
|
tab.AddCol(item.uname);
|
|
tab.AddCol(item.gname);
|
|
tab.AddCol(item.total);
|
|
tab.AddCol(item.isnew);
|
|
tab.AddCol(item.isold);
|
|
tab.AddCol(item.allocations);
|
|
tab.AddCol(item.quantity);
|
|
tab.AddCol(item.todayallocations);
|
|
tab.AddCol(item.tgquantity);
|
|
tab.AddRow();
|
|
}
|
|
if (list.Any())
|
|
{
|
|
tab.AddCol("合计:");
|
|
tab.AddCol("");
|
|
tab.AddCol("");
|
|
tab.AddCol("");
|
|
tab.AddCol(list.Sum(p => p.total));
|
|
tab.AddCol(list.Sum(p => p.isnew));
|
|
tab.AddCol(list.Sum(p => p.isold));
|
|
tab.AddCol(list.Sum(p => p.allocations));
|
|
tab.AddCol(list.Sum(p => p.quantity));
|
|
tab.AddCol(list.Sum(p => p.todayallocations));
|
|
tab.AddCol(list.Sum(p => p.tgquantity));
|
|
tab.AddRow();
|
|
}
|
|
}
|
|
|
|
var json = new { rowsList = tab.GetRows() };
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
}
|
|
}
|