cqpCow 10 tháng trước cách đây
mục cha
commit
5fdcb6b239

+ 3 - 0
app/Model/RoleMenuButton.php

@@ -13,4 +13,7 @@ class RoleMenuButton extends Model
 
     const special_one = -1;
     const special_two = -2;
+    const special_three = -3;
+    const special_four = -4;
+    const special_five = -5;
 }

+ 4 - 2
app/Service/EmployeeService.php

@@ -705,7 +705,7 @@ class EmployeeService extends Service
      */
     public function departList($data,$user){
         $model = Depart::where('del_time',0)
-            ->select('title','id','code','parent_id','is_main','basic_type_id','rate','notify_id')
+            ->select('title','id','code','parent_id','is_main','basic_type_id','rate','notify_id','channel_id')
             ->orderby('id', 'asc');
 
         if(! empty($data['get_top']) && $data['get_top'] == 1){
@@ -740,7 +740,8 @@ class EmployeeService extends Service
         $basic = BasicType::where('del_time',0)
             ->whereIn('id', array_unique(array_column($list,'basic_type_id')))
             ->pluck('title','id')->toArray();
-        $emp_map = Employee::whereIn('id',array_unique(array_column($list,'notify_id')))
+        $emp_id = array_unique(array_merge_recursive(array_column($list,'notify_id'),array_column($list,'channel_id')));
+        $emp_map = Employee::whereIn('id',$emp_id)
             ->pluck('emp_name','id')
             ->toArray();
 
@@ -748,6 +749,7 @@ class EmployeeService extends Service
             $list[$key]['basic_type_title'] = $basic[$value['basic_type_id']] ?? '';
             $list[$key]['is_show_basic_type'] = $user['is_all_depart'];
             $list[$key]['notify_name'] = $emp_map[$value['notify_id']] ?? '';
+            $list[$key]['channel_name'] = $emp_map[$value['channel_id']] ?? '';
         }
 
         return $list;

+ 50 - 4
app/Service/ScheduleService.php

@@ -9,6 +9,7 @@ use App\Model\Employee;
 use App\Model\Product;
 use App\Model\ProductActivity;
 use App\Model\ProductActivityPrice;
+use App\Model\RoleMenuButton;
 use App\Model\Schedule;
 use App\Model\ScheduleDetail;
 use App\Model\ScheduleInfo;
@@ -582,6 +583,7 @@ class ScheduleService extends Service
         $construction = $model->where('del_time',0)
             ->where('start_time','<=',$endTimestamp)
             ->where('end_time','>=',$startTimestamp)
+            ->where('state','>=',Construction::STATE_TWO)
             ->select('id','start_time','end_time')
             ->get()->toArray();
 
@@ -607,8 +609,9 @@ class ScheduleService extends Service
         if(empty($order_id)) return [true, ""];
 
         $construction = Construction::where('del_time',0)
+            ->where('state','>=',Construction::STATE_TWO)
             ->whereIn('id',$order_id)
-            ->select('id','order_number','crt_id','start_time','end_time','state')
+            ->select('id','order_number','crt_id','start_time','end_time','state','product_introduction','vin_no')
             ->get()->toArray();
         if(empty($construction)) return [true, ""];
         $emp = Employee::whereIn('id',array_unique(array_column($construction,'crt_id')))
@@ -631,26 +634,69 @@ class ScheduleService extends Service
 
         $return = [];
 
-        $construction_oa = (new OaService())->getConstructionOaOrderState(array_column($construction,'order_number'),$user,$data['menu_id']);
+//        $construction_oa = (new OaService())->getConstructionOaOrderState(array_column($construction,'order_number'),$user,$data['menu_id']);
+
+        //特殊功能按钮
+        $special_button = $user['special_button'] ?? [];
+        $special_button_list = config('specialButton');
+        $special_button_map = array_column($special_button_list,null,'id');
 
         //可见范围
         $employee = (new RangeService())->RangeConstructionEmpDetail($order_id);
         foreach ($construction as $value){
             $str = "";
             if(! empty($value['start_time']) && ! empty($value['end_time'])) $str = date('Y-m-d H:i',$value['start_time']) . '-' . date("Y-m-d H:i",$value['end_time']);
-
             $emp_tmp = $employee[$value['id']] ?? [];
+
+            $button = [];
+            if($value['state'] == Construction::STATE_TWO){
+                //分配/调配
+                if(in_array(RoleMenuButton::special_three,$special_button)){
+                    $button_tmp = $special_button_map[RoleMenuButton::special_three] ?? [];
+                    if(empty($emp_tmp)){
+                        $button_tmp['title'] = '分配';
+                        $button_tmp['type'] = 1;
+                    }else{
+                        $button_tmp['title'] = '调配';
+                        $button_tmp['type'] = 2;
+                    }
+                    $button[] = $button_tmp;
+                }
+
+                //完结
+                $button_tmp = $special_button_map[RoleMenuButton::special_four] ?? [];
+                if(in_array(RoleMenuButton::special_four,$special_button)){
+                    $button_tmp['is_button'] = 1;
+                }else{
+                    $button_tmp['is_button'] = 0;
+                }
+                $button[] = $button_tmp;
+            }elseif($value['state'] == Construction::STATE_THREE){
+                //待确认
+                $button_tmp = $special_button_map[RoleMenuButton::special_five] ?? [];
+                if(in_array(RoleMenuButton::special_five,$special_button)){
+                    $button_tmp['is_button'] = 1;
+                }else{
+                    $button_tmp['is_button'] = 0;
+                }
+                $button[] = $button_tmp;
+            }
+            $button = array_filter($button);
+
             $tmp = [
                 'id' => $value['id'],
                 'employee' => $emp_tmp,
                 'order_number' => $value['order_number'],
                 'crt_name' => $emp[$value['crt_id']] ?? "",
+                'product_introduction' => $value['product_introduction'],
+                'vin_no' => $value['vin_no'],
                 'product' => $product_title[$value['id']],
                 'crt_time' => $str,
                 'state' => $value['state'],
                 'state_title' => Construction::$name[$value['state']] ?? "",
+                'button' => $button
             ];
-            $tmp = $tmp + ($construction_oa[$value['order_number']] ?? []);
+//            $tmp = $tmp + ($construction_oa[$value['order_number']] ?? []);
             $return[] = $tmp;
         }
 

+ 37 - 32
app/Service/U8ServerService.php

@@ -280,8 +280,8 @@ class U8ServerService extends Service
         foreach ($result as $value){
             $bodys = [];
 
-//            $cdefine31 = "";
-//            if(! empty($value['cstname']) && $value['cstname'] == "线下销售") $cdefine31 = $value['cstname'];
+            $cdefine31 = "";
+            if($value['model_type'] == SalesOrder::Model_type_two) $cdefine31 = $value['ccusabbname'];
             foreach ($value['product'] as $son){
                 //子表数据
                 $bodys[] = [
@@ -307,16 +307,12 @@ class U8ServerService extends Service
 //                    "itax"=>$son['itax'],//原币税额
 //                    "cbmemo"=>$son['mark'], //表体备注
                     "cdefine22"=>$son['cdefine22'], //手机号码
-                    "cdefine23"=>"",
-                    "cdefine24"=>"",
                     "cdefine25"=>$son['cdefine25'], //平台类型
-                    "cdefine26"=>"",
-                    "cdefine27"=>"",
                     "cdefine28"=>$son['cdefine28'], //平台单号
                     "cdefine29"=>$son['cdefine29'], //分社施工
                     "cdefine30"=>$son['cdefine30'], //业务员
-                    "cdefine31"=>$son['cdefine31'], //客户名称
-                    "cdefine32"=>$son['cdefine32'], //直播销售
+                    "cdefine31"=>$cdefine31 ? $cdefine31 : $son['cdefine31'],//客户名称
+                    "cdefine32"=>$son['cdefine32'], //达人昵称
                     "cdefine33"=>"",
                     "cdefine34"=>"",
                     "cdefine35"=>"",
@@ -340,7 +336,7 @@ class U8ServerService extends Service
                 "csocode"=>'',
                 "ddate"=> $time,
                 "cmaker"=>$cmaker ?? 'admin',
-                "dcreatesystime"=>$time1,
+                "dcreatesystime"=> $time1,
                 "cstcode"=>"",
                 "cbustype" => $value['cbustype'], //业务类型
                 "cstname"=>$value['cstname'], //销售类型
@@ -515,20 +511,12 @@ class U8ServerService extends Service
         $customer_map = Customer::whereIn('id',array_unique(array_column($main,'customer_id')))
             ->pluck('title','id')
             ->toArray();
-//        $depart = Depart::where('parent_id',0)
-//            ->pluck('title','id')
-//            ->toArray();
         $empList = Employee::whereIn('id',array_unique(array_column($main,'crt_id')))
             ->select('number','id','emp_name')
             ->get()
             ->toArray();
         $emp = array_column($empList,'number','id');
         $emp2 = array_column($empList,'emp_name','id');
-//        $see = SeeRange::where('del_time',0)
-//            ->whereIn('data_id',array_column($main,'id'))
-//            ->where('data_type',SeeRange::type_seven)
-//            ->where('type',SeeRange::data_three)
-//            ->pluck('param_id','data_id')->toArray();//指派的分社
 
         $sub_map = [];
         foreach ($sub as $value){
@@ -536,11 +524,31 @@ class U8ServerService extends Service
             $main_tmp = $main_map[$value['sales_order_id']] ?? [];
             $position = $code_map[$main_tmp['install_position']] ?? "";
 
+            $cdefine25 = $code_map[$main_tmp['plat_type']] ?? "";//平台类型
+            $cdefine31 = $customer_map[$main_tmp['customer_id']] ?? "";
+            $cdefine28 = $cdefine29 = $cdefine30 = $cdefine32 = "";
             if($main_tmp['model_type'] == SalesOrder::Model_type_four){
                 //线上订单
-                $cdefine28 = $main_tmp['plat_order'] ?? "";
+                $cdefine28 = $main_tmp['plat_order'] ?? "";//平台单号
+                $cdefine29 = $main_tmp['cdefine29'] ?? "";
+                $cdefine30 = $main_tmp['cdefine30'] ?? "";
+                $cdefine32 = $main_tmp['cdefine32'] ?? "";
+            }elseif($main_tmp['model_type'] == SalesOrder::Model_type_two){
+                //分社订货
+                $purchase_order = PurchaseOrder::where('del_time',0)
+                    ->where('order_number',$main_tmp['contact_order_no'])
+                    ->first();
+                if(! empty($purchase_order)) $cdefine28 = SalesOrder::where('id',$purchase_order->sales_order_id)->value('order_number') ?? "";
+                $cdefine25 = "渠道部-分社";
+                $depart_tmp = Depart::where('id', $main_tmp['top_depart_id'])->first();
+                if(! empty($depart_tmp)) {
+                    $depart_tmp = $depart_tmp->toArray();
+                    if($depart_tmp['channel_id'] > 0) $cdefine30 = Employee::where('id',$depart_tmp['channel_id'])->value('emp_name');
+                }
             }else{
                 $cdefine28 = $main_tmp['order_number'] ?? "";
+                $cdefine29 = $position;
+                $cdefine30 = $emp2[$main_tmp['crt_id']] ?? "";
             }
 //            "itaxrate"=>$son['itaxrate'], //税率
 //            "iunitprice"=>$son['iunitprice'],//原币单价
@@ -575,33 +583,30 @@ class U8ServerService extends Service
 //                $value['imoney'] = $value['isum'];
 //                $value['itax'] = 0;
 //            }
-            $value['cdefine25'] = $code_map[$main_tmp['plat_type']] ?? ""; //平台类型
+            $value['cdefine25'] = $cdefine25;//平台类型
             $value['cdefine28'] = $cdefine28; //平台单号
-//            $top_depart_id = $see[$value['sales_order_id']] ?? 0;
-            $value['cdefine29'] = $position ?? "";//安装地点
-            $value['cdefine32'] = "";//直播销售 暂时没有
-            $value['cdefine31'] = $customer_map[$main_tmp['customer_id']] ?? "";//客户名称
+            $value['cdefine29'] = $cdefine29;//分社施工
+            $value['cdefine32'] = $cdefine32;//达人昵称
+            $value['cdefine31'] = $cdefine31;//客户名称
             $value['cdefine22'] = $main_tmp['customer_contact'] ?? "";//手机号码
-//            $value['cdefine31'] = "";//客户名称(线上的时候就是空  线下的话就是表头的客户简称)
-//            $value['cdefine22'] = "";//手机号码 暂时没有
-            $value['cdefine30'] = $emp2[$main_tmp['crt_id']] ?? "";//业务员
+            $value['cdefine30'] = $cdefine30;//业务员
             $value['code'] = $product_tmp['code'];//存货编码
 
             $sub_map[$value['sales_order_id']][] = $value;
         }
         foreach ($main as $key => $value){
             $customer_short_name = $code_map[$value['customer_short_name']] ?? "";
-//            if($plat_type == "营销部"){
-//                $ccusabbname = "营销部客户";
-//            }else{
-//                $ccusabbname = $customer_map[$value['customer_id']] ?? "";
-//            }
+            if($value['model_type'] == SalesOrder::Model_type_two && $value['customer_short_name'] == 0) {
+                $purchase_tmp = PurchaseOrder::where('order_number',$value['contact_order_no'])->value("top_depart_id");
+                $customer_short_name = Depart::where('id',$purchase_tmp)->value('title');
+            }
             $main[$key]['cbustype'] = "普通销售"; //业务类型(本身就是中文)
-            $main[$key]['cstname'] = SalesOrder::$model_type_title[$value['model_type']] ?? ""; //销售类型
+            $main[$key]['cstname'] = SalesOrder::$model_type_title_u8[$value['model_type']] ?? ""; //销售类型
             $main[$key]['ccusabbname'] = $customer_short_name;//客户简称
 //            $main[$key]['cdepname'] = $depart[$value['top_depart_id']] ?? "";//部门名称
 //            $main[$key]['cpersoncode'] = $emp[$value['crt_id']] ?? "";//业务员
             $main[$key]['jobnumber'] = $emp[$value['crt_id']] ?? "";
+            $main[$key]['jobnumber'] = "T90000";
             $main[$key]['product'] = $sub_map[$value['id']] ?? [];
         }
 

+ 22 - 0
config/specialButton.php

@@ -15,5 +15,27 @@ return [
         "func" => "special_show_cost",
         "menu_id" => 17,
     ],
+    [
+        "id" => \App\Model\RoleMenuButton::special_three,
+        "title" => "分配/调配",
+        "sort" => -3,
+        "func" => "special_allocation",
+        "menu_id" => 34,
+        "is_button" => 1,
+    ],
+    [
+        "id" => \App\Model\RoleMenuButton::special_four,
+        "title" => "完结",
+        "sort" => -4,
+        "func" => "special_finish_construction",
+        "menu_id" => 34,
+    ],
+    [
+        "id" => \App\Model\RoleMenuButton::special_five,
+        "title" => "待确认",
+        "sort" => -5,
+        "func" => "special_sure_construction",
+        "menu_id" => 34,
+    ],
 ];