|
@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
|
|
+import com.ydtech.modules.admin.constants.SwitchConfig;
|
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.po.SysQyWeChat;
|
|
import com.ydtech.modules.admin.model.po.SysQyWeChat;
|
|
|
import com.ydtech.modules.admin.service.*;
|
|
import com.ydtech.modules.admin.service.*;
|
|
@@ -33,6 +34,10 @@ public class SysQyWeChatController {
|
|
|
|
|
|
|
|
private final SysWechatCustomerBusinessService sysWechatCustomerBusinessService;
|
|
private final SysWechatCustomerBusinessService sysWechatCustomerBusinessService;
|
|
|
|
|
|
|
|
|
|
+ private final WechatCustomerService wechatCustomerService;
|
|
|
|
|
+
|
|
|
|
|
+ private final SysSwitchConfigService switchConfigService;
|
|
|
|
|
+
|
|
|
@ApiOperation(value = "配置宣传图/客服")
|
|
@ApiOperation(value = "配置宣传图/客服")
|
|
|
@PostMapping(value = "/save/picture")
|
|
@PostMapping(value = "/save/picture")
|
|
|
public HttpResult<SysQyWeChat> save(@RequestBody SysQyWeChat sysQyWeChat) {
|
|
public HttpResult<SysQyWeChat> save(@RequestBody SysQyWeChat sysQyWeChat) {
|
|
@@ -43,7 +48,7 @@ public class SysQyWeChatController {
|
|
|
if (serviceOne != null) {
|
|
if (serviceOne != null) {
|
|
|
sysQyWeChat.setId(serviceOne.getId());
|
|
sysQyWeChat.setId(serviceOne.getId());
|
|
|
save = sysQyWeChatService.updateById(sysQyWeChat);
|
|
save = sysQyWeChatService.updateById(sysQyWeChat);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
save = sysQyWeChatService.save(sysQyWeChat);
|
|
save = sysQyWeChatService.save(sysQyWeChat);
|
|
|
}
|
|
}
|
|
|
AssertionUtils.isSucceed(save, "添加失败");
|
|
AssertionUtils.isSucceed(save, "添加失败");
|
|
@@ -80,8 +85,20 @@ public class SysQyWeChatController {
|
|
|
public HttpResult<String> findWechatCustomerLink() throws WxErrorException {
|
|
public HttpResult<String> findWechatCustomerLink() throws WxErrorException {
|
|
|
String userId = BaseController.getUser().getId();
|
|
String userId = BaseController.getUser().getId();
|
|
|
SysUser user = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, userId));
|
|
SysUser user = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, userId));
|
|
|
- String link = sysWechatCustomerBusinessService.getWeChatCustomer(user);
|
|
|
|
|
- return HttpResult.ok(link);
|
|
|
|
|
|
|
+ if (switchConfigService.isEnabled(SwitchConfig.CUSTOMER.getCode())) {
|
|
|
|
|
+ String link = sysWechatCustomerBusinessService.getWeChatCustomer(user);
|
|
|
|
|
+ return HttpResult.ok(link);
|
|
|
|
|
+ }
|
|
|
|
|
+ SysQyWeChat sysQyWeChat = sysQyWeChatService.getOne(new LambdaQueryWrapper<SysQyWeChat>().eq(SysQyWeChat::getUserId, user.getLeaderId()));
|
|
|
|
|
+ if (sysQyWeChat == null) {
|
|
|
|
|
+ List<SysQyWeChat> list = sysQyWeChatService.list();
|
|
|
|
|
+ sysQyWeChat = list.get(new Random().nextInt(list.size()));
|
|
|
|
|
+ }
|
|
|
|
|
+ String s = wechatCustomerService.addContactWay(sysQyWeChat.getOpenKfId());
|
|
|
|
|
+ if (StringUtils.isNotEmpty(s)) {
|
|
|
|
|
+ String url = s + "&scene_param=" + userId;
|
|
|
|
|
+ return HttpResult.ok(url);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok(sysQyWeChat.getSupportStaffUrl());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|