|
|
|
@ -38,25 +38,24 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提交审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="idModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> SubmitAuditAsync(AuditRequest request)
|
|
|
|
|
public async Task<DataResult> SubmitAuditAsync(IdModel idModel)
|
|
|
|
|
{
|
|
|
|
|
var queryable = TenantDb.Queryable<InfoClientContact>().Where(x => request.Ids.Contains(x.ClientId));
|
|
|
|
|
var queryable = TenantDb.Queryable<InfoClientContact>().Where(x => idModel.Ids.Contains(x.ClientId));
|
|
|
|
|
if (await queryable.AnyAsync(x => (SqlFunc.IsNullOrEmpty(x.Tel) && SqlFunc.IsNullOrEmpty(x.Mobile)) || (SqlFunc.IsNullOrEmpty(x.Email) && SqlFunc.IsNullOrEmpty(x.QQ))))
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.ClientInfoIncomplete);
|
|
|
|
|
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: request.Ids);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
if (await TenantDb.Queryable<InfoClient>().AnyAsync(x => idModel.Ids.Contains(x.Id) && x.AuditStatus == AuditStatusEnum.Auditing))
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.ItemsAreAuditing);
|
|
|
|
|
|
|
|
|
|
var template = FindTemplateAsync(AuditType.InfoClient);
|
|
|
|
|
if (template == null)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.TemplateNotFound);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < request.Ids.Length; i++)
|
|
|
|
|
for (int i = 0; i < idModel.Ids.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var id = request.Ids[i];
|
|
|
|
|
var id = idModel.Ids[i];
|
|
|
|
|
var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
|
|
|
|
|
{
|
|
|
|
|
BusinessId = id,
|
|
|
|
@ -70,12 +69,66 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rows = await TenantDb.Updateable<InfoClient>().Where(x => request.Ids.Contains(x.Id))
|
|
|
|
|
var rows = await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.Auditing).ExecuteCommandAsync();
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 执行审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(AuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: request.Ids);
|
|
|
|
|
if (list.Count != request.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
var result = flowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 审核完成回调
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditCallbackAsync(FlowCallback callback)
|
|
|
|
|
{
|
|
|
|
|
if (callback.Type != AuditType.InfoClient)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.NoAuditItems);
|
|
|
|
|
|
|
|
|
|
InfoClient infoClient = new()
|
|
|
|
|
{
|
|
|
|
|
Id = callback.BusinessId,
|
|
|
|
|
AuditNote = callback.RejectReason,
|
|
|
|
|
AuditTime = DateTime.Now,
|
|
|
|
|
AuditStatus = callback.FlowStatus == FlowStatusEnum.Approve ? AuditStatusEnum.Approve : AuditStatusEnum.Reject,
|
|
|
|
|
Status = callback.FlowStatus == FlowStatusEnum.Approve ? 0 : 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int rows = await TenantDb.Updateable(infoClient).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.AuditNote,
|
|
|
|
|
x.AuditTime,
|
|
|
|
|
x.AuditStatus,
|
|
|
|
|
x.Status
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 撤销审核
|
|
|
|
@ -85,10 +138,10 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(IdModel idModel)
|
|
|
|
|
{
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: idModel.Ids);
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
if (list.Count != idModel.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
|
|
|
|
|
|
|
|
|
|
var result = await flowService.Value.WithdrawFlowInstanceAsync(idModel.Ids);
|
|
|
|
|
var result = await flowService.Value.WithdrawAsync(idModel.Ids);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
@ -132,8 +185,12 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult EditClientInfo(ClientInfoReq req)
|
|
|
|
|
public async Task<DataResult> EditClientInfoAsync(ClientInfoReq req)
|
|
|
|
|
{
|
|
|
|
|
var data = req.Adapt<InfoClient>();
|
|
|
|
|
data.Status = (int)StatusEnum.Disable;
|
|
|
|
|
data.AuditStatus = AuditStatusEnum.NoAudit;
|
|
|
|
|
|
|
|
|
|
if (req.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
if (TenantDb.Queryable<InfoClient>().Where(x => (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
|
|
|
|
@ -141,8 +198,6 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
return DataResult.Failed("客户信息已存在,请检查客户全称、简称或社会信用代码是否重复!", MultiLanguageConst.ClientInfoExist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = req.Adapt<InfoClient>();
|
|
|
|
|
data.AuditStatus = AuditStatusEnum.NoAudit;
|
|
|
|
|
var tag = req.ClientTag.Adapt<InfoClientTag>();
|
|
|
|
|
//助记码
|
|
|
|
|
data.CodeName = PinYinUtil.GetFristLetter(req.ShortName);
|
|
|
|
@ -153,20 +208,27 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var info = TenantDb.Queryable<InfoClient>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
var tag = TenantDb.Queryable<InfoClientTag>().Where(x => x.ClientId == req.Id).First();
|
|
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
var model = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == req.Id).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Status,
|
|
|
|
|
x.AuditStatus
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
if (model != null && model.AuditStatus == AuditStatusEnum.Auditing)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.ItemsAreAuditing);
|
|
|
|
|
|
|
|
|
|
if (TenantDb.Queryable<InfoClient>().Where(x => x.Id != info.Id && (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
|
|
|
|
|
var tag = TenantDb.Queryable<InfoClientTag>().Where(x => x.ClientId == req.Id).First();
|
|
|
|
|
if (TenantDb.Queryable<InfoClient>().Where(x => x.Id != data.Id && (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("请检查客户全称、简称或社会信用代码是否重复!", MultiLanguageConst.ClientInfoExist);
|
|
|
|
|
}
|
|
|
|
|
//助记码
|
|
|
|
|
info.CodeName = PinYinUtil.GetFristLetter(info.ShortName);
|
|
|
|
|
data.CodeName = PinYinUtil.GetFristLetter(data.ShortName);
|
|
|
|
|
tag = req.ClientTag.Adapt(tag);
|
|
|
|
|
|
|
|
|
|
TenantDb.Updateable(info).RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}").IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
|
|
|
|
|
TenantDb.Updateable(data).RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}")
|
|
|
|
|
.IgnoreColumns(ignoreAllNullColumns: true)
|
|
|
|
|
.IgnoreColumns(x => new { x.Status, x.AuditStatus })
|
|
|
|
|
.EnableDiffLogEvent().ExecuteCommand();
|
|
|
|
|
TenantDb.Updateable(tag).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//创建或更新发票抬头
|
|
|
|
@ -279,30 +341,6 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 客户合并
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="request"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//public async Task<DataResult> MergeAsync(ClientMergeRequest request)
|
|
|
|
|
//{
|
|
|
|
|
// await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
// return DataResult.Success;
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
// await ex.LogAsync(Db);
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取往来单位详情(含有联系人列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|