步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.2 KiB

3 years ago
using BBWY.Common.Models;
3 years ago
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using System.Collections.Generic;
using System.Linq;
3 years ago
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
3 years ago
public class FinancialTerminalBusiness : BaseBusiness, IDenpendency
3 years ago
{
public FinancialTerminalBusiness(IFreeSql fsql, NLog.ILogger logger, IIdGenerator idGenerator) : base(fsql, logger, idGenerator)
3 years ago
{
}
public IList<AuditPayBillResponse> GetAuditPayBillList(QueryAuditPayBillRequest request)
{
request.EndDate = request.EndDate.Date.AddDays(1).AddSeconds(-1);
return fsql.Select<AuditPayBill>().Where(apb => apb.ImportShopIds == request.ImportShopIds &&
apb.PayTime >= request.StartDate &&
apb.PayTime <= request.EndDate).OrderByDescending(b => b.PayTime).ToList<AuditPayBillResponse>();
3 years ago
}
3 years ago
public bool IsExistAuditPayBill(QueryAuditPayBillRequest request)
{
request.EndDate = request.EndDate.Date.AddDays(1).AddSeconds(-1);
return fsql.Select<AuditPayBill>().Where(apb => apb.ImportShopIds == request.ImportShopIds &&
apb.PayTime >= request.StartDate &&
apb.PayTime <= request.EndDate).Any();
}
3 years ago
3 years ago
public void BatchInsertAuditPayBill(List<AuditPayBill> insertList)
{
3 years ago
if (insertList == null || insertList.Count == 0)
throw new BusinessException("数据不全");
3 years ago
var importShopIds = insertList[0].ImportShopIds;
var startTime = insertList.Min(abp => abp.PayTime).Value;
var endTime = insertList.Max(abp => abp.PayTime).Value;
fsql.Transaction(() =>
{
fsql.Delete<AuditPayBill>().Where(apb => apb.ImportShopIds == importShopIds &&
apb.PayTime >= startTime &&
apb.PayTime <= endTime).ExecuteAffrows();
fsql.Insert(insertList).ExecuteAffrows();
});
}
3 years ago
}
}