|
|
|
@ -19,7 +19,9 @@ import com.kiisoo.ic.wx.entity.FollowUserDTO;
|
|
|
|
|
import com.kiisoo.ic.wx.entity.FollowUserTag;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpService;
|
|
|
|
|
import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -350,8 +352,9 @@ public class WxResponseService {
|
|
|
|
|
case "add_external_contact":
|
|
|
|
|
// state字段需要企业成员验证添加后回调给到
|
|
|
|
|
NodeList stateNode = root.getElementsByTagName("State");
|
|
|
|
|
String state = "";
|
|
|
|
|
if(stateNode.getLength() > 0) {
|
|
|
|
|
String state = stateNode.item(0).getTextContent();
|
|
|
|
|
state = stateNode.item(0).getTextContent();
|
|
|
|
|
log.info(state);
|
|
|
|
|
}
|
|
|
|
|
log.info("add_external_contact 配置了客户联系功能的成员添加外部联系人时,回调该事件");
|
|
|
|
@ -360,7 +363,7 @@ public class WxResponseService {
|
|
|
|
|
String res = WeixinApi.getExternalContactInfo(externalUserID);
|
|
|
|
|
log.info(res);
|
|
|
|
|
//添加客户并添加店铺企业微信信息
|
|
|
|
|
addExternalContact(res);
|
|
|
|
|
addExternalContact(res,state);
|
|
|
|
|
|
|
|
|
|
// welcomeCodeNode = root.getElementsByTagName("WelcomeCode");
|
|
|
|
|
// welcomeCode = welcomeCodeNode.item(0).getTextContent();
|
|
|
|
@ -417,11 +420,18 @@ public class WxResponseService {
|
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public OpCustomerEnterpriseWechat analyticCustomerEnterprise(String res){
|
|
|
|
|
public OpCustomerEnterpriseWechat analyticCustomerEnterprise(String res) throws WxErrorException {
|
|
|
|
|
JSONObject parseObject = JSON.parseObject(res);
|
|
|
|
|
//解析企业微信信息
|
|
|
|
|
OpCustomerEnterpriseWechat ocew = JSONObject.parseObject(parseObject.getString("external_contact"), OpCustomerEnterpriseWechat.class);
|
|
|
|
|
List<FollowUserDTO> fUserDTO = JSONObject.parseArray(parseObject.getString("follow_user"),FollowUserDTO.class);
|
|
|
|
|
|
|
|
|
|
WxCpService cpService = WxCpConfiguration.getCpService(APPLICATIONID);
|
|
|
|
|
WxCpExternalContactService externalContactService = cpService.getExternalContactService();
|
|
|
|
|
WxCpUserExternalContactInfo contactDetail = externalContactService.getContactDetail(ocew.getExternalUserid());
|
|
|
|
|
if (contactDetail!=null && contactDetail.getExternalContact()!=null && StringUtils.isNotBlank(contactDetail.getExternalContact().getUnionId())){
|
|
|
|
|
ocew.setUnionid(contactDetail.getExternalContact().getUnionId());
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fUserDTO)){
|
|
|
|
|
ocew.setUserid(fUserDTO.get(0).getUserid());
|
|
|
|
|
ocew.setRemark(fUserDTO.get(0).getRemark());
|
|
|
|
@ -446,10 +456,12 @@ public class WxResponseService {
|
|
|
|
|
* 添加客户
|
|
|
|
|
* @param res
|
|
|
|
|
*/
|
|
|
|
|
public void addExternalContact(String res){
|
|
|
|
|
public void addExternalContact(String res,String state) throws WxErrorException {
|
|
|
|
|
OpCustomerEnterpriseWechat ocew = analyticCustomerEnterprise(res);
|
|
|
|
|
ocew.setState(state);
|
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO();
|
|
|
|
|
customerDTO.setUniId(ocew.getUnionid());
|
|
|
|
|
customerDTO.setExternalUserid(ocew.getExternalUserid());
|
|
|
|
|
if (StringUtils.isNotBlank(ocew.getState())){
|
|
|
|
|
//解析state 店铺code-导购
|
|
|
|
|
String[] split = ocew.getState().split("-");
|
|
|
|
@ -476,7 +488,7 @@ public class WxResponseService {
|
|
|
|
|
* 更新客户信息
|
|
|
|
|
* @param res
|
|
|
|
|
*/
|
|
|
|
|
public void editExternalContact(String res){
|
|
|
|
|
public void editExternalContact(String res) throws WxErrorException {
|
|
|
|
|
OpCustomerEnterpriseWechat ocew = analyticCustomerEnterprise(res);
|
|
|
|
|
CustomerModifyDTO customerModifyDTO= new CustomerModifyDTO();
|
|
|
|
|
customerModifyDTO.setUniId(ocew.getUnionid());
|
|
|
|
|