|
@@ -0,0 +1,118 @@
|
|
|
|
|
+package org.dromara.customer.pc.controller;
|
|
|
|
|
+
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
+import org.dromara.common.web.core.BaseController;
|
|
|
|
|
+import org.dromara.customer.domain.vo.CustomerSalesInfoVo;
|
|
|
|
|
+import org.dromara.customer.service.ICustomerSalesInfoService;
|
|
|
|
|
+import org.dromara.system.api.RemoteComStaffService;
|
|
|
|
|
+import org.dromara.system.api.domain.vo.RemoteComStaffVo;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * PC端 - 专属服务人员查询
|
|
|
|
|
+ * 前端访问路由地址为:/pc/enterprise/servicePerson
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author Claude
|
|
|
|
|
+ * @date 2026-01-28
|
|
|
|
|
+ */
|
|
|
|
|
+@Validated
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/pc/enterprise/servicePerson")
|
|
|
|
|
+public class PcServicePersonController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ private final ICustomerSalesInfoService customerSalesInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private RemoteComStaffService remoteComStaffService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询当前企业的专属服务人员
|
|
|
|
|
+ * 返回:销售人员(专属采购顾问)、服务人员(客服人员)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
|
+ public R<List<ServicePersonVO>> getServicePersons() {
|
|
|
|
|
+ // 获取当前登录用户的企业ID
|
|
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询客户销售信息
|
|
|
|
|
+ CustomerSalesInfoVo salesInfo = customerSalesInfoService.queryByCustomerId(customerId);
|
|
|
|
|
+ if (salesInfo == null) {
|
|
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 收集服务人员ID
|
|
|
|
|
+ Set<Long> staffIds = new HashSet<>();
|
|
|
|
|
+ if (salesInfo.getSalesPersonId() != null) {
|
|
|
|
|
+ staffIds.add(salesInfo.getSalesPersonId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (salesInfo.getServiceStaffId() != null) {
|
|
|
|
|
+ staffIds.add(salesInfo.getServiceStaffId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (staffIds.isEmpty()) {
|
|
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 通过Dubbo远程调用获取人员详细信息
|
|
|
|
|
+ List<RemoteComStaffVo> staffList = remoteComStaffService.selectStaffByIds(staffIds);
|
|
|
|
|
+ if (staffList == null || staffList.isEmpty()) {
|
|
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 组装返回数据
|
|
|
|
|
+ List<ServicePersonVO> result = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 添加销售人员(专属采购顾问)
|
|
|
|
|
+ if (salesInfo.getSalesPersonId() != null) {
|
|
|
|
|
+ staffList.stream()
|
|
|
|
|
+ .filter(staff -> salesInfo.getSalesPersonId().equals(staff.getStaffId()))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .ifPresent(staff -> {
|
|
|
|
|
+ ServicePersonVO vo = new ServicePersonVO();
|
|
|
|
|
+ vo.setName(staff.getStaffName());
|
|
|
|
|
+ vo.setType("专属采购顾问");
|
|
|
|
|
+ vo.setDepartment(staff.getDeptName());
|
|
|
|
|
+ vo.setPhone(staff.getPhone());
|
|
|
|
|
+ vo.setAvatar("");
|
|
|
|
|
+ result.add(vo);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加服务人员(客服人员)
|
|
|
|
|
+ if (salesInfo.getServiceStaffId() != null) {
|
|
|
|
|
+ staffList.stream()
|
|
|
|
|
+ .filter(staff -> salesInfo.getServiceStaffId().equals(staff.getStaffId()))
|
|
|
|
|
+ .findFirst()
|
|
|
|
|
+ .ifPresent(staff -> {
|
|
|
|
|
+ ServicePersonVO vo = new ServicePersonVO();
|
|
|
|
|
+ vo.setName(staff.getStaffName());
|
|
|
|
|
+ vo.setType("客服人员");
|
|
|
|
|
+ vo.setDepartment(staff.getDeptName());
|
|
|
|
|
+ vo.setPhone(staff.getPhone());
|
|
|
|
|
+ vo.setAvatar("");
|
|
|
|
|
+ result.add(vo);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return R.ok(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 服务人员视图对象
|
|
|
|
|
+ */
|
|
|
|
|
+ @lombok.Data
|
|
|
|
|
+ public static class ServicePersonVO {
|
|
|
|
|
+ private String name;
|
|
|
|
|
+ private String type;
|
|
|
|
|
+ private String department;
|
|
|
|
|
+ private String phone;
|
|
|
|
|
+ private String avatar;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|