|
@@ -133,28 +133,46 @@ public class QwCustomerLinkController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增/获客链接
|
|
|
|
|
|
|
+ * 新增渠道链接
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/channel/create")
|
|
@PostMapping("/channel/create")
|
|
|
public Result<Void> createChannel(@RequestBody QwCustomerLinkChannelReq linkChannelReq) {
|
|
public Result<Void> createChannel(@RequestBody QwCustomerLinkChannelReq linkChannelReq) {
|
|
|
- // 渠道链接
|
|
|
|
|
- QwCustomerLinkChannel bean = BeanUtil.toBean(linkChannelReq, QwCustomerLinkChannel.class);
|
|
|
|
|
- // 主链信息
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 主链
|
|
|
QwCustomerLink qwCustomerLink = qwCustomerLinkService.getById(linkChannelReq.getSysLinkId());
|
|
QwCustomerLink qwCustomerLink = qwCustomerLinkService.getById(linkChannelReq.getSysLinkId());
|
|
|
- // 生成链接
|
|
|
|
|
- QwLinkCreateParam qwLinkCreateParam = new QwLinkCreateParam();
|
|
|
|
|
- qwLinkCreateParam.setLink_name(linkChannelReq.getLinkName());
|
|
|
|
|
- qwLinkCreateParam.setSkip_verify(qwCustomerLink.getSkipVerify().equals(1));
|
|
|
|
|
- List<QwCustomerLinkUser> list = qwCustomerLinkUserService.list(new LambdaQueryWrapper<QwCustomerLinkUser>()
|
|
|
|
|
- .eq(QwCustomerLinkUser::getSysQwUserId, qwCustomerLink.getId()));
|
|
|
|
|
- QwLinkCreateParam.Range range = new QwLinkCreateParam.Range();
|
|
|
|
|
- range.setUser_list(list.stream().map(QwCustomerLinkUser::getQwUserId).collect(Collectors.toList()));
|
|
|
|
|
- qwLinkCreateParam.setRange(range);
|
|
|
|
|
- QwLinkCreateResult qwLinkCreateResult = qwApiService.linkCreate(qwLinkCreateParam, qwCustomerLink.getCorpId());
|
|
|
|
|
- // 设置链接信息
|
|
|
|
|
- bean.setLinkId(qwLinkCreateResult.getLinkId());
|
|
|
|
|
- bean.setUrl(qwLinkCreateResult.getUrl());
|
|
|
|
|
- return qwCustomerLinkChannelService.save(bean) ? Result.success() : Result.error("创建失败");
|
|
|
|
|
|
|
+ // 主链关联的企微用户
|
|
|
|
|
+ List<QwCustomerLinkUser> linkUsers = qwCustomerLinkUserService.list(new LambdaQueryWrapper<QwCustomerLinkUser>()
|
|
|
|
|
+ .eq(QwCustomerLinkUser::getSysLinkId, qwCustomerLink.getId()));
|
|
|
|
|
+ List<String> userIdList = linkUsers.stream()
|
|
|
|
|
+ .map(QwCustomerLinkUser::getQwUserId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<QwCustomerLinkChannel> channels = linkChannelReq.getChannelList().stream()
|
|
|
|
|
+ .map(channelDto -> {
|
|
|
|
|
+ QwLinkCreateParam param = new QwLinkCreateParam();
|
|
|
|
|
+ param.setLink_name(channelDto.getChannelName());
|
|
|
|
|
+ param.setSkip_verify(qwCustomerLink.getSkipVerify().equals(1));
|
|
|
|
|
+ QwLinkCreateParam.Range range = new QwLinkCreateParam.Range();
|
|
|
|
|
+ range.setUser_list(userIdList);
|
|
|
|
|
+ param.setRange(range);
|
|
|
|
|
+
|
|
|
|
|
+ // QwLinkCreateResult linkResult = qwApiService.linkCreate(param, qwCustomerLink.getCorpId());
|
|
|
|
|
+
|
|
|
|
|
+ QwCustomerLinkChannel channel = new QwCustomerLinkChannel();
|
|
|
|
|
+ channel.setChannelId(channelDto.getChannelId());
|
|
|
|
|
+ channel.setChannelName(channelDto.getChannelName());
|
|
|
|
|
+ channel.setSysLinkId(linkChannelReq.getSysLinkId());
|
|
|
|
|
+ channel.setLinkName(channelDto.getChannelName());
|
|
|
|
|
+ // channel.setLinkId(linkResult.getLinkId());
|
|
|
|
|
+ // channel.setUrl(linkResult.getUrl());
|
|
|
|
|
+
|
|
|
|
|
+ channel.setLinkId(IdUtil.randomUUID());
|
|
|
|
|
+ channel.setUrl("https://work.weixin.qq.com/ca/" + IdUtil.randomUUID());
|
|
|
|
|
+ return channel;
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ return qwCustomerLinkChannelService.saveBatch(channels) ? Result.success() : Result.error("创建失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|