jianghaiqing 2 weeks ago
commit 0117b631fc

@ -441,5 +441,90 @@ namespace DS.WMS.Core.Fee.Dtos
} }
#endregion #endregion
public class DingCallBackInput
{
public string encrypt { get; set; }
}
public class ApprovalInstanceModel
{
public string EventType { get; set; }
public long TimeStamp { get; set; }
public string[] UserId { get; set; }
public string CorpId { get; set; }
public string processInstanceId { get; set; }
public string corpId { get; set; }
public long createTime { get; set; }
public string title { get; set; }
public string type { get; set; }
public string staffId { get; set; }
public string url { get; set; }
public string processCode { get; set; }
public string result { get; set; }
}
/// <summary>
/// 审批实例开始,结束
/// </summary>
public class bpms_instance_changeCallBack
{
/// <summary>
/// 事件类型
/// </summary>
public string EventType { get; set; }
/// <summary>
/// 审批实例id
/// </summary>
public string processInstanceId { get; set; }
/// <summary>
/// 审批实例所在的企业corpId。
/// </summary>
public string corpId { get; set; }
/// <summary>
/// 创建审批实例时间。时间戳,单位毫秒。
/// </summary>
public long createTime { get; set; }
/// <summary>
/// 审批实例标题。
/// </summary>
public string title { get; set; }
/// <summary>
/// 类型type为start表示审批实例开始。
/// </summary>
public string type { get; set; }
/// <summary>
/// 发起审批实例的员工userId。
/// </summary>
public string staffId { get; set; }
/// <summary>
/// 审批实例url可在钉钉内跳转到审批页面。
/// </summary>
public string url { get; set; }
/// <summary>
/// 审批模板的唯一码。
/// </summary>
public string processCode { get; set; }
/// <summary>
/// 正常结束时result为agree拒绝时result为refuse审批终止时没这个值。
/// </summary>
public string result { get; set; }
}
public class fromExtValue
{
public string label { get; set; }
public string key { get; set; }
}
} }

@ -161,10 +161,7 @@ namespace DS.WMS.Core.Fee.Entity
/// </summary> /// </summary>
public string? SpecialElements { get; set; } public string? SpecialElements { get; set; }
/// <summary>
/// 报销状态 bxzt
/// </summary>
public ReimbursementTypeEnums ReimbursementType { get; set; }
/// <summary> /// <summary>
/// 购方银行账号 gfyhzh /// 购方银行账号 gfyhzh
@ -301,6 +298,17 @@ namespace DS.WMS.Core.Fee.Entity
/// </summary> /// </summary>
public long OrgId { get; set; } public long OrgId { get; set; }
/// <summary>
/// 报销状态 bxzt
/// </summary>
public ReimbursementTypeEnums ReimbursementType { get; set; }
/// <summary>
/// 钉钉报销审批单编号
/// </summary>
public string BusinessId { get; set; }
//钉钉审批实例Id
public string ProcessInstanceId { get; set; }
} }
} }

@ -0,0 +1,15 @@
using DS.WMS.Core.Fee.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Fee.Interface
{
public interface IDingCallBackService
{
Dictionary<string, string> CallBack(DingCallBackInput model, string corpId, string signature, string timestamp, string nonce);
}
}

@ -78,5 +78,7 @@ namespace DS.WMS.Core.Fee.Interface
/// <param name="Id">报销单Id</param> /// <param name="Id">报销单Id</param>
/// <returns></returns> /// <returns></returns>
Task<DataResult> BankPayment(long Id); Task<DataResult> BankPayment(long Id);
} }
} }

@ -0,0 +1,181 @@
using DS.Module.Core.Enums;
using DS.Module.Core.Helpers;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NLog;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Fee.Method
{
public class DingCallBack: IDingCallBackService
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
public DingCallBack(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
}
/// <summary>
/// 钉钉回调
/// </summary>
/// <param name="model"></param>
/// <param name="corpId"></param>
/// <param name="signature"></param>
/// <param name="timestamp"></param>
/// <param name="nonce"></param>
/// <returns></returns>
public Dictionary<string, string> CallBack(DingCallBackInput model, string corpId, string signature, string timestamp, string nonce)
{
string strlog = $"钉钉回调,参数{JsonConvert.SerializeObject(model)},参数{corpId},参数{signature},参数{timestamp},参数{nonce}";
//Logger.Log(LogLevel.Info, strlog);
_logger.Info(strlog);
//查询所有租户的数据库连接
var dbLinkList = db.Queryable<Module.SqlSugar.SysTenantLink>().ClearFilter().ToList();
foreach (var item in dbLinkList)
{
SqlSugarClient? tenantDb = null;
tenantDb = new SqlSugarClient(new ConnectionConfig
{
ConfigId = item.Id,
ConnectionString = item.Connection,
DbType = item.DbType,
IsAutoCloseConnection = true
});
//对应的钉钉key
var dinginfo = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.AppKey == corpId && t.Deleted == false && t.AccountType == "DingConfig").First();
if (dinginfo == null)
{
continue;
}
//对应的钉钉回调key
var DingEvent = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.ApiOrgId == dinginfo.ApiOrgId && t.AccountType == "DingEvent" && t.Deleted == false).First();
//对应的钉钉审批模板
var DingProcessCode = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.ApiOrgId == dinginfo.ApiOrgId && t.AccountType == "DingProcessCode" && t.Deleted == false).First();
DingTalkEncryptor callbackCrypto = new DingTalkEncryptor( DingEvent.AppSecret, DingEvent.AppKey, corpId);
string decryptMsg = callbackCrypto.getDecryptMsg(signature, timestamp, nonce, model.encrypt);
string msg = "success";
// 3. 反序列化回调事件json数据
var approveModel = JsonConvert.DeserializeObject<ApprovalInstanceModel>(decryptMsg);
var type = approveModel.EventType;
switch (type)
{
//审批任务开始,结束,转交。
case "bpms_task_change":
//logger.Log("审批回调:" + JsonConvert.SerializeObject(model), "实例回调日志");
// 测试回调
break;
//审批实例开始,结束。
case "bpms_instance_change":
// 实例改变
var datamodel = JsonConvert.DeserializeObject<bpms_instance_changeCallBack>(decryptMsg);
//审批实例开始,将进项发票设为正在审批中
if (datamodel.processCode == DingProcessCode.AppKey)
{
//获取审批实例详细信息
var token = DingDing.GetDingToken(dinginfo.AppKey, dinginfo.AppSecret);
var processInstanceinfo = DingDing.GetProcessInstanceWithOptions(datamodel.processInstanceId, token);
var forminfo = processInstanceinfo.Body.Result.FormComponentValues.Where(t => t.Id == "DDSelectField-fymx").First();
var formext = JsonConvert.DeserializeObject<fromExtValue>(forminfo.ExtValue);
var ininvoice = db.Queryable<InInvoice>().ClearFilter().Where(t => t.InvoiceNumber == formext.key).First();
switch (processInstanceinfo.Body.Result.Status)
{
//新创建
case "NEW":
//将发票设置为正在使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.UnderReview;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
//ininvoice.ProcessInstanceId = processInstanceinfo.Body.Result.AttachedProcessInstanceIds
db.Updateable(ininvoice).ExecuteCommand();
break;
//审批中
case "RUNNING":
//将发票设置为正在使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.UnderReview;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
db.Updateable(ininvoice).ExecuteCommand();
break;
//被终止
case "TERMINATED":
//将发票设置为未使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
db.Updateable(ininvoice).ExecuteCommand();
break;
//完成
case "COMPLETED":
//判断是通过还是驳回
if (processInstanceinfo.Body.Result.Result == "agree")
{
//如果是同意 将发票设为已使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.Approved;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
db.Updateable(ininvoice).ExecuteCommand();
//获取对应的组织机构的发票列表
var ininviceList = tenantDb.Queryable<InInvoice>().Where(x => x.ReimbursementType == ReimbursementTypeEnums.NotSubmitted && x.OrgId == dinginfo.ApiOrgId).ToList();
var dictlist = db.Queryable<SysDictData>().LeftJoin<SysDictType>((d, t) => d.TypeId == t.Id).Where((d, t) => t.Code == "Reimbursement_Expense_Ategory").OrderBy(d => d.OrderNo).ToList();
//更新审批模板
DingDing.UpDingOAForm(token, DingProcessCode.AppKey, ininviceList, dictlist);
}
if (processInstanceinfo.Body.Result.Result == "refuse")
{
//如果是拒绝 将发票设为未使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
db.Updateable(ininvoice).ExecuteCommand();
}
break;
//取消
case "CANCELED":
//将发票设置为未使用
ininvoice.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId;
db.Updateable(ininvoice).ExecuteCommand();
break;
default:
break;
}
}
break;
}
var rspMsg = callbackCrypto.getEncryptedMap(msg);
_logger.Info($"钉钉回调接口返回{JsonConvert.SerializeObject(rspMsg)}");
return rspMsg;
}
return new Dictionary<string, string>();
}
}
}

@ -18,6 +18,25 @@ namespace DS.WMS.Core.Fee.Method
{ {
public class DingDing public class DingDing
{ {
/**
* 使 Token Client
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client CreateClient1()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client(config);
}
public static AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client CreateClient()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client(config);
}
/// <summary> /// <summary>
/// 获取token /// 获取token
@ -129,6 +148,21 @@ namespace DS.WMS.Core.Fee.Method
selectOptions.Add(st); selectOptions.Add(st);
} }
//明细金额
FormComponent mxje = new FormComponent
{
ComponentType = "MoneyField",
Props = new FormComponentProps
{
ComponentId = "MoneyField-mxje", // 控件id表单内唯一与bizAlias二选一
Required = false, // 控件是否必填
Label = "金额(元)", // 控件标题
Placeholder = "请输入", // 输入提示
Print = "1",//是否参与打印
}
};
FormComponent fymx = new FormComponent FormComponent fymx = new FormComponent
{ {
ComponentType = "DDSelectField", ComponentType = "DDSelectField",
@ -145,11 +179,10 @@ namespace DS.WMS.Core.Fee.Method
} }
}; };
FormComponent fymxList = new FormComponent FormComponent fymxList = new FormComponent
{ {
ComponentType = "TableField", ComponentType = "TableField",
Children = new List<FormComponent> { fymx }, Children = new List<FormComponent> { fymx, mxje },
Props = new FormComponentProps Props = new FormComponentProps
{ {
@ -160,21 +193,41 @@ namespace DS.WMS.Core.Fee.Method
#endregion #endregion
#region 金额 #region 金额
//FormComponent xmmcA = new FormComponent
//{
// ComponentType = "MoneyField",
// Props = new FormComponentProps
// {
// ComponentId = "MoneyField_1JZJIQ", // 控件id表单内唯一与bizAlias二选一
// Required = true, // 控件是否必填
// Label = "金额(元)", // 控件标题
// Placeholder = "请输入金额",// 输入提示
// Print = "1",//是否参与打印
// Disabled = false, //是否可编辑
// }
//};
#endregion
#region 自动计算金额
FormComponent xmmcA = new FormComponent FormComponent xmmcA = new FormComponent
{ {
ComponentType = "MoneyField", ComponentType = "CalculateField",
Props = new FormComponentProps Props = new FormComponentProps
{ {
ComponentId = "MoneyField_1JZJIQ", // 控件id表单内唯一与bizAlias二选一 ComponentId = "MoneyField_1JZJIQ", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填 Required = true, // 控件是否必填
Label = "金额(元)", // 控件标题 Label = "金额(元)", // 控件标题
Placeholder = "请输入金额",// 输入提示 Placeholder = "费用明细合计金额",// 输入提示
Print = "1",//是否参与打印
Disabled = false, //是否可编辑 Formula = "[{\"id\":\"MoneyField-mxje\"}]"
} }
}; };
#endregion #endregion
#region 收款账户 #region 收款账户
FormComponent skzh = new FormComponent FormComponent skzh = new FormComponent
{ {
@ -209,11 +262,11 @@ namespace DS.WMS.Core.Fee.Method
FormComponent bxsy = new FormComponent FormComponent bxsy = new FormComponent
{ {
ComponentType = "TextField", ComponentType = "TextareaField",
Props = new FormComponentProps Props = new FormComponentProps
{ {
ComponentId = "TextField-bxsy", // 控件id表单内唯一与bizAlias二选一 ComponentId = "TextareaField-bxsy", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填 Required = true, // 控件是否必填
Label = "报销事由", // 控件标题 Label = "报销事由", // 控件标题
Placeholder = "请输入",// 输入提示 Placeholder = "请输入",// 输入提示
@ -225,6 +278,69 @@ namespace DS.WMS.Core.Fee.Method
}; };
#endregion #endregion
#region 收款人姓名
FormComponent skrxm = new FormComponent
{
ComponentType = "TextField",
Props = new FormComponentProps
{
ComponentId = "TextField-skrxm", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填
Label = "收款人姓名", // 控件标题
Placeholder = "请输入",// 输入提示
Print = "1",//是否参与打印
Disabled = false, //是否可编辑
}
};
#endregion
#region 收款人卡号
FormComponent skrkh = new FormComponent
{
ComponentType = "TextField",
Props = new FormComponentProps
{
ComponentId = "TextField-skrkh", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填
Label = "收款人卡号", // 控件标题
Placeholder = "请输入",// 输入提示
Print = "1",//是否参与打印
Disabled = false, //是否可编辑
}
};
#endregion
#region 所属银行
FormComponent ssyh = new FormComponent
{
ComponentType = "TextField",
Props = new FormComponentProps
{
ComponentId = "TextField-ssyh", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填
Label = "所属银行", // 控件标题
Placeholder = "(例如)青岛银行",// 输入提示
Print = "1",//是否参与打印
Disabled = false, //是否可编辑
}
};
#endregion
#region 开户行
FormComponent khh = new FormComponent
{
ComponentType = "TextField",
Props = new FormComponentProps
{
ComponentId = "TextField-khh", // 控件id表单内唯一与bizAlias二选一
Required = true, // 控件是否必填
Label = "开户行", // 控件标题
Placeholder = "请输入",// 输入提示
Print = "1",//是否参与打印
Disabled = false, //是否可编辑
}
};
#endregion
FormCreateRequest formCreateRequest = new FormCreateRequest FormCreateRequest formCreateRequest = new FormCreateRequest
{ {
@ -234,11 +350,17 @@ namespace DS.WMS.Core.Fee.Method
FormComponents = new List<FormComponent> FormComponents = new List<FormComponent>
{ {
fylx,//费用类别 fylx,//费用类别
xmmc,//项目名称 //xmmc,//项目名称
fymxList,//费用明细 fymxList,//费用明细
xmmcA,//金额 xmmcA,//金额
skzh,//收款账户 //skzh,//收款账户
bxsy,//报销事由 bxsy,//报销事由
skrxm,//收款人姓名
skrkh,//收款人银行卡号
ssyh,//所属银行
khh,//收款人银行开户行
//glspd //关联审批单 //glspd //关联审批单
}, },
}; };
@ -266,28 +388,6 @@ namespace DS.WMS.Core.Fee.Method
} }
} }
/**
* 使 Token Client
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client CreateClient1()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client(config);
}
public static AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client CreateClient()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client(config);
}
/// <summary> /// <summary>
/// 获取审批实例详情 /// 获取审批实例详情
/// </summary> /// </summary>

@ -2,8 +2,10 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Enums; using DS.Module.Core.Enums;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
@ -25,6 +27,7 @@ using Masuit.Tools.Database;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using SqlSugar; using SqlSugar;
using static AnyDiff.DifferenceLines; using static AnyDiff.DifferenceLines;
@ -45,6 +48,7 @@ namespace DS.WMS.Core.Fee.Method
readonly IAuditTaskService taskService; readonly IAuditTaskService taskService;
Lazy<IClientFlowInstanceService> flowService; Lazy<IClientFlowInstanceService> flowService;
private readonly ICommonService commonService; private readonly ICommonService commonService;
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
/// <summary> /// <summary>
/// ///
@ -161,8 +165,6 @@ namespace DS.WMS.Core.Fee.Method
} }
} }
//新增 //新增
else else
@ -784,8 +786,10 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> GetSample() public async Task<DataResult> GetSample()
{ {
var dingconfig = db.Queryable<SysOrgAuth>().Where(t => t.Type == "DingConfig" && t.OrgId == user.OrgId).First(); //var dingconfig = db.Queryable<SysOrgAuth>().Where(t => t.Type == "DingConfig" && t.OrgId == user.OrgId).First();
var token = DingDing.GetDingToken(dingconfig.Key, dingconfig.Secret); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var dingconfig = await tenantDb.Queryable<CodeThirdParty>().Where(t => t.AccountType == "DingConfig" && t.ApiOrgId == user.OrgId).FirstAsync();
var token = DingDing.GetDingToken(dingconfig.AppKey, dingconfig.AppSecret);
DingDing.GetSample("PROC-528BFFFF-00D1-4AF0-AB5F-7BFB89787994", token); DingDing.GetSample("PROC-528BFFFF-00D1-4AF0-AB5F-7BFB89787994", token);
return DataResult.Success; return DataResult.Success;
} }
@ -802,5 +806,7 @@ namespace DS.WMS.Core.Fee.Method
TransferAccounts(Id); TransferAccounts(Id);
return DataResult.Success; return DataResult.Success;
} }
} }
} }

@ -200,7 +200,7 @@ namespace DS.WMS.Core.QuarztJobs.Method
try try
{ {
#region 同步发票到钉钉审批 #region 同步发票到钉钉审批
var dingconfig = db.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.Deleted == false && t.AccountType == "DingConfig" && t.ApiOrgId == orgauth.ApiOrgId).First(); var dingconfig = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.Deleted == false && t.AccountType == "DingConfig" && t.ApiOrgId == orgauth.ApiOrgId).First();
if (dingconfig != null) if (dingconfig != null)
{ {
@ -210,9 +210,10 @@ namespace DS.WMS.Core.QuarztJobs.Method
var ininviceList = await tenantDb.Queryable<InInvoice>().Where(x => x.ReimbursementType == ReimbursementTypeEnums.NotSubmitted && x.OrgId == dingconfig.ApiOrgId).ToListAsync(); var ininviceList = await tenantDb.Queryable<InInvoice>().Where(x => x.ReimbursementType == ReimbursementTypeEnums.NotSubmitted && x.OrgId == dingconfig.ApiOrgId).ToListAsync();
//将发票信息同步更新到钉钉 //将发票信息同步更新到钉钉
var DingProcess = db.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.Deleted == false && t.AccountType == "DingProcessCode" && t.ApiOrgId == orgauth.ApiOrgId).First(); var DingProcess = tenantDb.Queryable<CodeThirdParty>().ClearFilter().Where(t => t.Deleted == false && t.AccountType == "DingProcessCode" && t.ApiOrgId == orgauth.ApiOrgId).First();
var dictlist = db.Queryable<SysDictData>().LeftJoin<SysDictType>((d, t) => d.TypeId == t.Id).Where((d, t) => t.Code == "Reimbursement_Expense_Ategory").OrderBy(d => d.OrderNo).ToList();
var dictlist = db.Queryable<SysDictData>().Where(t => t.Value == "Reimbursement_Expense_Ategory").ToList();
if (DingProcess != null) if (DingProcess != null)
{ {

@ -1,3 +1,4 @@
using Amazon.Runtime.Internal;
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Constants; using DS.Module.Core.Constants;
using DS.Module.Core.Data; using DS.Module.Core.Data;
@ -12,6 +13,7 @@ using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Dtos; using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
@ -958,6 +960,8 @@ public class ClientCommonService : IClientCommonService
public async Task<DataResult<List<ClientSelectRes>>> GetClientListByCode(string code = "", string queryKey = "") public async Task<DataResult<List<ClientSelectRes>>> GetClientListByCode(string code = "", string queryKey = "")
{ {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().ToListAsync();
var conditions = new List<IConditionalModel>(); var conditions = new List<IConditionalModel>();
var otherConditions = new List<IConditionalModel>(); var otherConditions = new List<IConditionalModel>();
var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt()); var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt());
@ -1013,11 +1017,10 @@ public class ClientCommonService : IClientCommonService
} }
) )
.ClearFilter<ISharedOrgId>().MergeTable() .ClearFilter<ISharedOrgId>().MergeTable()
//.Mapper(it => .Mapper(it =>
// { {
// //it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList(); it.ClientContact = contacts.FirstOrDefault(x => x.ClientId == it.Id);
})
// })
.OrderBy(x => x.CodeName).Distinct().Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync(); .OrderBy(x => x.CodeName).Distinct().Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess)); return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
} }
@ -1029,6 +1032,7 @@ public class ClientCommonService : IClientCommonService
public async Task<DataResult<List<ClientSelectRes>>> GetSupplierAndClientListByCode(string code = "", string queryKey = "") public async Task<DataResult<List<ClientSelectRes>>> GetSupplierAndClientListByCode(string code = "", string queryKey = "")
{ {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().ToListAsync();
var conditions = new List<IConditionalModel>(); var conditions = new List<IConditionalModel>();
var otherConditions = new List<IConditionalModel>(); var otherConditions = new List<IConditionalModel>();
var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt() && c.IsCustomer == true); var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt() && c.IsCustomer == true);
@ -1085,6 +1089,10 @@ public class ClientCommonService : IClientCommonService
} }
) )
.ClearFilter<ISharedOrgId>().MergeTable() .ClearFilter<ISharedOrgId>().MergeTable()
.Mapper(it =>
{
it.ClientContact = contacts.FirstOrDefault(x => x.ClientId == it.Id);
})
.OrderBy(x => x.CodeName).Distinct().Take(20).WithCache($"{SqlSugarCacheConst.AllClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync(); .OrderBy(x => x.CodeName).Distinct().Take(20).WithCache($"{SqlSugarCacheConst.AllClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
@ -1097,6 +1105,8 @@ public class ClientCommonService : IClientCommonService
public async Task<DataResult<List<ClientSelectRes>>> GetSupplierListByCode(string code = "", string queryKey = "") public async Task<DataResult<List<ClientSelectRes>>> GetSupplierListByCode(string code = "", string queryKey = "")
{ {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().ToListAsync();
//code = code.ToLower(); //code = code.ToLower();
var data = await tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>() var data = await tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>()
.Where((a) => a.Status == StatusEnum.Enable.ToEnumInt()) .Where((a) => a.Status == StatusEnum.Enable.ToEnumInt())
@ -1117,8 +1127,8 @@ public class ClientCommonService : IClientCommonService
.ClearFilter<ISharedOrgId>().MergeTable() .ClearFilter<ISharedOrgId>().MergeTable()
.Mapper(it => .Mapper(it =>
{ {
it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList(); //it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList();
it.ClientContact = contacts.FirstOrDefault(x => x.ClientId == it.Id);
}) })
.OrderBy(x => x.CodeName).Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync(); .OrderBy(x => x.CodeName).Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess)); return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));

@ -0,0 +1,43 @@
using Autofac.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
public class DingCallBackController : ApiController
{
readonly IDingCallBackService _service;
/// <summary>
/// 初始化
/// </summary>
/// <param name="service"></param>
public DingCallBackController(IDingCallBackService service)
{
_service = service;
}
/// <summary>
/// 钉钉回调
/// </summary>
/// <param name="model"></param>
/// <param name="corpId"></param>
/// <returns></returns>
[HttpPost("/feeApi/DingCallBack/{corpId}"), AllowAnonymous]
public Dictionary<string, string> CallBack(DingCallBackInput model, string corpId)
{
string signature = Request.Query["signature"];
string timestamp = Request.Query["timestamp"];
string nonce = Request.Query["nonce"];
return _service.CallBack(model, corpId, signature, timestamp, nonce);
}
}
}

@ -6,6 +6,7 @@ using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskPlat.Dtos; using DS.WMS.Core.TaskPlat.Dtos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
@ -20,6 +21,7 @@ namespace DS.WMS.FeeApi.Controllers
{ {
readonly IReimbursementService _service; readonly IReimbursementService _service;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
/// <summary> /// <summary>
/// 初始化 /// 初始化
/// </summary> /// </summary>
@ -157,15 +159,15 @@ namespace DS.WMS.FeeApi.Controllers
//} //}
///// <summary> /// <summary>
///// 获取审批模板 /// 获取审批模板
///// </summary> /// </summary>
///// <returns></returns> /// <returns></returns>
//[HttpPost, Route("GetSample")] [HttpPost, Route("GetSample")]
//public async Task<DataResult> GetSample() public async Task<DataResult> GetSample()
//{ {
// return await _service.GetSample(); return await _service.GetSample();
//} }

@ -27,7 +27,7 @@ public class JwtSafeMiddleware
//if(ignoreUrl.Split(",", StringSplitOptions.RemoveEmptyEntries).ToArray().Contains(path)) //if(ignoreUrl.Split(",", StringSplitOptions.RemoveEmptyEntries).ToArray().Contains(path))
if (path.Contains("swagger") || path.Contains("login") || path.Contains("tenantregister") || path.Contains("linkattach") || path.Contains("printtempfile") if (path.Contains("swagger") || path.Contains("login") || path.Contains("tenantregister") || path.Contains("linkattach") || path.Contains("printtempfile")
|| path.Contains("favicon") || path.Contains("clientuserlogin") || path.Contains("addbookingstatuslog") || path.Contains("createbctaskjob") || path.Contains("clientuserrefreshtoken") || path.Contains("favicon") || path.Contains("clientuserlogin") || path.Contains("addbookingstatuslog") || path.Contains("createbctaskjob") || path.Contains("clientuserrefreshtoken")
|| path.Contains("createtaskjob") || path.Contains("querybookingslot")) || path.Contains("createtaskjob") || path.Contains("querybookingslot") || path.Contains("dingcallback"))
{ {
//跳过swagger及login //跳过swagger及login
} }

Loading…
Cancel
Save