Merge pull request 'khy-three' (#131) from khy-three into master
Reviewed-on: #131
This commit is contained in:
commit
d8f71b14cb
@ -37,6 +37,25 @@ public class KeFuConversationController {
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得客服会话")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:query')")
|
||||
public CommonResult<KeFuConversationRespVO> getConversation(@RequestParam("id") Long id) {
|
||||
KeFuConversationDO conversation = conversationService.getConversation(id);
|
||||
if (conversation == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 拼接数据
|
||||
KeFuConversationRespVO result = BeanUtils.toBean(conversation, KeFuConversationRespVO.class);
|
||||
MemberUserRespDTO memberUser = memberUserApi.getUser(conversation.getUserId());
|
||||
if (memberUser != null) {
|
||||
result.setUserAvatar(memberUser.getAvatar()).setUserNickname(memberUser.getNickname());
|
||||
}
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@PutMapping("/update-conversation-pinned")
|
||||
@Operation(summary = "置顶/取消置顶客服会话")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:update')")
|
||||
|
@ -10,8 +10,10 @@ import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.CircleRespVO
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.circle.vo.CircleSaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.circlereview.vo.CircleReviewSaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.circle.CircleDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.circlelike.CircleLikeDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.circlereview.CircleReviewDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.circle.CircleService;
|
||||
import cn.iocoder.yudao.module.promotion.service.circlelike.CircleLikeService;
|
||||
import cn.iocoder.yudao.module.promotion.service.circlereview.CircleReviewService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -37,6 +39,8 @@ public class AppCircleController {
|
||||
private CircleReviewService circleReviewService;
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
@Resource
|
||||
private CircleLikeService circleLikeService;
|
||||
|
||||
public String utilMethod(Long userId,Long reviewId){
|
||||
String nickname = memberUserApi.getUser(userId).getNickname();
|
||||
@ -108,6 +112,18 @@ public class AppCircleController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/getLike")
|
||||
@Operation(summary = "查询是否点赞")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> getLike(@RequestParam("id") Long lookId){
|
||||
CircleLikeDO circleLikeDO = circleLikeService.getCircleLike(lookId,getLoginUserId());
|
||||
Boolean isLike = false;
|
||||
if (circleLikeDO != null){
|
||||
isLike = true;
|
||||
}
|
||||
return success(isLike);
|
||||
}
|
||||
|
||||
@PutMapping("/doLike")
|
||||
@Operation(summary = "点赞/取消点赞")
|
||||
@PreAuthenticated
|
||||
|
@ -13,6 +13,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface KeFuConversationService {
|
||||
|
||||
/**
|
||||
* 获得客服会话
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 客服会话
|
||||
*/
|
||||
KeFuConversationDO getConversation(Long id);
|
||||
|
||||
/**
|
||||
* 【管理员】删除客服会话
|
||||
*
|
||||
|
@ -37,6 +37,11 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
|
||||
@Resource
|
||||
private SupportStaffMapper supportStaffMapper;
|
||||
|
||||
@Override
|
||||
public KeFuConversationDO getConversation(Long id) {
|
||||
return conversationMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKefuConversation(Long id) {
|
||||
// 校验存在
|
||||
@ -145,11 +150,20 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
|
||||
|
||||
@Override
|
||||
public String transferConversation(Long id, Long kefuId) {
|
||||
//先下线
|
||||
KeFuConversationDO currDo = conversationMapper.selectById(id);
|
||||
SupportStaffDO currSs = supportStaffMapper.selectById(currDo.getKefuId());
|
||||
currSs.setStatus(0);
|
||||
supportStaffMapper.updateById(currSs);
|
||||
//会话转接
|
||||
KeFuConversationDO keFuConversationDO = new KeFuConversationDO();
|
||||
keFuConversationDO.setId(id);
|
||||
keFuConversationDO.setKefuId(kefuId);
|
||||
conversationMapper.updateById(keFuConversationDO);
|
||||
//再上线新客服
|
||||
SupportStaffDO supportStaffDO = supportStaffMapper.selectById(kefuId);
|
||||
supportStaffDO.setStatus(1);
|
||||
supportStaffMapper.updateById(supportStaffDO);
|
||||
return supportStaffDO.getName();
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,13 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateKeFuMessageReadStatus(Long conversationId, Long userId, Integer userType) {
|
||||
//判断是否是客服
|
||||
SupportStaffDO staff = supportStaffMapper.selectOne(new LambdaUpdateWrapper<SupportStaffDO>()
|
||||
.eq(SupportStaffDO::getUserId,getLoginUserId()));
|
||||
if (staff != null && staff.getStatus() == 1){
|
||||
conversationService.updateAdminUnreadMessageCountToZero(conversationId);
|
||||
return;
|
||||
}
|
||||
// 1.1 校验会话是否存在
|
||||
KeFuConversationDO conversation = conversationService.validateKefuConversationExists(conversationId);
|
||||
// 1.2 如果是会员端处理已读,需要传递 userId;万一用户模拟一个 conversationId
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.supportstaff;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -13,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS;
|
||||
|
||||
/**
|
||||
* 客服人员 Service 实现类
|
||||
@ -26,6 +29,9 @@ public class SupportStaffServiceImpl implements SupportStaffService {
|
||||
@Resource
|
||||
private SupportStaffMapper supportStaffMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Integer createSupportStaff(SupportStaffSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -36,8 +42,23 @@ public class SupportStaffServiceImpl implements SupportStaffService {
|
||||
throw exception(SUPPORT_STAFF_USER_EXISTS);
|
||||
}
|
||||
}
|
||||
List<AdminUserRespDTO> users = adminUserApi.getListNoArgs();
|
||||
if(!users.isEmpty()){
|
||||
users.forEach(user -> {
|
||||
if(user.getUsername().equals(createReqVO.getAccount())){
|
||||
throw exception(USER_USERNAME_EXISTS);
|
||||
}
|
||||
});
|
||||
}
|
||||
supportStaff.setLineStatus(2);
|
||||
supportStaffMapper.insert(supportStaff);
|
||||
AdminUserRespDTO adminUserRespDTO = new AdminUserRespDTO();
|
||||
adminUserRespDTO.setUsername(createReqVO.getAccount());
|
||||
adminUserRespDTO.setMobile(supportStaff.getPhone());
|
||||
adminUserRespDTO.setPassword(createReqVO.getPassword());
|
||||
adminUserRespDTO.setNickname(supportStaff.getName());
|
||||
|
||||
adminUserApi.createUserBySupportStaff(adminUserRespDTO);
|
||||
// 返回
|
||||
return supportStaff.getId();
|
||||
}
|
||||
@ -50,6 +71,23 @@ public class SupportStaffServiceImpl implements SupportStaffService {
|
||||
SupportStaffDO updateObj = BeanUtils.toBean(updateReqVO, SupportStaffDO.class);
|
||||
|
||||
SupportStaffDO supportStaffDO = supportStaffMapper.selectOne("id", updateReqVO.getId());
|
||||
AdminUserRespDTO adminUser = new AdminUserRespDTO();
|
||||
adminUser.setUsername(updateReqVO.getAccount());
|
||||
adminUser.setMobile(updateReqVO.getPhone());
|
||||
adminUser.setPassword(updateReqVO.getPassword());
|
||||
adminUser.setNickname(updateReqVO.getName());
|
||||
|
||||
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUserByUserName(supportStaffDO.getAccount());
|
||||
if(adminUserRespDTO == null){
|
||||
// 新建一个后台账户
|
||||
adminUserApi.createUserBySupportStaff(adminUser);
|
||||
}
|
||||
else {
|
||||
adminUserRespDTO.setUsername(adminUser.getUsername());
|
||||
adminUserRespDTO.setPassword(adminUser.getPassword());
|
||||
adminUserApi.updateUserBySupportStaff(adminUserRespDTO);
|
||||
}
|
||||
|
||||
//判断用户是否被绑定
|
||||
if (updateObj.getUserId() != null){
|
||||
if (supportStaffDO.getUserId() == null || !supportStaffDO.getUserId().equals(updateObj.getUserId())){
|
||||
|
@ -123,4 +123,10 @@ public class AppAuthController {
|
||||
return success(AuthConvert.INSTANCE.convert(signature));
|
||||
}
|
||||
|
||||
@PostMapping("/checkLogin")
|
||||
@PermitAll
|
||||
public CommonResult<Integer> checkLogin(@RequestBody @Valid AppAuthSocialLoginReqVO reqVO) {
|
||||
return success(authService.checkLogin(reqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,4 +85,6 @@ public interface MemberAuthService {
|
||||
*/
|
||||
AppAuthLoginRespVO refreshToken(String refreshToken);
|
||||
|
||||
Integer checkLogin(AppAuthSocialLoginReqVO reqVO);
|
||||
|
||||
}
|
||||
|
@ -258,6 +258,25 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
return AuthConvert.INSTANCE.convert(accessTokenDO, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer checkLogin(AppAuthSocialLoginReqVO reqVO) {
|
||||
// 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
|
||||
SocialUserRespDTO socialUser = socialUserApi.getSocialUserByCode(UserTypeEnum.MEMBER.getValue(), reqVO.getType(),
|
||||
reqVO.getCode(), reqVO.getState());
|
||||
System.out.println(socialUser);
|
||||
if (socialUser == null) {
|
||||
System.out.println("111");
|
||||
throw exception(AUTH_SOCIAL_USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
//判断openid是否存在
|
||||
// SocialUserRespDTO respDTO = socialUserApi.getSocialUserByOpenId(socialUser.getOpenid());
|
||||
if (socialUser.getUserId() == null) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void createLogoutLog(Long userId) {
|
||||
LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
|
||||
reqDTO.setLogType(LoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
|
@ -589,7 +589,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
userPostMapper.insertBatch(convertList(user.getPostIds(),
|
||||
postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId)));
|
||||
}
|
||||
RoleDO role = roleService.getRoleByCode("support_staff");
|
||||
RoleDO role = roleService.getRoleByCode("chat");
|
||||
if (role != null){
|
||||
//给后台用户关联客服角色
|
||||
permissionService.assignUserRole(user.getId(), Collections.singleton(role.getId()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user