| | |
| | | package com.xiaopeng.operation.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xiaopeng.api.dto.account.UserResourcesDto; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.model.operation.XpFeedbackType; |
| | | import com.xiaopeng.api.model.operation.XpUserFeedback; |
| | | import com.xiaopeng.api.vo.account.GetUserListByUidsVo; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.operation.mapper.XpUserFeedbackMapper; |
| | | import com.xiaopeng.operation.query.UserFeedBackQuery; |
| | | import com.xiaopeng.operation.service.IXpFeedbackTypeService; |
| | | import com.xiaopeng.operation.service.IXpUserFeedbackService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.operation.vo.XpUserFeedbackVO; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2026-02-03 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor(onConstructor_ = @Lazy) |
| | | public class XpUserFeedbackServiceImpl extends ServiceImpl<XpUserFeedbackMapper, XpUserFeedback> implements IXpUserFeedbackService { |
| | | private final UserResourcesClient userResourcesClient; |
| | | private final IXpFeedbackTypeService xpFeedbackTypeService; |
| | | |
| | | @Override |
| | | public PageInfo<XpUserFeedbackVO> getPageList(UserFeedBackQuery query) { |
| | | Page<XpUserFeedback> page = lambdaQuery() |
| | | .like(StringUtils.isNotBlank(query.getFeedbackContent()), XpUserFeedback::getFeedbackContent, query.getFeedbackContent()) |
| | | .page(new Page<>(query.getPageNum(), query.getPageSize())); |
| | | //转换为VO |
| | | List<XpUserFeedbackVO> xpUserFeedbackVOS = BeanUtil.copyToList(page.getRecords(), XpUserFeedbackVO.class); |
| | | //获取小鹏用户信息 |
| | | List<Long> xpUid = xpUserFeedbackVOS.stream().map(XpUserFeedback::getFeedbackUserId).distinct().collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(xpUid)) { |
| | | GetUserListByUidsVo getUserListByUidsVo = new GetUserListByUidsVo(); |
| | | getUserListByUidsVo.setUids(xpUid); |
| | | getUserListByUidsVo.setGetPreCarOwner(Boolean.TRUE); |
| | | UserResourcesDto resultData = userResourcesClient.getUserListByUids(getUserListByUidsVo); |
| | | if (resultData.getCode().equals(HttpStatus.OK.value())) { |
| | | JSONObject jsonObject = JSONObject.parseObject(resultData.getData().toString()); |
| | | for (XpUserFeedbackVO xpUserFeedbackVO : xpUserFeedbackVOS) { |
| | | JSONObject userInfo = jsonObject.getJSONObject(xpUserFeedbackVO.getFeedbackUserId().toString()); |
| | | if (Objects.nonNull(userInfo)) { |
| | | xpUserFeedbackVO.setNickname(userInfo.getString("nickName")); |
| | | xpUserFeedbackVO.setAvatar(userInfo.getString("headImg")); |
| | | xpUserFeedbackVO.setPhone(userInfo.getString("mobile")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //收集意见反馈类型ID |
| | | List<Long> feedbackTypeIds = xpUserFeedbackVOS.stream().map(XpUserFeedback::getFeedbackTypeId).distinct().collect(Collectors.toList()); |
| | | Map<Long, String> feedbackTypeMap = CollUtil.isNotEmpty(feedbackTypeIds) ? |
| | | xpFeedbackTypeService.listByIds(feedbackTypeIds).stream() |
| | | .collect(Collectors.toMap(XpFeedbackType::getId, XpFeedbackType::getFeedbackType)) |
| | | : Collections.emptyMap(); |
| | | xpUserFeedbackVOS.forEach(item-> item.setFeedbackTypeName(feedbackTypeMap.get(item.getFeedbackTypeId()))); |
| | | |
| | | //封装分页信息 |
| | | PageInfo<XpUserFeedbackVO> pageInfo = new PageInfo<>(); |
| | | pageInfo.setTotal(page.getTotal()); |
| | | pageInfo.setSize(page.getSize()); |
| | | pageInfo.setPages(page.getPages()); |
| | | pageInfo.setRecords(xpUserFeedbackVOS); |
| | | return pageInfo; |
| | | } |
| | | } |