Browse Source

企业微信应用-OA通知 修改

jiangjc 10 months ago
parent
commit
326a7c01cd
1 changed files with 74 additions and 31 deletions
  1. 74 31
      OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

+ 74 - 31
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -13,6 +13,32 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
 
         private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
 
+        #region 获取企微Id
+
+        public static List<string> GetQiyeChatUserIdList(List<string> userId)
+        {
+            List<string> result = new List<string>();
+
+            try
+            {
+                foreach (string item in userId)
+                {
+                    int uid = int.Parse(item);
+                    Sys_Users users = _grpDeleRep.Query<Sys_Users>(s => s.Id == uid).First();
+                    if (!string.IsNullOrEmpty(users.QiyeChatUserId))
+                    {
+                        result.Add(users.QiyeChatUserId);
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+            }
+            return result;
+        }
+
+        #endregion
+
         #region 确认出团
 
         /// <summary>
@@ -77,13 +103,17 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             };
 
             //发送信息
-            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.GroupStatus_Create(info));
-            if (result.errcode != 0)
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
             {
-                //抄送日志 
-                return false;
-            }
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.GroupStatus_Create(info));
 
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
             return true;
         }
 
@@ -111,7 +141,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             List<Grp_CreditCardPayment> entityList = _grpDeleRep
                    .Query<Grp_CreditCardPayment>(s => s.DIId == ccp.DIId && s.IsDel == 0 && s.CreateUserId > 0 && s.IsAuditGM == 0)
                    .ToList();
-            
+
             GroupStatus_ApplyFeeModel info = new GroupStatus_ApplyFeeModel()
             {
                 QueueCount = entityList.Count,
@@ -467,17 +497,21 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             #endregion
 
             //发送信息
-            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.AuditResult_ApplyFee_User(info));
-            if (ccp.IsAuditGM == 1)
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
             {
-                await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
-            }
-            if (result.errcode != 0)
-            {
-                //抄送日志 
-                return false;
-            }
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.AuditResult_ApplyFee_User(info));
 
+                if (ccp.IsAuditGM == 1)
+                {
+                    await SendChatMsg_GroupStatus_AuditFee(Grp_CreditCardPaymentId, qwEnum);
+                }
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
             return true;
         }
 
@@ -558,13 +592,17 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
             #endregion
 
             //发送信息
-            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.PayResult_Group_ToUser(info));
-            if (result.errcode != 0)
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
             {
-                //抄送日志 
-                return false;
-            }
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.PayResult_Group_ToUser(info));
 
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
             return true;
         }
 
@@ -702,12 +740,15 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
                 info.Result = "你有一笔日付申请未通过财务审核";
                 info.ResultColor = "warning";
             }
-
-            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
-            if (result.errcode != 0)
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
             {
-                //抄送日志 
-                return false;
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.DailyPayReminder_Audit_ToUser(info));
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
             }
 
             return true;
@@ -728,14 +769,16 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
                 PriceName = fin_DailyFeePayment.Instructions,
                 Price = priceStr
             };
-
-            ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
-            if (result.errcode != 0)
+            List<string> qwUserIdList = GetQiyeChatUserIdList(userId);
+            if (qwUserIdList.Count > 0)
             {
-                //抄送日志 
-                return false;
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(userId, MarkdownLib.DailyPayReminder_Pay_ToUser(info));
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
             }
-
             return true;
         }