cqpCow 1 년 전
부모
커밋
4c2c9619a0
4개의 변경된 파일60개의 추가작업 그리고 39개의 파일을 삭제
  1. 13 0
      app/Model/Customer.php
  2. 25 37
      app/Service/FollowUpRecordService.php
  3. 21 1
      app/Service/Service.php
  4. 1 1
      config/app.php

+ 13 - 0
app/Model/Customer.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Customer extends Model
+{
+    protected $table = "customer"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}

+ 25 - 37
app/Service/FollowUpRecordService.php

@@ -2,9 +2,7 @@
 
 namespace App\Service;
 
-use App\Model\Depart;
 use App\Model\Employee;
-use App\Model\EmployeeRole;
 use App\Model\FollowUpRecord;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Hash;
@@ -17,19 +15,14 @@ class FollowUpRecordService extends Service
 
         $model = new FollowUpRecord();
         $model = $model->where('id',$data['id'])->first();
-        $model->id_card = $data['id_card']??'';
-        $model->number = $data['number'] ;
-        $model->mobile = $data['mobile'];
-        $model->emp_name = $data['emp_name'];
-        $model->is_admin = $data['is_admin'];
-        if($model->is_admin == 1){
-            $model->account = $data['account'];
-            if($data['password'] !== '********'){
-                $model->password   = Hash::make($data['password']);
-            }
-        }
+        $model->customer_id = $data['customer_id'];
+        $model->basic_type_id = $data['basic_type_id'] ;
+        $model->visit_time = $data['visit_time'];
+        $model->content = $data['content'];
+        $model->is_remind = $data['is_remind'];
         $model->save();
-        return [true,'保存成功!'];
+
+        return [true,''];
     }
 
     public function followUpRecordAdd($data,$user){
@@ -37,23 +30,18 @@ class FollowUpRecordService extends Service
         if(!$status) return [$status,$msg];
 
         $model = new FollowUpRecord();
-        $model->id_card = $data['id_card']??'';
-        $model->number = $data['number'] ;
-        $model->mobile = $data['mobile'];
-        $model->emp_name = $data['emp_name'];
-        $model->state = 1;
+        $model->customer_id = $data['customer_id'];
+        $model->basic_type_id = $data['basic_type_id'] ;
+        $model->visit_time = $data['visit_time'];
+        $model->content = $data['content'];
+        $model->is_remind = $data['is_remind'];
         $model->crt_id = $user['id'];
-        $model->is_admin = $data['is_admin'];
-        if($model->is_admin == 1){
-            $model->account = $data['account'];
-            $model->password = Hash::make($data['password']);
-        }
         $model->save();
 
-        return [true,'保存成功!'];
+        return [true,''];
     }
 
-    public function followUpRecordDel($data,){
+    public function followUpRecordDel($data){
         if($this->isEmpty($data,'id')) return [false,'ID必须!'];
 
         FollowUpRecord::where('id',$data['id'])->update([
@@ -65,12 +53,12 @@ class FollowUpRecordService extends Service
 
     public function followUpRecordList($data,$user){
         $model = FollowUpRecord::where('del_time',0)
-            ->select('number','mobile','emp_name','id','entry_time','leave_time','is_technical','is_admin','state')
+            ->select('customer_id','basic_type_id','visit_time','id','content','is_remind','crt_time','crt_id')
             ->orderBy('id','desc');
 
-        if(! empty($data['state'])) $model->where('state',$data['state']);
-        if(! empty($data['mobile'])) $model->where('mobile', 'LIKE', '%'.$data['mobile'].'%');
-        if(! isset($data['all_emp'])) $model->where('id','<>',Employee::SPECIAL_ADMIN);
+        if(! empty($data['customer_id'])) $model->where('customer_id',$data['customer_id']);
+        if(! empty($data['basic_type_id'])) $model->where('basic_type_id', $data['basic_type_id']);
+        if(! empty($data['crt_id'])) $model->where('crt_id',$data['crt_id']);
 
         $list = $this->limit($model,'',$data);
 
@@ -89,16 +77,16 @@ class FollowUpRecordService extends Service
         return $data;
     }
 
-    public function followUpRecordRule($data,$is_add = true){
-        if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
-        if($this->isEmpty($data,'mobile')) return [false,'手机号不存在!'];
-        if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
+    public function followUpRecordRule(&$data,$is_add = true){
+        if($this->isEmpty($data,'customer_id')) return [false,'客户不能为空'];
+        if($this->isEmpty($data,'basic_type_id')) return [false,'跟进方式不能为空'];
+        if($this->isEmpty($data,'visit_time')) return [false,'拜访时间不能为空'];
+        if($this->isEmpty($data,'content')) return [false,'跟进内容不能为空'];
+
         if(! $is_add){
             if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
-
-        }else{
-
         }
+        $data['visit_time'] = $this->changeDateToDate($data['visit_time']);
 
         return [true,''];
     }

+ 21 - 1
app/Service/Service.php

@@ -262,7 +262,8 @@ class Service
         return [false,'操作频繁, 请在 ' . $ttl . '秒后重试'];
     }
 
-    //前端传来的时间转换为时间戳 关于时间段 2023-09-17T16:00:00.000Z
+    //前端传来的时间段转换为时间戳
+    //精确到秒
     function changeDateToTimeStampAboutRange($time_range){
         if(empty($time_range[0]) || empty($time_range[1])) return [];
 
@@ -285,6 +286,8 @@ class Service
         return $return;
     }
 
+    //前端传来的时间段转换为时间戳
+    //精确到日
     function changeDateToNewDate($time_range){
         if(empty($time_range[0]) || empty($time_range[1])) return [];
 
@@ -306,4 +309,21 @@ class Service
 
         return $return;
     }
+
+    //前端传来的时间转为时间戳
+    //精确到分
+    function changeDateToDate($time){
+        if(empty($time)) return '';
+
+        // 创建一个 DateTime 对象并设置时区为 UTC
+        $dateTime = new \DateTime($time, new \DateTimeZone('UTC'));
+
+        // 将时区设置为 PRC
+        $dateTime->setTimezone(new \DateTimeZone('Asia/Shanghai'));
+
+        // 将日期时间格式化为特定格式
+        $formattedDate = $dateTime->format('Y-m-d H:i');
+
+        return $formattedDate;
+    }
 }

+ 1 - 1
config/app.php

@@ -67,7 +67,7 @@ return [
     |
     */
 
-    'timezone' => 'UTC',
+    'timezone' => 'PRC',
 
     /*
     |--------------------------------------------------------------------------