Commit 046938bd by fudahua

好友同步次数

parent 2360e01b
package com.gic.haoban.manage.api.service;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.QywxTagCallbackDTO;
import com.gic.haoban.manage.api.dto.QywxTagInfoDTO;
import com.gic.haoban.manage.api.dto.QywxTagItemDTO;
......@@ -26,7 +27,7 @@ public interface QywxTagApiService {
* @param infoDTO 标签
* @param items 标签项
*/
public void syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items);
public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items);
/**
* 关闭同步
......
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
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;
......@@ -80,14 +81,16 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
}
@Override
public void syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) {
public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) {
ServiceResponse ret = new ServiceResponse();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
//调用企业微信接口保存
QywxGetCorpTagListDTO resp = this.saveQywxTag(wxEnterpriseDTO, infoDTO, items);
if (resp.getErrcode() != 0) {
logger.info("同步失败:{}", JSONObject.toJSONString(resp));
return;
ret.setCode(1);
ret.setMessage(resp.getErrmsg());
return ret;
}
//拉取保存所有标签
List<QywxTagGroupDTO> tagGroup = resp.getTagGroup();
......@@ -96,18 +99,21 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
Pair<TabQywxTag, List<TabQywxTagItem>> savePair = qywxTagService.saveQywxTagByQywxGroupKey(wxEnterpriseId, groupDTO);
if (null == savePair) {
logger.info("保存失败:{}", JSONObject.toJSONString(groupDTO));
return;
ret.setCode(1);
ret.setMessage("保存企业微信标签失败");
return ret;
}
//保存关联关系
saveRelation(wxEnterpriseId, enterpriseId, infoDTO, items, savePair);
String taskId = dealSyncOperationApiService.createTagTask(wxEnterpriseId, "-1", infoDTO.getMemberTagId());
if (null == taskId) {
logger.info("标签不能重复执行");
throw new RuntimeException("标签不能重复执行:" + infoDTO.getQywxGroupName());
}
List<String> tagItemIds = items.stream().map(dto -> dto.getQywxTagItemId()).collect(Collectors.toList());
dealSyncOperationApiService.dealTagTask(wxEnterpriseId, enterpriseId, tagItemIds, taskId);
return ret;
// String taskId = dealSyncOperationApiService.createTagTask(wxEnterpriseId, "-1", infoDTO.getMemberTagId());
// if (null == taskId) {
// logger.info("标签不能重复执行");
// throw new RuntimeException("标签不能重复执行:" + infoDTO.getQywxGroupName());
// }
// List<String> tagItemIds = items.stream().map(dto -> dto.getQywxTagItemId()).collect(Collectors.toList());
// dealSyncOperationApiService.dealTagTask(wxEnterpriseId, enterpriseId, tagItemIds, taskId);
}
/**
......
......@@ -12,7 +12,10 @@ import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.TestService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.QywxExternalcontactDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -51,6 +54,9 @@ public class DealSyncTest {
private QywxUserApiService qywxUserApiService;
@Autowired
private QywxDepartmentApiService qywxDepartmentApiService;
@Autowired
private TestService testService;
@Autowired
......@@ -94,4 +100,17 @@ public class DealSyncTest {
// countDownLatch.countDown();
}
@Test
public void test3() {
List<DepartmentDTO> department = qywxDepartmentApiService.listSelfDepartment("wweac4ef962720aa12", "GFu4FwkfcGFPue-qinB7ThEU4wR2SadbBH1yT5sLDzs", null);
System.out.println(JSONObject.toJSONString(department));
}
@Test
public void test4() {
UserDTO workWxUser = qywxUserApiService.getSelfWorkWxUser("wweac4ef962720aa12", "GFu4FwkfcGFPue-qinB7ThEU4wR2SadbBH1yT5sLDzs", "WuXiangHong");
System.out.println(JSONObject.toJSONString(workWxUser));
}
}
......@@ -505,11 +505,28 @@ public class ClerkController extends WebBaseController{
*/
@HttpLimit
@RequestMapping("/check-fresh-friend")
public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId) {
public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId, String version) {
boolean freshFriendSyncTask = dealSyncOperationApiService.getFreshFriendSyncTask(wxEnterpriseId, staffId);
return resultResponse(HaoBanErrCode.ERR_1, freshFriendSyncTask);
}
/**
* 刷新好友状态
*
* @param staffId
* @param storeId
* @param wxEnterpriseId
* @return
*/
@HttpLimit
@RequestMapping("/fresh-friend-count")
public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId) {
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer) RedisUtil.getCache(key);
return resultResponse(HaoBanErrCode.ERR_1, count);
}
//获取门店详情
public boolean isEnterpriseOver(String eid) {
......
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