|
@@ -4,11 +4,10 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
-import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.cache.*;
|
|
|
import com.idiot.operationbackend.config.PlatformProperties;
|
|
|
import com.idiot.operationbackend.entity.*;
|
|
|
-import com.idiot.operationbackend.handler.SyncUserTask;
|
|
|
+import com.idiot.operationbackend.handler.FansInfoHandler;
|
|
|
import com.idiot.operationbackend.service.facade.AccountFansService;
|
|
|
import com.idiot.operationbackend.service.facade.AccountService;
|
|
|
import com.idiot.operationbackend.service.facade.AccountTagService;
|
|
@@ -22,8 +21,6 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.core.io.FileSystemResource;
|
|
|
-import org.springframework.core.io.WritableResource;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -31,12 +28,8 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.InputStream;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -65,22 +58,18 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
|
|
|
|
private final String ERROR_CODE = "errcode";
|
|
|
|
|
|
- @Resource(name = "rpcRestTemplate")
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
-
|
|
|
- @Autowired
|
|
|
private PlatformProperties properties;
|
|
|
|
|
|
- @Autowired
|
|
|
private AccountService accountService;
|
|
|
|
|
|
- @Autowired
|
|
|
private AccountFansService fansService;
|
|
|
|
|
|
- @Autowired
|
|
|
private AccountTagService tagService;
|
|
|
|
|
|
+ private FansInfoHandler fansInfoHandler;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public String notice(Map<String, String> param) {
|
|
@@ -306,7 +295,7 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
|
nextOpenId = respJsonBody.getString("next_openid");
|
|
|
JSONArray openIdArray = respJsonBody.getJSONObject("data").getJSONArray("openid");
|
|
|
List<String> openIds = JSONArray.parseArray(openIdArray.toJSONString(),String.class);
|
|
|
- new SyncUserTask(accountId,openIds,this);
|
|
|
+ fansInfoHandler.doSyncUserTask(accountId,openIds);
|
|
|
}while (count < total);
|
|
|
cache.invalidate(lockKey);
|
|
|
logger.info("公众号:{}同步粉丝数据----end,时间:{}",accountId, LocalDateTime.now().toString());
|
|
@@ -344,7 +333,8 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
|
fans.setUnionId(fansObject.getString("unionid"));
|
|
|
fans.setRemark(fansObject.getString("remark"));
|
|
|
fans.setGroupId(fansObject.getInteger("groupid"));
|
|
|
- fans.setTagIdList(JSONObject.toJSONString(fansObject.getJSONObject("tagid_list")));
|
|
|
+ fans.setTagIdList(JSONObject.toJSONString(fansObject.getJSONArray("tagid_list")));
|
|
|
+ fans.setTags(fans.initTags());
|
|
|
accountFans.add(fans);
|
|
|
}
|
|
|
logger.info("公众号:{}同步粉丝请求粉丝信息,openId 大小:{}---- end,时间:{}",accountId,size,LocalDateTime.now().toString());
|
|
@@ -713,6 +703,29 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
|
return jsonStr;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void groupMsgTask(GroupMsg groupMsg) {
|
|
|
+ if (Objects.isNull(groupMsg)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ String accountId = groupMsg.getAccountId();
|
|
|
+ Integer sex = null;
|
|
|
+ String province = null;
|
|
|
+ String city = null;
|
|
|
+ String tag = null;
|
|
|
+ String subscribeTime = null;
|
|
|
+ if (Constants.SELECT == groupMsg.getType()) {
|
|
|
+ sex = groupMsg.getSelectSex();
|
|
|
+ province = groupMsg.getSelectProvince();
|
|
|
+ city = groupMsg.getSelectCity();
|
|
|
+ tag = groupMsg.getSelectTag();
|
|
|
+ subscribeTime = groupMsg.getSelectSubscribeTime();
|
|
|
+ }
|
|
|
+ List<AccountFans> fans = fansService.queryAccountFans(accountId,sex,province,city,tag,subscribeTime);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private String parseToJson (List<AccountMenu> accountMenus) {
|
|
|
int size = accountMenus.size();
|
|
|
JSONObject jsonObject = new JSONObject(1);
|
|
@@ -744,4 +757,34 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
|
jsonObject.put("button",button);
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
+ @Resource(name = "rpcRestTemplate")
|
|
|
+ public void setRestTemplate(RestTemplate restTemplate) {
|
|
|
+ this.restTemplate = restTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setProperties(PlatformProperties properties) {
|
|
|
+ this.properties = properties;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setAccountService(AccountService accountService) {
|
|
|
+ this.accountService = accountService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setFansService(AccountFansService fansService) {
|
|
|
+ this.fansService = fansService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setTagService(AccountTagService tagService) {
|
|
|
+ this.tagService = tagService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ public void setFansInfoHandler(FansInfoHandler fansInfoHandler) {
|
|
|
+ this.fansInfoHandler = fansInfoHandler;
|
|
|
+ }
|
|
|
}
|