Browse Source

Merge remote-tracking branch 'origin/master'

caozj 1 year ago
parent
commit
8290651a5d

+ 9 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerSelectDto.java

@@ -84,5 +84,14 @@ public class CustomerSelectDto extends BaseSelectDto {
      */
     private String tag;
 
+    /**
+     * 客户名称
+     */
+    private String contactName;
+
+    /**
+     * 客户邮箱
+     */
+    private String contactEmail;
 
 }

+ 13 - 5
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -16,7 +16,6 @@ import com.fjhx.common.service.coding.CodingRuleCustomerService;
 import com.fjhx.customer.entity.customer.dto.CustomerDto;
 import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
 import com.fjhx.customer.entity.customer.po.Customer;
-import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
 import com.fjhx.customer.entity.customer.po.CustomerTop;
 import com.fjhx.customer.entity.customer.po.CustomerUser;
 import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
@@ -78,6 +77,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         IWrapper<CustomerVo> wrapper = IWrapper.getWrapper();
         wrapper.like(Customer::getName, dto.getKeyword());
         wrapper.eq("c", Customer::getUserId, dto.getUserId());
+        wrapper.groupBy("c.id");
         Page<CustomerVo> page = baseMapper.getPage(dto.getPage(), wrapper);
         CustomizeAreaUtil.setAreaName(page.getRecords());
         return page;
@@ -113,7 +113,14 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         // 关键字
         wrapper.keyword(dto.getKeyword(),
                 new SqlField("c", Customer::getName),
-                new SqlField("c", Customer::getCode));
+                new SqlField("c", Customer::getCode),
+                new SqlField("cu", CustomerUser::getName),
+                new SqlField("cu", CustomerUser::getEmail)
+        );
+        //客户联系人过滤
+        wrapper.eq("cu", CustomerUser::getName, dto.getContactName());
+        //客户联系人邮箱
+        wrapper.eq("cu", CustomerUser::getEmail, dto.getContactEmail());
 
         // 客户标签查询(多个标签用逗号隔开)
         if (StrUtil.isNotBlank(dto.getTag())) {
@@ -137,12 +144,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
 
         if (ObjectUtil.isNotEmpty(customerIds)) {
             String join = StringUtils.join(customerIds, ",");
-            wrapper.orderByDesc("id IN ( " + join + " )");
+            wrapper.orderByDesc("c.id IN ( " + join + " )");
         }
 
-        wrapper.orderByDesc(Customer::getUpdateTime);
-        wrapper.orderByDesc(Customer::getCreateTime);
+        wrapper.orderByDesc("c", Customer::getUpdateTime);
+        wrapper.orderByDesc("c", Customer::getCreateTime);
 
+        wrapper.groupBy("c.id");
         Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
 
         // 复制城市信息

+ 1 - 0
hx-customer/src/main/resources/mapper/customer/CustomerMapper.xml

@@ -47,6 +47,7 @@
             c.update_time,
             c.tag
         from customer c
+	        LEFT JOIN customer_user cu ON cu.customer_id = c.id
             ${ew.customSqlSegment}
     </select>