cqp преди 5 месеца
родител
ревизия
0cae2017f0
променени са 6 файла, в които са добавени 152 реда и са изтрити 52 реда
  1. 1 0
      app/Model/BasicType.php
  2. 7 3
      app/Model/Customer.php
  3. 97 11
      app/Service/ConstructionService.php
  4. 33 1
      app/Service/CustomerService.php
  5. 0 23
      app/Service/PurchaseOrderService.php
  6. 14 14
      config/specialButton.php

+ 1 - 0
app/Model/BasicType.php

@@ -41,5 +41,6 @@ class BasicType extends UseScopeBaseModel
         28 => '默认账户',
         29 => '客户简称',
         30 => '客户类型(T9二手车)',
+        31 => '客户类型(T9分社)',
     ];
 }

+ 7 - 3
app/Model/Customer.php

@@ -8,20 +8,24 @@ class Customer extends UseScopeBaseModel
     const CREATED_AT = 'crt_time';
     const UPDATED_AT = 'upd_time';
     protected $dateFormat = 'U';
-    const Model_type_one = 1; // 基础模板
+    const Model_type_one = 1; // T9改装
     const Model_type_two = 2; // T9二手车客户模板
+    const Model_type_three = 3; // T9分社
     const special_id = -1;
     public static $model_type = [
         self::Model_type_one,
-        self::Model_type_two
+        self::Model_type_two,
+        self::Model_type_three,
     ];
     const dk = [
         'T9改装' => self::Model_type_one,
-        'T9二手车' => self::Model_type_two
+        'T9二手车' => self::Model_type_two,
+        'T9分社' => self::Model_type_three,
     ];
     const dk2 = [
         self::Model_type_one => 'T9改装',
         self::Model_type_two => 'T9二手车',
+        self::Model_type_three => 'T9分社',
     ];
 
     public static $user = [];

+ 97 - 11
app/Service/ConstructionService.php

@@ -430,6 +430,24 @@ class ConstructionService extends Service
         $construction['construction_period'] = $start_time . '——' . $end_time;
         $sales = SalesOrder::where('id',$construction['sales_order_id'])->value('order_number');
         $construction['sales_order_number'] = $sales;
+        $sales_info = SalesOrderInfo::where('del_time',0)
+            ->where('sales_order_id',$construction['sales_order_id'])
+            ->where('type', SalesOrderInfo::type_two)
+            ->get()->toArray();
+        $emp = Employee::whereIn('id',array_unique(array_column($sales_info,'data_id')))
+            ->pluck('emp_name','id')
+            ->toArray();
+        $sale_man = [];
+        foreach ($sales_info as $value){
+            $tt = $emp[$value['data_id']] ?? '';
+            $tmp = [
+                'id' => $value['data_id'],
+                'name' => $tt?? '',
+            ];
+            $sale_man[] = $tmp;
+        }
+        $construction['sale_man'] = $sale_man;
+
         $customer_title = Customer::where('id',$construction['customer_id'])->value('title');
         $construction['customer_title'] = $customer_title ?? "";
         $info = CustomerInfo::from('customer_info as a')
@@ -1067,6 +1085,7 @@ class ConstructionService extends Service
         try {
             $model->upd_id = $id;
             $model->construction_order_number = $data['construction_order_number'] ?? '';
+            $model->sales_order_number = $data['sales_order_number'] ?? '';
             $model->start_time = $data['start_time'] ?? '';
             $model->end_time = $data['end_time'] ?? '';
             $model->vin_no = $data['vin_no'] ?? '';
@@ -1090,41 +1109,108 @@ class ConstructionService extends Service
             $model->img2 = $data['img2'] ?? '';
             $model->img3 = $data['img3'] ?? '';
             $model->save();
-            return [true,'保存成功!'];
         }catch (\Throwable $e){
-            return [true,'保存成功!'];
+            return [false, $e->getMessage()];
         }
+
+        return [true,''];
     }
 
     public function deliveryNoteList($data)
     {
-        $list = DeliveryNote::where('del_time',0);
-        $list = $this->limit($list,'*',$data);
+        $model = DeliveryNote::where('del_time',0)
+            ->select("*")
+            ->orderBy("id","desc");
+        $list = $this->limit($model,'', $data);
+
         return [true,$list];
     }
 
+    public function fillDeliveryNoteData($data){
+        if(empty($data['data'])) return $data;
+
+        $emp = $this->returnMan($data['data']);
+
+        foreach ($data['data'] as $key => $value){
+            $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']] ?? '';
+            $data['data'][$key]['sale_man_title'] = $this->returnMan2($value['sale_man']);
+            $data['data'][$key]['install_man_title'] = $this->returnMan2($value['install_man']);
+        }
+
+        return $data;
+    }
+
+    public function returnMan($data = []){
+        if(empty($data)) return [];
+
+        $man = [];
+        foreach ($data as $value){
+            if(! empty($value['sale_man'])){
+                $tmp = explode(',', $value['sale_man']);
+                foreach ($tmp as $t){
+                    if(! in_array($t, $man)) $man[] = $t;
+                }
+            }
+            if(! empty($value['install_man'])){
+                $tmp = explode(',', $value['install_man']);
+                foreach ($tmp as $t){
+                    if(! in_array($t, $man)) $man[] = $t;
+                }
+            }
+
+            if(! in_array($value['crt_id'], $man)) $man[] = $value['crt_id'];
+        }
+        $emp = Employee::whereIn('id', $man)
+            ->pluck('emp_name','id')
+            ->toArray();
+        return $emp;
+    }
+
+    public function returnMan2($value){
+        $str_man = "";
+        if(! empty($value)){
+            $tmp = explode(',', $value);
+            foreach ($tmp as $t){
+                $t2 = $emp[$t] ?? "";
+                if($t2) $str_man .= $t2 . ",";
+            }
+            $str_man = rtrim($str_man, ',');
+        }
+
+        return $str_man;
+    }
+
     public function deliveryNoteDetail($data){
         if(isset($data['id'])) $model = DeliveryNote::where('id',$data['id'])->where('del_time',0)->first();
         if(isset($data['construction_order_number'])) $model = DeliveryNote::where('id',$data['construction_order_number'])->where('del_time',0)->first();
-        if(empty($model)) return [false,'数据不存在!'];
-        $employee_key_list = Employee::pluck('emp_name','id')->toArray();
+        if(empty($model)) return [false,'单据不存在或已被删除'];
         $detail = $model->toArray();
+        $emp = $this->returnMan([$detail]);
 
-        $detail['install_man_title'] = $employee_key_list[$detail['install_man']] ?? "";
-        $detail['sale_man_title'] = $employee_key_list[$detail['sale_man']] ?? "";
-        $img_list = ConstructionFile::where('order_number',$detail['construction_order_number'])->where('del_time',0)->select('file as url','name','mark')->get()->toArray();
+        $detail['sale_man_title'] = $emp[$detail['sale_man']] ?? "";
+        $detail['install_man_title'] = $emp[$detail['install_man']] ?? "";
+        $detail['crt_name'] = $emp[$detail['crt_id']] ?? "";
+        $detail['crt_time'] = $detail['crt_time'] ? date('Y-m-d H:i:s',$detail['crt_time']) : '';
+        $img_list = ConstructionFile::where('order_number',$detail['construction_order_number'])
+            ->where('del_time',0)
+            ->select('file as url','name','mark')->get()->toArray();
         $detail['file'] = $img_list;
-        return [true,$detail];
+
+        return [true, $detail];
     }
 
     public function deliveryNoteDel($data,$user){
+        if(empty($data['id'])) return [false, '请选择删除的交车单数据'];
+
         DeliveryNote::where('id',$data['id'])->update(
             [
                 'del_time' => time(),
                 'upd_id' => $user['id'],
             ]
         );
-        return [true,'删除成功!'];
+
+        return [true,''];
     }
 
     public function constructionPdf($data, $user){

+ 33 - 1
app/Service/CustomerService.php

@@ -568,9 +568,13 @@ class CustomerService extends Service
             $model->whereIn('customer_from', $id);
         }
         if(! empty($data['customer_type_title'])) {
-            $id = (new RangeService())->customerBasicTypeSearch($data['customer_type_title'],[3,30]);
+            $id = (new RangeService())->customerBasicTypeSearch($data['customer_type_title'],[3,30,31]);
             $model->whereIn('customer_type', $id);
         }
+        if(! empty($data['progress_stage_title'])){
+            $id = (new RangeService())->customerBasicTypeSearch($data['progress_stage_title'],[5]);
+            $model->whereIn('progress_stage', $id);
+        }
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->where('crt_time','>=',$return[0]);
@@ -596,6 +600,7 @@ class CustomerService extends Service
                 ->get()->toArray();
             $model->whereIn('id',array_column($customer_info,'customer_id'));
         }
+        if(! empty($data['no_fp_time'])) $model->where('fp_time', 0);
 
         if(! empty($data['wx_crt_time'][0]) && ! empty($data['wx_crt_time'][1])) {
             $model->where('crt_time','>=',$data['wx_crt_time'][0]);
@@ -685,6 +690,10 @@ class CustomerService extends Service
             $model->where('fp_time','>=',$return[0]);
             $model->where('fp_time','<=',$return[1]);
         }
+        if(! empty($data['belong_top_depart_title'])){
+            $id = $this->searchCustomerDepart($data['belong_top_depart_title']);
+            $model->whereIn('id', $id);
+        }
         if(! empty($data['wx_fp_time'][0]) && ! empty($data['wx_fp_time'][1])) {
             $model->where('fp_time','>=',$data['wx_fp_time'][0]);
             $model->where('fp_time','<=',$data['wx_fp_time'][1]);
@@ -1002,6 +1011,29 @@ class CustomerService extends Service
         return $return;
     }
 
+    //客资门店搜索
+    public function searchCustomerDepart($depart_title = ""){
+        $customer_id = [];
+        if(empty($depart_title)) return $customer_id;
+
+        $depart_id = Depart::where('del_time', 0)
+            ->where('parent_id', 0)
+            ->where('title', 'LIKE', '%'. $depart_title .'%')
+            ->select('id')->get()->toArray();
+        $depart_id = array_column($depart_id, 'id');
+        if(empty($depart_id)) return $customer_id;
+
+        $customer_id = SeeRange::where('del_time',0)
+            ->whereIn('param_id', $depart_id)
+            ->where('data_type',SeeRange::type_one)
+            ->where('type',SeeRange::data_three)
+            ->select('data_id as customer_id')
+            ->get()->toArray();
+        $customer_id = array_column($customer_id, 'customer_id');
+
+        return $customer_id;
+    }
+
     //抢客户
     public function customerGrabbing($data, $user){
         $key = Customer::$limitKey . $data['customer_id'];

+ 0 - 23
app/Service/PurchaseOrderService.php

@@ -248,19 +248,6 @@ class PurchaseOrderService extends Service
         if(empty($order)) return [false, '采购订单不存在或已被删除'];
         $order = $order->toArray();
 
-        //特殊功能按钮
-        $special_button = $user['special_button'] ?? [];
-
-        //其它费用隐藏
-        $price = "******";
-        if(in_array(RoleMenuButton::special_six,$special_button)) $price = $order['other_fee'];
-        $order['other_fee_show'] = $price;
-
-        //优惠金额隐藏
-        $price = "******";
-        if(in_array(RoleMenuButton::special_seven,$special_button)) $price = $order['discount_fee'];
-        $order['discount_fee_show'] = $price;
-
         $order['activity_product'] = $order['file'] = [];
         $order['purchase_type_title'] = BasicType::where('id',$order['purchase_type'])->value('title') ?? '';
         $order['storehouse_title'] = Storehouse::where('id',$order['storehouse_id'])->value('title');
@@ -633,16 +620,6 @@ class PurchaseOrderService extends Service
             //坏账金额
             $data['data'][$key]['fee4'] = $bad;
             //用于统计--------
-
-            //其它费用隐藏
-            $price = "******";
-            if(in_array(RoleMenuButton::special_six,$special_button)) $price = $value['other_fee'];
-            $data['data'][$key]['other_fee_show'] = $price;
-
-            //优惠金额隐藏
-            $price = "******";
-            if(in_array(RoleMenuButton::special_seven,$special_button)) $price = $value['discount_fee'];
-            $data['data'][$key]['discount_fee_show'] = $price;
         }
 
         return $data;

+ 14 - 14
config/specialButton.php

@@ -37,19 +37,19 @@ return [
         "func" => "special_sure_construction",
         "menu_id" => 34,
     ],
-    [
-        "id" => \App\Model\RoleMenuButton::special_six,
-        "title" => "其它费用",
-        "sort" => -6,
-        "func" => "special_purchase_other_fee",
-        "menu_id" => 45,
-    ],
-    [
-        "id" => \App\Model\RoleMenuButton::special_seven,
-        "title" => "优惠金额",
-        "sort" => -7,
-        "func" => "special_purchase_discount_fee",
-        "menu_id" => 45,
-    ],
+//    [
+//        "id" => \App\Model\RoleMenuButton::special_six,
+//        "title" => "其它费用",
+//        "sort" => -6,
+//        "func" => "special_purchase_other_fee",
+//        "menu_id" => 45,
+//    ],
+//    [
+//        "id" => \App\Model\RoleMenuButton::special_seven,
+//        "title" => "优惠金额",
+//        "sort" => -7,
+//        "func" => "special_purchase_discount_fee",
+//        "menu_id" => 45,
+//    ],
 ];