|
|
|
@ -14,6 +14,7 @@ using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
|
|
using DS.WMS.Core.Sys.Method;
|
|
|
|
|
using Mapster;
|
|
|
|
@ -50,11 +51,23 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
public DataResult<List<VW_CheckBill_Detail>> GetBusinessQueryList(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
var users = db.Queryable<SysUser>().Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
var data = tenantDb.Queryable<VW_CheckBill_Detail>()
|
|
|
|
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
var otherConditons = new List<IConditionalModel>();
|
|
|
|
|
if (request.OtherQueryCondition.IsNotNull())
|
|
|
|
|
otherConditons = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.OtherQueryCondition);
|
|
|
|
|
|
|
|
|
|
var queryData = tenantDb.Queryable<VW_CheckBill_Detail>()
|
|
|
|
|
.Where(whereList);
|
|
|
|
|
if (otherConditons.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var businessIds = tenantDb.Queryable<FeeRecord>().Where(otherConditons).Select(x => x.BusinessId).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
queryData = queryData.Where(x => businessIds.Contains(x.Id));
|
|
|
|
|
}
|
|
|
|
|
var data = queryData.ToQueryPage(request.PageCondition);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -81,31 +94,64 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<List<CheckBillRes>> GetCheckBillList(PageRequest request)
|
|
|
|
|
public DataResult<List<CheckBillSumRes>> GetCheckBillList(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
var users = db.Queryable<SysUser>().Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
var data = tenantDb.Queryable<CheckBill>()
|
|
|
|
|
//.LeftJoin<VW_CheckBill_Bussiness>((a,b)=>a.Id == b.CheckId)
|
|
|
|
|
|
|
|
|
|
var otherConditons = new List<IConditionalModel>();
|
|
|
|
|
if (request.OtherQueryCondition.IsNotNull())
|
|
|
|
|
otherConditons = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.OtherQueryCondition);
|
|
|
|
|
|
|
|
|
|
var queryData = tenantDb.Queryable<CheckBill>()
|
|
|
|
|
.Where(whereList)
|
|
|
|
|
.Select<CheckBillRes>()
|
|
|
|
|
.Mapper(it =>
|
|
|
|
|
{
|
|
|
|
|
var checkBillDetails = tenantDb.Queryable<VW_CheckBill_Business>().Where(x => x.CheckId == it.Id).ToList();
|
|
|
|
|
it.RMBDR = checkBillDetails.Sum(x => x.RMBDR);
|
|
|
|
|
it.RMBCR = checkBillDetails.Sum(x => x.RMBCR);
|
|
|
|
|
it.USDDR = checkBillDetails.Sum(x => x.USDDR);
|
|
|
|
|
it.USDCR = checkBillDetails.Sum(x => x.USDCR);
|
|
|
|
|
it.BALRMBDR = checkBillDetails.Sum(x => x.BALRMBDR);
|
|
|
|
|
it.BALRMBCR = checkBillDetails.Sum(x => x.BALRMBCR);
|
|
|
|
|
it.BALUSDDR = checkBillDetails.Sum(x => x.BALUSDDR);
|
|
|
|
|
it.BALUSDCR = checkBillDetails.Sum(x => x.BALUSDCR);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.ToQueryPage(request.PageCondition);
|
|
|
|
|
.Select<CheckBillSumRes>();
|
|
|
|
|
if (otherConditons.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var checkIds = tenantDb.Queryable<VW_CheckBill_Business>().Where(otherConditons).Select(x => x.CheckId).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
queryData = queryData.Where(x => checkIds.Contains(x.Id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = queryData.Mapper(it =>
|
|
|
|
|
{
|
|
|
|
|
var checkBillDetails = tenantDb.Queryable<VW_CheckBill_Business>().Where(x => x.CheckId == it.Id).ToList();
|
|
|
|
|
it.CreateByName = users.Find(x => x.Id == it.CreateBy).UserName;
|
|
|
|
|
it.RMBDR = checkBillDetails.Sum(x => x.RMBDR);
|
|
|
|
|
it.RMBCR = checkBillDetails.Sum(x => x.RMBCR);
|
|
|
|
|
it.USDDR = checkBillDetails.Sum(x => x.USDDR);
|
|
|
|
|
it.USDCR = checkBillDetails.Sum(x => x.USDCR);
|
|
|
|
|
it.BALRMBDR = checkBillDetails.Sum(x => x.BALRMBDR);
|
|
|
|
|
it.BALRMBCR = checkBillDetails.Sum(x => x.BALRMBCR);
|
|
|
|
|
it.BALUSDDR = checkBillDetails.Sum(x => x.BALUSDDR);
|
|
|
|
|
it.BALUSDCR = checkBillDetails.Sum(x => x.BALUSDCR);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.ToQueryPage(request.PageCondition);
|
|
|
|
|
return data;
|
|
|
|
|
//var data = tenantDb.Queryable<CheckBill>()
|
|
|
|
|
// //.LeftJoin<VW_CheckBill_Business>((a,b)=>a.Id == b.CheckId)
|
|
|
|
|
// //.Select<CheckBillRes>()
|
|
|
|
|
// .Where(whereList)
|
|
|
|
|
// .Select<CheckBillSumRes>()
|
|
|
|
|
// .Mapper(it =>
|
|
|
|
|
// {
|
|
|
|
|
// var checkBillDetails = tenantDb.Queryable<VW_CheckBill_Business>().Where(x => x.CheckId == it.Id).ToList();
|
|
|
|
|
// it.CreateByName = users.Find(x => x.Id == it.CreateBy).UserName;
|
|
|
|
|
// it.RMBDR = checkBillDetails.Sum(x => x.RMBDR);
|
|
|
|
|
// it.RMBCR = checkBillDetails.Sum(x => x.RMBCR);
|
|
|
|
|
// it.USDDR = checkBillDetails.Sum(x => x.USDDR);
|
|
|
|
|
// it.USDCR = checkBillDetails.Sum(x => x.USDCR);
|
|
|
|
|
// it.BALRMBDR = checkBillDetails.Sum(x => x.BALRMBDR);
|
|
|
|
|
// it.BALRMBCR = checkBillDetails.Sum(x => x.BALRMBCR);
|
|
|
|
|
// it.BALUSDDR = checkBillDetails.Sum(x => x.BALUSDDR);
|
|
|
|
|
// it.BALUSDCR = checkBillDetails.Sum(x => x.BALUSDCR);
|
|
|
|
|
// }
|
|
|
|
|
// )
|
|
|
|
|
// .ToQueryPage(request.PageCondition);
|
|
|
|
|
//return data;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
@ -371,7 +417,7 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
}
|
|
|
|
|
tenantDb.Insertable(businessList).ExecuteCommand();
|
|
|
|
|
tenantDb.Insertable(feeList).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return DataResult.Successed("添加成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -398,7 +444,7 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
return DataResult.Failed("客户对账信息已锁定");
|
|
|
|
|
|
|
|
|
|
var feeList = new List<CheckBillFeeRecords>();
|
|
|
|
|
var feeIds = tenantDb.Queryable<CheckBillFeeRecords>().Where(x => x.CheckId == checkId ).Select(x => x.FeeRecordId).ToList();
|
|
|
|
|
var feeIds = tenantDb.Queryable<CheckBillFeeRecords>().Where(x => x.CheckId == checkId).Select(x => x.FeeRecordId).ToList();
|
|
|
|
|
var addFeeIds = req.Ids.AsQueryable().Except(feeIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -406,7 +452,7 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var item in addFeeIds)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
var feeRecords = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == item).ToList();
|
|
|
|
|
foreach (var record in feeRecords)
|
|
|
|
|
{
|
|
|
|
@ -418,7 +464,7 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
CheckBillAmount = record.Amount,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tenantDb.Insertable(feeList).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
return DataResult.Successed("添加成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
@ -432,17 +478,18 @@ namespace DS.WMS.Core.Check.Method
|
|
|
|
|
public DataResult CheckBillLocking(IdModel req)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
if (req.Ids.Length==0)
|
|
|
|
|
if (req.Ids.Length == 0)
|
|
|
|
|
return DataResult.Failed("业务Ids不能为空");
|
|
|
|
|
|
|
|
|
|
if (tenantDb.Queryable<CheckBill>().Where(x=> req.Ids.Contains(x.Id) && x.IsLocking == true).Any())
|
|
|
|
|
if (tenantDb.Queryable<CheckBill>().Where(x => req.Ids.Contains(x.Id) && x.IsLocking == true).Any())
|
|
|
|
|
return DataResult.Failed("存在已锁定的客户对账信息");
|
|
|
|
|
|
|
|
|
|
var list = tenantDb.Queryable<CheckBill>().Where(x => req.Ids.Contains(x.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
//tenantDb.Updateable(list).SetColumns(it=>it.IsLocking == true).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
foreach (var item in list) {
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
item.IsLocking = true;
|
|
|
|
|
}
|
|
|
|
|
tenantDb.Updateable(list).ExecuteCommand();
|
|
|
|
|