using Org.BouncyCastle.Ocsp; using YLErp.DBModels; using YLErp.Modules.EodModule; namespace YLErp.Web.Controllers { public class BondPaymentController : BaseController { readonly IViewRenderService _viewRenderer; public BondPaymentController(IViewRenderService viewRenderer) { _viewRenderer = viewRenderer; } [MyAuthorize("结算管理-债券付息数据查看")] public ActionResult BondPaymentList() { return View(); } [HttpPost] public JsonResult BondPaymentQuery(BondPaymentReq req) { var sList = new BondPaymentService(CurUser).SearchList(req); return Json(sList); } public ActionResult BondPaymentView(string enid) { var intid = DecryptLong(enid); var r = yldb.bondPayment.Find(intid); var um = yldb.underlying_manager.FirstOrDefault(x => x.UnderlyingCode == r.underlyingCode); r.symbol = um?.UnderlyingName; r.security_id = um?.UnderlyingCode; return View(r); } public ActionResult BondPaymentEdit(string enid) { if (string.IsNullOrEmpty(enid) || enid == "0") { return View(new BondPayment()); } var intid = DecryptLong(enid); var dbmodel = yldb.bondPayment.Find(intid); if (dbmodel == null) { return ShowError("找不到数据"); } var um = yldb.underlying_manager.FirstOrDefault(x => x.UnderlyingCode == dbmodel.security_id); dbmodel.symbol = um?.UnderlyingName; return View(dbmodel); } public JsonResult BondPaymentEditJson(BondPayment req) { if (!string.IsNullOrEmpty(req.EncryptId)) { req.id = DecryptLong(req.EncryptId); } var r = new BondPaymentService(CurUser).SaveBondPayment(req); return JsonSuccess("更新成功", r); } [HttpPost] public JsonResult DeletBondPayment(string id) { var intid = DecryptLong(id); var r = yldb.bondPayment.Find(intid); if (r == null) { return JsonError("找不到债券期间付息信息"); } yldb.bondPayment.Remove(r); yldb.SaveChanges(); return JsonSuccess("删除成功"); } /// /// 获取某债券期间付息 /// /// /// /// /// public JsonResult GetBondPayMentInterest(DateTime startDate, DateTime endDate, string underlyingCode) { var payments = new BondPaymentService(CurUser).GetBondPayments(underlyingCode, startDate, endDate); decimal interest = payments.Sum(s => s.payment_interest ?? 0) * 0.01m; return JsonSuccess("", interest); } } }