diff --git a/ds-wms-service/DS.WMS.Core/Fee/Dtos/FeeReimbursementDto.cs b/ds-wms-service/DS.WMS.Core/Fee/Dtos/FeeReimbursementDto.cs index aa3715d1..be1dbb08 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Dtos/FeeReimbursementDto.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Dtos/FeeReimbursementDto.cs @@ -1,5 +1,6 @@ using DS.Module.Core.Enums; using DS.WMS.Core.Fee.Entity; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; @@ -124,33 +125,34 @@ namespace DS.WMS.Core.Fee.Dtos /// public long InfoClientBankId { get; set; } + #region 与用户报销银行卡Id 二选一 + /// + /// 收款人名称 + /// + public string PayeeName { get; set; } + + /// + /// 银行代码 + /// + public string CodeName { get; set; } + /// + /// 币别 + /// + public string Currency { get; set; } - ///// - ///// 收款人名称 - ///// - //public string PayeeName { get; set; } - - ///// - ///// 银行代码 - ///// - //public string CodeName { get; set; } - ///// - ///// 币别 - ///// - //public string Currency { get; set; } - - ///// - ///// 银行名称(例如农业银行) - ///// - //public string BankName { get; set; } - ///// - ///// 银行账户(开户行) - ///// - //public string Account { get; set; } - ///// - ///// 银行账号(卡号) - ///// - //public string BankAccountNo { get; set; } + /// + /// 银行名称(例如农业银行) + /// + public string BankName { get; set; } + /// + /// 开户行 + /// + public string Account { get; set; } + /// + /// 银行账号(卡号) + /// + public string BankAccountNo { get; set; } + #endregion /// /// 费用类别 @@ -499,6 +501,31 @@ namespace DS.WMS.Core.Fee.Dtos } + /// + /// 审批任务开始、结束、取消 + /// + public class bpms_task_changeModel + { + public string EventType { get; set; } + public long EventTime { get; set; } + public string CorpId { get; set; } + public string BizId { get; set; } + public string eventId { get; set; } + public string result { get; set; } + public string processInstanceId { get; set; } + public long finishTime { get; set; } + public long createTime { get; set; } + public string processCode { get; set; } + public string bizCategoryId { get; set; } + public string businessId { get; set; } + public string remark { get; set; } + public string type { get; set; } + public string title { get; set; } + public long taskId { get; set; } + public string staffId { get; set; } + } + + /// /// 审批实例开始,结束 /// @@ -608,7 +635,7 @@ namespace DS.WMS.Core.Fee.Dtos } - + public class FormComponentValuesList { public Rowvalue[] rowValue { get; set; } @@ -624,4 +651,37 @@ namespace DS.WMS.Core.Fee.Dtos public bool mask { get; set; } } + + public class FormRootObject + { + [JsonProperty("rowValue")] + public List RowValue { get; set; } + + [JsonProperty("rowNumber")] + public string RowNumber { get; set; } + } + + public class RowValue + { + [JsonProperty("label")] + public string Label { get; set; } + + [JsonProperty("extendValue")] + public ExtendValue ExtendValue { get; set; } + + [JsonProperty("value")] + public string Value { get; set; } + + [JsonProperty("key")] + public string Key { get; set; } + } + + public class ExtendValue + { + [JsonProperty("label")] + public string Label { get; set; } + + [JsonProperty("key")] + public string Key { get; set; } + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/DingCallBack.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/DingCallBack.cs index fca819c6..4df26fee 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/DingCallBack.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/DingCallBack.cs @@ -1,20 +1,15 @@ -using DS.Module.Core.Enums; +using DS.Module.Core; +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 { @@ -23,10 +18,12 @@ namespace DS.WMS.Core.Fee.Method private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; - public DingCallBack(IServiceProvider serviceProvider) + readonly IReimbursementService _service; + public DingCallBack(IServiceProvider serviceProvider, IReimbursementService service) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); + _service = service; } @@ -82,12 +79,41 @@ namespace DS.WMS.Core.Fee.Method var approveModel = JsonConvert.DeserializeObject(decryptMsg); var type = approveModel.EventType; + var token = DingDing.GetDingToken(dinginfo.AppKey, dinginfo.AppSecret); switch (type) { //审批任务开始,结束,转交。 case "bpms_task_change": - //logger.Log("审批回调:" + JsonConvert.SerializeObject(model), "实例回调日志"); - // 测试回调 + var datamodelinfo = JsonConvert.DeserializeObject(decryptMsg); + //获取实例 + + var info = DingDing.processInstances(token, datamodelinfo.processInstanceId); + + //解析获取到的数据,添加到数据库 + ReimbursementReq req = new ReimbursementReq(); + req.PayeeName = info.FormComponentValues.Where(t => t.Name == "收款人姓名").Select(t => t.Value).FirstOrDefault() ?? "";//收款人姓名 + req.BankName = info.FormComponentValues.Where(t => t.Name == "银行名称").Select(t => t.Value).FirstOrDefault() ?? "";//银行名称 + req.Account = info.FormComponentValues.Where(t => t.Name == "开户行").Select(t => t.Value).FirstOrDefault() ?? ""; //开户行 + req.BankName = info.FormComponentValues.Where(t => t.Name == "所属银行").Select(t => t.Value).FirstOrDefault() ?? ""; //银行名称 + req.ExpenseCategory = info.FormComponentValues.Where(t => t.Name == "费用类别").Select(t => t.Value).FirstOrDefault() ?? ""; //费用类别 + req.Reason = info.FormComponentValues.Where(t => t.Name == "报销事由").Select(t => t.Value).FirstOrDefault() ?? ""; //事由 + req.BankAccountNo = info.FormComponentValues.Where(t => t.Name == "收款人卡号").Select(t => t.Value).FirstOrDefault() ?? ""; //收款人卡号 + req.Data = new List(); + var dt = info.FormComponentValues.Where(t => t.Name == "费用明细").Select(t => t.Value).FirstOrDefault() ?? "";//费用明细 + //var dtinfo = JsonConvert.DeserializeObject>>(dt); + var result = JsonConvert.DeserializeObject>(dt); + foreach (var formitem in result) + { + ReimbursementReqData reimbursementReqData = new ReimbursementReqData(); + reimbursementReqData.InvoiceNumber = formitem.RowValue[0].Value.Split(":").LastOrDefault(); + reimbursementReqData.Amount = Convert.ToDecimal(formitem.RowValue[0].Value.Split(";")[0].Split(":")[1]); + req.Data.Add(reimbursementReqData); + + } + _service.AddReimbursement(req); + //保存后调用工作流 + SubmitReimbursementReq rt=new SubmitReimbursementReq() { Id = req.Id }; + _service.SubmitReimbursement(rt); break; //审批实例开始,结束。 @@ -100,7 +126,7 @@ namespace DS.WMS.Core.Fee.Method 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.Name == "费用明细").First(); @@ -130,6 +156,7 @@ namespace DS.WMS.Core.Fee.Method ininvoice.BusinessId = processInstanceinfo.Body.Result.BusinessId; //ininvoice.ProcessInstanceId = processInstanceinfo.Body.Result.AttachedProcessInstanceIds tenantDb.Updateable(ininvoice).ExecuteCommand(); + break; //审批中 @@ -203,5 +230,8 @@ namespace DS.WMS.Core.Fee.Method } return new Dictionary(); } + + + } } diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/DingDing.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/DingDing.cs index 67a7a500..385d465a 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/DingDing.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/DingDing.cs @@ -118,26 +118,7 @@ namespace DS.WMS.Core.Fee.Method }; #endregion - - #region 项目名称 - FormComponent xmmc = new FormComponent - { - ComponentType = "TextField", - Props = new FormComponentProps - { - ComponentId = "TextField-abcd", // 控件id,表单内唯一,与bizAlias二选一 - Required = false, // 控件是否必填 - Label = "项目名称", // 控件标题 - Placeholder = "请输入",// 输入提示 - - Print = "1",//是否参与打印 - Disabled = false, //是否可编辑 - - } - - }; - - #endregion + #region 费用明细 @@ -217,15 +198,14 @@ namespace DS.WMS.Core.Fee.Method #region 自动计算金额 FormComponent xmmcA = new FormComponent { - ComponentType = "CalculateField", + ComponentType = "MoneyField", Props = new FormComponentProps { ComponentId = "MoneyField_1JZJIQ", // 控件id,表单内唯一,与bizAlias二选一 Required = false, // 控件是否必填 Label = "总金额(元)", // 控件标题 Placeholder = "费用明细合计金额",// 输入提示 - - Formula = "[{\"id\":\"MoneyField-mxje\"}]" + } }; #endregion @@ -430,8 +410,7 @@ namespace DS.WMS.Core.Fee.Method } return new GetProcessInstanceResponse(); } - - + /// /// 获取钉钉报销审批列表 /// @@ -532,8 +511,7 @@ namespace DS.WMS.Core.Fee.Method } } } - - + /// /// 提交钉钉OA审批实例 /// @@ -551,18 +529,13 @@ namespace DS.WMS.Core.Fee.Method Name = "费用类别", Value = model.fylb, }; - - string form_name_values = "[[{\"name\":\"费用明细\",\"value\":\"测试1\"},{\"name\":\"金额(元)\",\"value\":\"1000\"}]," + - "[{\"name\":\"费用明细\",\"value\":\"彩色3\"},{\"name\":\"金额(元)\",\"value\":\"395.05\"}]]"; - - + StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues fymx = new StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues { Name = "费用明细", //ComponentType = "TableField", Value = JsonConvert.SerializeObject( model.fymx), - }; StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues je = new StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues { @@ -649,9 +622,7 @@ namespace DS.WMS.Core.Fee.Method } return ""; } - - - + /// /// 同意或拒绝审批实例 /// @@ -660,8 +631,7 @@ namespace DS.WMS.Core.Fee.Method AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClient(); ExecuteProcessInstanceHeaders executeProcessInstanceHeaders = new ExecuteProcessInstanceHeaders(); executeProcessInstanceHeaders.XAcsDingtalkAccessToken = token; - - + ExecuteProcessInstanceRequest executeProcessInstanceRequest = new ExecuteProcessInstanceRequest { ProcessInstanceId = process_instance_id, diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeReimbursementService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeReimbursementService.cs index 7588abd4..8cecb50d 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeReimbursementService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeReimbursementService.cs @@ -1,9 +1,7 @@ -using AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models; -using AngleSharp.Dom; +using AngleSharp.Dom; using DS.Module.Core; using DS.Module.Core.Enums; using DS.Module.Core.Extensions; -using DS.Module.Core.Helpers; using DS.Module.SqlSugar; using DS.Module.UserModule; using DS.WMS.Core.Code.Entity; @@ -13,28 +11,17 @@ using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Interface; using DS.WMS.Core.Info.Entity; -using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.QuarztJobs.Other; using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Interface; -using DS.WMS.Core.Sys.Method; using DS.WMS.Core.TaskInteraction.Dtos; using DS.WMS.Core.TaskInteraction.Interface; -using DS.WMS.Core.TaskPlat.Dtos; -using DS.WMS.Core.TaskPlat.Entity; -using LanguageExt.Common; -using LanguageExt.Pipes; using Mapster; -using Masuit.Tools.Database; -using Masuit.Tools.Hardware; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using NLog; -using NPOI.POIFS.Crypt.Dsig; -using NPOI.SS.Formula.Functions; using SqlSugar; -using static AnyDiff.DifferenceLines; namespace DS.WMS.Core.Fee.Method { @@ -107,19 +94,55 @@ namespace DS.WMS.Core.Fee.Method return DataResult.Failed($"报销单状态不为未提交,不可修改"); } - var bank = tenantDb.Queryable().Where(t => t.Id == req.InfoClientBankId).First(); - - if (bank == null) return DataResult.Failed($"报销银行账户信息未找到"); var data = req.Adapt(); - data.PayeeName = user.UserName; - data.CodeName = bank.CodeName; - data.Currency = bank.Currency; - data.BankName = bank.BankName; - data.Account = bank.Account; - data.BankAccountNo = bank.BankAccountNo; + //如果银行卡Id不为空,则取银行卡信息给收款人 + if (req.InfoClientBankId != null&& req.InfoClientBankId > 0) + { + var bank = tenantDb.Queryable().Where(t => t.Id == req.InfoClientBankId).First(); + + if (bank == null) return DataResult.Failed($"报销银行账户信息未找到"); + + data.CodeName = bank.CodeName; + data.Currency = bank.Currency; + data.BankName = bank.BankName; + data.Account = bank.Account; + data.BankAccountNo = bank.BankAccountNo; + + + } + else + { + //如果银行卡id信息为空,则使用传过来的收款人信息,用于钉钉 + if (string.IsNullOrEmpty(req.PayeeName)) + { + return DataResult.Failed($"InfoClientBankId为空时,收款人名称不可为空"); + } + else if (string.IsNullOrEmpty(req.BankName)) + { + return DataResult.Failed($"InfoClientBankId为空时,银行名称不可为空"); + } + else if (string.IsNullOrEmpty(req.Account)) + { + return DataResult.Failed($"InfoClientBankId为空时,开户行不可为空"); + } + else if (string.IsNullOrEmpty(req.BankAccountNo)) + { + return DataResult.Failed($"InfoClientBankId为空时,卡号不可为空"); + } + + data.CodeName = req.CodeName; + data.Currency = "RMB"; + data.BankName = req.BankName; + data.Account = req.Account; + data.BankAccountNo = req.BankAccountNo; + + } + + data.PayeeName = user.UserName; + data.UserId = user.UserId; data.ReimbursementType = ReimbursementTypeEnums.NotSubmitted; data.Reimburser = user.UserName; @@ -207,13 +230,53 @@ namespace DS.WMS.Core.Fee.Method var data = req.Adapt(); + + //如果银行卡Id不为空,则取银行卡信息给收款人 + if (req.InfoClientBankId != null && req.InfoClientBankId > 0) + { + bank = tenantDb.Queryable().Where(t => t.Id == req.InfoClientBankId).First(); + if (bank == null) return DataResult.Failed($"报销银行账户信息未找到"); + + data.CodeName = bank.CodeName; + data.Currency = bank.Currency; + data.BankName = bank.BankName; + data.Account = bank.Account; + data.BankAccountNo = bank.BankAccountNo; + } + else + { + //如果银行卡id信息为空,则使用传过来的收款人信息,用于钉钉 + if (string.IsNullOrEmpty(req.PayeeName)) + { + return DataResult.Failed($"InfoClientBankId为空时,收款人名称不可为空"); + } + else if (string.IsNullOrEmpty(req.BankName)) + { + return DataResult.Failed($"InfoClientBankId为空时,银行名称不可为空"); + } + else if (string.IsNullOrEmpty(req.Account)) + { + return DataResult.Failed($"InfoClientBankId为空时,开户行不可为空"); + } + else if (string.IsNullOrEmpty(req.BankAccountNo)) + { + return DataResult.Failed($"InfoClientBankId为空时,卡号不可为空"); + } + + data.CodeName = req.CodeName; + data.Currency = "RMB"; + data.BankName = req.BankName; + data.Account = req.Account; + data.BankAccountNo = req.BankAccountNo; + } + data.InfoClientBankId = req.InfoClientBankId; data.PayeeName = user.UserName; - data.CodeName = bank.CodeName; - data.Currency = bank.Currency; - data.BankName = bank.BankName; - data.Account = bank.Account; - data.BankAccountNo = bank.BankAccountNo; + //data.CodeName = bank.CodeName; + //data.Currency = bank.Currency; + //data.BankName = bank.BankName; + //data.Account = bank.Account; + //data.BankAccountNo = bank.BankAccountNo; data.ExpenseCategory = req.ExpenseCategory; data.UserId = user.UserId; data.ReimbursementType = ReimbursementTypeEnums.NotSubmitted; @@ -235,11 +298,8 @@ namespace DS.WMS.Core.Fee.Method inviceinfo.ReimbursementType = ReimbursementTypeEnums.UnderReview; tenantDb.Updateable(inviceinfo).ExecuteCommand(); } - return DataResult.Successed("添加成功!", info.Id, MultiLanguageConst.DataCreateSuccess); } - - return await Task.FromResult(DataResult.Successed("操作成功")); }