浏览代码

添加费用申请通知功能

在 `FinancialController.cs` 中,新增了向特定用户发送费用申请消息的功能,检查用户ID并调用通知方法。

在 `Library.cs` 中,新增 `SendUserMsg_CompanyShare_ToDailtPay` 异步方法,用于构建并发送费用申请通知,包括费用明细和申请信息。
Lyyyi 2 周之前
父节点
当前提交
23c6a67a34

+ 13 - 0
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -210,6 +210,19 @@ namespace OASystem.API.Controllers
 
                 var h5 = new PageParam_PriceAuditH5() { diid = "", uid = "21" };
                 await APNsTools.iOS_PushNotifications1("051", "日付费用审核", "", content, true, "ExpenseAuditWebView", h5);
+
+                //罗颖申请的费用发送通知
+                if (dto.UserId == 374)
+                {
+                    var qw_userIds = new List<string>() { 
+                        //"374", //罗颖
+                        "208", //雷怡
+                        "309", //赖红燕
+                    };
+
+                    //Todo:企微消息通知
+                    await AppNoticeLibrary.SendUserMsg_CompanyShare_ToDailtPay(dailyId, 374, qw_userIds);
+                }
             }
             catch (Exception ex)
             {

+ 66 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -1339,6 +1339,72 @@ DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
         }
         #endregion
 
+        #region 日服申请 
+        /// <summary>
+        /// 日服申请、编辑通知
+        /// 接收者:指定接收者
+        /// </summary>
+        /// <param name="dataId"></param>
+        /// <param name="operationId">操作人Id</param>
+        /// <param name="recipients">接收者Id集合</param>
+        /// <returns></returns>
+        public static async Task<bool> SendUserMsg_CompanyShare_ToDailtPay(int dataId, int operationId,List<string> recipients)
+        {
+            //企微通知
+            var userIds = recipients;
+
+            string operationName = _grpDeleRep._sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel 
+             == 0 && x.Id == operationId).CnName ?? "Unknown";
+
+            var dailyPaymentInfo = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePayment>()
+                .FirstAsync(x => x.IsDel == 0 && x.Id == dataId);
+
+            var details = await _grpDeleRep._sqlSugar.Queryable<Fin_DailyFeePaymentContent>()
+                .Where(x => x.IsDel == 0 && x.DFPId == dataId)
+                .Select(x => new { x.PriceName, x.Quantity, x.Price })
+                .ToListAsync();
+            var detailsMsg = new StringBuilder();
+            foreach (var info in details)
+            {
+                detailsMsg.AppendLine($">- {info.PriceName}:{info.Quantity:#0.00} * {info.Price:#0.00} = {info.Quantity * info.Price:#0.00} 元");
+            }
+            if (detailsMsg.Length == 0 || detailsMsg == null)
+            {
+                detailsMsg.Append("无费用明细");
+            }
+
+
+            //普通物品审批消息通知
+            string resMsg = string.Format(@" ` 日付申请通知 `  
+
+> ` {0} `提交费用申请: 
+
+>**费用明细**   
+{1}
+
+>总金额:<font color='comment'>{2} 元</font> 
+>申请说明:<font color='comment'>{3}</font> 
+>申请时间:<font color='comment'>{4}</font> 
+
+[详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/)   ",
+operationName,
+detailsMsg.ToString(),
+dailyPaymentInfo?.SumPrice.ToString("#0.00") ?? "0.00",
+dailyPaymentInfo?.Instructions ?? "无申请说明",
+DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
+
+            List<string> qwUserIdList = GetQiyeChatUserIdList(recipients);
+            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
+            if (result.errcode != 0)
+            {
+                //抄送日志 
+                return false;
+            }
+
+            return true;
+        }
+        #endregion
+
         #region Helper
 
         private static string getClientNameStr(List<SimplClientInfo> list, string origin)