|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.tzld.piaoquan.longarticle.common.constants.TimeConstant;
|
|
|
import com.tzld.piaoquan.longarticle.common.enums.*;
|
|
|
import com.tzld.piaoquan.longarticle.dao.mapper.crawler.ArticleUseGroupMapper;
|
|
|
@@ -1059,19 +1060,11 @@ public class CoreServiceImpl implements CoreService {
|
|
|
.andUserGroupIdEqualTo(Integer.parseInt(userGroupId));
|
|
|
List<GroupSendOpenId> groupSendOpenIds = groupSendOpenIdMapper.selectByExample(groupSendOpenIdExample);
|
|
|
if (!CollectionUtils.isEmpty(groupSendOpenIds)) {
|
|
|
- for (GroupSendOpenId groupSendOpenId : groupSendOpenIds) {
|
|
|
- ArticleUseGroupExample articleUseGroupExample = new ArticleUseGroupExample();
|
|
|
- articleUseGroupExample.createCriteria().andGzhIdEqualTo(groupSendOpenId.getGhId())
|
|
|
- .andOpenIdEqualTo(groupSendOpenId.getOpenId());
|
|
|
- List<ArticleUseGroup> articleUseGroups = articleUseGroupMapper.selectByExample(articleUseGroupExample);
|
|
|
- if (!CollectionUtils.isEmpty(articleUseGroups)) {
|
|
|
- for (ArticleUseGroup articleUseGroup : articleUseGroups) {
|
|
|
- ArticleUseGroup updateArticleUseGroup = new ArticleUseGroup();
|
|
|
- updateArticleUseGroup.setId(articleUseGroup.getId());
|
|
|
- updateArticleUseGroup.setRemainingCount(articleUseGroup.getRemainingCount() - 1);
|
|
|
- articleUseGroupMapper.updateByPrimaryKeySelective(updateArticleUseGroup);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 提取所有 openId
|
|
|
+ List<String> openIdList = groupSendOpenIds.stream().map(GroupSendOpenId::getOpenId).distinct().collect(Collectors.toList());
|
|
|
+ // 批量更新,一次性减少所有匹配记录的 remaining_count
|
|
|
+ for (List<String> partition : Lists.partition(openIdList, 1000)) {
|
|
|
+ articleUseGroupMapper.batchDecreaseRemainingCount(ghId, partition);
|
|
|
}
|
|
|
}
|
|
|
}
|