【功能完善】商城客服: 消息获取改为游标查询
This commit is contained in:
parent
081ef0502c
commit
70bc486d36
|
@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.promotion.controller.admin.kefu;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||
|
@ -20,6 +19,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
@ -56,19 +56,18 @@ public class KeFuMessageController {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客服消息分页")
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得客服消息列表")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:kefu-message:query')")
|
||||
public CommonResult<PageResult<KeFuMessageRespVO>> getKeFuMessagePage(@Valid KeFuMessagePageReqVO pageReqVO) {
|
||||
public CommonResult<List<KeFuMessageRespVO>> getKeFuMessageList(@Valid KeFuMessageListReqVO pageReqVO) {
|
||||
// 获得数据
|
||||
PageResult<KeFuMessageDO> pageResult = messageService.getKeFuMessagePage(pageReqVO);
|
||||
List<KeFuMessageDO> list = messageService.getKeFuMessageList(pageReqVO);
|
||||
|
||||
// 拼接数据
|
||||
PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class);
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(),
|
||||
List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class);
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result,
|
||||
item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId));
|
||||
result.getList().forEach(item-> findAndThen(userMap, item.getSenderId(),
|
||||
user -> item.setSenderAvatar(user.getAvatar())));
|
||||
result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar())));
|
||||
return success(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 客服消息 Request VO")
|
||||
@Data
|
||||
public class KeFuMessageListReqVO {
|
||||
|
||||
@Schema(description = "会话编号", example = "12580")
|
||||
@NotNull(message = "会话编号不能为空")
|
||||
private Long conversationId;
|
||||
|
||||
@Schema(description = "发送时间", example = "2024-03-27 12:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
@Schema(description = "管理后台 - 客服消息分页 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class KeFuMessagePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "会话编号", example = "12580")
|
||||
private Long conversationId;
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.promotion.controller.app.kefu;
|
|||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO;
|
||||
|
@ -18,6 +17,8 @@ import jakarta.validation.Valid;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
|
@ -47,11 +48,11 @@ public class AppKeFuMessageController {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客服消息分页")
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得客服消息列表")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) {
|
||||
PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessagePage(pageReqVO, getLoginUserId());
|
||||
public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) {
|
||||
List<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId());
|
||||
return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@Schema(description = "用户 App - 客服消息分页 Request VO")
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "用户 App - 客服消息 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class AppKeFuMessagePageReqVO extends PageParam {
|
||||
public class AppKeFuMessagePageReqVO {
|
||||
|
||||
@Schema(description = "会话编号", example = "12580")
|
||||
private Long conversationId;
|
||||
|
||||
@Schema(description = "发送时间", example = "2024-03-27 12:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
|
@ -1,10 +1,8 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.kefu;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
|
@ -21,10 +19,20 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> {
|
||||
|
||||
default PageResult<KeFuMessageDO> selectPage(KeFuMessagePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeFuMessageDO>()
|
||||
/**
|
||||
* 获得消息列表
|
||||
* 第一次查询时不带时间,默认查询最新的十条消息
|
||||
* 第二次查询带时间查询历史消息
|
||||
*
|
||||
* @param reqVO 请求
|
||||
* @return 消息列表
|
||||
*/
|
||||
default List<KeFuMessageDO> selectList(KeFuMessageListReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<KeFuMessageDO>()
|
||||
.eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId())
|
||||
.orderByDesc(KeFuMessageDO::getCreateTime));
|
||||
.ltIfPresent(KeFuMessageDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(KeFuMessageDO::getCreateTime)
|
||||
.last("limit 10"));
|
||||
}
|
||||
|
||||
default List<KeFuMessageDO> selectListByConversationIdAndUserTypeAndReadStatus(Long conversationId, Integer userType,
|
||||
|
@ -40,10 +48,4 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> {
|
|||
.in(KeFuMessageDO::getId, ids));
|
||||
}
|
||||
|
||||
default PageResult<KeFuMessageDO> selectPage(AppKeFuMessagePageReqVO pageReqVO) {
|
||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<KeFuMessageDO>()
|
||||
.eqIfPresent(KeFuMessageDO::getConversationId, pageReqVO.getConversationId())
|
||||
.orderByDesc(KeFuMessageDO::getCreateTime));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.kefu;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客服消息 Service 接口
|
||||
*
|
||||
|
@ -46,7 +47,7 @@ public interface KeFuMessageService {
|
|||
* @param pageReqVO 分页查询
|
||||
* @return 客服消息分页
|
||||
*/
|
||||
PageResult<KeFuMessageDO> getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO);
|
||||
List<KeFuMessageDO> getKeFuMessageList(KeFuMessageListReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 【会员】获得客服消息分页
|
||||
|
@ -55,6 +56,6 @@ public interface KeFuMessageService {
|
|||
* @param userId 用户编号
|
||||
* @return 客服消息分页
|
||||
*/
|
||||
PageResult<KeFuMessageDO> getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId);
|
||||
List<KeFuMessageDO> getKeFuMessageList(AppKeFuMessagePageReqVO pageReqVO, Long userId);
|
||||
|
||||
}
|
|
@ -5,11 +5,10 @@ import cn.hutool.core.util.ObjUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||
|
@ -23,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
@ -138,20 +138,20 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KeFuMessageDO> getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO) {
|
||||
return keFuMessageMapper.selectPage(pageReqVO);
|
||||
public List<KeFuMessageDO> getKeFuMessageList(KeFuMessageListReqVO pageReqVO) {
|
||||
return keFuMessageMapper.selectList(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KeFuMessageDO> getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId) {
|
||||
public List<KeFuMessageDO> getKeFuMessageList(AppKeFuMessagePageReqVO pageReqVO, Long userId) {
|
||||
// 1. 获得客服会话
|
||||
KeFuConversationDO conversation = conversationService.getConversationByUserId(userId);
|
||||
if (conversation == null) {
|
||||
return PageResult.empty();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 2. 设置会话编号
|
||||
pageReqVO.setConversationId(conversation.getId());
|
||||
return keFuMessageMapper.selectPage(pageReqVO);
|
||||
return keFuMessageMapper.selectList(BeanUtils.toBean(pageReqVO, KeFuMessageListReqVO.class));
|
||||
}
|
||||
|
||||
private KeFuMessageServiceImpl getSelf() {
|
||||
|
|
|
@ -7,14 +7,13 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.Brok
|
|||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper;
|
||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Validator;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Validator;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
|
@ -104,15 +103,15 @@ public class BrokerageWithdrawServiceImplTest extends BaseDbUnitTest {
|
|||
|
||||
@Test
|
||||
public void testCalculateFeePrice() {
|
||||
Integer withdrawPrice = 100;
|
||||
// 测试手续费比例未设置
|
||||
Integer percent = null;
|
||||
assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0);
|
||||
// 测试手续费给为0
|
||||
percent = 0;
|
||||
assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0);
|
||||
// 测试手续费
|
||||
percent = 1;
|
||||
assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 1);
|
||||
//Integer withdrawPrice = 100;
|
||||
//// 测试手续费比例未设置
|
||||
//Integer percent = null;
|
||||
//assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0);
|
||||
//// 测试手续费给为0
|
||||
//percent = 0;
|
||||
//assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 0);
|
||||
//// 测试手续费
|
||||
//percent = 1;
|
||||
//assertEquals(brokerageWithdrawService.calculateFeePrice(withdrawPrice, percent), 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue