|
|
@@ -22,9 +22,12 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.dromara.yingpaipay.api.erp.CommonErpClientService;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 客户管理 Service业务层处理
|
|
|
@@ -60,45 +63,92 @@ public class SysCustomerServiceImpl implements ISysCustomerService, CustomerServ
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量填充授权客户信息
|
|
|
+ * 查询客户详情(含授权客户完整信息列表)
|
|
|
+ * @Author: Antigravity
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SysCustomerVo queryDetail(Long id) {
|
|
|
+ SysCustomerVo vo = baseMapper.selectVoById(id);
|
|
|
+ fillAuthClientDetail(vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量填充授权客户信息(列表用,逗号分隔拼接名称/类型/时间)
|
|
|
+ * @Author: Antigravity
|
|
|
*/
|
|
|
private void fillAuthClientName(List<SysCustomerVo> list) {
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
- List<String> authClientFRowIDs = list.stream()
|
|
|
+ List<String> allIds = list.stream()
|
|
|
.map(SysCustomerVo::getAuthClientFRowID)
|
|
|
.filter(StringUtils::isNotBlank)
|
|
|
+ .flatMap(ids -> Arrays.stream(ids.split(",")))
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
.distinct()
|
|
|
- .toList();
|
|
|
- if (authClientFRowIDs.isEmpty()) {
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (allIds.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
- Map<String, CommonErpClientVo> infoMap = commonErpClientService.selectInfoByFRowIDs(authClientFRowIDs);
|
|
|
+ Map<String, CommonErpClientVo> infoMap = commonErpClientService.selectInfoByFRowIDs(allIds);
|
|
|
list.forEach(vo -> {
|
|
|
- CommonErpClientVo erpVo = infoMap.get(vo.getAuthClientFRowID());
|
|
|
- if (erpVo != null) {
|
|
|
- vo.setAuthClientName(erpVo.getName());
|
|
|
- vo.setAuthClientClass(erpVo.getClientClass());
|
|
|
- vo.setAuthClientEnterDate(erpVo.getEnterDate());
|
|
|
+ if (StringUtils.isBlank(vo.getAuthClientFRowID())) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ List<String> ids = Arrays.stream(vo.getAuthClientFRowID().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<CommonErpClientVo> clients = ids.stream()
|
|
|
+ .map(infoMap::get)
|
|
|
+ .filter(c -> c != null)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setAuthClientName(clients.stream().map(CommonErpClientVo::getName)
|
|
|
+ .collect(Collectors.joining(" / ")));
|
|
|
+ vo.setAuthClientClass(clients.stream().map(CommonErpClientVo::getClientClass)
|
|
|
+ .collect(Collectors.joining(" / ")));
|
|
|
+ vo.setAuthClientEnterDate(clients.stream()
|
|
|
+ .map(c -> c.getEnterDate() != null ? c.getEnterDate().toString() : "")
|
|
|
+ .collect(Collectors.joining(" / ")));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 单个填充授权客户信息
|
|
|
+ * 单个填充授权客户简要信息(兼容旧逻辑)
|
|
|
+ * @Author: Antigravity
|
|
|
*/
|
|
|
private void fillAuthClientName(SysCustomerVo vo) {
|
|
|
if (vo == null || StringUtils.isBlank(vo.getAuthClientFRowID())) {
|
|
|
return;
|
|
|
}
|
|
|
- Map<String, CommonErpClientVo> infoMap = commonErpClientService.selectInfoByFRowIDs(List.of(vo.getAuthClientFRowID()));
|
|
|
- CommonErpClientVo erpVo = infoMap.get(vo.getAuthClientFRowID());
|
|
|
- if (erpVo != null) {
|
|
|
- vo.setAuthClientName(erpVo.getName());
|
|
|
- vo.setAuthClientClass(erpVo.getClientClass());
|
|
|
- vo.setAuthClientEnterDate(erpVo.getEnterDate());
|
|
|
+ fillAuthClientName(Collections.singletonList(vo));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 填充授权客户完整详情列表(详情弹框用)
|
|
|
+ * @Author: Antigravity
|
|
|
+ */
|
|
|
+ private void fillAuthClientDetail(SysCustomerVo vo) {
|
|
|
+ if (vo == null || StringUtils.isBlank(vo.getAuthClientFRowID())) {
|
|
|
+ vo.setAuthClientList(Collections.emptyList());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> ids = Arrays.stream(vo.getAuthClientFRowID().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ids.isEmpty()) {
|
|
|
+ vo.setAuthClientList(Collections.emptyList());
|
|
|
+ return;
|
|
|
}
|
|
|
+ Map<String, CommonErpClientVo> infoMap = commonErpClientService.selectInfoByFRowIDs(ids);
|
|
|
+ List<CommonErpClientVo> clients = ids.stream()
|
|
|
+ .map(infoMap::get)
|
|
|
+ .filter(c -> c != null)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setAuthClientList(clients);
|
|
|
}
|
|
|
|
|
|
private LambdaQueryWrapper<SysCustomer> buildQueryWrapper(SysCustomerBo bo) {
|
|
|
@@ -157,4 +207,18 @@ public class SysCustomerServiceImpl implements ISysCustomerService, CustomerServ
|
|
|
);
|
|
|
return customer != null ? customer.getUserName() : null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改客户状态(启用/禁用)
|
|
|
+ * @Author: Antigravity
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean changeStatus(Long id, String status) {
|
|
|
+ SysCustomer customer = baseMapper.selectById(id);
|
|
|
+ if (customer == null) {
|
|
|
+ throw new org.dromara.common.core.exception.ServiceException("客户不存在");
|
|
|
+ }
|
|
|
+ customer.setStatus(status);
|
|
|
+ return baseMapper.updateById(customer) > 0;
|
|
|
+ }
|
|
|
}
|