Commit 6c0b619c by fudahua

会员标签同步-同步没有打的标签加锁

parent d729d0fb
......@@ -12,6 +12,7 @@ import com.gic.haoban.manage.service.entity.TabQywxTag;
import com.gic.haoban.manage.service.entity.TabQywxTagItem;
import com.gic.haoban.manage.service.entity.TabQywxTagRelation;
import com.gic.haoban.manage.service.service.QywxTagService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.QywxTagDTO;
import com.gic.wechat.api.dto.qywx.QywxTagGroupDTO;
import org.apache.commons.lang3.tuple.Pair;
......@@ -61,6 +62,8 @@ public class QywxTagServiceImpl implements QywxTagService {
@Override
public Pair<TabQywxTag, List<TabQywxTagItem>> saveQywxTagByQywxGroupKey(String wxEnterpriseId, QywxTagGroupDTO groupDTO) {
String lockKey = "group-add-" + groupDTO.getGroupId();
RedisUtil.lock(lockKey, 3L);
//判断保存 分组
TabQywxTag qywxTag = this.getQywxTagByQywxGroupKey(wxEnterpriseId, groupDTO.getGroupId());
if (null == qywxTag) {
......@@ -116,6 +119,7 @@ public class QywxTagServiceImpl implements QywxTagService {
}
items.add(qywxTagItem);
}
RedisUtil.unlock(lockKey);
return Pair.of(qywxTag, items);
}
......
......@@ -279,6 +279,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
QywxTagRelationTypeEnum relationTypeEnum = QywxTagRelationTypeEnum.getByTagType(callbackDTO.getTagType());
//标签组
if (relationTypeEnum.getTagType() == QywxTagRelationTypeEnum.TAG_GROUP.getTagType()) {
logger.info("新增标签组无需操作:{}", callbackDTO.getTagId());
List<String> ids = new ArrayList<>();
ids.add(callbackDTO.getTagId());
QywxGetCorpTagListDTO tagDetail = qywxSuiteApiService.getCorpTagList(wxEnterpriseDto.getCorpid(), config.getWxSuiteid(), ids, QywxTagRelationTypeEnum.TAG_GROUP.getType());
......@@ -286,8 +287,9 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("没有关联,无需操作:{}", JSONObject.toJSONString(tagDetail));
return;
}
QywxTagGroupDTO qywxTagGroupDTO = tagDetail.getTagGroup().get(0);
//保存标签项
qywxTagService.saveQywxTagByQywxGroupKey(wxEnterpriseDto.getWxEnterpriseId(), tagDetail.getTagGroup().get(0));
qywxTagService.saveQywxTagByQywxGroupKey(wxEnterpriseDto.getWxEnterpriseId(), qywxTagGroupDTO);
//标签项
} else if (relationTypeEnum.getTagType() == QywxTagRelationTypeEnum.TAG_ITEM.getTagType()) {
//查找对应的标签组 如果标签组关联了
......@@ -306,6 +308,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
//保存标签项
qywxTagService.saveQywxTagByQywxGroupKey(wxEnterpriseDto.getWxEnterpriseId(), qywxTagGroupDTO);
}
}
......
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