using System;
using System.Collections.Generic;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.Csvr;
using WX.CRM.IBLL.Res;
using WX.CRM.IBLL.Util;
using WX.CRM.Model.Entity;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Csvr
{
public class ApplyVipController : BaseController
{
ICSVR_APPLYVIP applyvipBiz;
ICSVR_APPLYVIP_Q applyvipBiz_Q;
IRES_CUSTOMERDETAIL_Q customer_Q;
IRES_RESOURCEMOBILE_Q ressourceMobile_Q;
ICACHE_Q _cacheQ;
ValidationErrors errors = new ValidationErrors();
public ApplyVipController(ICSVR_APPLYVIP _applyvipBiz, ICSVR_APPLYVIP_Q _applyvipBiz_Q, IRES_CUSTOMERDETAIL_Q _customer_Q, IRES_RESOURCEMOBILE_Q _ressourceMobile_Q, ICACHE_Q _cacheQ)
{
this.applyvipBiz = _applyvipBiz;
this.applyvipBiz_Q = _applyvipBiz_Q;
this.customer_Q = _customer_Q;
this.ressourceMobile_Q = _ressourceMobile_Q;
this._cacheQ = _cacheQ;
}
#region 首页
[AuthorizeRedirect(Roles = InitRights.CONST_审核VIP通道申请)]
public ActionResult Index()
{
//ToolBar
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.审核VIP通道申请, userRightId);
tool.AllowButton(toolbtn);
tool.AddOtherButton("Other1", "确认审核", "icon-yes", "Check_Click", true);
tool.AddOtherButton("Other2", "删除审核", "icon-no", "DelCheck_Click", true);
ViewBag.ToolBar = tool;
//table
Pager pager = new Pager() { page = 1, rows = 15 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHiddenHeadCol("PKID", "主键");
tab.AddHeadCol("RESID", "", "客户ID");
tab.AddHeadCol("PHONE", "", "号码");
tab.AddHeadCol("MEMO", "", "申请原因");
tab.AddHeadCol("INNERUSERID", "10%", "申请人");
tab.AddHeadCol("CTIME", "", "申请时间");
tab.AddHeadCol("STATUS", "", "申请状态");
tab.AddHeadCol("OPERATORID", "", "审核人");
tab.AddHeadCol("UTIME", "", "审核时间");
tab.AddHeadRow();
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "15,30,50");
var deptCode = _cacheQ.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_Environment_DeptCode);
ViewBag.DeptCode = deptCode;
return View();
}
#endregion
#region 列表
[HttpPost]
///
/// 按照条件获取数据
///
///
///
///
[AuthorizeRedirect(Roles = InitRights.CONST_审核VIP通道申请)]
public JsonResult GetHtmlList(Pager pager, string columns, string resid, bool showCheck)
{
List list = applyvipBiz_Q.GetList(ref pager, resid, showCheck);
Table table = new Table(columns, true);
table.gridPager = pager;
foreach (WX.CRM.Model.Entity.CSVR_APPLYVIP model in list)
{
table.AddHiddenCol(model.PKID);
table.AddCol(model.RESID);
table.AddCol(model.PHONE);
table.AddCol(model.MEMO);
table.AddCol(InnerUserHelper.Instance.EidAndName(model.INNERUSERID));
table.AddCol(model.CTIME.ToUnityString(2));
table.AddCol(model.STATUS == null ? "" : GetStatus(Convert.ToInt32(model.STATUS.Value)));
table.AddCol(InnerUserHelper.Instance.EidAndName(model.OPERATORID));
table.AddCol(model.UTIME.ToUnityString(2));
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
private string GetStatus(int status)
{
string strStatus = string.Empty;
switch (status)
{
case (int)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.删除审核: strStatus = "删除审核"; break;
case (int)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.审核通过: strStatus = "审核通过"; break;
case (int)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.未审核: strStatus = "未审核"; break;
}
return strStatus;
}
#endregion
[HttpPost]
public string JudgeVIPNumber(string resId)
{
return applyvipBiz_Q.IsExistApplyNumber(resId).ToString();
}
[HttpPost]
public JsonResult DelCheck(decimal id)
{
bool result = applyvipBiz.UpdateStatus(ref errors, id, UserId, (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.删除审核);
return JsonHandler.InsertMessage(errors, result);
}
[HttpPost]
public JsonResult ApplyVIPNumber(string resId, string memo, decimal isLocal, string mobile)
{
CSVR_APPLYVIP applyVIP = new CSVR_APPLYVIP();
applyVIP.RESID = resId;
applyVIP.PHONE = mobile;
applyVIP.ISLOCAL = isLocal;
applyVIP.MEMO = memo;
applyVIP.CTIME = DateTime.Now;
applyVIP.STATUS = (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.未审核;
applyVIP.INNERUSERID = UserId;
bool result = applyvipBiz.Create(ref errors, applyVIP);
return JsonHandler.InsertMessage(errors, result);
}
#region VIP审核
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_审核VIP通道申请, InitToolBar.CONST_Other1)]
public ActionResult BCHCheck(string resid, string reson)
{
return View();
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_审核VIP通道申请, InitToolBar.CONST_Other1)]
public JsonResult BCHCheck(decimal pkid, string resid, DateTime stime, DateTime etime, string outNumber)
{
if (string.IsNullOrWhiteSpace(outNumber))
{
return JsonHandler.ManageMessage("VIP号码不能为空!", false);
}
//string TelNum = ressourceMobile_Q.GetNumberByResId(resid);
//bool result = applyvipBiz.AddBCHVIP(ref errors, TelNum, stime, etime, outNumber);
//if (result)
//{
var result = applyvipBiz.UpdateStatus(ref errors, pkid, UserId, (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.审核通过);
//}
return JsonHandler.InsertMessage(errors, result);
}
#endregion
#region 保存审核
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_审核VIP通道申请, InitToolBar.CONST_Other1)]
public ActionResult Check(string id, string phone)
{
RES_CUSTOMERDETAIL customer = customer_Q.GetModel_RES_CUSTOMERDETAIL(id);
ViewBag.TradeName = customer.CNAME == null ? "" : customer.CNAME;
return View();
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_审核VIP通道申请, InitToolBar.CONST_Other1)]
public JsonResult Check(decimal pkid, string resid, string TradeName, DateTime stime, DateTime etime, string listType, int levelDDL, string CheckStatus)
{
//string userName = TradeName;
//string TelNum = ressourceMobile_Q.GetNumberByResId(resid);
//string type = listType;
//DateTime dateFrom = stime;
//DateTime dateTo = etime;
//string memo = CheckStatus;
//int level = levelDDL;
//string agentId = UserId.ToString();
//bool result = applyvipBiz.AddBWList(ref errors, userName, TelNum, type, dateFrom, dateTo, memo, level, agentId);
//if (result)
//{
var result = applyvipBiz.UpdateStatus(ref errors, pkid, UserId, (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.审核通过);
//}
return JsonHandler.InsertMessage(errors, result);
}
#endregion
}
}