浏览代码

fix 群发消息频率限制

Eric 11 月之前
父节点
当前提交
03781481ae

+ 14 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceBatchSendingServiceImpl.java

@@ -444,15 +444,22 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
                         messageNum += 1;
                     }
 
-                    int messageSendLimit; // 默认发送11000/分钟
+                    int messageSendLimit; // 默认发送10000/分钟
                     // 群发消息频率限制
                     SysConfig config = sysConfigService.findByParamName(SysConfigConstant.MESSAGE_SEND_LIMIT);
-                    // 群发消息频率限制不能超过11000/分钟,超过当前值默认取值为11000
-                    if (config != null && config.getParamValue().matches("\\d+")
-                        && Integer.parseInt(config.getParamValue()) < 11000) {
-                        messageSendLimit = Integer.parseInt(config.getParamValue());
+                    // 群发消息频率限制不能超过10000/分钟,超过当前值默认取值为10000
+                    if (config != null && config.getParamValue().matches("\\d+")) {
+                        int sendLimit = Integer.parseInt(config.getParamValue());
+                        if (sendLimit > 0 && sendLimit < 10000) {
+                            // 消息发送频率限制
+                            messageSendLimit = Integer.parseInt(config.getParamValue());
+                        } else {
+                            // 默认发送10000/分钟
+                            messageSendLimit = 10000;
+                        }
                     } else {
-                        messageSendLimit = 11000;
+                        // 默认发送10000/分钟
+                        messageSendLimit = 10000;
                     }
 
                     int finalMessageNum = messageNum;
@@ -489,6 +496,7 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
                                         .map(x -> imGroupService.getImUserId(x, clientType))
                                         .collect(Collectors.toList());
 
+                                // 累加线程休眠计算器,若大于指定阀值时,线程休眠1分钟
                                 sleepCount = messageSendSleepCondition(info, sleepCount, receiveUserIds.size(), finalMessageNum, messageSendLimit);
 
                                 batchSendCustomerServiceMessage(info, receiveNums, receiveUserIds);