ComplianceServer/oldcode/Core.Web/Controllers/BillController.cs

180 lines
8.3 KiB
C#

using Core.Web.App_Start;
using Core.Web.WebHelper;
using CRM.Core.BLL;
using CRM.Core.BLL.Application.B;
using CRM.Core.BLL.Application.Bill;
using CRM.Core.BLL.Util;
using CRM.Core.Common.Layui;
using CRM.Core.DTO.Bill;
using CRM.Core.Model.Entity;
using System;
using System.Linq;
using System.Web.Mvc;
using WX.CRM.WebHelper;
namespace Core.Web.Controllers
{
public class BillController : BaseController
{
private CACHE_BL _cache = new CACHE_BL();
private Bill_Account_BL bill_accountBL = new Bill_Account_BL();
// GET: Bill
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_NotButton, true)]
public ActionResult Index()
{
ViewBag.rightCode = RightsConfig.CONST_账单管理;
ViewBag.companyList = _cache.GetCompanyVirtual();
return View();
}
[HttpPost]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_NotButton, false)]
public JsonResult Index(Laypage pager, string columns, string trade_no, string mch, string trade_type, string yearMonth, DateTime? sTime, DateTime? eTime)
{
var where = PredicateExtensionses.True<Bill_Account>();
if (!string.IsNullOrWhiteSpace(trade_no))
where = where.And(p => p.trade_no == trade_no);
if (!string.IsNullOrWhiteSpace(mch))
where = where.And(p => p.mch == mch);
if (!string.IsNullOrEmpty(trade_type))
where = where.And(p => p.trade_type == trade_type);
if (!string.IsNullOrEmpty(yearMonth))
{
var date = DateTime.ParseExact(yearMonth, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
var enddate = date.AddMonths(1);
where = where.And(p => p.trade_datetime >= date && p.trade_datetime < enddate);
}
if (sTime.HasValue)
where = where.And(p => p.trade_datetime >= sTime.Value);
if (eTime.HasValue)
{
var endtime = eTime.Value.AddDays(1);
where = where.And(p => p.trade_datetime < endtime);
}
BillService billService = new BillService(UserName);
var list = bill_accountBL.GetList(where, p => p.Id, pager).ToList();
//var sumList = _orderPay.GetList(where, p => p.id, new Laypage() { page = 1, limit = int.MaxValue });
//var sum = bill_accountBL.Sum(where, m => m.trade_amount) ?? 0;
var alllist = bill_accountBL.GetList(where).ToList();
var billmsg = billService.getbillsMsg(alllist);
var trade_amount = alllist.Sum(d => d.trade_amount);
var fee_amount = alllist.Sum(d => d.fee_amount);
var data = new { msg = "数据加载成功!", count = pager.count, code = 0, data = list, totalRow = new { trade_amount = trade_amount, fee_amount = fee_amount }, billmsg = billmsg };
return Json(data, JsonRequestBehavior.AllowGet);
}
[HttpPost]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_Other1, false)]
public JsonResult Import()
{
var file = Request.Files[0];
BillService billService = new BillService(UserName);
// var dt = ExcelToDataTable(file);
var data = billService.ImportBill(file.FileName, file.InputStream);
return Json(data, JsonRequestBehavior.AllowGet);
}
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_Other2, false)]
public FileResult Export(string mch, string trade_type, string yearMonth, DateTime? sTime, DateTime? eTime)
{
var where = PredicateExtensionses.True<Bill_Account>();
if (!string.IsNullOrWhiteSpace(mch))
where = where.And(p => p.mch == mch);
if (!string.IsNullOrEmpty(trade_type))
where = where.And(p => p.trade_type == trade_type);
if (!string.IsNullOrEmpty(yearMonth))
{
var date = DateTime.ParseExact(yearMonth, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
var enddate = date.AddMonths(1);
where = where.And(p => p.trade_datetime >= date && p.trade_datetime < enddate);
}
if (sTime.HasValue)
where = where.And(p => p.trade_datetime >= sTime.Value);
if (eTime.HasValue)
{
var endtime = eTime.Value.AddDays(1);
where = where.And(p => p.trade_datetime < endtime);
}
var alllist = bill_accountBL.GetList(where).ToList();
// var reslut = new { msg = "数据加载成功!", count = alllist.Count, code = 0, data = values };
// return Json(reslut, JsonRequestBehavior.AllowGet);
return File(ExcelHelper.ExportListModelToExcel<Bill_Account>(alllist, "Bill", 30000, null), "application/ms-excel", "BillQuery.xls");
}
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_Other2, false)]
public FileResult CheckBillDepositExport(string mch, string trade_type, string yearMonth, DateTime? sTime, DateTime? eTime)
{
var where = PredicateExtensionses.True<Bill_Account>();
if (!string.IsNullOrWhiteSpace(mch))
where = where.And(p => p.mch == mch);
if (!string.IsNullOrEmpty(trade_type))
where = where.And(p => p.trade_type == trade_type);
if (!string.IsNullOrEmpty(yearMonth))
{
var date = DateTime.ParseExact(yearMonth, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
var enddate = date.AddMonths(1);
where = where.And(p => p.trade_datetime >= date && p.trade_datetime < enddate);
}
if (sTime.HasValue)
where = where.And(p => p.trade_datetime >= sTime.Value);
if (eTime.HasValue)
{
var endtime = eTime.Value.AddDays(1);
where = where.And(p => p.trade_datetime < endtime);
}
var alllist = bill_accountBL.GetList(where).ToList();
BillService billService = new BillService(UserName);
var billcheckes = billService.billAccountChecks(alllist);
String file = string.Format("BillDepositCheckExport{0}.xls", DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmssfffff"));
return File(ExcelHelper.ExportListModelToExcel<BillDto.BillAccountCheck>(billcheckes, "BillCheck", 30000, null), "application/ms-excel", file);
}
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_账单管理, ToolBarConfig.CONST_Other2, false)]
public FileResult CheckBillRefundExport(string mch, string trade_type, string yearMonth, DateTime? sTime, DateTime? eTime)
{
var where = PredicateExtensionses.True<Bill_Account>();
if (!string.IsNullOrWhiteSpace(mch))
where = where.And(p => p.mch == mch);
if (!string.IsNullOrEmpty(trade_type))
where = where.And(p => p.trade_type == trade_type);
if (!string.IsNullOrEmpty(yearMonth))
{
var date = DateTime.ParseExact(yearMonth, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
var enddate = date.AddMonths(1);
where = where.And(p => p.trade_datetime >= date && p.trade_datetime < enddate);
}
if (sTime.HasValue)
where = where.And(p => p.trade_datetime >= sTime.Value);
if (eTime.HasValue)
{
var endtime = eTime.Value.AddDays(1);
where = where.And(p => p.trade_datetime < endtime);
}
var alllist = bill_accountBL.GetList(where).ToList();
BillService billService = new BillService(UserName);
var billcheckes = billService.billAccountRefundChecks(alllist);
String file = string.Format("BillRefundCheckExport{0}.xls", DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmssfffff"));
return File(ExcelHelper.ExportListModelToExcel<BillDto.BillRefundCheck>(billcheckes, "BillRefundCheck", 30000, null), "application/ms-excel", file);
}
}
}