BatchMessagingService.java
8.58 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package cn.com.glsx.entmicro.service.wechatcloudcontrol;
import cn.com.glsx.entmicro.convert.ConvertRequest;
import cn.com.glsx.entmicro.convert.ConvertResponse;
import cn.com.glsx.entmicro.dto.activityreport.ScrmActivityReportLogDTO;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.activityreport.ActivityReportLogSearchRpcRequest;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.batchmessaging.BatchMessagingMerchantRpcRequest;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.batchmessaging.BatchMessagingQueryRpcRequest;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.batchmessaging.BatchMessagingRpcRequest;
import cn.com.glsx.entmicro.model.request.wechatcloudcontrol.batchmessaging.BatchMessagingUserRpcRequest;
import cn.com.glsx.entmicro.model.response.wechatcloudcontrol.batchmessaging.BatchMessagingGroupResponse;
import cn.com.glsx.entmicro.model.response.wechatcloudcontrol.batchmessaging.BatchMessagingMerchantResponse;
import cn.com.glsx.entmicro.model.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordOfSendResponse;
import cn.com.glsx.entmicro.model.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordResponse;
import cn.com.glsx.entmicro.remote.BatchMessagingRemote;
import cn.com.glsx.entmicro.request.wechatcloudcontrol.ActivityReportLog.ActivityReportLogSearchRopRequest;
import cn.com.glsx.entmicro.request.wechatcloudcontrol.batchmessaging.*;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingMerchantVO;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordOfSendVO;
import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMessagingRecordVO;
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.entmicro.utils.RopHttpUtil;
import cn.com.glsx.worktool.model.response.ScrmWorktoolGroupResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description
* @author chizw
* @create 2022/9/19 16:14
* @version ver.1.0.0
*/
@Service
@Slf4j
public class BatchMessagingService {
@Resource
private BatchMessagingRemote batchMessagingRemote;
@Autowired
private Environment env;
/**
* 企微高级群发任务创建
* @param ropRequest
* @return
*/
public Boolean createBatchMessagingTask(BatchMessagingCreateRopRequest ropRequest) {
BatchMessagingRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingRpcRequest());
RpcResponse<Boolean> response = batchMessagingRemote.createBatchMessagingTask(rpcRequest);
if (response.isSuccess()) {
return response.getResult();
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 查看预计群发人数
* @param ropRequest
* @return
*/
public Integer getEstimateCustomerCount(BatchMessagingCreateRopRequest ropRequest) {
BatchMessagingRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingRpcRequest());
RpcResponse<Integer> response = batchMessagingRemote.getEstimateCustomerCount(rpcRequest);
if (response.isSuccess()) {
return response.getResult();
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 企微高级群发查询创建门店
* @param ropRequest
* @return
*/
public List<BatchMessagingMerchantVO> findBatchMessagingMerchantList(BatchMessagingMerchantRopRequest ropRequest) {
BatchMessagingMerchantRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingMerchantRpcRequest());
RpcResponse<List<BatchMessagingMerchantResponse>> response = batchMessagingRemote.findBatchMessagingMerchantList(rpcRequest);
if (response.isSuccess()) {
return ConvertResponse.convertList(response.getResult(), BatchMessagingMerchantVO.class);
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 企微高级群发查询群发记录
* @param ropRequest
* @return
*/
public Pagination<BatchMessagingRecordVO> queryBatchMessaging(BatchMessagingRecordRopRequest ropRequest) {
BatchMessagingQueryRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingQueryRpcRequest());
RpcResponse<RpcPagination<BatchMessagingRecordResponse>> response = batchMessagingRemote.queryBatchMessaging(rpcRequest);
if (response.isSuccess()) {
return ConvertResponse.convertPage(response.getResult(), BatchMessagingRecordVO.class);
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 企微高级群发查询群发发送记录
* @param ropRequest
* @return
*/
public Pagination<BatchMessagingRecordOfSendVO> queryBatchMessagingOfSend(BatchMessagingRecordOfSendRopRequest ropRequest) {
BatchMessagingQueryRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingQueryRpcRequest());
RpcResponse<RpcPagination<BatchMessagingRecordOfSendResponse>> response = batchMessagingRemote.queryBatchMessagingOfSend(rpcRequest);
if (response.isSuccess()) {
return ConvertResponse.convertPage(response.getResult(), BatchMessagingRecordOfSendVO.class);
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 获取企微群列表
* @param ropRequest
* @return
*/
public List<BatchMessagingGroupResponse> getBatchMessagingGroupList(BatchMessagingUserRopRequest ropRequest) {
BatchMessagingUserRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new BatchMessagingUserRpcRequest());
RpcResponse<List<BatchMessagingGroupResponse>> response = batchMessagingRemote.getBatchMessagingGroupList(rpcRequest);
if (response.isSuccess()) {
return ConvertResponse.convertList(response.getResult(), BatchMessagingGroupResponse.class);
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 群发记录停止发送
* @param ropRequest
* @return
*/
public Boolean stopBatchMessagingSend(BatchMessagingRecordOfSendRopRequest ropRequest) {
RpcResponse<Boolean> response = batchMessagingRemote.stopBatchMessagingSend(ropRequest.getMsgId());
if (response.isSuccess()) {
return response.getResult();
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
/**
* 查询喜报战报推送日志分页列表
* @param ropRequest
* @return
*/
public Pagination<ScrmActivityReportLogDTO> getActivityReportLogPage(ActivityReportLogSearchRopRequest ropRequest) {
ActivityReportLogSearchRpcRequest rpcRequest = ConvertRequest.convertRequest(ropRequest, new ActivityReportLogSearchRpcRequest());
RpcResponse<RpcPagination<ScrmActivityReportLogDTO>> response = batchMessagingRemote.getActivityReportLogPage(rpcRequest);
if (response.isSuccess()) {
return ConvertResponse.convertPage(response.getResult(), ScrmActivityReportLogDTO.class);
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
public RpcResponse<List<ScrmWorktoolGroupResponse>> getNewReportGroupList() {
// 获取请求url
String requestUrl = env.getProperty("dj.new.report.group.push.url");
if (StringUtils.isBlank(requestUrl)) {
log.error("新版群推送url配置为空");
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, "新版群推送url配置为空");
}
log.info("requestUrl:{}", requestUrl);
try {
// 获取群列表
List<ScrmWorktoolGroupResponse> groupList = RopHttpUtil.getGroupList(requestUrl);
return RpcResponse.success(groupList);
} catch (Exception e) {
log.error("获取群列表失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, "获取群列表失败: " + e.getMessage());
}
}
}