|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.ContainerManagement.Info.Method
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 费用服务基类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class CMServiceBase
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 人民币代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string RMB_CODE = "CNY";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 美元代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string USD_CODE = "USD";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取用户相关信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected IUser User { get; private set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取主库访问对象
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected ISqlSugarClient Db { get; private set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取业务库访问对象
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected ISaasDbService SaasService { get; private set; }
|
|
|
|
|
|
|
|
|
|
SqlSugarScopeProvider? _tenantDb;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取业务库访问对象
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected SqlSugarScopeProvider TenantDb
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_tenantDb == null)
|
|
|
|
|
_tenantDb = SaasService.GetBizDbScopeById(User.TenantId);
|
|
|
|
|
|
|
|
|
|
return _tenantDb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="serviceProvider">服务提供程序</param>
|
|
|
|
|
protected CMServiceBase(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
User = serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
Db = serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
SaasService = serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查业务是否已费用锁定或已业务锁定
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bid">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="type">锁定范围</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal async Task<bool> IsLockedAsync(long bizid, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
bool? isFeeLocking = null;
|
|
|
|
|
|
|
|
|
|
isFeeLocking = await TenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
|
x => x.BusinessId == bizid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var IsBusinessLocking = await TenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
|
x => x.BusinessId == bizid && x.BusinessType == businessType).Select(x => x.IsBusinessLocking).FirstAsync();
|
|
|
|
|
|
|
|
|
|
return (isFeeLocking.GetValueOrDefault()|| IsBusinessLocking.GetValueOrDefault());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否业务锁定
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bizid"></param>
|
|
|
|
|
/// <param name="businessType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal async Task<bool> IsBusinessLocking(long bizid, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
var IsBusinessLocking = await TenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
|
x => x.BusinessId == bizid && x.BusinessType == businessType).Select(x => x.IsBusinessLocking).FirstAsync();
|
|
|
|
|
|
|
|
|
|
return IsBusinessLocking.GetValueOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否费用锁定
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bizid"></param>
|
|
|
|
|
/// <param name="businessType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
|
internal async Task<bool> IsFeeLockedAsync(long bizid, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
bool? isFeeLocking = null;
|
|
|
|
|
|
|
|
|
|
isFeeLocking = await TenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
|
x => x.BusinessId == bizid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).FirstAsync();
|
|
|
|
|
|
|
|
|
|
return isFeeLocking.GetValueOrDefault() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 业务是否包含费用
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bizid"></param>
|
|
|
|
|
/// <param name="businessType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal async Task<bool> IsHaveFee(long bizid, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
bool? isFeeLocking = null;
|
|
|
|
|
|
|
|
|
|
isFeeLocking = await TenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
|
x => x.BusinessId == bizid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).FirstAsync();
|
|
|
|
|
|
|
|
|
|
return isFeeLocking.GetValueOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|