EntmicroFollowerStaffService.java
4.99 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
package cn.com.glsx.entmicro.service;
import cn.com.glsx.entmicro.mapper.EntmicroStaffMapper;
import cn.com.glsx.entmicro.model.request.EntmicroFollowerStaffRequest;
import cn.com.glsx.entmicro.model.response.EntmicroFollowerStaffResponse;
import cn.com.glsx.entmicro.util.EmojiUtils;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.shopmall.remote.WeappNoticeConfigRemote;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.plat.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Lichongyuan
* @Description:
* @date 2021/9/18 11:56
*/
@Service
@Slf4j
public class EntmicroFollowerStaffService {
@Resource
private EntmicroStaffMapper entmicroStaffMapper;
@Resource
private WeappNoticeConfigRemote weappNoticeConfigRemote;
@Autowired
private Environment environment;
/**
* 添加跟进员工
*
* @param entmicroFollowerStaffRequest
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = RpcServiceException.class)
public void saveFollowerStaff(EntmicroFollowerStaffRequest entmicroFollowerStaffRequest) {
entmicroFollowerStaffRequest.setFollowerCreatedTime(new Date());
entmicroStaffMapper.saveEntmicroFollowerStaff(entmicroFollowerStaffRequest);
}
/**
* 删除跟进员工
*
* @param entmicroFollowerStaffRequest
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = RpcServiceException.class)
public void deleteFollowerStaff(EntmicroFollowerStaffRequest entmicroFollowerStaffRequest) {
entmicroStaffMapper.deleteEntmicroFollowerStaff(entmicroFollowerStaffRequest);
//删除商城跟进员
log.info("删除商城跟进员入参: {}", entmicroFollowerStaffRequest);
RpcResponse<Boolean> booleanRpcResponse = weappNoticeConfigRemote.deleteCustomerServer(entmicroFollowerStaffRequest.getMerchantId(), entmicroFollowerStaffRequest.getUserOneId());
if (booleanRpcResponse.isFailed()) {
log.info("商城跟进员未能成功移除: {}", JSONArray.toJSONString(booleanRpcResponse));
}
}
/**
* 查询跟进员工列表
*
* @param pagination
* @return
*/
public Page<EntmicroFollowerStaffResponse> listFollowerStaffByPage(RpcPagination<EntmicroFollowerStaffRequest> pagination) {
PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize());
EntmicroFollowerStaffRequest condition = pagination.getCondition();
condition.setStaffName(StringUtils.isNotEmpty(condition.getStaffName()) ? EmojiUtils.parseToHtmlHexadecimal(condition.getStaffName()) : condition.getStaffName());
Page<EntmicroFollowerStaffResponse> result = entmicroStaffMapper.listEntmicroFollowerStaffByPage(condition);
if (!CollectionUtils.isEmpty(result.getResult())) {
List<Integer> collect = result.stream().map(EntmicroFollowerStaffResponse::getId).collect(Collectors.toList());
Map<Integer, Map> departMap = entmicroStaffMapper.findDepartByMerIdAndId(collect, condition.getMerchantId());
result.forEach(index -> {
Map map = departMap.get(index.getId());
if (!map.isEmpty()) {
String departName = map.get("department_name") + "";
String departmentName = departName != null ? EmojiUtils.parseToUnicode(departName) : null;
index.setDepartmentName(departmentName);
}
String staffName = index.getStaffName() != null ? EmojiUtils.parseToUnicode(index.getStaffName()) : null;
index.setStaffName(staffName);
});
}
return result;
}
/**
* 查询指定跟进类型的员工
* @param entmicroFollowerStaffRequest
* @return
*/
public List<EntmicroFollowerStaffResponse> findEntFollowStaffSpec(EntmicroFollowerStaffRequest entmicroFollowerStaffRequest) {
String followTypeName = environment.getProperty("enmicro.notice.followTypeName");
List<String> followTypeNameList = Arrays.asList(followTypeName.split(","));
entmicroFollowerStaffRequest.setFollowerTypeNameList(followTypeNameList);
return entmicroStaffMapper.listEntmicroFollower(entmicroFollowerStaffRequest);
}
}