Prechádzať zdrojové kódy

客户添加近7天跟进

yzc 1 rok pred
rodič
commit
9df4c4b996

+ 9 - 7
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerFollowRecordsServiceImpl.java

@@ -26,6 +26,7 @@ import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -126,11 +127,12 @@ public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollow
     @DSTransactional
     @Override
     public void delete(Long id) {
+        CustomerFollowRecords customerFollowRecords = this.getById(id);
+
         this.removeById(id);
         ObsFileUtil.removeFile(id);
 
         //更新最后一次跟进时间
-        CustomerFollowRecords customerFollowRecords = this.getById(id);
         if (ObjectUtil.isNotEmpty(customerFollowRecords)) {
             updateLastFollowTime(customerFollowRecords.getCustomerId());
         }
@@ -146,12 +148,12 @@ public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollow
                 .orderByDesc(CustomerFollowRecords::getDate)
                 .orderByDesc(CustomerFollowRecords::getId)
         );
-        if (ObjectUtil.isNotEmpty(customerFollowRecords)) {
-            customerService.update(q -> q
-                    .eq(Customer::getId, customerId)
-                    .set(Customer::getLastFollowTime, customerFollowRecords.getDate())
-            );
-        }
+        Date lastFollowTime = ObjectUtil.isNotEmpty(customerFollowRecords) ? customerFollowRecords.getDate() : null;
+        customerService.update(q -> q
+                .eq(Customer::getId, customerId)
+                .set(Customer::getLastFollowTime, lastFollowTime)
+        );
+
     }
 
 }

+ 7 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -419,6 +419,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         }
 
         // 客户最后一次跟进时间范围计数
+        QueryWrapper<Customer> clone0 = query.clone();
+        clone0.select("count(1) as count");
+        clone0.gt("DATEDIFF( NOW(), last_follow_time )", -1);
+        clone0.le("DATEDIFF( NOW(), last_follow_time )", 7);
+        Customer customer0 = baseMapper.selectOne(clone0);
+
         QueryWrapper<Customer> clone = query.clone();
         clone.select("count(1) as count");
         clone.gt("DATEDIFF( NOW(), last_follow_time )", 7);
@@ -442,6 +448,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
 
         //返回最终结果
         Map<String, Object> map = new HashMap<>();
+        map.put("0", customer0.getCount());
         map.put("7", customer.getCount());
         map.put("30", customer1.getCount());
         map.put("180", customer2.getCount());