WeCustomerServiceImpl.java
3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.linkwechat.wecom.service.impl;
import java.util.Arrays;
import java.util.List;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeFollowUserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.service.IWeCustomerService;
/**
* 企业微信客户Service业务层处理
*
* @author ruoyi
* @date 2020-09-13
*/
@Service
public class WeCustomerServiceImpl implements IWeCustomerService
{
@Autowired
private WeCustomerMapper weCustomerMapper;
@Autowired
private WeCustomerClient weFollowUserClient;
/**
* 查询企业微信客户
*
* @param id 企业微信客户ID
* @return 企业微信客户
*/
@Override
public WeCustomer selectWeCustomerById(Long id)
{
return weCustomerMapper.selectWeCustomerById(id);
}
/**
* 查询企业微信客户列表
*
* @param weCustomer 企业微信客户
* @return 企业微信客户
*/
@Override
public List<WeCustomer> selectWeCustomerList(WeCustomer weCustomer)
{
return weCustomerMapper.selectWeCustomerList(weCustomer);
}
/**
* 新增企业微信客户
*
* @param weCustomer 企业微信客户
* @return 结果
*/
@Override
public int insertWeCustomer(WeCustomer weCustomer)
{
weCustomer.setCreateTime(DateUtils.getNowDate());
return weCustomerMapper.insertWeCustomer(weCustomer);
}
/**
* 修改企业微信客户
*
* @param weCustomer 企业微信客户
* @return 结果
*/
@Override
public int updateWeCustomer(WeCustomer weCustomer)
{
return weCustomerMapper.updateWeCustomer(weCustomer);
}
/**
* 批量删除企业微信客户
*
* @param ids 需要删除的企业微信客户ID
* @return 结果
*/
@Override
public int deleteWeCustomerByIds(Long[] ids)
{
return weCustomerMapper.deleteWeCustomerByIds(ids);
}
/**
* 删除企业微信客户信息
*
* @param id 企业微信客户ID
* @return 结果
*/
@Override
public int deleteWeCustomerById(Long id)
{
return weCustomerMapper.deleteWeCustomerById(id);
}
/**
* 客户同步接口
* @return
*/
@Override
public void synchWeCustomer() {
WeFollowUserDto weFollowUserDto = weFollowUserClient.getFollowUserList();
if(WeConstans.WE_SUCCESS_CODE.equals(weFollowUserDto.getErrcode())
&& ArrayUtil.isNotEmpty(weFollowUserDto.getFollow_user())){
Arrays.asList(weFollowUserDto.getFollow_user())
.stream().forEach(k->{
//获取指定联系人对应的客户
WeCustomerDto externalUserid
= weFollowUserClient.list(k);
if(WeConstans.WE_SUCCESS_CODE.equals(externalUserid.getErrcode())
&& ArrayUtil.isNotEmpty(externalUserid.getExternal_userid())){
Arrays.asList(externalUserid.getExternal_userid()).forEach(v->{
//获取指定客户的详情
WeCustomerDto externalContact = weFollowUserClient.get(v);
if(WeConstans.WE_SUCCESS_CODE.equals(externalContact.getErrcode())
&& null != externalContact.getExternal_contact()){
//分装成需要入库的数据格式
}
});
}
});
}
}
}