소스 검색

客户问题处理

yzc 1 년 전
부모
커밋
db2a10f7cd

+ 14 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerUserVo.java

@@ -7,11 +7,24 @@ import lombok.Setter;
 /**
  * 客户用户表列表查询返回值实体
  *
- * @author 
+ * @author
  * @since 2023-04-04
  */
 @Getter
 @Setter
 public class CustomerUserVo extends CustomerUser {
 
+    /**
+     * 客户名称
+     */
+    private String customerName;
+
+    /**
+     * 客户主体
+     */
+    private String customerMainPart;
+    /**
+     * 客户客体
+     */
+    private String customerMinorPart;
 }

+ 19 - 5
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerUserServiceImpl.java

@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
 import com.fjhx.customer.entity.customer.dto.CustomerUserSelectDto;
+import com.fjhx.customer.entity.customer.po.Customer;
 import com.fjhx.customer.entity.customer.po.CustomerUser;
 import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
 import com.fjhx.customer.mapper.customer.CustomerUserMapper;
+import com.fjhx.customer.service.customer.CustomerService;
 import com.fjhx.customer.service.customer.CustomerUserService;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -22,12 +25,15 @@ import java.util.List;
  * 客户用户表 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-04-04
  */
 @Service
 public class CustomerUserServiceImpl extends ServiceImpl<CustomerUserMapper, CustomerUser> implements CustomerUserService {
 
+    @Autowired
+    private CustomerService customerService;
+
     @Override
     public List<CustomerUserVo> getList(CustomerUserSelectDto dto) {
         IWrapper<CustomerUser> wrapper = getWrapper();
@@ -62,17 +68,25 @@ public class CustomerUserServiceImpl extends ServiceImpl<CustomerUserMapper, Cus
     public CustomerUserVo detail(Long id) {
         CustomerUser CustomerUser = this.getById(id);
         CustomerUserVo result = BeanUtil.toBean(CustomerUser, CustomerUserVo.class);
+        Customer customer = customerService.getById(result.getCustomerId());
+        if (ObjectUtil.isNotEmpty(customer)) {
+            result.setCustomerName(customer.getName());
+        }
         return result;
     }
 
     @Override
     public void add(CustomerUserDto customerUserDto) {
-        if(ObjectUtil.isEmpty(customerUserDto.getCustomerId())){
+        if (ObjectUtil.isEmpty(customerUserDto.getCustomerId())) {
             throw new ServiceException("客户id不能为空");
         }
-        List<CustomerUser> list = this.list(q -> q.eq(CustomerUser::getCustomerId, customerUserDto.getCustomerId()).eq(CustomerUser::getEmail, customerUserDto.getEmail()));
-        if(ObjectUtil.isNotEmpty(list)){
-            throw new ServiceException("邮箱不能重复");
+        if (ObjectUtil.isNotEmpty(customerUserDto.getEmail())) {
+            List<CustomerUser> list = this.list(q -> q
+                    .eq(CustomerUser::getCustomerId, customerUserDto.getCustomerId())
+                    .eq(CustomerUser::getEmail, customerUserDto.getEmail()));
+            if (ObjectUtil.isNotEmpty(list)) {
+                throw new ServiceException("邮箱不能重复");
+            }
         }
         this.save(customerUserDto);
     }

+ 35 - 24
hx-customer/src/main/resources/mapper/customer/CustomerUserMapper.xml

@@ -1,34 +1,45 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.customer.mapper.customer.CustomerUserMapper">
+
+    <sql id="listOrPage">
+        SELECT cu.id,
+               cu.customer_id,
+               cu.`name`,
+               cu.sex,
+               cu.position,
+               cu.is_kp,
+               cu.we_chat,
+               cu.wang_wang,
+               cu.tel,
+               cu.phone,
+               cu.whats_app,
+               cu.qq,
+               cu.skype,
+               cu.linked_in,
+               cu.facebook,
+               cu.direct_line,
+               cu.email,
+               cu.tenant_id,
+               cu.create_user,
+               cu.create_time,
+               cu.update_user,
+               cu.update_time,
+               c.`name`     AS customerName,
+               c.main_part  AS customerMainPart,
+               c.minor_part AS customerMinorPart
+        FROM customer_user cu
+                 LEFT JOIN customer c ON cu.customer_id = c.id
+    </sql>
+
     <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerUserVo">
-        select
-            cu.id,
-            cu.customer_id,
-            cu.name,
-            cu.phone,
-            cu.email,
-            cu.create_user,
-            cu.create_time,
-            cu.update_user,
-            cu.update_time
-        from customer_user cu
-            ${ew.customSqlSegment}
+        <include refid="listOrPage"></include>
+        ${ew.customSqlSegment}
     </select>
 
     <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerUserVo">
-        select
-            cu.id,
-            cu.customer_id,
-            cu.name,
-            cu.phone,
-            cu.email,
-            cu.create_user,
-            cu.create_time,
-            cu.update_user,
-            cu.update_time
-        from customer_user cu
-            ${ew.customSqlSegment}
+        <include refid="listOrPage"></include>
+        ${ew.customSqlSegment}
     </select>
 
 </mapper>