using YLErp.Modules.ClientModule; namespace YLErp.Web.Controllers { public class CreditController : BaseController { public static string GetWhiteListVarietyNames(CreditTable credit) { var allVarieties = VarietyBLL.GetAllvarietyModel(); if (credit.Type == CreditTable.ClientType && !PS.Config.ClientElement.CanSelectCreditVariety || !credit.LimitVariety) { return string.Join(",", allVarieties.Select(v => v.VarietyName)); } if (credit.IsFeelingWhiteList) { return credit.VarietyName; } return string.Join(",", allVarieties.Where(v => !credit.VarietyIdsInt.Contains(v.id)).Select(v => v.VarietyName)); } public static string GetWhiteListVarietyNames(CreditDto credit) { var allVarieties = VarietyBLL.GetAllvarietyModel(); if (credit.Type == DBModels.CreditTable.ClientType && !PS.Config.ClientElement.CanSelectCreditVariety || !credit.LimitVariety) { return string.Join(",", allVarieties.Select(v => v.VarietyName)); } if (credit.IsFeelingWhiteList) { return credit.VarietyName; } return string.Join(",", allVarieties.Where(v => !credit.VarietyIdsInt.Contains(v.id)).Select(v => v.VarietyName)); } [MyAuthorize("客户管理-授信管理")] public ActionResult creditList() { ViewBag.SystemDate = valuedateBLL.ValueDate; return View(); } [MyAuthorize("系统管理-交易权限")] public ActionResult rolecreditList() { return View(); } public ActionResult rolecreditEdit(string enid) { var allVarieties = VarietyBLL.GetAllvarietyModel(); var intid = DataProtectHelper.DecryptInt(enid); var r = yldb.credit.Find(intid); if (r == null) { r = new CreditTable(); } else { var oldv = r.VarietyIdsInt.ToArray(); } ViewBag.All = string.Join(",", allVarieties.Select(x => x.id).ToArray()); return View(r); } [HttpPost] public JsonResult creditQuery(ClientCreditReq req) { var bll = new ClientCreditService(CurUser); req.CurUserClientIds = CurUser.GetClientIdsByCustomerManager(); var sList = bll.SearchList(req); foreach (var c in sList.rows) { c.VarietyName = GetWhiteListVarietyNames(c); } return Json(sList); } [HttpPost] public ActionResult SubmitProcess(int creditId) { var message = new ClientCreditService(CurUser).SubmitProcess(creditId); return JsonSuccess(message); } public ActionResult creditView(string enid) { var intid = DataProtectHelper.DecryptInt(enid); var r = yldb.credit.Find(intid); return View(r); } public ActionResult creditEdit(string enid) { var r = new CreditTable(); var isAdd = string.IsNullOrEmpty(enid) || enid == "0"; if (isAdd) { return View(r); } var intid = DataProtectHelper.DecryptInt(enid); r = yldb.credit.Find(intid); ViewBag.IsVariety = r.IsVariety; return View(r); } [HttpPost] public JsonResult creditEditJson(CreditTable req) { if (!string.IsNullOrEmpty(req.EncryptId)) { req.id = DataProtectHelper.DecryptInt(req.EncryptId); } var dbModel = new CreditTableService(CurUser).SaveCredit(req); return JsonSuccess("更新成功", dbModel); } [HttpPost] public JsonResult Deletecredit(string id) { var intid = DataProtectHelper.DecryptInt(id); var r = yldb.credit.Find(intid); if (r == null) { return JsonError("找不到授信"); } new ClientCreditService(CurUser).CreditLog(r.id, "删除"); yldb.credit.Remove(r); yldb.SaveChanges(); return JsonSuccess("删除成功"); } #region----(瑞达)日内授信---- [HttpPost] public JsonResult CreditIntradayQuery(ClientCreditReq req) { var slist = new CreditIntradayService(CurUser).SearchData(req); return Json(slist); } public ActionResult CreditIntradayView(string enid) { var intid = DataProtectHelper.DecryptInt(enid); var dto = new CreditIntradayService(CurUser).GetData(intid); return View("CreditIntradayView", dto); } public ActionResult CreditIntradayEdit(string enid) { if (string.IsNullOrEmpty(enid) || enid == "0") { return View(new CreditIntradayDto()); } var intid = DataProtectHelper.DecryptInt(enid); var dto = new CreditIntradayService(CurUser).GetData(intid); return View(dto); } public JsonResult DeleteCreditIntraday(string id) { var intid = DataProtectHelper.DecryptInt(id); new CreditIntradayService(CurUser).RemoveData(intid); return JsonSuccess("删除成功"); } public JsonResult AjaxSaveCreditIntraday(CreditIntraday req) { if (!string.IsNullOrEmpty(req.EncryptId)) { req.id = DataProtectHelper.DecryptInt(req.EncryptId); } var dbmodel = new CreditIntradayService(CurUser).SaveCreditIntraday(req); return JsonSuccess("更新成功", dbmodel); } #endregion #region----来自客户的授信---- [HttpPost] public JsonResult CreditFromClientQuery(ClientCreditReq req) { var slist = new CreditFromClientService(CurUser).SearchData(req); return Json(slist); } public ActionResult CreditFromClientView(string enid) { var intid = DataProtectHelper.DecryptInt(enid); var dto = new CreditFromClientService(CurUser).GetData(intid); return View(dto); } public ActionResult CreditFromClientEdit(string enid) { if (string.IsNullOrEmpty(enid) || enid == "0") { return View(new CreditFromClient()); } var intid = DataProtectHelper.DecryptInt(enid); var dto = new CreditFromClientService(CurUser).GetData(intid); return View(dto); } [HttpPost] public JsonResult DeleteCreditFromClient(string id) { var intid = DataProtectHelper.DecryptInt(id); new CreditFromClientService(CurUser).RemoveData(intid); return JsonSuccess("删除成功"); } [HttpPost] public JsonResult AjaxSaveCreditFromClient(CreditFromClient req) { if (!string.IsNullOrEmpty(req.EncryptId)) { req.id = DataProtectHelper.DecryptInt(req.EncryptId); } var dbmodel = new CreditFromClientService(CurUser).SaveCreditFromClient(req); return JsonSuccess("更新成功", dbmodel); } #endregion } }