|
|
|
@ -0,0 +1,222 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
{
|
|
|
|
|
public class FeeAuditService : IFeeAuditService
|
|
|
|
|
{
|
|
|
|
|
//待审核的状态值
|
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
public int RunningStatus = (int)FlowStatusEnum.Running;
|
|
|
|
|
|
|
|
|
|
readonly IServiceProvider _serviceProvider;
|
|
|
|
|
readonly ISqlSugarClient db;
|
|
|
|
|
readonly IUser user;
|
|
|
|
|
readonly ISaasDbService saasService;
|
|
|
|
|
|
|
|
|
|
public FeeAuditService(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataResult<List<FeeAuditBusiness>> GetListByPage(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus && x.MakerList.Contains(user.UserId))
|
|
|
|
|
.Select(x => new { x.BusinessId, x.BusinessType }).ToList();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
List<IConditionalModel> whereList = null;
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = tenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord>((s, b, f) => new JoinQueryInfos(
|
|
|
|
|
JoinType.Left, s.Id == b.BusinessId && b.BusinessType == BusinessType.OceanShippingExport,
|
|
|
|
|
JoinType.Inner, s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport && AuditStatusArray.Contains(f.FeeStatus)
|
|
|
|
|
))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f) => new FeeAuditBusiness
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = SqlFunc.ToDate(s.AccountDate),
|
|
|
|
|
APFeeStatus = b.APFeeStatus,
|
|
|
|
|
ARFeeStatus = b.ARFeeStatus,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
BusinessStatus = s.BusinessStatusName,
|
|
|
|
|
BusinessDate = s.BusinessDate,//业务日期
|
|
|
|
|
BLType = s.BLType,
|
|
|
|
|
//BookingCompany = //订舱公司
|
|
|
|
|
//BusinessUnit = //经营单位
|
|
|
|
|
CargoId = s.CargoId,
|
|
|
|
|
Carrier = s.Carrier,
|
|
|
|
|
AgencyId = s.AgentId,
|
|
|
|
|
CBM = s.CBM,
|
|
|
|
|
CntrTotal = s.CntrTotal,
|
|
|
|
|
ContractNo = s.ContractNo,
|
|
|
|
|
CreateBy = s.CreateBy,
|
|
|
|
|
CustomerId = s.CustomerId,
|
|
|
|
|
CustomerName = s.CustomerName,//委托单位
|
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
|
CustomerService = s.CustomerService,
|
|
|
|
|
CustomNo = s.CustomNo,
|
|
|
|
|
CustomsNum = s.CustomsNum,
|
|
|
|
|
DangerClass = s.DangerClass,
|
|
|
|
|
Destination = s.Destination,
|
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
|
Doc = s.Doc,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
GoodsName = s.GoodsName,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
|
InvoiceNo = s.InvoiceNo,
|
|
|
|
|
IsBusinessLocking = b.IsBusinessLocking,
|
|
|
|
|
IsFeeLocking = b.IsFeeLocking,
|
|
|
|
|
IssueType = s.IssueType,
|
|
|
|
|
KGS = s.KGS,
|
|
|
|
|
LoadPort = s.LoadPort,
|
|
|
|
|
MBLFrt = s.MBLFrt,
|
|
|
|
|
MBLNO = s.MBLNO,
|
|
|
|
|
Note = s.Note,
|
|
|
|
|
OperatorId = s.OperatorId,
|
|
|
|
|
OrderNo = s.OrderNo,
|
|
|
|
|
PKGS = s.PKGS,
|
|
|
|
|
ReceiptPlace = s.ReceiptPlace,
|
|
|
|
|
Remark = s.Remark,
|
|
|
|
|
SaleDeptId = s.SaleDeptId,
|
|
|
|
|
SaleId = s.SaleId,//揽货人
|
|
|
|
|
SaleName = s.Sale,
|
|
|
|
|
SourceId = s.SourceId,
|
|
|
|
|
SourceDetailId = s.SourceDetailId,
|
|
|
|
|
TradeTerm = s.TradeTerm,
|
|
|
|
|
Vessel = s.Vessel,//船名
|
|
|
|
|
Voyage = s.Voyno,//航次
|
|
|
|
|
Yard = s.Yard
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var queryList = tenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
|
|
|
|
|
|
|
|
|
|
var bidList = flowList.Select(x => x.BusinessId);
|
|
|
|
|
queryList = queryList.Where(x => bidList.Contains(x.Id));
|
|
|
|
|
|
|
|
|
|
if (whereList != null)
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
|
|
|
|
|
var result = queryList.ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
|
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
|
|
|
|
|
.Union(result.Data.Select(x => x.CreateBy))
|
|
|
|
|
.Distinct();
|
|
|
|
|
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
foreach (var item in result.Data)
|
|
|
|
|
{
|
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
|
|
if (item.OperatorId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
item.Operator = users.Find(x => x.Id == item.OperatorId.Value)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public DataResult<List<FeeAudit>> GetListByPage(PageRequest request)
|
|
|
|
|
//{
|
|
|
|
|
// var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
// var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
|
|
|
|
|
// var query1 = tenantDb.Queryable<FeeRecord>()
|
|
|
|
|
// .InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
|
// .LeftJoin<InfoClient>((x, y, z) => x.CustomerId == z.Id)
|
|
|
|
|
// .Select((x, y, z) => new FeeAudit
|
|
|
|
|
// {
|
|
|
|
|
// Id = x.Id,
|
|
|
|
|
// BusinessId = x.BusinessId,
|
|
|
|
|
// BusinessType = x.BusinessType,
|
|
|
|
|
// FeeStatus = x.FeeStatus,
|
|
|
|
|
// FeeType = x.FeeType,
|
|
|
|
|
// FeeName = x.FeeName,
|
|
|
|
|
// FeeEnName = x.FeeEnName,
|
|
|
|
|
// CustomerName = x.CustomerName,
|
|
|
|
|
// CustomerFullName = z.Description, //结算对象全称
|
|
|
|
|
// CustomerType = x.CustomerType,
|
|
|
|
|
// CustomerTypeText = x.CustomerTypeText,
|
|
|
|
|
// Unit = x.Unit,
|
|
|
|
|
// UnitText = x.UnitText,
|
|
|
|
|
// UnitPrice = x.UnitPrice,
|
|
|
|
|
// TaxUnitPrice = x.TaxUnitPrice,
|
|
|
|
|
// Quantity = x.Quantity,
|
|
|
|
|
// TaxRate = x.TaxRate,
|
|
|
|
|
// NoTaxAmount = x.NoTaxAmount,
|
|
|
|
|
// Amount = x.Amount,
|
|
|
|
|
// Currency = x.Currency,
|
|
|
|
|
// CurrencyText = x.CurrencyText,
|
|
|
|
|
// ExchangeRate = x.ExchangeRate,
|
|
|
|
|
// AccTaxRate = x.AccTaxRate,//销项汇率
|
|
|
|
|
// Remark = x.Remark,
|
|
|
|
|
// IsAdvancedPay = x.IsAdvancedPay,//是否垫付
|
|
|
|
|
// IsInvoice = x.IsInvoice, //是否开发票
|
|
|
|
|
// //FRT
|
|
|
|
|
// CommissionRate = x.CommissionRate, //佣金比率
|
|
|
|
|
// CreateBy = x.CreateBy,
|
|
|
|
|
// CreateTime = x.CreateTime,
|
|
|
|
|
// AuditOperator = x.AuditOperator,
|
|
|
|
|
// AuditDate = x.AuditDate,
|
|
|
|
|
// SettlementAmount = x.SettlementAmount,//结算金额
|
|
|
|
|
// InvoiceAmount = x.InvoiceAmount,//开票金额
|
|
|
|
|
// OrderAmount = x.OrderAmount,//申请金额
|
|
|
|
|
// InvoiceNum = x.InvoiceNum,//发票号
|
|
|
|
|
// Tax = x.Tax,//税额
|
|
|
|
|
// DebitNo = x.DebitNo,//对账编号
|
|
|
|
|
// SubmitBy = x.SubmitBy,
|
|
|
|
|
// SubmitDate = x.SubmitDate,
|
|
|
|
|
// SaleOrg = x.SaleOrg,
|
|
|
|
|
// Reason = x.Reason,
|
|
|
|
|
// IsOpen = x.IsOpen,//是否机密
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// var queryList = tenantDb.UnionAll(new List<ISugarQueryable<FeeAudit>> { query1 });
|
|
|
|
|
// var result = queryList.Where(whereList).ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
// if (result.Data.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// //关联用户名称
|
|
|
|
|
// var userIds = result.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.Value)
|
|
|
|
|
// .Union(result.Data.Select(x => x.CreateBy))
|
|
|
|
|
// .Distinct();
|
|
|
|
|
// var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
// foreach (var item in result.Data)
|
|
|
|
|
// {
|
|
|
|
|
// item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
|
|
// if (item.SubmitBy.HasValue)
|
|
|
|
|
// {
|
|
|
|
|
// item.SubmitByName = users.Find(x => x.Id == item.SubmitBy.Value)?.UserName;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|