Commit a0ded935 by 王祖波

立即触发场景限制发送频率

parent d4672d99
...@@ -15,6 +15,7 @@ import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessa ...@@ -15,6 +15,7 @@ import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessa
import com.gic.haoban.manage.service.service.content.InteractRecordService; import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService; import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder; import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder;
import com.gic.haoban.manage.service.util.IntervalUtils;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -172,9 +173,13 @@ public class InteractRecordMessageService { ...@@ -172,9 +173,13 @@ public class InteractRecordMessageService {
.enterpriseId(interactRecordMessageBO.getEnterpriseId()) .enterpriseId(interactRecordMessageBO.getEnterpriseId())
.customerStaticsBos(Lists.newArrayList(new PotentialCustomerStaticsBO(interactRecordBO.getClerkId(), 1))) .customerStaticsBos(Lists.newArrayList(new PotentialCustomerStaticsBO(interactRecordBO.getClerkId(), 1)))
.build(); .build();
// 立即触发场景限制发送频率
boolean send = IntervalUtils.tryAddInterval(interactRecordBO.getClerkId(), interactRecordBO.getMemberId(), interactRecordBO.getUnionId());
if (send) {
potentialCustomerService.sendPotentialCustomerNotice(notifyContext); potentialCustomerService.sendPotentialCustomerNotice(notifyContext);
} }
} }
}
}finally { }finally {
RedisUtil.unlock(recordKey); RedisUtil.unlock(recordKey);
} }
......
package com.gic.haoban.manage.service.util;
import com.gic.redis.data.util.RedisUtil;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import java.util.concurrent.TimeUnit;
/**
* Created by wangzubo on 2025/3/5.
*/
public class IntervalUtils {
private static final String INTERVAL_KEY = "haoban-manage3-service:interval_potential:%s:%s:%s";
public static boolean tryAddInterval(String clerkId,String memberId,String unionId) {
String key = String.format(INTERVAL_KEY, clerkId, memberId, unionId);
RedissonClient redisClient = RedisUtil.getRedisClient();
RBucket<Object> bucket = redisClient.getBucket(key);
boolean trySet = bucket.trySet(1, 10, TimeUnit.SECONDS);
if (!trySet) {
return false;
}
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment