cqpCow 1 ano atrás
pai
commit
54cf917624

+ 8 - 0
app/Model/CustomerInfo.php

@@ -18,6 +18,7 @@ class CustomerInfo extends Model
     const type_six = 6; // 文件
     const type_seven = 7; // 可见部门
     const type_eight = 8; // 可见人
+    const type_nine = 9; //前负责人
     public static $type = [
         self::type_one,
         self::type_two,
@@ -28,13 +29,20 @@ class CustomerInfo extends Model
         self::type_seven,
         self::type_eight,
     ];
+    public static $see_man = [
+        self::type_two,
+        self::type_three,
+        self::type_eight,
+    ];
     public static $man = [
         self::type_two,
         self::type_three,
         self::type_eight,
+        self::type_nine,
     ];
     public static $man2 = [
         self::type_two,
         self::type_three,
+        self::type_nine,
     ];
 }

+ 14 - 0
app/Service/ConstructionService.php

@@ -359,6 +359,20 @@ class ConstructionService extends Service
 
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
         if(! empty($data['model_type'])) $model->where('model_type',$data['model_type']);
+        if(! empty($data['time_type'])) {
+            if($data['time_type'] == 1) {
+                $start = strtotime('today');
+                $end = strtotime('tomorrow') - 1;
+            }elseif ($data['time_type'] == 2){
+                $start = strtotime('this week',strtotime('today'));
+                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
+            }
+            if(! empty($start) && ! empty($end)) {
+                $model->where('crt_time','>=',$start);
+                $model->where('crt_time','<=',$end);
+            }
+        }
+
         $list = $this->limit($model,'',$data);
         $list = $this->fillData($list);
 

+ 31 - 5
app/Service/CustomerService.php

@@ -377,7 +377,7 @@ class CustomerService extends Service
             $address = $tmp;
         }
         $customer['address'] = $address;
-        $customer['customer_contact'] = $customer['employee_one'] = $customer['employee_two'] = $customer['employee_three'] = $customer['img'] = $customer['file'] = $customer['employee'] = $customer['depart'] = [];
+        $customer['customer_contact'] = $customer['employee_one'] = $customer['employee_two'] = $customer['employee_three'] = $customer['img'] = $customer['file'] = $customer['employee'] = $customer['depart'] = $customer['old_employee_one'] = [];
         $array = [
             $customer['customer_intention'],
             $customer['customer_from'],
@@ -481,6 +481,12 @@ class CustomerService extends Service
                     'name' => $emp_map[$value['data_id']] ?? '',
                 ];
                 $customer['employee'][] = $tmp;
+            }elseif ($value['type'] == CustomerInfo::type_nine){
+                $tmp = [
+                    'id' => $value['data_id'],
+                    'name' => $emp_map[$value['data_id']] ?? '',
+                ];
+                $customer['old_employee_one'][] = $tmp;
             }
         }
         $customer['crt_name'] = $emp_map[$customer['crt_id']] ?? '';
@@ -642,11 +648,21 @@ class CustomerService extends Service
             DB::beginTransaction();
             $time = time();
 
-            //销售/负责/协同人清空
-            CustomerInfo::where('del_time',0)
+            $insert = [];
+
+            //负责人获取 改为前负责人
+            $man = CustomerInfo::where('del_time',0)
                 ->where('customer_id',$data['customer_id'])
-                ->whereIn('type', CustomerInfo::$man2)
-                ->update(['del_time' => $time]);
+                ->where('type', CustomerInfo::type_two)
+                ->get()->toArray();
+            foreach ($man as $value){
+                $insert[] = [
+                    'customer_id' => $data['customer_id'],
+                    'data_id' => $value['data_id'],
+                    'type' => CustomerInfo::type_nine,
+                    'crt_time' => $time
+                ];
+            }
             //增加自己为负责人
             $insert[] = [
                 'customer_id' => $data['customer_id'],
@@ -654,7 +670,17 @@ class CustomerService extends Service
                 'type' => CustomerInfo::type_two,
                 'crt_time' => $time
             ];
+
+            //人员清空
+            CustomerInfo::where('del_time',0)
+                ->where('customer_id',$data['customer_id'])
+                ->whereIn('type', CustomerInfo::$man2)
+                ->update(['del_time' => $time]);
+
+            //写入最新人员
             CustomerInfo::insert($insert);
+
+            //更新公海池状态
             Customer::where('id',$data['customer_id'])->update([
                 'pond_state' => 0
             ]);

+ 13 - 0
app/Service/InvoiceOrderService.php

@@ -219,6 +219,19 @@ class InvoiceOrderService extends Service
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->whereBetween('crt_time',[$return[0],$return[1]]);
         }
+        if(! empty($data['time_type'])) {
+            if($data['time_type'] == 1) {
+                $start = strtotime('today');
+                $end = strtotime('tomorrow') - 1;
+            }elseif ($data['time_type'] == 2){
+                $start = strtotime('this week',strtotime('today'));
+                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
+            }
+            if(! empty($start) && ! empty($end)) {
+                $model->where('crt_time','>=',$start);
+                $model->where('crt_time','<=',$end);
+            }
+        }
 
         $list = $this->limit($model,'',$data);
         $list = $this->fillListData($list);

+ 5 - 0
app/Service/ProductInventoryService.php

@@ -346,6 +346,11 @@ class ProductInventoryService extends Service
             ->select('id','top_depart_id','param_one')
             ->get()->toArray();
 
+        $map = Depart::whereIn('id',array_column($list,'top_depart_id'))->pluck('title','id')->toArray();
+        foreach ($list as $key => $value){
+            $list[$key]['top_depart_title'] = $map[$value['top_depart_id']] ?? "";
+        }
+
         return [true, $list];
     }
 

+ 1 - 0
app/Service/ProductService.php

@@ -596,6 +596,7 @@ class ProductService extends Service
         if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
         $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
 
+        $top_depart = Depart::where('del_time',0)->where('parent_id',0)->where('is_main',1)->value('id');
         if($is_add){
             $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
                 ->where('del_time',0)

+ 13 - 0
app/Service/PurchaseOrderService.php

@@ -223,6 +223,19 @@ class PurchaseOrderService extends Service
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->whereBetween('crt_time',[$return[0],$return[1]]);
         }
+        if(! empty($data['time_type'])) {
+            if($data['time_type'] == 1) {
+                $start = strtotime('today');
+                $end = strtotime('tomorrow') - 1;
+            }elseif ($data['time_type'] == 2){
+                $start = strtotime('this week',strtotime('today'));
+                $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
+            }
+            if(! empty($start) && ! empty($end)) {
+                $model->where('crt_time','>=',$start);
+                $model->where('crt_time','<=',$end);
+            }
+        }
 
         $list = $this->limit($model,'',$data);
         $list = $this->fillListData($list);

+ 1 - 1
app/Service/RangeService.php

@@ -16,7 +16,7 @@ class RangeService extends Service
     public static function customerRange($user){
         $user_id = $user['id'];
         $depart_id = $user['depart_range'];
-        $type = implode(',',CustomerInfo::$man);
+        $type = implode(',',CustomerInfo::$see_man);
         $type2 = CustomerInfo::type_eight;
         $depart_str = implode(',',$depart_id);
         $str = "(data_id = $user_id AND type IN({$type})) OR (data_id IN({$depart_str}) AND type = {$type2})";