171 lines
6.3 KiB
C#
171 lines
6.3 KiB
C#
using YLErp.Model.Enum;
|
|
using YLErp.Modules.ClientModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class ClientInvestorController : BaseController
|
|
{
|
|
public ActionResult investorEditPopInner(int? rid, bool isOnlyView = false)
|
|
{
|
|
var clientCount = yldb.approvalprocess.Where(x => x.processType == "OpenProcess").Count();
|
|
ViewBag.ClientApprovalProcessCount = clientCount;
|
|
|
|
var client = clientDB.client.Find(rid);
|
|
ViewBag.ProcessStatus = client == null ? "未提交" : client.ProcessStatus;
|
|
|
|
var investor = new List<ClientInvestor>();
|
|
var models = clientDB.ClientInvestor.Where(b => b.ClientId == rid).ToList();
|
|
if (models != null)
|
|
{
|
|
foreach (var m in models)
|
|
{
|
|
var b = new ClientInvestor
|
|
{
|
|
id = m.id,
|
|
ClientId = m.ClientId,
|
|
Investor = m.Investor,
|
|
EligibilityType = m.EligibilityType,
|
|
ShareRate = m.ShareRate,
|
|
OptId = m.OptId,
|
|
OptName = m.OptName,
|
|
OptDate = m.OptDate,
|
|
Comments = m.Comments
|
|
};
|
|
investor.Add(b);
|
|
}
|
|
}
|
|
|
|
ViewBag.IsOnlyView = isOnlyView;
|
|
return View(investor);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult investorQuery(ClientInvestorReq req)
|
|
{
|
|
var sList = new ClientInvestorService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult investorEdit(string enid, int? rid)
|
|
{
|
|
var r = new ClientInvestor();
|
|
var isAdd = string.IsNullOrEmpty(enid) || enid == "0";
|
|
var clientCount = yldb.approvalprocess.Where(x => x.processType == "OpenProcess").Count();
|
|
ViewBag.ClientApprovalProcessCount = clientCount;
|
|
if (isAdd)
|
|
{
|
|
if (rid != null)
|
|
{
|
|
//客户id
|
|
var client = clientDB.client.Find(rid);
|
|
if (client == null)
|
|
{
|
|
throw new ServiceException("请先保存用户基本信息");
|
|
}
|
|
r.ClientId = client == null ? 0 : client.id;
|
|
r.ClientName = client == null ? "" : client.Name;
|
|
ViewBag.ProcessStatus = client == null ? "未提交" : client.ProcessStatus;
|
|
ViewBag.IsProductType = client.ClientType == ClientTypeEnum.产品.ToString();
|
|
}
|
|
else
|
|
{
|
|
ViewBag.ProcessStatus = "未提交";
|
|
ViewBag.IsProductType = false;
|
|
}
|
|
|
|
return View(r);
|
|
}
|
|
else
|
|
{
|
|
var intid = DecryptInt(enid);
|
|
r = clientDB.ClientInvestor.Find(intid);
|
|
if (r != null)
|
|
{
|
|
var client = clientDB.client.Find(r.ClientId);
|
|
ViewBag.ProcessStatus = client == null ? "未提交" : client.ProcessStatus;
|
|
ViewBag.IsProductType = client.ClientType == ClientTypeEnum.产品.ToString();
|
|
}
|
|
else
|
|
{
|
|
ViewBag.ProcessStatus = "未提交";
|
|
ViewBag.IsProductType = false;
|
|
}
|
|
|
|
return View(r);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult investorEditJson(ClientInvestor req)
|
|
{
|
|
var set = Request.Form.Keys.Cast<string>().ToHashSet(StringComparer.OrdinalIgnoreCase);
|
|
var r = new ClientInvestorService(CurUser).SaveInvestor(set, req, out _);
|
|
return JsonSuccess("更新成功", r);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 产品投资人详情
|
|
/// </summary>
|
|
public JsonResult AjaxGetInvestorDetail(string enid)
|
|
{
|
|
var intid = DecryptInt(enid);
|
|
var dbModel = intid > 0 ? clientDB.ClientInvestor.AsNoTracking().FirstOrDefault(n => n.id == intid) : null;
|
|
if (dbModel == null)
|
|
{
|
|
return JsonError("没有找到产品投资人信息");
|
|
}
|
|
dbModel.ShareRate = dbModel.ShareRate * 100;
|
|
return JsonSuccessData(dbModel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除产品投资人
|
|
/// </summary>
|
|
/// <param name="enid"></param>
|
|
/// <returns></returns>
|
|
public JsonResult AjaxRemoveInvestor(string enid)
|
|
{
|
|
var intid = DecryptInt(enid);
|
|
var r = clientDB.ClientInvestor.FirstOrDefault(s => s.id == intid);
|
|
if (r == null)
|
|
{
|
|
return JsonError("删除失败,找不到人员信息");
|
|
}
|
|
clientDB.ClientInvestor.Remove(r);
|
|
clientDB.SaveChanges();
|
|
clientDB.ClientAuditLog.Add(new ClientAuditLog
|
|
{
|
|
ClientId = r.ClientId ?? 0,
|
|
OptType = "删除产品投资人",
|
|
Changes = string.Empty,
|
|
DataType = "00",
|
|
OptId = UserId,
|
|
OptName = UserName,
|
|
OptDate = DateTime.Now
|
|
});
|
|
clientDB.SaveChanges();
|
|
return JsonSuccess("删除成功", r);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据客户ID获取产品投资人信息列表
|
|
/// </summary>
|
|
public JsonResult AjaxGetInvestorList(int clientId)
|
|
{
|
|
var list = clientDB.ClientInvestor.AsNoTracking().Where(n => n.ClientId == clientId).ToList();
|
|
return JsonSuccessData(list);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存产品投资人信息
|
|
/// </summary>
|
|
public JsonResult AjaxSaveInvestor(ClientInvestor req)
|
|
{
|
|
var set = Request.Form.Keys.Cast<string>().ToHashSet(StringComparer.OrdinalIgnoreCase);
|
|
req.ShareRate = req.ShareRate / 100;
|
|
var investor = new ClientInvestorService(CurUser).SaveInvestor(set, req, out var client);
|
|
return JsonSuccess("更新成功", new { investor, client = new { client.ProcessStatus, client.ProcessOrderId, client.ProcessOptDate } });
|
|
}
|
|
}
|
|
}
|