| | |
| | | package com.xiaopeng.order.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.dto.account.UserResourcesDto; |
| | | import com.xiaopeng.api.dto.account.UcUserInfo; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpSystemSettingClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.XpAppUser; |
| | | import com.xiaopeng.api.model.operation.XpInvitationCode; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.order.XpOrderEvaluate; |
| | | import com.xiaopeng.api.vo.account.GetUserListByUidsVo; |
| | | import com.xiaopeng.common.core.constant.HttpStatus; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | |
| | | } |
| | | |
| | | // 4. 批量查询关联数据 |
| | | JSONObject jsonObject = batchGetUsers(userIds); |
| | | Map<String, UcUserInfo> userInfoMap = batchGetUsers(userIds); |
| | | Map<Long, XpVehicle> vehicleMap = batchGetVehicles(vehicleIds); |
| | | Map<Long, XpOrder> orderMap = batchGetOrders(orderIds); |
| | | |
| | | // 5. 根据查询条件过滤(手机号、车牌号) |
| | | List<OrderEvaluatePageVO> voList = evaluatePage.getRecords().stream() |
| | | .map(evaluate -> convertToPageVO(evaluate, jsonObject, vehicleMap, orderMap)) |
| | | .map(evaluate -> convertToPageVO(evaluate, userInfoMap, vehicleMap, orderMap)) |
| | | .filter(vo -> filterByQuery(vo, query)) |
| | | .collect(Collectors.toList()); |
| | | |
| | |
| | | return new PageInfo<>(); |
| | | } |
| | | List<Long> userIds = list.stream().map(OrderEvaluateManagementPageListVO::getUserId).collect(Collectors.toList()); |
| | | GetUserListByUidsVo getUserListByUidsVo = new GetUserListByUidsVo(); |
| | | getUserListByUidsVo.setUids(userIds); |
| | | getUserListByUidsVo.setGetPreCarOwner(false); |
| | | UserResourcesDto userListByUids = userResourcesClient.getUserListByUids(getUserListByUidsVo); |
| | | Map<String, UcUserInfo> userInfoMap = userResourcesClient.getUserListByUids(userIds, false); |
| | | for (OrderEvaluateManagementPageListVO orderEvaluateManagementPageListVO : list) { |
| | | // Object data = userListByUids.getData(); |
| | | // // 转化为jsonArray |
| | | // JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(data)); |
| | | // for (Object o : jsonArray) { |
| | | // // 转化为JsonObject |
| | | // JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(o)); |
| | | // String mobile = jsonObject.getString("mobile"); |
| | | // String nickName = jsonObject.getString("nickName"); |
| | | // String headImage = jsonObject.getString("headImage"); |
| | | // orderEvaluateManagementPageListVO.setPhoneNumber(mobile); |
| | | // orderEvaluateManagementPageListVO.setNickName(nickName); |
| | | // orderEvaluateManagementPageListVO.setHeadImage(headImage); |
| | | // } |
| | | orderEvaluateManagementPageListVO.setPhoneNumber("19983174515"); |
| | | orderEvaluateManagementPageListVO.setNickName("默认用户"); |
| | | orderEvaluateManagementPageListVO.setHeadImage("[]"); |
| | | if (userInfoMap != null && !userInfoMap.isEmpty()) { |
| | | UcUserInfo userInfo = userInfoMap.get(orderEvaluateManagementPageListVO.getUserId().toString()); |
| | | if (userInfo != null) { |
| | | orderEvaluateManagementPageListVO.setPhoneNumber(userInfo.getMobile()); |
| | | orderEvaluateManagementPageListVO.setNickName(userInfo.getNickName()); |
| | | orderEvaluateManagementPageListVO.setHeadImage(userInfo.getHeadImg()); |
| | | } |
| | | } else { |
| | | orderEvaluateManagementPageListVO.setPhoneNumber("19983174515"); |
| | | orderEvaluateManagementPageListVO.setNickName("默认用户"); |
| | | orderEvaluateManagementPageListVO.setHeadImage("[]"); |
| | | } |
| | | systemSettingClient.getFeedbackTypeById(orderEvaluateManagementPageListVO.getFeedbackTypeId()); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 批量获取用户信息 |
| | | */ |
| | | private JSONObject batchGetUsers(Set<Long> userIds) { |
| | | private Map<String, UcUserInfo> batchGetUsers(Set<Long> userIds) { |
| | | if (CollectionUtils.isEmpty(userIds)) { |
| | | return new JSONObject(); |
| | | return new HashMap<>(); |
| | | } |
| | | try { |
| | | GetUserListByUidsVo getUserListByUidsVo = new GetUserListByUidsVo(); |
| | | getUserListByUidsVo.setUids(new ArrayList<>(userIds)); |
| | | getUserListByUidsVo.setGetPreCarOwner(Boolean.TRUE); |
| | | UserResourcesDto userListByUids = userResourcesClient.getUserListByUids(getUserListByUidsVo); |
| | | if (userListByUids.getCode().equals(HttpStatus.SUCCESS)) { |
| | | return JSONObject.parseObject(userListByUids.getData().toString()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("批量获取用户信息失败: {}", e.getMessage()); |
| | | } |
| | | return new JSONObject(); |
| | | return userResourcesClient.getUserListByUids(new ArrayList<>(userIds), false); |
| | | } |
| | | |
| | | /** |
| | |
| | | * VO转换 |
| | | */ |
| | | private OrderEvaluatePageVO convertToPageVO(XpOrderEvaluate evaluate, |
| | | JSONObject jsonObject, |
| | | Map<String, UcUserInfo> userInfoMap, |
| | | Map<Long, XpVehicle> vehicleMap, |
| | | Map<Long, XpOrder> orderMap) { |
| | | OrderEvaluatePageVO vo = new OrderEvaluatePageVO(); |
| | |
| | | vo.setEvaluateTime(evaluate.getEvaluateTime()); |
| | | |
| | | // 用户信息 |
| | | if (Objects.nonNull(evaluate.getAppUserId()) && jsonObject.containsKey(evaluate.getAppUserId().toString())) { |
| | | JSONObject userInfo = jsonObject.getJSONObject(evaluate.getAppUserId().toString()); |
| | | vo.setNickName(userInfo.getString("nickName")); |
| | | vo.setPhoneNumber(userInfo.getString("mobile")); |
| | | if (Objects.nonNull(evaluate.getAppUserId()) && userInfoMap.containsKey(evaluate.getAppUserId().toString())) { |
| | | UcUserInfo userInfo = userInfoMap.get(evaluate.getAppUserId().toString()); |
| | | vo.setNickName(userInfo.getNickName()); |
| | | vo.setPhoneNumber(userInfo.getMobile()); |
| | | } |
| | | |
| | | // 车辆信息 |