Browse Source

客户新增客户最后跟进时间

cqpCow 1 năm trước cách đây
mục cha
commit
896a13c6af
2 tập tin đã thay đổi với 17 bổ sung0 xóa
  1. 4 0
      app/Service/CustomerService.php
  2. 13 0
      app/Service/FollowUpRecordService.php

+ 4 - 0
app/Service/CustomerService.php

@@ -512,6 +512,10 @@ class CustomerService extends Service
             $id = (new RangeService())->customerSearch($data);
             $model->whereIn('id',$id);
         }
+        if(! empty($data['visit_time'])){
+            $id = (new FollowUpRecordService())->getLastVisitData($data['visit_time']);
+            $model->whereIn('id',$id);
+        }
 
         $list = $this->limit($model,'',$data);
         $list = $this->fillData($list,$data);

+ 13 - 0
app/Service/FollowUpRecordService.php

@@ -192,4 +192,17 @@ class FollowUpRecordService extends Service
 
         return [true, $record];
     }
+
+    public function getLastVisitData($time, $type = FollowUpRecord::type_one){
+        $visit_time = $this->changeDateToDateMin($time);
+
+        $follow_up_record = FollowUpRecord::where('del_time',0)
+            ->where('visit_time',$visit_time)
+            ->where('type',$type)
+            ->whereRaw("data_id not in (select data_id from follow_up_record where visit_time > $visit_time and del_time = 0)")
+            ->select('data_id')
+            ->get()->toArray();
+
+        return array_values(array_column($follow_up_record,'data_id'));
+    }
 }