|
@@ -95,23 +95,30 @@ public class WxaAddContactController {
|
|
|
|
|
|
//企业人信息
|
|
|
WxCpUser wxUser = wxCpService.getUserService().getById(inMessage.getUserId());
|
|
|
+ this.logger.info("\n消息 "+JsonUtils.toJson(exuser)+"--------"+JsonUtils.toJson(wxUser));
|
|
|
//添加好友回调add_external_contact
|
|
|
- if(inMessage.getChangeType().equals("add_external_contact")){
|
|
|
+ if(inMessage.getChangeType().equals("edit_external_contact") &&exuser.getFollowedUsers()!=null&&exuser.getFollowedUsers().size()>0&& exuser.getFollowedUsers().get(0).getRemarkMobiles()!=null && exuser.getFollowedUsers().get(0).getRemarkMobiles().length>0){
|
|
|
+ ExternalUser externalUser=externalUserService.getExternalByMobile2(inMessage.getExternalUserId());
|
|
|
+ if(externalUser!=null&&externalUser.getId()!=null){
|
|
|
+ externalUser.setRemark_mobiles(exuser.getFollowedUsers().get(0).getRemarkMobiles()[0]);
|
|
|
+ externalUserService.updateExternalUserById(externalUser);
|
|
|
+ }
|
|
|
+ }else if(inMessage.getChangeType().equals("add_external_contact")){
|
|
|
List<WxCpUserExternalContactInfo.FollowedUser> follList=exuser.getFollowedUsers();
|
|
|
- for (WxCpUserExternalContactInfo.FollowedUser foll:follList) {
|
|
|
- if(foll.getRemarkMobiles()!=null && foll.getRemarkMobiles().length>0){
|
|
|
+ //for (WxCpUserExternalContactInfo.FollowedUser foll:follList) {
|
|
|
+ if(follList.size()>0 && follList.get(0).getRemarkMobiles()!=null && follList.get(0).getRemarkMobiles().length>0){
|
|
|
//是否存在
|
|
|
- ExternalUser externalUser1 =externalUserService.getExternalCount(foll.getRemarkMobiles()[0]);
|
|
|
+ ExternalUser externalUser1 =externalUserService.getExternalCount(follList.get(0).getRemarkMobiles()[0]);
|
|
|
if(externalUser1!=null && externalUser1.getId()!=null){
|
|
|
if(!externalUser1.getCompany_name().equals(wxUser.getName())){
|
|
|
externalUser1.setCompany_name(externalUser1.getCompany_name()+","+wxUser.getName());
|
|
|
- externalUser1.setUserid(externalUser1.getUserid()+","+foll.getUserId());
|
|
|
+ externalUser1.setUserid(externalUser1.getUserid()+","+wxUser.getUserId());
|
|
|
}
|
|
|
externalUser1.setIs_delete(1);
|
|
|
externalUserService.updateExternalUserById(externalUser1);
|
|
|
//externalUserService.updateExternalUser(externalUser1);
|
|
|
}else{
|
|
|
- this.logger.info("已存在用户:",foll.getRemarkMobiles()[0]);
|
|
|
+ this.logger.info("已存在用户:",follList.get(0).getRemarkMobiles()[0]);
|
|
|
//保存用户信息
|
|
|
ExternalUser externalUser=new ExternalUser();
|
|
|
externalUser.setAvatar(exuser.getExternalContact().getAvatar());
|
|
@@ -119,9 +126,9 @@ public class WxaAddContactController {
|
|
|
externalUser.setName(exuser.getExternalContact().getName());
|
|
|
externalUser.setGender(String.valueOf(exuser.getExternalContact().getGender()));
|
|
|
externalUser.setType(exuser.getExternalContact().getType());
|
|
|
- externalUser.setUserid(foll.getUserId());
|
|
|
+ externalUser.setUserid(wxUser.getUserId());
|
|
|
externalUser.setCreatetime(date);
|
|
|
- externalUser.setRemark_mobiles(foll.getRemarkMobiles()[0]);
|
|
|
+ externalUser.setRemark_mobiles(follList.get(0).getRemarkMobiles()[0]);
|
|
|
|
|
|
externalUser.setCompany_avatar(wxUser.getAvatar());
|
|
|
externalUser.setCompany_gender(wxUser.getGender().getGenderName());
|
|
@@ -132,36 +139,53 @@ public class WxaAddContactController {
|
|
|
externalUser.setUser_age(0);
|
|
|
externalUserService.updateExternalUser(externalUser);
|
|
|
}
|
|
|
- this.logger.info("通过手机号查找的外部客户:",foll.getRemarkMobiles()[0]);
|
|
|
+ this.logger.info("通过手机号查找的外部客户:",follList.get(0).getRemarkMobiles()[0]);
|
|
|
}else{
|
|
|
- ExternalUser externalUser=new ExternalUser();
|
|
|
- externalUser.setAvatar(exuser.getExternalContact().getAvatar());
|
|
|
- externalUser.setExternal_userid(exuser.getExternalContact().getExternalUserId());
|
|
|
- externalUser.setName(exuser.getExternalContact().getName());
|
|
|
- externalUser.setGender(String.valueOf(exuser.getExternalContact().getGender()));
|
|
|
- externalUser.setType(exuser.getExternalContact().getType());
|
|
|
- externalUser.setUserid(foll.getUserId());
|
|
|
- externalUser.setCreatetime(date);
|
|
|
- externalUser.setCompany_avatar(wxUser.getAvatar());
|
|
|
- externalUser.setCompany_gender(wxUser.getGender().getGenderName());
|
|
|
- externalUser.setCompany_mobiles(wxUser.getMobile());
|
|
|
- externalUser.setCompany_name(wxUser.getName());
|
|
|
- externalUser.setTermain_type("企业微信/其他加入方式");
|
|
|
- //企业微信未返回年龄,默认0
|
|
|
- externalUser.setUser_age(0);
|
|
|
- externalUserService.updateExternalUser(externalUser);
|
|
|
+ ExternalUser externalUser1=externalUserService.getExternalByMobile2(inMessage.getExternalUserId());
|
|
|
+ if(externalUser1!=null&&externalUser1.getId()!=null){
|
|
|
+ if(!externalUser1.getCompany_name().equals(wxUser.getName())){
|
|
|
+ externalUser1.setCompany_name(externalUser1.getCompany_name()+","+wxUser.getName());
|
|
|
+ externalUser1.setUserid(externalUser1.getUserid()+","+wxUser.getUserId());
|
|
|
+ }
|
|
|
+ externalUser1.setIs_delete(1);
|
|
|
+ externalUserService.updateExternalUserById(externalUser1);
|
|
|
+ }else{
|
|
|
+ ExternalUser externalUser=new ExternalUser();
|
|
|
+ externalUser.setAvatar(exuser.getExternalContact().getAvatar());
|
|
|
+ externalUser.setExternal_userid(exuser.getExternalContact().getExternalUserId());
|
|
|
+ externalUser.setName(exuser.getExternalContact().getName());
|
|
|
+ externalUser.setGender(String.valueOf(exuser.getExternalContact().getGender()));
|
|
|
+ externalUser.setType(exuser.getExternalContact().getType());
|
|
|
+ externalUser.setUserid(wxUser.getUserId());
|
|
|
+ externalUser.setCreatetime(date);
|
|
|
+ externalUser.setCompany_avatar(wxUser.getAvatar());
|
|
|
+ externalUser.setCompany_gender(wxUser.getGender().getGenderName());
|
|
|
+ externalUser.setCompany_mobiles(wxUser.getMobile());
|
|
|
+ externalUser.setCompany_name(wxUser.getName());
|
|
|
+ externalUser.setTermain_type("企业微信/其他加入方式");
|
|
|
+ //企业微信未返回年龄,默认0
|
|
|
+ externalUser.setUser_age(0);
|
|
|
+ externalUserService.updateExternalUser(externalUser);
|
|
|
+ }
|
|
|
+
|
|
|
this.logger.info("不是通过手机号查找的外部客户:",exuser.getExternalContact().getName());
|
|
|
}
|
|
|
- }
|
|
|
+ //}
|
|
|
}else{//微信删除回调del_follow_user
|
|
|
List<WxCpUserExternalContactInfo.FollowedUser> follList=exuser.getFollowedUsers();
|
|
|
- String [] mobile=follList.get(0).getRemarkMobiles();
|
|
|
- if(mobile!=null&&mobile.length>0){
|
|
|
+ if(follList.size()>0 && follList.get(0).getRemarkMobiles()!=null&&follList.get(0).getRemarkMobiles().length>0){
|
|
|
+ String [] mobile=follList.get(0).getRemarkMobiles();
|
|
|
ExternalUser externalUser=externalUserService.getExternalByMobile(mobile[0]);
|
|
|
if(externalUser!=null&&externalUser.getId()!=null){
|
|
|
externalUser.setIs_delete(0);
|
|
|
externalUserService.updateExternalUserById(externalUser);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ ExternalUser externalUser=externalUserService.getExternalByMobile2(inMessage.getExternalUserId());
|
|
|
+ if(externalUser!=null&&externalUser.getId()!=null){
|
|
|
+ externalUser.setIs_delete(0);
|
|
|
+ externalUserService.updateExternalUserById(externalUser);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|