Jelajahi Sumber

客户公海认领

沐梦. 1 bulan lalu
induk
melakukan
d09aff359a

+ 17 - 4
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java

@@ -543,13 +543,19 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
 
             // 8. 填充数据
             records.forEach(vo -> {
-                vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
-                vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
+                if (StringUtils.isBlank(vo.getSalesPersonName())) {
+                    vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
+                }
+                if (StringUtils.isBlank(vo.getServiceStaffName())) {
+                    vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
+                }
                 vo.setCreditLevelName(creditLevelMap.get(vo.getCreditLevelId()));
                 vo.setCompanyName(companyMap.get(vo.getBelongCompanyId()));
                 vo.setEnterpriseTypeName(enterpriseTypeMap.get(vo.getEnterpriseTypeId()));
                 vo.setCustomerLevelName(customerLevelMap.get(vo.getCustomerLevelId()));
-                vo.setDeptName(deptMap.get(vo.getBelongingDepartmentId()));
+                if (StringUtils.isBlank(vo.getDeptName())) {
+                    vo.setDeptName(deptMap.get(vo.getBelongingDepartmentId()));
+                }
                 vo.setCooperationName(cooperationMap.get(vo.getStatus()));
             });
         }
@@ -1395,7 +1401,14 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
             salesInfo.setSalesPersonId(claimBo.getSalesPersonId());
             salesInfo.setServiceStaffId(claimBo.getServiceStaffId());
             salesInfo.setStatus("0");
-            return customerSalesInfoMapper.insert(salesInfo) > 0;
+            boolean insertResult = customerSalesInfoMapper.insert(salesInfo) > 0;
+            CustomerInfo customer = new CustomerInfo();
+            customer.setId(customerId);
+            customer.setSalesPersonId(claimBo.getSalesPersonId());
+            customer.setServiceStaffId(claimBo.getServiceStaffId());
+            customer.setStatus("0");
+            baseMapper.updateById(customer);
+            return insertResult;
         }
 
         // 更新销售负责人和客服

+ 10 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/SalesAnnualFinalizationServiceImpl.java

@@ -15,8 +15,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.SequenceUtils;
 import org.dromara.customer.domain.SalesAnnualFinalization;
 import org.dromara.customer.domain.bo.SalesAnnualFinalizationBo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
 import org.dromara.customer.domain.vo.SalesAnnualFinalizationVo;
 import org.dromara.customer.mapper.SalesAnnualFinalizationMapper;
+import org.dromara.customer.service.ICustomerInfoService;
 import org.dromara.customer.service.IOperationLogService;
 import org.dromara.customer.domain.bo.TeamMemberBo;
 import org.dromara.customer.service.ITeamMemberService;
@@ -48,6 +50,7 @@ public class SalesAnnualFinalizationServiceImpl implements ISalesAnnualFinalizat
     private final SalesAnnualFinalizationMapper baseMapper;
     private final IOperationLogService operationLogService;
     private final ITeamMemberService teamMemberService;
+    private final ICustomerInfoService customerInfoService;
 
     @DubboReference
     private RemoteUserService remoteUserService;
@@ -106,6 +109,13 @@ public class SalesAnnualFinalizationServiceImpl implements ISalesAnnualFinalizat
             add.setProjectNo(SequenceUtils.nextPaddedIdStr(PROJECT_NO_KEY, Duration.ofDays(3650), 6));
         }
 
+        if (StrUtil.isBlank(add.getCustomNo()) && StrUtil.isNotBlank(add.getCustomName())) {
+            CustomerInfoVo customerInfo = customerInfoService.selectCustomerByName(add.getCustomName());
+            if (customerInfo != null && StrUtil.isNotBlank(customerInfo.getCustomerNo())) {
+                add.setCustomNo(customerInfo.getCustomerNo());
+            }
+        }
+
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setId(add.getId());

+ 6 - 0
ruoyi-modules/ruoyi-customer/src/main/resources/mapper/customer/CustomerInfoMapper.xml

@@ -62,15 +62,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             csi.credit_management_id AS creditLevelId,
             csi.accounts_receivable AS accountsReceivable,
             ci.sales_person_id AS salesPersonId,
+            sp.staff_name AS salesPersonName,
             ci.belong_company_id AS belongCompanyId,
             ci.customer_type_id AS enterpriseTypeId,
             ci.customer_level_id AS customerLevelId,
             ci.service_staff_id AS serviceStaffId,
+            ss.staff_name AS serviceStaffName,
             ci.belonging_department_id AS belongingDepartmentId,
+            sd.dept_name AS deptName,
             ci.status
         FROM customer_info ci
         LEFT JOIN customer_sales_info csi ON ci.id = csi.customer_id AND csi.del_flag = '0'
         LEFT JOIN industry_category ic ON ci.industry_category_id = ic.id AND ic.del_flag = '0'
+        LEFT JOIN com_staff sp ON ci.sales_person_id = sp.staff_id AND sp.del_flag = '0'
+        LEFT JOIN com_staff ss ON ci.service_staff_id = ss.staff_id AND ss.del_flag = '0'
+        LEFT JOIN sys_dept sd ON sp.dept_id = sd.dept_id
         <where>
             ci.del_flag = '0'
             <choose>