|
@@ -530,8 +530,54 @@ public class WeChatServiceImpl implements WeChatService, InitializingBean {
|
|
String jsonStr = respStr.getBody();
|
|
String jsonStr = respStr.getBody();
|
|
logger.info("微信用户打标签,accountId:{},opedId size:{}----end,时间:{},微信返回:{}",accountId,size, LocalDateTime.now().toString(),jsonStr);
|
|
logger.info("微信用户打标签,accountId:{},opedId size:{}----end,时间:{},微信返回:{}",accountId,size, LocalDateTime.now().toString(),jsonStr);
|
|
if (0 ==JSONObject.parseObject(jsonStr).getIntValue("errcode")) {
|
|
if (0 ==JSONObject.parseObject(jsonStr).getIntValue("errcode")) {
|
|
- return tagService.updateTagSize(accountId,wxId,size);
|
|
|
|
|
|
+ return tagService.addTagSize(accountId,wxId,size);
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean removeUserTag(String accountId, List<String> openIds, int wxId) {
|
|
|
|
+ String requestUrl = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=%s";
|
|
|
|
+ String accessToken = getAuthorizerAccessToken(accountId);
|
|
|
|
+ requestUrl = String.format(requestUrl,accessToken);
|
|
|
|
+ MultiValueMap<String,Object> params = new LinkedMultiValueMap<>(2);
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
+ params.add("openid_list",openIds);
|
|
|
|
+ params.add("tagid",wxId);
|
|
|
|
+ int size = openIds.size();
|
|
|
|
+ HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<> (params,headers);
|
|
|
|
+ logger.info("微信用户去除标签,accountId:{},opedId size:{}----start,时间:{}",accountId,size, LocalDateTime.now().toString());
|
|
|
|
+ ResponseEntity<String> respStr = restTemplate.exchange(requestUrl,HttpMethod.POST,entity,String.class);
|
|
|
|
+ String jsonStr = respStr.getBody();
|
|
|
|
+ logger.info("微信用去除标签,accountId:{},opedId size:{}----end,时间:{},微信返回:{}",accountId,size, LocalDateTime.now().toString(),jsonStr);
|
|
|
|
+ if (0 ==JSONObject.parseObject(jsonStr).getIntValue("errcode")) {
|
|
|
|
+ return tagService.subTagSize(accountId,wxId,size);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean upTag(String accountId, int wxId, String name) {
|
|
|
|
+
|
|
|
|
+ String requestUrl = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN";
|
|
|
|
+ String accessToken = getAuthorizerAccessToken(accountId);
|
|
|
|
+ requestUrl = String.format(requestUrl,accessToken);
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
+ MultiValueMap<String,Object> params = new LinkedMultiValueMap<>(2);
|
|
|
|
+ HashMap<String,Object> map = new HashMap<>(2);
|
|
|
|
+ map.put("name",name);
|
|
|
|
+ map.put("id",wxId);
|
|
|
|
+ params.add("tag",map);
|
|
|
|
+ HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<> (params,headers);
|
|
|
|
+ logger.info("微信创建标签,accountId:{}----start,时间:{}",accountId, LocalDateTime.now().toString());
|
|
|
|
+ ResponseEntity<String> respStr = restTemplate.exchange(requestUrl,HttpMethod.POST,entity,String.class);
|
|
|
|
+ String jsonStr = respStr.getBody();
|
|
|
|
+ logger.info("微信创建标签,accountId:{}----end,时间:{},微信返回{}",accountId,LocalDateTime.now().toString(),jsonStr);
|
|
|
|
+ int errorCode = JSONObject.parseObject(jsonStr).getIntValue("errcode");
|
|
|
|
+ return 0 == errorCode;
|
|
|
|
+ }
|
|
}
|
|
}
|