Browse Source

客户&商机

cqp 11 months ago
parent
commit
357b9f5ea8

+ 6 - 0
app/Model/BusinessOpportunityInfo.php

@@ -19,4 +19,10 @@ class BusinessOpportunityInfo extends Model
         self::type_six,
     ];
 
+    public static $contact_type = [
+        1 => '手机',
+        2 => '电话',
+        3 => '微信号',
+        4 => '其他',
+    ];
 }

+ 5 - 4
app/Model/CustomerInfo.php

@@ -26,9 +26,10 @@ class CustomerInfo extends Model
         self::type_six,
     ];
 
-    public static $man2 = [
-        self::type_two,
-        self::type_three,
-        self::type_nine,
+    public static $contact_type = [
+        1 => '手机',
+        2 => '电话',
+        3 => '微信号',
+        4 => '其他',
     ];
 }

+ 7 - 5
app/Service/BusinessOpportunityService.php

@@ -27,7 +27,7 @@ class BusinessOpportunityService extends Service
             $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
             $model->address2 = $data['address2'] ?? '';
             $model->mark = $data['mark'] ?? '';
-            $model->intention = $data['intention'] ?? '';
+            $model->intention = $data['intention'] ?? 0;
             $model->customer_type = $data['customer_type'] ?? '';
             $model->save();
             $time = time();
@@ -123,7 +123,7 @@ class BusinessOpportunityService extends Service
             $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
             $model->address2 = $data['address2'] ?? '';
             $model->mark = $data['mark'] ?? '';
-            $model->intention = $data['intention'] ?? '';
+            $model->intention = $data['intention'] ?? 0;
             $model->customer_type = $data['customer_type'] ?? '';
             $model->crt_id = $user['id'];
             $model->save();
@@ -257,6 +257,7 @@ class BusinessOpportunityService extends Service
                 $tmp = [
                     'id' => $value['contact_type'],
                     'type' => $value['contact_type'],
+                    'type_title' => BusinessOpportunityInfo::$contact_type[$value['contact_type']] ?? "",
                     'info' => $value['contact_info']
                 ];
                 $customer['customer_contact'][] = $tmp;
@@ -305,7 +306,7 @@ class BusinessOpportunityService extends Service
             }
         }
         if(! empty($data['mark'])) $model->where('mark','LIKE', '%'.$data['mark'].'%');
-        if(! empty($data['intention'])) $model->where('intention',$data['intention']);
+        if(isset($data['intention'])) $model->where('intention',$data['intention']);
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->where('crt_time','>=',$return[0]);
@@ -351,12 +352,13 @@ class BusinessOpportunityService extends Service
         $customer_info = BusinessOpportunityInfo::where('del_time',0)
             ->whereIn('business_opportunity_id',array_column($data['data'],'id'))
             ->whereIn('type',[BusinessOpportunityInfo::type_one])
-            ->select('type','contact_type','contact_info','customer_id','data_id')
+            ->select('contact_type as type','contact_info as info','customer_id','data_id')
             ->get()->toArray();
 
         //联系方式
         $customer_info_map = [];
         foreach ($customer_info as $value){
+            $value['type_title'] = BusinessOpportunityInfo::$contact_type[$value['type']] ?? "";
             $customer_info_map[$value['customer_id']][] = $value;
         }
 
@@ -373,7 +375,7 @@ class BusinessOpportunityService extends Service
                 $address = $value['address2'];
             }
             $data['data'][$key]['address'] = $address;
-            $data['data'][$key]['is_company_title'] = $value['customer_intention'] ? '是' : '否';
+            $data['data'][$key]['is_company_title'] = $value['is_company'] ? '是' : '否';
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
             $record_tmp = $record_array[$value['id']] ?? "";

+ 6 - 4
app/Service/CustomerService.php

@@ -143,7 +143,7 @@ class CustomerService extends Service
             $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
             $model->address2 = $data['address2'] ?? '';
             $model->mark = $data['mark'] ?? '';
-            $model->intention = $data['intention'] ?? '';
+            $model->intention = $data['intention'] ?? 0;
             $model->customer_type = $data['customer_type'] ?? '';
             $model->crt_id = $user['id'];
             $model->save();
@@ -287,6 +287,7 @@ class CustomerService extends Service
                 $tmp = [
                     'id' => $value['contact_type'],
                     'type' => $value['contact_type'],
+                    'type_title' => CustomerInfo::$contact_type[$value['contact_type']] ?? "",
                     'info' => $value['contact_info']
                 ];
                 $customer['customer_contact'][] = $tmp;
@@ -341,7 +342,7 @@ class CustomerService extends Service
             }
         }
         if(! empty($data['mark'])) $model->where('mark','LIKE', '%'.$data['mark'].'%');
-        if(! empty($data['intention'])) $model->where('intention',$data['intention']);
+        if(isset($data['intention'])) $model->where('intention',$data['intention']);
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->where('crt_time','>=',$return[0]);
@@ -434,12 +435,13 @@ class CustomerService extends Service
         $customer_info = CustomerInfo::where('del_time',0)
             ->whereIn('customer_id',array_column($data['data'],'id'))
             ->whereIn('type',[CustomerInfo::type_one])
-            ->select('type','contact_type','contact_info','customer_id','data_id')
+            ->select('contact_type as type','contact_info as info','customer_id','data_id')
             ->get()->toArray();
 
         //客户的联系方式
         $customer_info_map = [];
         foreach ($customer_info as $value){
+            $value['type_title'] = CustomerInfo::$contact_type[$value['type']] ?? "";
             $customer_info_map[$value['customer_id']][] = $value;
         }
 
@@ -456,7 +458,7 @@ class CustomerService extends Service
                 $address = $value['address2'];
             }
             $data['data'][$key]['address'] = $address;
-            $data['data'][$key]['is_company_title'] = $value['customer_intention'] ? '是' : '否';
+            $data['data'][$key]['is_company_title'] = $value['is_company'] ? '是' : '否';
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
             $record_tmp = $record_array[$value['id']] ?? "";

+ 2 - 1
app/Service/FollowUpRecordService.php

@@ -2,6 +2,7 @@
 
 namespace App\Service;
 
+use App\Model\BusinessOpportunity;
 use App\Model\Customer;
 use App\Model\FollowUpRecord;
 use App\Model\FollowUpRecordFile;
@@ -165,7 +166,7 @@ class FollowUpRecordService extends Service
         if($data['type'] == FollowUpRecord::type_one){
             $data['data_title'] = Customer::where('id',$data['data_id'])->value('title');
         }elseif($data['type'] == FollowUpRecord::type_two){
-            $data['data_title'] = Customer::where('id',$data['data_id'])->value('title');
+            $data['data_title'] = BusinessOpportunity::where('id',$data['data_id'])->value('title');
         }
         if($this->isEmpty($data,'visit_time')) return [false,'拜访时间不能为空'];
         if($this->isEmpty($data,'content')) return [false,'跟进内容不能为空'];