Pārlūkot izejas kodu

客户数据分享带来的问题解决

cqpCow 11 mēneši atpakaļ
vecāks
revīzija
499f437ce5

+ 13 - 0
app/Http/Controllers/Api/BasicTypeController.php

@@ -58,4 +58,17 @@ class BasicTypeController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function basicTypeCustomerList(Request $request)
+    {
+        $service = new BasicTypeService();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->basicTypeCustomerList($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 2 - 1
app/Http/Controllers/Api/CustomerController.php

@@ -75,7 +75,8 @@ class CustomerController extends BaseController
     public function customerDetail(Request $request)
     {
         $service = new CustomerService();
-        list($status,$data) = $service->customerDetail($request->all());
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->customerDetail($request->all(),$userData);
 
         if($status){
             return $this->json_return(200,'',$data);

+ 18 - 1
app/Service/BasicTypeService.php

@@ -4,6 +4,7 @@ namespace App\Service;
 
 use App\Model\BasicType;
 use App\Model\Depart;
+use Illuminate\Support\Facades\DB;
 
 /**
  * 基础分类设置相关
@@ -62,7 +63,23 @@ class BasicTypeService extends Service
     public function basicTypeList($data, $user){
         $model = BasicType::TopClear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('title','id','type','code')
+            ->select('title','id','type','code','top_depart_id')
+            ->orderby('id', 'asc');
+
+        if(! empty($data['type'])) $model->where('type',$data['type']);
+        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list);
+
+        return [true, $list];
+    }
+
+    public function basicTypeCustomerList($data, $user){
+        $data['top_depart_id'] = $user['head']['id'];
+        $model = BasicType::TopClear($user,$data);
+        $model = $model->where('del_time',0)
+            ->select('title','id','type','code','top_depart_id')
             ->orderby('id', 'asc');
 
         if(! empty($data['type'])) $model->where('type',$data['type']);

+ 5 - 1
app/Service/CustomerService.php

@@ -365,7 +365,7 @@ class CustomerService extends Service
      * @param $data
      * @return array
      */
-    public function customerDetail($data){
+    public function customerDetail($data,$user){
         if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
 
         $customer = Customer::where('del_time',0)
@@ -373,6 +373,10 @@ class CustomerService extends Service
             ->first();
         if(empty($customer)) return [false,'客户不存在或已被删除'];
         $customer = $customer->toArray();
+        //是否是总社的客户
+        $is_main = 0;
+        if($customer['top_depart_id'] == $user['head']['id']) $is_main = 1;
+        $customer['is_belong_to_main'] = $is_main;
         $customer['order_number'] = Customer::$order_number . "|" . $data['id'] . "|" . $customer['title'];
         $product = Product::where('id',$customer['intention_product'])->value('title');
         $customer['intention_product_title'] = $product;

+ 1 - 0
routes/api.php

@@ -108,6 +108,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('basicTypeEdit', 'Api\BasicTypeController@basicTypeEdit');
     $route->any('basicTypeAdd', 'Api\BasicTypeController@basicTypeAdd');
     $route->any('basicTypeDel', 'Api\BasicTypeController@basicTypeDel');
+    $route->any('basicTypeCustomerList', 'Api\BasicTypeController@basicTypeCustomerList');
 
     //跟进记录
     $route->any('followUpRecordList', 'Api\FollowUpRecordController@followUpRecordList');

+ 1 - 0
routes/wx.php

@@ -64,6 +64,7 @@ Route::group(['middleware'=> ['checkWx']],function ($route){
     $route->any('departList', 'Api\EmployeeController@departList');
     $route->any('storehouseList', 'Api\StorehouseController@storehouseList');
     $route->any('basicTypeList', 'Api\BasicTypeController@basicTypeList');
+    $route->any('basicTypeCustomerList', 'Api\BasicTypeController@basicTypeCustomerList');
     $route->any('productList', 'Api\ProductController@productList');
     $route->any('supplierList', 'Api\SupplierController@customerList');
     $route->any('customerList', 'Api\CustomerController@customerList');