Commit 23260b05 by fudahua

会员标签同步-gic同步企业为西

parent dff5e6e4
......@@ -33,9 +33,17 @@ public interface QywxTagApiService {
* 关闭同步
*
* @param wxEnterpriseId
* @param tagRelationId
* @param memberTagId
*/
public void closeSync(String wxEnterpriseId, String tagRelationId);
public ServiceResponse closeSync(String wxEnterpriseId, String memberTagId);
/**
* 删除gic标签项导致 并删除企业微信的数据
*
* @param wxEnterpriseId
* @param tagItemId
*/
public ServiceResponse delGicTagItem(String wxEnterpriseId, String tagItemId);
/**
* 查询所有同步的标签
......@@ -103,4 +111,33 @@ public interface QywxTagApiService {
*/
public boolean saveRelation(String wxEnterpriseId, String enterpriseId, List<String> memberTagIds);
/**
* 更新qywx的标签或者标签组名称
*
* @param wxEnterpriseId
* @param id (企业微信的对应的id)
* @param name
* @param type
* @return
*/
public ServiceResponse renameQywxTag(String wxEnterpriseId, String id, String name, Integer type);
/**
* 根据会员标签id 拉取列表
*
* @param wxEnterpriseId
* @param memberTagId
* @return
*/
public List<QywxTagRelationDTO> listQywxTagRelationByMemberTagId(String wxEnterpriseId, String memberTagId);
/**
* 根据会员标签关联id 查询关联信息
*
* @param relationId
* @return
*/
public QywxTagRelationDTO getQywxTagRelationByRelationId(String relationId);
}
......@@ -49,6 +49,16 @@ public interface QywxTagRelationMapper {
*/
List<TabQywxTagRelation> listByMemberTagId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("memberTagId") String memberTagId);
/**
* 查询企业下所有同步的 根据tagItemId
*
* @param wxEnterpriseId
* @param tagItemId
* @return
*/
TabQywxTagRelation getQywxTagRelationByTagItemId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("tagItemId") String tagItemId);
/**
* 删除同步信息
*
......
......@@ -112,6 +112,14 @@ public interface QywxTagService {
public List<TabQywxTagRelation> listQywxTagRelationByMemberTagId(String wxEnterpriseId, String memberTagId);
/**
* 根据tagItemId 查询
*
* @param tagItemId
* @return
*/
public TabQywxTagRelation getQywxTagRelationByTagItemId(String wxEnterpriseId, String tagItemId);
/**
* 根据qywxTagId查询
*
* @param qywxTagId
......@@ -173,5 +181,14 @@ public interface QywxTagService {
*/
public void changeTagRelationStatus(String id, int status);
/**
* 根据企业微信的标签项获取 标签项
*
* @param wxEnterpriseId
* @param id
* @return
*/
public TabQywxTagItem getQywxTagItemById(String wxEnterpriseId, String id);
}
......@@ -169,6 +169,11 @@ public class QywxTagServiceImpl implements QywxTagService {
}
@Override
public TabQywxTagRelation getQywxTagRelationByTagItemId(String wxEnterpriseId, String tagItemId) {
return qywxTagRelationMapper.getQywxTagRelationByTagItemId(wxEnterpriseId, tagItemId);
}
@Override
public List<TabQywxTagRelation> listQywxTagRelationByQywxTagId(String wxEnterpriseId, String qywxTagId) {
List<TabQywxTagRelation> ret = qywxTagRelationMapper.listByQywxTagId(wxEnterpriseId, qywxTagId);
return ret;
......@@ -219,4 +224,9 @@ public class QywxTagServiceImpl implements QywxTagService {
tabQywxTagRelation.setUpdateTime(new Date());
qywxTagRelationMapper.updateByPrimaryKeySelective(tabQywxTagRelation);
}
@Override
public TabQywxTagItem getQywxTagItemById(String wxEnterpriseId, String id) {
return qywxTagItemMapper.selectByPrimaryKey(id);
}
}
......@@ -5,17 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.app.customer.dto.SearchComputeDTO;
import com.gic.haoban.app.customer.dto.SearchDataDTO;
import com.gic.haoban.app.customer.dto.TagDTO;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.api.service.QywxTagApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.exception.WxApiLimitException;
import com.gic.haoban.manage.service.pojo.QywxSyncTagFormatPojo;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.QywxTagService;
......@@ -213,11 +210,12 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
}
@Override
public void closeSync(String wxEnterpriseId, String memberTagId) {
public ServiceResponse closeSync(String wxEnterpriseId, String memberTagId) {
ServiceResponse resp = new ServiceResponse();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
List<TabQywxTagRelation> tagRelations = qywxTagService.listQywxTagRelationByMemberTagId(wxEnterpriseId, memberTagId);
if (CollectionUtils.isEmpty(tagRelations)) {
return;
return resp;
}
TabQywxTag tabQywxTag = qywxTagService.getQywxTagByQywxTagId(wxEnterpriseId, tagRelations.get(0).getQywxTagId());
//关闭同步
......@@ -225,10 +223,41 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
List<String> delIds = new ArrayList<>();
delIds.add(memberTagId);
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), delIds, 0);
if (responseDTO.getErrcode() == 0) {
qywxTagService.delQywxTag(tabQywxTag.getQywxGroupKey(), wxEnterpriseId);
logger.info("关闭同步:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg());
resp.setCode(responseDTO.getErrcode());
return resp;
}
qywxTagService.delQywxTag(tabQywxTag.getQywxGroupKey(), wxEnterpriseId);
return resp;
}
@Override
public ServiceResponse delGicTagItem(String wxEnterpriseId, String tagItemId) {
ServiceResponse resp = new ServiceResponse();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
TabQywxTagRelation qywxTagRelation = qywxTagService.getQywxTagRelationByTagItemId(wxEnterpriseId, tagItemId);
if (null == qywxTagRelation) {
resp.setMessage("没有同步,无需删除");
return resp;
}
TabQywxTagItem qywxTagItem = qywxTagService.getQywxTagItemById(wxEnterpriseId, qywxTagRelation.getQywxTagItemId());
List<String> delIds = new ArrayList<>();
delIds.add(qywxTagItem.getQywxTagKey());
QywxResponseDTO responseDTO = qywxSuiteApiService.delCorpTag(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), delIds, 1);
logger.info("删除标签项:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg());
resp.setCode(responseDTO.getErrcode());
return resp;
}
//删除标签项 以及同步关系
qywxTagService.delQywxTagItemById(wxEnterpriseId, qywxTagItem.getQywxTagItemId());
qywxTagService.changeTagRelationStatus(qywxTagRelation.getQywxTagRelationId(), 0);
return resp;
}
@Override
......@@ -458,6 +487,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
@Override
public ServiceResponse syncFriendTagToQywxByExternalUserId(String wxEnterpriseId, String enterpriseId, String externalUserId, List<String> tagItemIds) {
logger.info("同步微信好友到企业微信:{},{},{},{}", wxEnterpriseId, enterpriseId, externalUserId, JSONObject.toJSONString(tagItemIds));
ServiceResponse resp = new ServiceResponse();
//获取需要同步的标签
QywxSyncTagFormatPojo syncTagFormat = listSyncTagItems(wxEnterpriseId);
......@@ -789,4 +819,59 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
}
return false;
}
@Override
public ServiceResponse renameQywxTag(String wxEnterpriseId, String id, String name, Integer type) {
ServiceResponse resp = new ServiceResponse();
String renameQywxKey = null;
Long order = null;
//标签组
if (type == QywxTagRelationTypeEnum.TAG_GROUP.getType()) {
TabQywxTag tabQywxTag = qywxTagService.getQywxTagByQywxTagId(wxEnterpriseId, id);
if (null == tabQywxTag) {
resp.setMessage("没有关联无需处理");
return resp;
}
renameQywxKey = tabQywxTag.getQywxGroupKey();
order = tabQywxTag.getOrder();
name = "GIC" + name;
} else if (type == QywxTagRelationTypeEnum.TAG_ITEM.getType()) {
TabQywxTagItem qywxTagItem = qywxTagService.getQywxTagItemById(wxEnterpriseId, id);
if (null == qywxTagItem) {
resp.setMessage("没有关联无需处理");
return resp;
}
renameQywxKey = qywxTagItem.getQywxTagKey();
order = qywxTagItem.getOrder();
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
//名称同步回去
QywxTagDTO qywxTagDTO = new QywxTagDTO();
qywxTagDTO.setId(renameQywxKey);
qywxTagDTO.setName(name);
qywxTagDTO.setOrder(order);
QywxResponseDTO responseDTO = qywxSuiteApiService.editCorpTagNameOrOrder(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxTagDTO);
logger.info("同步名称:{}", JSONObject.toJSONString(responseDTO));
if (responseDTO.getErrcode() != 0) {
resp.setMessage(responseDTO.getErrmsg());
resp.setCode(responseDTO.getErrcode());
}
return resp;
}
@Override
public List<QywxTagRelationDTO> listQywxTagRelationByMemberTagId(String wxEnterpriseId, String memberTagId) {
List<TabQywxTagRelation> tagRelations = qywxTagService.listQywxTagRelationByMemberTagId(wxEnterpriseId, memberTagId);
return EntityUtil.changeEntityListByJSON(QywxTagRelationDTO.class, tagRelations);
}
@Override
public QywxTagRelationDTO getQywxTagRelationByRelationId(String relationId) {
TabQywxTagRelation tagRelation = qywxTagService.getQywxTagRelationById(relationId);
return EntityUtil.changeEntityByJSON(QywxTagRelationDTO.class, tagRelation);
}
}
......@@ -200,11 +200,25 @@
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_tag_relation
where
member_tag_id = #{memberTagId,jdbcType=VARCHAR}
<if test="wxEnterpriseId!=null">
and wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</if>
and status_flag=1
and sync_flag=1
</select>
<select id="getQywxTagRelationByTagItemId" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_tag_relation
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and member_tag_id = #{memberTagId,jdbcType=VARCHAR}
and tag_item_id = #{tagItemId,jdbcType=VARCHAR}
and status_flag=1
and sync_flag=1
</select>
<update id="delByMemberTagId">
update tab_haoban_qywx_tag_relation
set
......
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