浏览代码

Merge remote-tracking branch 'origin/master'

gogs 1 年之前
父节点
当前提交
3443f521ca

+ 22 - 0
app/Http/Controllers/Api/DataSyncToU8Controller.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Service\DataSyncToU8Service;
+use Illuminate\Http\Request;
+
+class DataSyncToU8Controller extends BaseController
+{
+    public function add(Request $request)
+    {
+        $service = new DataSyncToU8Service();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->add($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+}

+ 90 - 0
app/Http/Controllers/Api/ScheduleController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+
+use App\Service\ScheduleService;
+use Illuminate\Http\Request;
+
+class ScheduleController extends BaseController
+{
+    public function edit(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->edit($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function add(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->add($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function del(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->del($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function getList(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->getList($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function detail(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->detail($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function scheduleGetForConstruction(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->scheduleGetForConstruction($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+}

+ 12 - 0
app/Http/Middleware/CheckWx.php

@@ -29,6 +29,18 @@ class CheckWx
         if (empty($employee)) return response()->json(['code'=> 202,'msg'=>'用户信息不存在!','data'=>null]);
         $employee = $employee->toArray();
         if (empty($employee['mobile'])) return response()->json(['code'=> 202,'msg'=>'用户手机信息不存在!','data'=>null]);
+        if (empty($employee['employee_id'])) {
+            //找到对应的账号
+            $emp = Employee::where('del_time',0)
+                ->where('mobile',$employee['mobile'])
+                ->where('state',Employee::USE)
+                ->select('id')
+                ->first();
+            if(empty($emp)) return response()->json(['code'=> 202,'msg'=>'用户手机信息未匹配到系统账号!','data'=>null]);
+            $emp = $emp->toArray();
+            WxEmployee::where('id',$employee['id'])->update(['employee_id' => $emp['id']]);
+            $employee['employee_id'] = $emp['id'];
+        }
 
         //当前请求接口
         $uri = $request->path();

+ 98 - 0
app/Jobs/ProcessDataJob.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Model\ErrorTable;
+use App\Model\U8Job;
+use App\Service\U8ServerService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
+use MongoDB\Driver\Exception\Exception;
+use Symfony\Component\Console\Output\ConsoleOutput;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class ProcessDataJob implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $data;
+
+    public $tries = 0;
+    public $timeout = 60;
+
+    //1 采购  2 销售(合同)
+    protected $function = [
+        1 => 'U8PO_PomainSave',
+        2 => 'U8SaleOrderSave',
+    ];
+
+    public function __construct($data)
+    {
+        $this->data = $data;
+    }
+
+    public function handle()
+    {
+        try {
+            $function = $this->function[$this->data['type']] ?? '';
+            if(empty($function)) return;
+
+            //调用同步方法
+            $this->$function();
+        } catch (\Exception $e) {
+            $this->delete();
+        }
+    }
+
+    //采购
+    private function U8PO_PomainSave(){
+        $service = new U8ServerService();
+        if(! empty($service->error)) {
+            $service->finalSettle($this->data['id'], U8Job::one, $service->error);
+            return;
+        }
+
+        $service->U8PO_PomainSave($this->data['id']);
+    }
+
+    //销售(合同)
+    private function U8SaleOrderSave(){
+        $service = new U8ServerService();
+        if(! empty($service->error)) {
+            $service->finalSettle($this->data['id'], U8Job::two, $service->error);
+            return;
+        }
+
+        $service->U8SaleOrderSave($this->data['id']);
+    }
+
+//    public function failed($exception)
+//    {
+//        // 记录失败错误信息到日志或其他媒介
+//        $errorMessage = $exception->getFile() . $exception->getMessage() . $exception->getLine();
+//        $this->recordErrorTable($errorMessage);
+//    }
+
+    private function recordErrorTable($msg){
+        $data = $this->data;
+
+        ErrorTable::insert([
+            'msg' => $msg,
+            'data' => json_encode($this->data),
+            'user_id' => $data['user']['id'],
+            'user_operation_time' => $data['user']['operate_time'],
+            'type' => $data['type']
+        ]);
+    }
+
+    protected function echoMessage(OutputInterface $output)
+    {
+        //输出消息
+        $output->writeln(json_encode($this->data));
+    }
+}

+ 4 - 0
app/Model/Construction.php

@@ -14,6 +14,10 @@ class Construction extends UseScopeBaseModel
         self::Model_type_one,
         self::Model_type_two,
     ];
+    public static $model_type_title = [
+        self::Model_type_one => '总部安装',
+        self::Model_type_two => '分社网点安装',
+    ];
 
     public static $prefix = [
         self::Model_type_one => 'WO0.',

+ 19 - 0
app/Model/ErrorTable.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+class ErrorTable extends Model
+{
+    protected $table = "error_table"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+    public static $type = [
+        1 => '采购单同步',
+        2 => '销售订单(合同同步)',
+    ];
+}

+ 17 - 0
app/Model/FollowUpRecordFile.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class FollowUpRecordFile extends Model
+{
+    protected $table = "follow_up_record_file"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+    const type_one = 1; // 图片
+    public static $type = [
+        self::type_one,
+    ];
+}

+ 12 - 0
app/Model/Schedule.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Model;
+
+class Schedule extends UseScopeBaseModel
+{
+    protected $table = "schedule"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+    const range_function = '';
+}

+ 15 - 0
app/Model/ScheduleInfo.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ScheduleInfo extends Model
+{
+    protected $table = "schedule_info"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+    const not_use = 0;
+    const limit_key = "scheduleInfo";
+}

+ 35 - 0
app/Model/U8Job.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+class U8Job extends Model
+{
+    protected $table = "u8_job"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+    const success = 1;
+    const failed = 2;
+
+    const one = 1;
+    const two = 2;
+    public static $type = [
+        self::one,
+        self::two,
+    ];
+    public static $type_title = [
+        self::one => '采购单同步',
+        self::two => '销售订单(合同同步)',
+    ];
+
+    const job1 = 't9u8_purchase';
+    const job2 = 't9u8_sales';
+    public static $job = [
+        self::one => self::job1,
+        self::two => self::job2,
+    ];
+}

+ 1 - 1
app/Service/BasicTypeService.php

@@ -60,7 +60,7 @@ class BasicTypeService extends Service
     public function basicTypeList($data, $user){
         $model = BasicType::TopClear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('title','id','type')
+            ->select('title','id','type','code')
             ->orderby('id', 'asc');
 
         if(! empty($data['type'])) $model->where('type',$data['type']);

+ 5 - 5
app/Service/CheckService.php

@@ -903,14 +903,14 @@ class CheckService extends Service
                 'order' => $msg,
             ];
 
-            $return_msg = '';
-
             $oa = new OaService();
-            $bool = $oa->createOaOrder($args);
-            if(! $bool) $return_msg = '审批失败!';
+            list($bool,$msg) = $oa->createOaOrder($args);
+            if(! $bool) {
+                DB::rollBack();
+                if($msg) return [false,$msg];
+            }
 
             DB::commit();
-            if($return_msg) return [false,$msg];
             return [true, ''];
         }catch (\Throwable $exception){
             DB::rollBack();

+ 64 - 5
app/Service/ConstructionService.php

@@ -11,6 +11,7 @@ use App\Model\Depart;
 use App\Model\Employee;
 use App\Model\SalesOrder;
 use App\Model\SalesOrderProductInfo;
+use App\Model\ScheduleInfo;
 use App\Model\SeeRange;
 use App\Model\Storehouse;
 use Illuminate\Support\Facades\DB;
@@ -57,6 +58,10 @@ class ConstructionService extends Service
             $model->storehouse_id = $data['storehouse_id'] ?? 0;
             $model->start_time = $data['start_time'] ?? 0;
             $model->end_time = $data['end_time'] ?? 0;
+            $model->schedule_id = $data['schedule_id'] ?? 0;
+            $model->day_stamp = $data['day_stamp'] ?? 0;
+            $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
+            $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
             $model->save();
             $time = time();
 
@@ -117,6 +122,8 @@ class ConstructionService extends Service
                 ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
             }
 
+            if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -163,6 +170,10 @@ class ConstructionService extends Service
             $model->storehouse_id = $data['storehouse_id'] ?? 0;
             $model->start_time = $data['start_time'] ?? 0;
             $model->end_time = $data['end_time'] ?? 0;
+            $model->schedule_id = $data['schedule_id'] ?? 0;
+            $model->day_stamp = $data['day_stamp'] ?? 0;
+            $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
+            $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
             $model->save();
             $time = time();
 
@@ -216,6 +227,8 @@ class ConstructionService extends Service
                 ProductInventoryService::changeLockNumber($user,$msg[0],[]);
             }
 
+            if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -256,6 +269,15 @@ class ConstructionService extends Service
             //锁定库存释放
             ProductInventoryService::changeLockNumber($user,[],$product_save);
 
+            //排班修改
+            $schedule = ScheduleInfo::where('del_time',0)
+                ->where('schedule_id',$construction['schedule_id'])
+                ->where('start_time',$construction['day_start_stamp'])
+                ->where('end_time',$construction['day_end_stamp'])
+                ->where('is_use','>', ScheduleInfo::not_use)
+                ->first();
+            if(! empty($schedule)) ScheduleInfo::where('id',$schedule->id)->update(['is_use' => ScheduleInfo::not_use]);
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -452,7 +474,6 @@ class ConstructionService extends Service
         if(! empty($data['service_price'])){
             $res = $this->checkNumber($data['service_price']);
             if(! $res) return [false,'服务价格请输入不超过两位小数并且大于0的数值'];
-            if(! $res) return [false,'服务价格请输入不超过两位小数并且大于0的数值'];
         }
         if(! empty($data['construction_time'])) $data['construction_time'] = $this->changeDateToDateMin($data['construction_time']);
         if(! empty($data['handover_time'])) $data['handover_time'] = $this->changeDateToDateMin($data['handover_time']);
@@ -464,9 +485,12 @@ class ConstructionService extends Service
 //            if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
 //            if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
         }
+        //校验排班
+        if(empty($data['schedule_id']) ||empty($data['day_stamp']) || empty($data['day_start_stamp']) || empty($data['day_end_stamp'])) return [false,'排班时间信息不能为空'];
+
         //所属部门 以及  顶级部门
         if(empty($data['depart_id'])) {
-            $data['depart_id'] = $this->getDepart($user);
+            $data['depart_id'] = $this->getDepazrt($user);
             $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
         }
 
@@ -520,7 +544,18 @@ class ConstructionService extends Service
                 ->where('start_time', '<=', $data['end_time'])
                 ->where('end_time', '>=', $data['start_time'])
                 ->exists();
-            if($bool)  return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
+            if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
+
+            $schedule = ScheduleInfo::where('del_time',0)
+                ->where('day',$data['day_stamp'])
+                ->where('start_time',$data['day_start_stamp'])
+                ->where('end_time',$data['day_end_stamp'])
+                ->where('is_use',ScheduleInfo::not_use)
+                ->first();
+            if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
+            $data['schedule_info_id'] = $schedule->id;
+            list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
+            if(! $status) return [false,'操作频繁,请稍等!'];
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
             $bool = Construction::where('del_time',0)
@@ -530,6 +565,22 @@ class ConstructionService extends Service
                 ->where('end_time', '>=', $data['start_time'])
                 ->exists();
             if($bool)  return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
+
+            $construction = Construction::where('id',$data['id'])->first();
+            if(empty($construction)) return [false,'施工单不存在或已被删除'];
+            $construction = $construction->toArray();
+            if($construction['day_stamp'] != $data['day_stamp'] || $construction['day_start_stamp'] != $data['day_start_stamp'] && $construction['day_end_stamp'] != $data['day_end_stamp']) {
+                $schedule = ScheduleInfo::where('del_time',0)
+                    ->where('day',$data['day_stamp'])
+                    ->where('start_time',$data['day_start_stamp'])
+                    ->where('end_time',$data['day_end_stamp'])
+                    ->where('is_use',ScheduleInfo::not_use)
+                    ->first();
+                if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
+                $data['schedule_info_id'] = $schedule->id;
+                list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
+                if(! $status) return [false,'操作频繁,请稍等!'];
+            }
         }
 
         return [true, [$product_submit, $product_save]];
@@ -553,7 +604,11 @@ class ConstructionService extends Service
         $customer = Customer::whereIn('id',array_unique(array_column($data['data'],'customer_id')))
             ->pluck('title','id')
             ->toArray();
-        $sales = SalesOrder::whereIn('id',array_unique(array_column($data['data'],'sales_order_id')))->pluck('order_number','id')->toArray();
+        $sales = SalesOrder::whereIn('id',array_unique(array_column($data['data'],'sales_order_id')))->select('order_number','id','handover_time')->get()->toArray();
+        $sales_map = [];
+        foreach ($sales as $value){
+            $sales_map[$value['id']] = $value;
+        }
         $storehouse = Storehouse::whereIn('id',array_unique(array_column($data['data'],'storehouse_id')))
             ->pluck('title','id')
             ->toArray();
@@ -573,6 +628,7 @@ class ConstructionService extends Service
             $end_time = $value['end_time'] ? date("Y-m-d H:i",$value['end_time']) : '';
             $data['data'][$key]['construction_period'] = $start_time . '——' . $end_time;
             $data['data'][$key]['address'] = $address;
+            $data['data'][$key]['model_type_title'] = Construction::$model_type_title[$value['model_type']] ?? '';
             $data['data'][$key]['install_position_title'] = $basic_map[$value['install_position']] ?? '';
             $data['data'][$key]['install_method_title'] = $basic_map[$value['install_method']] ?? '';
             $data['data'][$key]['urgency_title'] = $basic_map[$value['urgency']] ?? '';
@@ -581,7 +637,10 @@ class ConstructionService extends Service
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
             $data['data'][$key]['customer_contact_title'] = $emp[$value['customer_contact_id']] ?? '';
             $data['data'][$key]['state_title'] = Construction::$name[$value['state']] ?? '';
-            $data['data'][$key]['sales_order_number'] = $sales[$value['sales_order_id']] ?? '';
+            $tmp_sales = $sales_map[$value['sales_order_id']] ?? [];
+            $tmp_sales_time = $tmp_sales['handover_time'] ? date("Y-m-d") : "";
+            $data['data'][$key]['sales_order_number'] = $tmp_sales['order_number'];
+            $data['data'][$key]['handover_time'] = $tmp_sales_time;
             $data['data'][$key]['storehouse_title'] = $storehouse[$value['storehouse_id']] ?? '';
             $data['data'][$key]['dispatch_company'] = $dispatch[$value['sales_order_id']] ?? '';
         }

+ 3 - 1
app/Service/CustomerService.php

@@ -31,6 +31,7 @@ class CustomerService extends Service
 
             $model = Customer::where('id',$data['id'])->first();
             $model->title = $data['title'];
+            $model->code = $data['code'] ?? "";
             $model->model_type = $data['model_type'];
             $model->customer_intention = $data['customer_intention'] ?? 0;
             $model->customer_from = $data['customer_from'] ?? 0;
@@ -160,6 +161,7 @@ class CustomerService extends Service
 
             $model = new Customer();
             $model->title = $data['title'];
+            $model->code = $data['code'] ?? "";
             $model->model_type = $data['model_type'];
             $model->customer_intention = $data['customer_intention'] ?? 0;
             $model->customer_from = $data['customer_from'] ?? 0;
@@ -445,7 +447,7 @@ class CustomerService extends Service
     public function customerList($data,$user){
         $model = Customer::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','customer_grade','pond_state','top_depart_id')
+            ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','customer_grade','pond_state','top_depart_id','code')
             ->orderby('id', 'desc');
 
         if(! empty($data['pond_state'])) {

+ 43 - 0
app/Service/DataSyncToU8Service.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Service;
+
+use App\Jobs\ProcessDataJob;
+use App\Model\PurchaseOrder;
+use App\Model\U8Job;
+
+class DataSyncToU8Service extends Service
+{
+    public function add($data,$user){
+        list($status,$msg) = $this->orderRule($data);
+        if(!$status) return [$status,$msg];
+
+//        dd((new U8ServerService())->U8PO_PomainSave($data['id']));
+        try{
+            $job = ProcessDataJob::dispatch($data)->onQueue($data['job']);
+            if(! $job) return [false,'任务没有进入队列!'];
+        }catch (\Throwable $e){
+            return [false,$e->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    public function orderRule(&$data){
+        if(empty($data['type'])) return [false,'type不能为空!'];
+        if(! in_array($data['type'],U8Job::$type)) return [false,'type不能存在!'];
+        if(empty($data['id'])) return [false,'同步数据不能为空!'];
+        $data['job'] = U8Job::$job[$data['type']] ?? "";
+        if(empty($data['job'])) return [false,'未找到同步任务!'];
+        if($data['type'] == U8Job::one){
+            //采购同步校验
+            $bool = PurchaseOrder::whereIn('id',$data['id'])
+                ->where('del_time',0)
+                ->where('supplier',0)
+                ->exists();
+            if($bool) return [false,'同步的采购单供应商不能为空!'];
+        }
+
+        return [true, ''];
+    }
+}

+ 104 - 33
app/Service/FollowUpRecordService.php

@@ -6,7 +6,9 @@ use App\Model\BasicType;
 use App\Model\Customer;
 use App\Model\Employee;
 use App\Model\FollowUpRecord;
+use App\Model\FollowUpRecordFile;
 use App\Model\SalesOrder;
+use Illuminate\Support\Facades\DB;
 
 class FollowUpRecordService extends Service
 {
@@ -14,17 +16,45 @@ class FollowUpRecordService extends Service
         list($status,$msg) = $this->followUpRecordRule($data,false);
         if(!$status) return [$status,$msg];
 
-        $model = new FollowUpRecord();
-        $model = $model->where('id',$data['id'])->first();
-        $model->data_id = $data['data_id'] ?? 0;
-        $model->data_title = $data['data_title'] ?? '';
-        $model->type = $data['type'] ?? '';
-        $model->basic_type_id = $data['basic_type_id'] ;
-        $model->visit_time = $data['visit_time'];
-        $model->content = $data['content'];
-        $model->is_remind = $data['is_remind'] ?? 0;
-        $model->result = $data['result'] ?? '';
-        $model->save();
+        try {
+            DB::beginTransaction();
+
+            $model = new FollowUpRecord();
+            $model = $model->where('id',$data['id'])->first();
+            $model->data_id = $data['data_id'] ?? 0;
+            $model->data_title = $data['data_title'] ?? '';
+            $model->type = $data['type'] ?? '';
+            $model->basic_type_id = $data['basic_type_id'] ;
+            $model->visit_time = $data['visit_time'];
+            $model->content = $data['content'];
+            $model->is_remind = $data['is_remind'] ?? 0;
+            $model->result = $data['result'] ?? '';
+            $model->save();
+
+            $time = time();
+            FollowUpRecordFile::where('del_time',0)
+                ->where('follow_up_record_id',$data['id'])
+                ->update(['del_time' => $time]);
+
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'follow_up_record_id' => $data['id'],
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'type' => FollowUpRecordFile::type_one,
+                        'crt_time' => $time,
+                    ];
+                }
+                FollowUpRecordFile::insert($insert);
+            }
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
 
         return [true,''];
     }
@@ -33,17 +63,42 @@ class FollowUpRecordService extends Service
         list($status,$msg) = $this->followUpRecordRule($data);
         if(!$status) return [$status,$msg];
 
-        $model = new FollowUpRecord();
-        $model->data_id = $data['data_id'] ?? 0;
-        $model->data_title = $data['data_title'] ?? '';
-        $model->type = $data['type'] ?? '';
-        $model->basic_type_id = $data['basic_type_id'] ;
-        $model->visit_time = $data['visit_time'];
-        $model->content = $data['content'];
-        $model->is_remind = $data['is_remind'] ?? 0;
-        $model->crt_id = $user['id'];
-        $model->result = $data['result'] ?? '';
-        $model->save();
+        try {
+            DB::beginTransaction();
+
+            $model = new FollowUpRecord();
+            $model->data_id = $data['data_id'] ?? 0;
+            $model->data_title = $data['data_title'] ?? '';
+            $model->type = $data['type'] ?? '';
+            $model->basic_type_id = $data['basic_type_id'] ;
+            $model->visit_time = $data['visit_time'];
+            $model->content = $data['content'];
+            $model->is_remind = $data['is_remind'] ?? 0;
+            $model->crt_id = $user['id'];
+            $model->result = $data['result'] ?? '';
+            $model->save();
+
+            $time = time();
+
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'follow_up_record_id' => $model->id,
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'type' => FollowUpRecordFile::type_one,
+                        'crt_time' => $time,
+                    ];
+                }
+                FollowUpRecordFile::insert($insert);
+            }
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
 
         return [true,''];
     }
@@ -51,9 +106,21 @@ class FollowUpRecordService extends Service
     public function followUpRecordDel($data){
         if($this->isEmpty($data,'id')) return [false,'ID必须!'];
 
-        FollowUpRecord::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
+        try {
+            DB::beginTransaction();
+
+            FollowUpRecord::where('id',$data['id'])->update([
+                'del_time'=>time()
+            ]);
+            FollowUpRecordFile::where('del_time',0)
+                ->where('follow_up_record_id', $data['id'])
+                ->update(['del_time' => time()]);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
 
         return [true,'删除成功'];
     }
@@ -110,14 +177,18 @@ class FollowUpRecordService extends Service
     public function followUpRecordDetail($data){
         if($this->isEmpty($data,'id')) return [false,'ID必须!'];
 
-        $record = FollowUpRecord::where('del_time',0)
-            ->where('id',$data['id'])
-            ->first();
-        if(empty($record)) return [false,'跟进记录不存在或已被删除'];
-        $record = $record->toArray();
-        $emp_map = Employee::where('id',$record['crt_id'])->value('emp_name');
-        $record['crt_name'] = $emp_map;
-        $record['crt_time'] = $record['crt_time'] ? date("Y-m-d H:i:s",$record['crt_time']): '';
+        $record = [];
+        $sales_info = FollowUpRecordFile::where('del_time',0)
+            ->where('follow_up_record_id',$data['id'])
+            ->get()->toArray();
+        foreach ($sales_info as $value){
+            if ($value['type'] == FollowUpRecordFile::type_one){
+                $record[] = [
+                    'url' => $value['file'],
+                    'name' => $value['name'],
+                ];
+            }
+        }
 
         return [true, $record];
     }

+ 4 - 3
app/Service/ProductActivityService.php

@@ -180,9 +180,10 @@ class ProductActivityService extends Service
             $model->where('crt_time','<=',$return[1]);
         }
         if(! empty($data['activity_time'][0]) && ! empty($data['activity_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['activity_time']);
-            $model->where('start_time','>=',$return[0]);
-            $model->where('end_time','<=',$return[1]);
+            $start_time = $this->changeDateToDateMin($data['activity_time'][0]);
+            $end_time = $this->changeDateToDateMin($data['activity_time'][1]);
+            $model->where('start_time','>=',$start_time);
+            $model->where('end_time','<=',$end_time);
         }
 
         $list = $this->limit($model,'',$data);

+ 2 - 3
app/Service/ProductService.php

@@ -515,9 +515,8 @@ class ProductService extends Service
         if(isset($data['state'])) $model->where('state', $data['state']);
         if(! empty($data['product_category_id'])) $model->where('product_category_id', $data['product_category_id']);
         if(! empty($data['product_category'])) {
-            $model2 = ProductCategory::TopClear($user,$data);
-            $product_category = $model2->where('del_time',0)
-                ->where('title', 'LIKE', '%'.$data['title'].'%')
+            $product_category = ProductCategory::where('del_time',0)
+                ->where('title', 'LIKE', '%'.$data['product_category'].'%')
                 ->select('id')
                 ->get()->toArray();
             $model->whereIn('product_category_id',array_unique(array_column($product_category,'id')));

+ 2 - 0
app/Service/PurchaseOrderService.php

@@ -68,6 +68,7 @@ class PurchaseOrderService extends Service
                         'basic_type_id' => $value['basic_type_id'],
                         'price' => $value['price'],
                         'mark' => $value['mark'] ?? '',
+                        'rate' => $value['rate'] ?? 0,
                     ];
                 }
                 PurchaseOrderInfo::insert($sub);
@@ -141,6 +142,7 @@ class PurchaseOrderService extends Service
                         'basic_type_id' => $value['basic_type_id'],
                         'price' => $value['price'],
                         'mark' => $value['mark'] ?? '',
+                        'rate' => $value['rate'] ?? 0,
                     ];
                 }
                 PurchaseOrderInfo::insert($sub);

+ 9 - 6
app/Service/SalesOrderService.php

@@ -159,6 +159,7 @@ class SalesOrderService extends Service
                         'final_amount' => $value['final_amount'] ?? 0,
                         'sports_bag_id' => $value['sports_bag_id'] ?? 0,
                         'sports_bag_product_info_id' => $sports_bag_product_info_id,
+                        'rate' => $value['rate'] ?? 0,
                     ];
                 }
                 SalesOrderProductInfo::insert($insert);
@@ -309,6 +310,7 @@ class SalesOrderService extends Service
                         'final_amount' => $value['final_amount'] ?? 0,
                         'sports_bag_id' => $value['sports_bag_id'] ?? 0,
                         'sports_bag_product_info_id' => $sports_bag_product_info_id,
+                        'rate' => $value['rate'] ?? 0,
                     ];
                 }
                 SalesOrderProductInfo::insert($insert);
@@ -608,8 +610,8 @@ class SalesOrderService extends Service
                 ->get()->toArray();
             $model->whereIn('customer_id',array_unique(array_column($customer,'id')));
         }
-        if(! empty($data['sign_time'])){
-            $return = $this->changeDateToNewDate2($data['sign_time']);
+        if(! empty($data['sign_time'][0]) && ! empty($data['sign_time'][1])){
+            $return = $this->changeDateToTimeStampAboutRange($data['sign_time']);
             $model->where('sign_time','>=',$return[0]);
             $model->where('sign_time','<=',$return[1]);
         }
@@ -767,7 +769,7 @@ class SalesOrderService extends Service
             ->whereIn('sales_order_id',array_column($data['data'],'id'))
             ->get()->toArray();
         foreach ($sales_o_info as $value){
-            $fee[$value['sales_order_id']][] = $value;
+            $fee[$value['sales_order_id']] = $value['other_fee_1'];
         }
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['business_type_title'] = $basic_map[$value['business_type']] ?? '';
@@ -793,12 +795,13 @@ class SalesOrderService extends Service
             $data['data'][$key]['product'] = $product[$value['id']] ?? [];
             $data['data'][$key]['fee'] = $fee[$value['id']] ?? "";
             if($value['sales_order_type'] == SalesOrder::Order_type_one){
-                $data['data'][$key]['state_name'] = SalesOrder::$state[$value['state']] ?? '';
+                $data['data'][$key]['state_title'] = SalesOrder::$state[$value['state']] ?? '';
             }else{
-                $data['data'][$key]['state_name'] = SalesOrder::$state2[$value['state']] ?? '';
+                $data['data'][$key]['state_title'] = SalesOrder::$state2[$value['state']] ?? '';
             }
             $data['data'][$key]['invoice_state_name'] = SalesOrder::$invoice_state[$value['invoice_state']] ?? '';
-            $data['data'][$key]['invoice_arr'] = $invoiceData[$value['id']] ?? [];
+            $tmp = $invoiceData[$value['id']] ?? [];
+            $data['data'][$key]['invoice_arr'] = implode(',', $tmp);
             $data['data'][$key]['dispatch_company'] = $dispatch[$value['id']] ?? '';
 
             //合同对应的金额数据

+ 289 - 0
app/Service/ScheduleService.php

@@ -0,0 +1,289 @@
+<?php
+
+namespace App\Service;
+
+use App\Model\BasicType;
+use App\Model\Employee;
+use App\Model\Product;
+use App\Model\ProductActivity;
+use App\Model\ProductActivityPrice;
+use App\Model\Schedule;
+use App\Model\ScheduleInfo;
+use Illuminate\Support\Facades\DB;
+
+class ScheduleService extends Service
+{
+    public function edit($data,$user){
+        list($status,$msg) = $this->scheduleRule($data, $user, false);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = Schedule::where('id',$data['id'])->first();
+            $model->start_time = $data['start_time'] ?? 0;
+            $model->end_time = $data['end_time'] ?? 0;
+            $model->mark = $data['mark'] ?? '';
+            $model->save();
+
+            $time = time();
+            ScheduleInfo::where('schedule_id',$data['id'])
+                ->where('del_time',0)
+                ->update(['del_time' => $time]);
+
+            if(! empty($data['day_time'])){
+                $insert = [];
+                foreach ($data['day_time'] as $value){
+                    for ($i=0;$i<$value['num'];$i++){
+                        foreach ($data['time_range'] as $range){
+                            $date = date('Y-m-d',$range);
+                            $start_time = strtotime($date . " " .$value['start_time']);
+                            $end_time = strtotime($date . " " .$value['end_time']);
+                            $insert[] = [
+                                'schedule_id' => $model->id,
+                                'crt_time' => $time,
+                                'day' => $range ?? 0, //0点的时间戳
+                                'start_time' => $start_time ?? 0, //加上开始时间段
+                                'end_time' => $end_time ?? 0,//加上结束时间段
+                            ];
+                        }
+                    }
+                }
+                ScheduleInfo::insert($insert);
+            }
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    public function add($data,$user){
+        list($status,$msg) = $this->scheduleRule($data, $user);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = new Schedule();
+            $model->start_time = $data['start_time'] ?? 0;
+            $model->end_time = $data['end_time'] ?? 0;
+            $model->mark = $data['mark'] ?? '';
+            $model->crt_id = $user['id'];
+            $model->depart_id = $data['depart_id'] ?? 0;
+            $model->top_depart_id = $data['top_depart_id'] ?? 0;
+            $model->save();
+
+            $time = time();
+            if(! empty($data['day_time'])){
+                $insert = [];
+                foreach ($data['day_time'] as $value){
+                    for ($i=0;$i<$value['num'];$i++){
+                        foreach ($data['time_range'] as $range){
+                            $date = date('Y-m-d',$range);
+                            $start_time = strtotime($date . " " .$value['start_time']);
+                            $end_time = strtotime($date . " " .$value['end_time']);
+                            $insert[] = [
+                                'schedule_id' => $model->id,
+                                'crt_time' => $time,
+                                'day' => $range ?? 0, //0点的时间戳
+                                'start_time' => $start_time ?? 0, //加上开始时间段
+                                'end_time' => $end_time ?? 0,//加上结束时间段
+                            ];
+                        }
+                    }
+                }
+                ScheduleInfo::insert($insert);
+            }
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    public function del($data){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+
+        try {
+            DB::beginTransaction();
+
+            $time = time();
+
+            Schedule::where('id',$data['id'])->update(['del_time' => $time]);
+
+            ScheduleInfo::where('schedule_id',$data['id'])
+                ->where('del_time',0)
+                ->update(['del_time' => $time]);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    public function detail($data,$user){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+        $schedule = Schedule::where('del_time',0)
+            ->where('id',$data['id'])
+            ->first();
+        if(empty($schedule)) return [false,'排班设置不存在或已被删除'];
+        $schedule = $schedule->toArray();
+
+        $schedule['crt_name'] = Employee::where('id',$schedule['crt_id'])->value('emp_name');
+        $schedule['crt_time'] = $schedule['crt_time'] ? date("Y-m-d H:i:s",$schedule['crt_time']): '';
+
+        return [true, $schedule];
+    }
+
+    public function getList($data,$user){
+        $model = Schedule::TopClear($user,$data);
+        $model = $model->where('del_time',0)
+            ->select('id','crt_id','mark','start_time','end_time','crt_time')
+            ->orderby('id', 'desc');
+
+        if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
+        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
+            $model->where('crt_time','>=',$return[0]);
+            $model->where('crt_time','<=',$return[1]);
+        }
+        if(! empty($data['schedule'][0]) && ! empty($data['schedule'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['schedule']);
+            $model->where('start_time','>=',$return[0]);
+            $model->where('end_time','<=',$return[1]);
+        }
+
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list,$user);
+
+        return [true, $list];
+    }
+
+    public function scheduleRule(&$data, $user, $is_add = true){
+        if(empty($data['schedule'][0]) || empty($data['schedule'][1])) return [false,'排班日期不能为空'];
+        $data['start_time'] = $this->changeDateToDate($data['schedule'][0]);
+        $data['end_time'] = $this->changeDateToDate($data['schedule'][1]);
+        $data['time_range'] = $this->getTimestampRange($data['start_time'],$data['end_time']);
+        if(empty($data['day_time'])) return [false,'排班时间段不能为空'];
+        foreach ($data['day_time'] as $value){
+            if(empty($value['start_time'])) return [false,'排班时间段开始时间不能为空'];
+            if(empty($value['end_time'])) return [false,'排班时间段结束时间不能为空'];
+            if(empty($value['num'])) return [false,'排班车间数量不能为空'];
+        }
+
+        if($is_add){
+            $model = Schedule::TopClear($user,$data);
+            $bool = $model->where('del_time',0)
+                ->where('start_time', '<=', $data['end_time'])
+                ->where('end_time', '>=', $data['start_time'])
+                ->exists();
+        }else{
+            if(empty($data['id'])) return [false,'ID不能为空'];
+            $model = Schedule::TopClear($user,$data);
+            $bool = $model->where('del_time',0)
+                ->where('id','<>',$data['id'])
+                ->where('start_time', '<=', $data['end_time'])
+                ->where('end_time', '>=', $data['start_time'])
+                ->exists();
+        }
+        if($bool) return [false,'排班日期已经设置,请不要重复设置!'];
+
+        //所属部门 以及 顶级部门
+        if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
+        $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
+
+        return [true, $data];
+    }
+
+    public function fillData($data, $user){
+        if(empty($data['data'])) return $data;
+
+        $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
+            ->pluck('emp_name','id')
+            ->toArray();
+
+        foreach ($data['data'] as $key => $value){
+            $start_time = $value['start_time'] ? date("Y-m-d H:i",$value['start_time']) : '';
+            $end_time = $value['end_time'] ? date("Y-m-d H:i",$value['end_time']) : '';
+            $data['data'][$key]['schedule'] = $start_time . '——' . $end_time;
+            $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']] ?? '';
+        }
+
+        return $data;
+    }
+
+    public function scheduleGetForConstruction($data,$user){
+        if(empty($data['schedule'])) return [false,'请选择日期!'];
+        $schedule = $this->changeDateToDate($data['schedule']);
+        $model = Schedule::TopClear($user,$data);
+        $schedule_id = $model->where('del_time',0)
+            ->where('start_time', '<=', $schedule)
+            ->where('end_time', '>=', $schedule)
+            ->select('id')->get()->toArray();
+        $schedule_id = array_column($schedule_id,'id');
+        if(empty($schedule_id)) return [false,'该时间排班设置不存在或已被删除!'];
+
+        $schedule_detail_list = ScheduleInfo::where('del_time',0)
+            ->whereIn('schedule_id',$schedule_id)
+            ->where('day',$schedule)
+            ->where('is_use',ScheduleInfo::not_use)
+            ->select('schedule_id','day','start_time','end_time')
+            ->get()->toArray();
+        if(empty($schedule_detail_list)) return [false,'该时间排班已满、不存在或已被删除!'];
+
+        $return = [];
+        foreach ($schedule_detail_list as $value){
+            if(isset($return[$value['start_time'] . $value['end_time']])){
+                $return[$value['start_time'] . $value['end_time']]['num'] += 1;
+            }else{
+                $tmp['schedule_id'] = $value['schedule_id'];
+                $tmp['num'] = 1;
+                $tmp['day_stamp'] = $value['day'];
+                $tmp['day_start_stamp'] = $value['start_time'];
+                $tmp['day_end_stamp'] = $value['end_time'];
+                $tmp['day'] = date('Y-m-d',$value['day']);
+                $tmp['start_time'] = date('H:i',$value['start_time']);
+                $tmp['end_time'] = date('H:i',$value['end_time']);
+                $return[$value['start_time'] . $value['end_time']] = $tmp;
+            }
+        }
+        ksort($return);
+
+        return [true, array_values($return)];
+    }
+
+    public function getTimestampRange($startTimestamp, $endTimestamp){
+        // 将时间戳转换为日期格式
+        $startDate = date('Y-m-d', $startTimestamp);
+        $endDate = date('Y-m-d', $endTimestamp);
+
+        // 创建日期范围
+        $dateRange = [];
+        $currentDate = strtotime($startDate);
+
+        while ($currentDate <= strtotime($endDate)) {
+            $dateRange[] = $currentDate;
+            $currentDate = strtotime('+1 day', $currentDate);
+        }
+
+        // 将每个日期设置为当天的 0 点 0 分 0 秒并转换为时间戳
+        $zeroTimestamps = [];
+
+        foreach ($dateRange as $date) {
+            $zeroTimestamps[] = strtotime(date('Y-m-d 00:00:00', $date));
+        }
+
+        return $zeroTimestamps;
+    }
+}

+ 20 - 2
app/Service/Service.php

@@ -239,9 +239,10 @@ class Service
 
     //后台端 某些需要限制请求频率的接口
     //需要主动删除  Redis::del($key)
-    public function limitingSendRequestBackg($key){
+    public function limitingSendRequestBackg($key,$value=0){
+        if(! empty($value)) $value = 1;
         // 使用Redis Facade设置,当键名不存在时才设置成功
-        if (Redis::setnx($key, 1)) return [true, ''];
+        if (Redis::setnx($key, $value)) return [true, ''];
 
         return [false,'操作频繁!'];
     }
@@ -349,6 +350,23 @@ class Service
         return strtotime($formattedDate);
     }
 
+    //前端传来的时间 转为时间戳
+    //精确到日
+    function changeDateToDate($time){
+        if(empty($time)) return '';
+
+        // 创建一个 DateTime 对象并设置时区为 UTC
+        $dateTime = new \DateTime($time, new \DateTimeZone('UTC'));
+
+        // 将时区设置为 PRC
+        $dateTime->setTimezone(new \DateTimeZone('Asia/Shanghai'));
+
+        // 将日期时间格式化为特定格式
+        $formattedDate = $dateTime->format('Y-m-d 00:00:00');
+
+        return strtotime($formattedDate);
+    }
+
     /**
      * 用于用户行为操作日志记录
      * @param $insert

+ 4 - 3
app/Service/SportsBagService.php

@@ -187,9 +187,10 @@ class SportsBagService extends Service
             $model->where('crt_time','<=',$return[1]);
         }
         if(! empty($data['sports_bag_time'][0]) && ! empty($data['sports_bag_time'][1])) {
-            $return = $this->changeDateToTimeStampAboutRange($data['sports_bag_time']);
-            $model->where('start_time','>=',$return[0]);
-            $model->where('end_time','<=',$return[1]);
+            $start_time = $this->changeDateToDateMin($data['sports_bag_time'][0]);
+            $end_time = $this->changeDateToDateMin($data['sports_bag_time'][1]);
+            $model->where('start_time','>=',$start_time);
+            $model->where('end_time','<=',$end_time);
         }
 
         $list = $this->limit($model,'',$data);

+ 6 - 1
app/Service/SupplierService.php

@@ -24,6 +24,7 @@ class SupplierService extends Service
 
             $model = Supplier::where('id',$data['id'])->first();
             $model->title = $data['title'];
+            $model->code = $data['code'];
             $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
             $model->address2 = $data['address2'] ?? '';
             $model->mark = $data['mark'] ?? '';
@@ -54,6 +55,7 @@ class SupplierService extends Service
 
             $model = new Supplier();
             $model->title = $data['title'];
+            $model->code = $data['code'];
             $model->mobile = $data['mobile'] ?? "";
             $model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
             $model->address2 = $data['address2'] ?? '';
@@ -140,12 +142,13 @@ class SupplierService extends Service
     public function customerList($data,$user){
         $model = Supplier::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('id','title','address1','address2','mobile','crt_id','crt_time','is_main','mark')
+            ->select('id','title','address1','address2','mobile','crt_id','crt_time','is_main','mark','code')
             ->orderby('id', 'asc');
 
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
         if(! empty($data['mobile'])) $model->where('mobile', 'LIKE', '%'.$data['mobile'].'%');
         if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
+        if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->where('crt_time','>=',$return[0]);
@@ -167,6 +170,8 @@ class SupplierService extends Service
      */
     public function customerRule(&$data, $user, $is_add = true){
         if(empty($data['title'])) return [false,'供应商名称不能为空'];
+        if(empty($data['code'])) return [false,'供应商编码不能为空'];
+
         //所属部门 以及  顶级部门
         if(empty($data['depart_id'])) {
             $data['depart_id'] = $this->getDepart($user);

+ 25 - 6
app/Service/TableHeadService.php

@@ -17,13 +17,15 @@ class TableHeadService extends Service
             if(empty($value['key'])) return [false, 'key不能为空'];
             if(empty($value['value'])) return [false, 'value不能为空'];
             if(empty($value['sort'])) return [false, 'sort不能为空'];
-            if(empty($value['is_show'])) return [false, 'is_show不能为空'];
+            if(! isset($value['is_show'])) return [false, 'is_show不能为空'];
 
             $insert[] = [
                 'key' => $value['key'],
                 'value' => $value['value'],
                 'sort' => $value['sort'],
                 'is_show' => $value['is_show'],
+                'is_click_detail' => $value['is_click_detail'] ?? 0,
+                'float' => $value['float'],
                 'menu_id' => $data['menu_id'],
                 'crt_time' => $time,
                 'crt_id' => $user['id'],
@@ -50,13 +52,30 @@ class TableHeadService extends Service
     public function tableheadGet($data, $user){
         if(empty($data['menu_id'])) return [false,'menu_id不能为空!'];
 
-        $header = config("header.{$data['menu_id']}") ?? [];
+        $header = TableSetting::where('del_time',0)
+            ->where('menu_id',$data['menu_id'])
+            ->where('crt_id',$user['id'])
+            ->select('key','value','sort','is_show','is_click_detail','menu_id','float')
+            ->get()->toArray();
+        $header_map = array_column($header,null,'key');
 
-        foreach ($header as $key => $value){
-            $header[$key]['sort'] = $key + 1;
-            $header[$key]['is_show'] = 1;
+        $header_default = config("header.{$data['menu_id']}") ?? [];
+        foreach ($header_default as $key => $value){
+            if(isset($header_map[$value['key']])) {
+                //存在保存好的设置的表头 以下信息沿用
+                $tmp = $header_map[$value['key']];
+                $header_default[$key]['sort'] = $tmp['sort'];
+                $header_default[$key]['is_show'] = $tmp['is_show'];
+                $header_default[$key]['is_click_detail'] = $tmp['is_click_detail'];
+                $header_default[$key]['float'] = $tmp['float'];
+            }else{
+                $header_default[$key]['sort'] = $key + 1;
+                $header_default[$key]['is_show'] = 1;
+                $header_default[$key]['is_click_detail'] = 0;
+                $header_default[$key]['float'] = 0;
+            }
         }
 
-        return [true, $header];
+        return [true, $header_default];
     }
 }

+ 572 - 0
app/Service/U8ServerService.php

@@ -0,0 +1,572 @@
+<?php
+
+namespace App\Service;
+
+use App\Model\BasicType;
+use App\Model\Customer;
+use App\Model\Depart;
+use App\Model\Employee;
+use App\Model\Product;
+use App\Model\PurchaseOrder;
+use App\Model\PurchaseOrderInfo;
+use App\Model\SalesOrder;
+use App\Model\SalesOrderProductInfo;
+use App\Model\SeeRange;
+use App\Model\Setting;
+use App\Model\Supplier;
+use App\Model\U8Job;
+use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Redis;
+
+class U8ServerService extends Service
+{
+    public $db = null;
+    public $error = null; // 错误信息
+    public $u8 = []; //u8 配置连接参数
+    public $u8_api = ""; //u8接口请求地址
+    public $post_common = [];//u8接口公用参数
+
+    public function __construct($is_need_connect = 0)
+    {
+        //u8 配置连接参数 u8_api设置
+        list($status,$msg) = $this->settingConnection();
+        if(! $status) {
+            $this->error = $msg;
+            return;
+        }
+
+        //是否需要连接u8数据库
+        if($is_need_connect){
+            //构建数据库连接对象
+            list($status,$msg) = $this->settingDb();
+            if(! $status) {
+                $this->error = $msg;
+            }
+        }
+    }
+
+    //设置u8连接参数
+    private function settingConnection(){
+        $u8 = Setting::where('setting_name','u8')->where('setting_value','<>','')->first();
+        if(empty($u8)) return [false, 'u8配置参数不存在!'];
+        $u8 = $u8->toArray();
+        // 使用 eval() 函数执行字符串并转换为数组
+        $u8 = eval("return {$u8['setting_value']};");
+
+        if(empty($u8['domain'])) return [false, '外部域名不能为空!'];
+        if(empty($u8['u8_api_port'])) return [false, 'u8程序API端口不能为空!'];
+        if(empty($u8['u8_database_port'])) return [false, 'u8程序数据库端口不能为空!'];
+        if(empty($u8['database'])) return [false, 'u8程序数据库不能为空!'];
+        if(empty($u8['database_account'])) return [false, 'u8程序数据库登录账号不能为空!'];
+        if(empty($u8['database_password'])) return [false, 'u8程序数据库登录密码不能为空!'];
+        if(empty($u8['sAccID'])) return [false, 'u8程序sAccID不能为空!'];
+        if(empty($u8['sServer'])) return [false, 'u8程序sServer不能为空!'];
+        if(empty($u8['sUserID'])) return [false, 'u8程序sUserID不能为空!'];
+        if(empty($u8['sPassword'])) return [false, 'u8程序sPassword不能为空!'];
+
+        $this->u8 = $u8;
+        $this->u8_api = "https://" . $u8['domain'] . ":" . $u8['u8_api_port'] . "/U8Sys/U8API";
+        $this->post_common = [
+            "password"=>"cloud@123456",
+            "entity"=>"", //调用方法
+            "login"=>[
+                "sAccID"=> $u8['sAccID'],
+                "sDate"=> date("Y-m-d"),
+                "sServer"=> $u8['sServer'],
+                "sUserID"=> $u8['sUserID'],
+                "sSerial"=> "",
+                "sPassword"=> $u8['sPassword']
+            ]
+        ];
+
+        return [true, ''];
+    }
+
+    //设置u8数据库连接
+    private function settingDb(){
+        if(empty($this->db)){
+            $u8 = $this->u8;
+
+            $config = [
+                'driver' => 'sqlsrv',
+                'host' =>  $u8['domain'],
+                'port' => $u8['u8_database_port'],
+                'database' => $u8['database'],
+                'username' => $u8['database_account'],
+                'password' => $u8['database_password'],
+            ];
+
+            // 数据库配置设置
+            Config::set('database.connections.sqlsrvs', $config);
+
+            // 连接
+            try {
+                $pdo = DB::connection('sqlsrvs')->getPdo();
+                if ($pdo instanceof \PDO) {
+                    // 连接成功的逻辑代码
+                    $this->db = DB::connection('sqlsrvs');
+                } else {
+                    return [false, '连接失败!'];
+                }
+            } catch (\Throwable $e) {
+                return [false, $e->getMessage()];
+            }
+
+        }
+
+        return [true, ''];
+    }
+
+    //采购订单保存
+    public function U8PO_PomainSave($data){
+        $id = $data;
+
+        //映射ip是否通畅
+        $bool = $this->isDomainAvailable($this->u8['domain']);
+        if(! $bool) {
+            $msg = 'U8程序外部域名不可达';
+            $this->finalSettle($id, U8Job::one,$msg);
+            return;
+        }
+
+        //获取数据
+        $result = $this->getPurchaseData($id);
+        if(empty($result)) {
+            $msg = "同步数据获取失败";
+            $this->finalSettle($id, U8Job::one, $msg);
+            return;
+        }
+
+        //u8接口参数组织
+        $post = $this->post_common;
+        $post['entity'] = "U8PO_PomainSave";
+
+        $time = date("Y-m-d");
+
+        foreach ($result as $value){
+            $bodys = [];
+            foreach ($value['product'] as $son){
+                //子表数据
+                $bodys[] = [
+                    "iappids"=>"", //子表id
+                    "cinvcode"=>$son['code'], //存货编码
+                    "iquantity"=>$son['number'], //数量
+                    "inum"=>$son['number'], //件数
+                    "ipertaxrate"=>$son['ipertaxrate'], //税率
+                    "iunitprice"=>$son['iunitprice'], //原币单价
+                    "itaxprice"=>$son['itaxprice'], //原币含税单价
+                    "isum"=>$son['isum'], //原币价税合计
+                    "imoney"=>$son['imoney'], //原币无税金额
+                    "itax"=>$son['itax'],//原币税额
+                    "cbmemo"=>$son['mark'], //表体备注
+                    "cdefine22"=>"",
+                    "cdefine23"=>"",
+                    "cdefine24"=>"",
+                    "cdefine25"=>"",
+                    "cdefine26"=>"",
+                    "cdefine27"=>"",
+                    "cdefine28"=>"",
+                    "cdefine29"=>"",
+                    "cdefine30"=>"",
+                    "cdefine31"=>"",
+                    "cdefine32"=>"",
+                    "cdefine33"=>"",
+                    "cdefine34"=>"",
+                    "cdefine35"=>"",
+                    "cdefine36"=>"",
+                    "cdefine37"=>"",
+                    "cfree1"=>"",
+                    "cfree2"=>"",
+                    "cfree3"=>"",
+                    "cfree4"=>"",
+                    "cfree5"=>"",
+                    "cfree6"=>"",
+                    "cfree7"=>"",
+                    "cfree8"=>"",
+                    "cfree9"=>"",
+                    "cfree10"=>""
+                ];
+            }
+
+            //最终数据
+            $post['data'] = [
+                "cpoid"=>"",
+                "dpodate"=>date("Y-m-d",$value['crt_time']),
+                "cmemo"=>"T9采购单:" . $value['order_number'],
+                "cmaker"=>"admin",
+                "cmaketime"=>$time,
+                "IsExamine"=>false,
+                "cvencode"=>"", //供应商编码
+                "cvenname"=>$value['cvenname'], //供应商名称
+                "cdepcode"=>"", //部门编号
+                "cdepname"=>$value['cdepname'], //部门名称
+                "cpersoncode"=>$value['cpersoncode'], //业务员编码
+                "cdefine1"=>"",
+                "cdefine2"=>"",
+                "cdefine3"=>"",
+                "cdefine4"=>"",
+                "cdefine5"=>"",
+                "cdefine6"=>"",
+                "cdefine7"=>"",
+                "cdefine8"=>"",
+                "cdefine9"=>"",
+                "cdefine10"=>"",
+                "cdefine11"=>"",
+                "cdefine12"=>"",
+                "cdefine13"=>"",
+                "cdefine14"=>"",
+                "cdefine15"=>"",
+                "cdefine16"=>"",
+                "bodys"=>$bodys
+            ];
+
+            file_put_contents('record_purchase.txt',"请求参数:" . json_encode($post) . PHP_EOL,8);
+            $return = $this->post_helper($this->u8_api,json_encode($post), ['Content-Type:application/json']);
+            file_put_contents('record_purchase.txt',"返回结果:" . json_encode($return). PHP_EOL,8);
+
+            //剔除数据
+            $id = array_diff($id, [$value['id']]);
+
+            if(empty($return)) {
+                $msg = '异常错误,请确认请求接口地址或地址不可达';
+                $this->finalSettle($value['id'], U8Job::one, $msg);
+            }else{
+                if( ! empty($return['flag'])){
+                    $this->finalSettle($value['id'], U8Job::one);
+                }else{
+                    $this->finalSettle($value['id'],  U8Job::one, $return['msg']);
+                }
+            }
+        }
+
+        if(! empty($id)){
+            $msg = "未找到同步数据";
+            $this->finalSettle($id, U8Job::one, $msg);
+        }
+    }
+
+    //销售订单(合同)保存
+    public function U8SaleOrderSave($data){
+        $id = $data;
+
+        //映射ip是否通畅
+        $bool = $this->isDomainAvailable($this->u8['domain']);
+        if(! $bool) {
+            $msg = 'U8程序外部域名不可达';
+            $this->finalSettle($id, U8Job::two, $msg);
+            return;
+        }
+
+        //获取数据
+        $result = $this->getSaleOrderData($id);
+        if(empty($result)) {
+            $msg = "同步数据获取失败";
+            $this->finalSettle($id, U8Job::two, $msg);
+            return;
+        }
+
+        //u8接口参数组织
+        $post = $this->post_common;
+        $post['entity'] = "U8SaleOrderSave";
+
+        $time = date("Y-m-d");
+        $time1 = date("Y-m-d H:i:s");
+        foreach ($result as $value){
+            $bodys = [];
+
+            $cdefine31 = "";
+            if(! empty($value['cstname']) && $value['cstname'] == "线下销售") $cdefine31 = $value['cstname'];
+            foreach ($value['product'] as $son){
+                //子表数据
+                $bodys[] = [
+                    "iappids"=>"", //子表id
+                    "cinvcode"=>$son['code'], //存货编码
+                    "iquantity"=>$son['number'], //数量
+                    "inum"=>$son['number'], //件数
+                    "ipertaxrate"=>$son['ipertaxrate'], //税率
+                    "iunitprice"=>$son['iunitprice'], //原币单价
+                    "itaxprice"=>$son['itaxprice'], //原币含税单价
+                    "isum"=>$son['isum'], //原币价税合计
+                    "imoney"=>$son['imoney'], //原币无税金额
+                    "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"=>$cdefine31, //客户名称
+                    "cdefine32"=>$son['cdefine32'], //直播销售
+                    "cdefine33"=>"",
+                    "cdefine34"=>"",
+                    "cdefine35"=>"",
+                    "cdefine36"=>"",
+                    "cdefine37"=>"",
+                    "cfree1"=>"",
+                    "cfree2"=>"",
+                    "cfree3"=>"",
+                    "cfree4"=>"",
+                    "cfree5"=>"",
+                    "cfree6"=>"",
+                    "cfree7"=>"",
+                    "cfree8"=>"",
+                    "cfree9"=>"",
+                    "cfree10"=>""
+                ];
+            }
+
+            //最终数据
+            $post['data'] = [
+                "csocode"=>'',
+                "ddate"=> $time,
+                "cmaker"=>"admin",
+                "dcreatesystime"=>$time1,
+                "cstcode"=>"",
+                "cbustype" => $value['cbustype'], //业务类型
+                "cstname"=>$value['cstname'], //销售类型
+                "ccuscode"=>"",
+                "ccusabbname"=>$value['ccusabbname'], //客户简称
+                "cdepcode"=>"",
+                "cdepname"=>$value['cdepname'], // 部门名称
+                "cpersoncode"=>"", //业务员编码 暂时不要
+                "itaxrate"=>"0",
+                "cmemo"=>"T9销售订单:". $value['order_number'],
+                "cdefine1"=>"",
+                "cdefine2"=>"",
+                "cdefine3"=>"",
+                "cdefine4"=>"",
+                "cdefine5"=>"",
+                "cdefine6"=>"",
+                "cdefine7"=>"",
+                "cdefine8"=>"",
+                "cdefine9"=>"",
+                "cdefine10"=>"",
+                "cdefine11"=>"",
+                "cdefine12"=>"",
+                "cdefine13"=>"",
+                "cdefine14"=>"",
+                "cdefine15"=>"",
+                "cdefine16"=>"",
+                "bodys"=>$bodys
+            ];
+
+            file_put_contents('record_purchase.txt',"请求参数:" . json_encode($post) . PHP_EOL,8);
+            $return = $this->post_helper($this->u8_api,json_encode($post), ['Content-Type:application/json']);
+            file_put_contents('record_purchase.txt',"返回结果:" . json_encode($return). PHP_EOL,8);
+
+            //剔除数据
+            $id = array_diff($id, [$value['id']]);
+
+            if(empty($return)) {
+                $msg = '异常错误,请确认请求接口地址或地址不可达';
+                $this->finalSettle($value['id'],U8Job::two, $msg);
+            }else{
+                if( ! empty($return['flag'])){
+                    $this->finalSettle($value['id'],U8Job::two);
+                }else{
+                    $this->finalSettle($value['id'], U8Job::two, $return['msg']);
+                }
+            }
+        }
+
+        if(! empty($id)){
+            $msg = "未找到同步数据";
+            $this->finalSettle($id,U8Job::two, $msg);
+        }
+    }
+
+    //最终处理
+    public function finalSettle($data,$data_type, $msg = ''){
+        if(! is_array($data)) $data = [$data];
+        $time = time();
+        $insert = [];
+
+        U8Job::where('del_time',0)
+            ->where('data_type',U8Job::one)
+            ->whereIn('data',$data)
+            ->update(['del_time' => $time]);
+        foreach ($data as $value){
+            if(empty($msg)){
+                $insert[] = [
+                    'data' => $value,
+                    'data_type' => $data_type,
+                    'crt_time' => $time,
+                    'state' => U8Job::success,
+                ];
+            }else{
+                $insert[] = [
+                    'data' => $value,
+                    'data_type' => $data_type,
+                    'crt_time' => $time,
+                    'state' => U8Job::failed,
+                    'msg' => $msg
+                ];
+            }
+        }
+
+        U8Job::insert($insert);
+    }
+
+    public function getPurchaseData($id){
+        $main = PurchaseOrder::whereIn('id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        if(empty($main)) return [];
+        $supplier = Supplier::whereIn('id',array_unique(array_column($main,'supplier')))
+            ->pluck('title','id')
+            ->toArray();
+        $depart = Depart::whereIn('id',array_unique(array_column($main,'depart_id')))
+            ->pluck('title','id')
+            ->toArray();
+        $emp = Employee::whereIn('id',array_unique(array_column($main,'purchase_id')))
+            ->pluck('number','id')
+            ->toArray();
+
+        $sub = PurchaseOrderInfo::whereIn('purchase_order_id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        $product = Product::whereIn('id',array_unique(array_column($sub,'product_id')))
+            ->get()->toArray();
+        $product_map = array_column($product,null,'id');
+
+        $sub_map = [];
+        foreach ($sub as $value){
+            $product_tmp = $product_map[$value['product_id']] ?? [];
+            $value['code'] = $product_tmp['code'];
+
+            //计算金额
+            if($value['rate'] > 0){
+//                    ipertaxrate 税率
+//                    iunitprice 原币单价
+//                    itaxprice 原币含税单价
+//                    isum 原币价税合计
+//                    imoney 原币无税金额
+//                    itax 原币税额
+                $value['ipertaxrate'] = $value['rate'];
+                $rate = round($value['rate'] / 100,2);
+                $value['iunitprice'] = round($value['price'] / (1 + $rate),2);
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = round($value['price'] * $value['number'],2);
+                $value['imoney'] = round($value['iunitprice'] * $value['number'],2);
+                $value['itax'] = round($value['isum'] - $value['imoney'],2);
+            }else{
+                $value['ipertaxrate'] = 0;
+                $value['iunitprice'] = $value['price'];
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = $value['price'] * $value['number'];
+                $value['imoney'] = $value['isum'];
+                $value['itax'] = 0;
+            }
+
+            $sub_map[$value['purchase_order_id']][] = $value;
+        }
+        foreach ($main as $key => $value){
+            $main[$key]['cptname'] = $supplier[$value['supplier']] ?? "";
+            $main[$key]['cvenname'] = $supplier[$value['supplier']] ?? "";
+            $main[$key]['cdepname'] = $depart[$value['depart_id']] ?? "";
+            $main[$key]['cpersoncode'] = $emp[$value['purchase_id']] ?? "";
+            $main[$key]['product'] = $sub_map[$value['id']] ?? [];
+        }
+
+        return $main;
+    }
+
+    public function getSaleOrderData($id){
+        $main = SalesOrder::whereIn('id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        if(empty($main)) return [];
+        $main_map = array_column($main,null,'id');
+        $sub = SalesOrderProductInfo::whereIn('sales_order_id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        $product = Product::whereIn('id',array_unique(array_column($sub,'product_id')))
+            ->get()->toArray();
+        $product_map = array_column($product,null,'id');
+
+        $code_map = BasicType::whereIn('id',array_unique(array_merge_recursive(array_column($main,'business_type'),array_column($main,'sale_type'),array_column($main,'plat_type'))))
+            ->pluck('title','id')
+            ->toArray();
+        $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();
+        $emp = Employee::whereIn('id',array_unique(array_column($main,'crt_id')))
+            ->pluck('number','id')
+            ->toArray();
+        $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){
+            $product_tmp = $product_map[$value['product_id']] ?? [];
+            $main_tmp = $main_map[$value['sales_order_id']] ?? [];
+
+            //计算金额
+            if($value['rate'] > 0){
+                $value['ipertaxrate'] = $value['rate'];
+                $rate = round($value['rate'] / 100,2);
+                $value['iunitprice'] = round($value['price'] / (1 + $rate),2);
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = round($value['price'] * $value['number'],2);
+                $value['imoney'] = round($value['iunitprice'] * $value['number'],2);
+                $value['itax'] = round($value['isum'] - $value['imoney'],2);
+            }else{
+                $value['ipertaxrate'] = 0;
+                $value['iunitprice'] = $value['price'];
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = $value['price'] * $value['number'];
+                $value['imoney'] = $value['isum'];
+                $value['itax'] = 0;
+            }
+            $value['cdefine25'] = $code_map[$main_tmp['plat_type']] ?? ""; //平台类型
+            $value['cdefine28'] = $main_tmp['plat_order'] ?? ""; //平台单号
+            $top_depart_id = $see[$value['sales_order_id']] ?? 0;
+            $value['cdefine29'] = $depart[$top_depart_id] ?? "";//分社施工
+            $value['cdefine32'] = "";//直播销售 暂时没有
+            $value['cdefine31'] = "";//客户名称(线上的时候就是空  线下的话就是表头的客户简称)
+            $value['cdefine22'] = "";//手机号码 暂时没有
+            $value['cdefine30'] = $emp[$main_tmp['crt_id']] ?? "";//业务员
+            $value['code'] = $product_tmp['code'];//存货编码
+
+            $sub_map[$value['sales_order_id']][] = $value;
+        }
+        foreach ($main as $key => $value){
+            $main[$key]['cbustype'] = $code_map[$value['business_type']] ?? ""; //业务类型(本身就是中文)
+            $main[$key]['cstname'] = $code_map[$value['sale_type']] ?? ""; //销售类型
+            $main[$key]['ccusabbname'] = $customer_map[$value['customer_id']] ?? "";//客户简称
+            $main[$key]['cdepname'] = $depart[$value['top_depart_id']] ?? "";//部门名称
+//            $main[$key]['cpersoncode'] = $emp[$value['crt_id']] ?? "";//业务员
+            $main[$key]['product'] = $sub_map[$value['id']] ?? [];
+        }
+
+        return $main;
+    }
+
+    public function post_helper($url, $data, $header = [], $timeout = 20){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_ENCODING, '');
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        $r = curl_exec($ch);
+        curl_close($ch);
+        return json_decode($r, true);
+    }
+}

+ 61 - 0
config/header/34.php

@@ -0,0 +1,61 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '工单编号',
+    ],
+    [
+        'key' => 'title',
+        'value' => '工单来源',
+    ],
+    [
+        'key' => 'sales_order_number',
+        'value' => '关联合同',
+    ],
+    [
+        'key' => 'handover_time',
+        'value' => '交车日期',
+    ],
+    [
+        'key' => 'install_method_title',
+        'value' => '安装方式',
+    ],
+    [
+        'key' => 'install_position_title',
+        'value' => '安装地点',
+    ],
+    [
+        'key' => 'mark',
+        'value' => '备注',
+    ],
+    [
+        'key' => 'urgency_title',
+        'value' => '紧急程度',
+    ],
+    [
+        'key' => 'construction_period',
+        'value' => '施工时间',
+    ],
+    [
+        'key' => 'order_type_title',
+        'value' => '订单类型',
+    ],
+    [
+        'key' => 'state_title',
+        'value' => '订单状态',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+    [
+        'key' => 'crt_name',
+        'value' => '创建人',
+    ],
+];

+ 41 - 0
config/header/35.php

@@ -0,0 +1,41 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '退换货编码',
+    ],
+    [
+        'key' => 'data_title',
+        'value' => '关联合同',
+    ],
+    [
+        'key' => 'model_type_title',
+        'value' => '单据类型',
+    ],
+    [
+        'key' => 'difference_amount',
+        'value' => '差异金额',
+    ],
+    [
+        'key' => 'mark',
+        'value' => '备注',
+    ],
+    [
+        'key' => 'state_title',
+        'value' => '订单状态',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+    [
+        'key' => 'crt_name',
+        'value' => '创建人',
+    ],
+];

+ 61 - 0
config/header/36.php

@@ -0,0 +1,61 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '发货单编码',
+    ],
+    [
+        'key' => 'sales_order_number',
+        'value' => '关联单号',
+    ],
+    [
+        'key' => 'storehouse_title',
+        'value' => '仓库',
+    ],
+    [
+        'key' => 'take',
+        'value' => '收货人',
+    ],
+    [
+        'key' => 'take_address',
+        'value' => '收货地址',
+    ],
+    [
+        'key' => 'take_phone',
+        'value' => '收货电话',
+    ],
+    [
+        'key' => 'logistics_company',
+        'value' => '物流公司',
+    ],
+    [
+        'key' => 'logistics_number',
+        'value' => '物流单号',
+    ],
+    [
+        'key' => 'send_name',
+        'value' => '发货人',
+    ],
+    [
+        'key' => 'mark',
+        'value' => '备注',
+    ],
+    [
+        'key' => 'state_title',
+        'value' => '订单状态',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+    [
+        'key' => 'crt_name',
+        'value' => '创建人',
+    ],
+];

+ 8 - 4
config/header/37.php

@@ -46,10 +46,10 @@ return [
         'key' => 'product_total',
         'value' => '产品合计',
     ],
-    [
-        'key' => 'rate',
-        'value' => '整单折扣率',
-    ],
+//    [
+//        'key' => 'rate',
+//        'value' => '整单折扣率',
+//    ],
     [
         'key' => 'other_fee',
         'value' => '其它费用',
@@ -91,6 +91,10 @@ return [
         'value' => '创建时间',
     ],
     [
+        'key' => 'crt_name',
+        'value' => '创建人',
+    ],
+    [
         'key' => 'state_name',
         'value' => '订单状态',
     ],

+ 70 - 0
config/header/38.php

@@ -0,0 +1,70 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '采购单号',
+    ],
+    [
+        'key' => 'sales_order_number',
+        'value' => '关联单号',
+    ],
+    [
+        'key' => 'purchase_name',
+        'value' => '采购人',
+    ],
+    [
+        'key' => 'supplier_title',
+        'value' => '供应商',
+    ],
+    [
+        'key' => 'total',
+        'value' => '产品合计',
+    ],
+    [
+        'key' => 'purchase_total',
+        'value' => '采购金额',
+    ],
+    [
+        'key' => 'other_fee',
+        'value' => '其它费用',
+    ],
+    [
+        'key' => 'discount_fee',
+        'value' => '优惠金额',
+    ],
+    [
+        'key' => 'fee1',
+        'value' => '已收金额',
+    ],
+    [
+        'key' => 'fee2',
+        'value' => '未收金额',
+    ],
+    [
+        'key' => 'fee3',
+        'value' => '坏账金额',
+    ],
+    [
+        'key' => 'fee4',
+        'value' => '最终金额',
+    ],
+
+    [
+        'key' => 'state_title',
+        'value' => '状态',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+];

+ 121 - 0
config/header/43.php

@@ -0,0 +1,121 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '合同编号',
+    ],
+    [
+        'key' => 'model_type_title',
+        'value' => '合同模板',
+    ],
+    [
+        'key' => 'sales_order_type_title',
+        'value' => '类型',
+    ],
+    [
+        'key' => 'business_type_title',
+        'value' => '业务类型',
+    ],
+    [
+        'key' => 'sale_type_title',
+        'value' => '销售类型',
+    ],
+    [
+        'key' => 'sign_time',
+        'value' => '签订时间',
+    ],
+    [
+        'key' => 'plat_order',
+        'value' => '平台单号',
+    ],
+    [
+        'key' => 'plat_type_title',
+        'value' => '平台类型',
+    ],
+    [
+        'key' => 'contract_state_title',
+        'value' => '合同状态',
+    ],
+    [
+        'key' => 'product_total',
+        'value' => '产品合计',
+    ],
+//    [
+//        'key' => 'rate',
+//        'value' => '整单折扣率',
+//    ],
+    [
+        'key' => 'other_fee',
+        'value' => '其它费用',
+    ],
+    [
+        'key' => 'discount_fee',
+        'value' => '优惠金额',
+    ],
+    [
+        'key' => 'contract_fee',
+        'value' => '合同金额',
+    ],
+    [
+        'key' => 'fee',
+        'value' => '指派金额',
+    ],
+    [
+        'key' => 'fee1',
+        'value' => '已收金额',
+    ],
+    [
+        'key' => 'fee2',
+        'value' => '未收金额',
+    ],
+    [
+        'key' => 'fee3',
+        'value' => '坏账金额',
+    ],
+    [
+        'key' => 'fee4',
+        'value' => '最终金额',
+    ],
+    [
+        'key' => 'order_type_title',
+        'value' => '订单类型',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+    [
+        'key' => 'crt_name',
+        'value' => '创建人',
+    ],
+    [
+        'key' => 'state_name',
+        'value' => '订单状态',
+    ],
+    [
+        'key' => 'invoice_state_name',
+        'value' => '发货状态',
+    ],
+    [
+        'key' => 'invoice_arr',
+        'value' => '发货单号',
+    ],
+    [
+        'key' => 'dispatch_company',
+        'value' => '派遣公司',
+    ],
+    [
+        'key' => 'contract_type_title',
+        'value' => '合同类型',
+    ],
+    [
+        'key' => 'pay_way_title',
+        'value' => '付款方式',
+    ],
+];

+ 66 - 0
config/header/45.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    [
+        'key' => 'order_number',
+        'value' => '采购单号',
+    ],
+    [
+        'key' => 'sales_order_number',
+        'value' => '关联单号',
+    ],
+    [
+        'key' => 'purchase_name',
+        'value' => '采购人',
+    ],
+    [
+        'key' => 'supplier_title',
+        'value' => '供应商',
+    ],
+    [
+        'key' => 'total',
+        'value' => '产品合计',
+    ],
+    [
+        'key' => 'purchase_total',
+        'value' => '采购金额',
+    ],
+    [
+        'key' => 'other_fee',
+        'value' => '其它费用',
+    ],
+    [
+        'key' => 'discount_fee',
+        'value' => '优惠金额',
+    ],
+    [
+        'key' => 'fee1',
+        'value' => '已收金额',
+    ],
+    [
+        'key' => 'fee2',
+        'value' => '未收金额',
+    ],
+    [
+        'key' => 'fee3',
+        'value' => '坏账金额',
+    ],
+    [
+        'key' => 'fee4',
+        'value' => '最终金额',
+    ],
+
+    [
+        'key' => 'state_title',
+        'value' => '状态',
+    ],
+    [
+        'key' => 'crt_time',
+        'value' => '创建时间',
+    ],
+];

+ 259 - 247
config/oa.php

@@ -6,11 +6,11 @@ return [
         'menu_title' => '订单合同',
         'children' => [
             [
-                'key' => 'sales_order_type',
+                'key' => 'sales_order_type_title',
                 'title' => '销售订单类型',
             ],
             [
-                'key' => 'model_type',
+                'key' => 'model_type_title',
                 'title' => '销售订单模板',
             ],
             [
@@ -18,159 +18,21 @@ return [
                 'title' => '订单合同编号',
             ],
             [
-                'key' => 'sales_order_type',
-                'title' => '销售订单类型',
-            ],
-            [
-                'key' => 'title',
-                'title' => '合同名称',
-            ],
-            [
-                'key' => 'selling_price',
-                'title' => '含精品售价',
-            ],
-            [
-                'key' => 'vin_no',
-                'title' => '车架号',
-            ],
-            [
-                'key' => 'order_type',
-                'title' => '订单类型',
-            ],
-            [
-                'key' => 'deal_type',
-                'title' => '成交类型',
-            ],
-            [
-                'key' => 'customer_id',
-                'title' => '客户id',
-            ],
-            [
-                'key' => 'sign_time',
-                'title' => '签订日期',
-            ],
-            [
-                'key' => 'contract_state',
-                'title' => '合同状态',
-            ],
-            [
-                'key' => 'product_total',
-                'title' => '产品合计',
-            ],
-            [
-                'key' => 'rate',
-                'title' => '整单扣除率',
-            ],
-            [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
-            ],
-            [
-                'key' => 'crt_time',
-                'title' => '创建时间',
-            ],
-            [
-                'key' => 'mark',
-                'title' => '备注',
-            ],
-            [
-                'key' => 'construction_time',
-                'title' => '施工日期',
-            ],
-            [
-                'key' => 'handover_time',
-                'title' => '交车日期',
-            ],
-            [
-                'key' => 'expire_time',
-                'title' => '到期日期',
-            ],
-            [
-                'key' => 'other_fee',
-                'title' => '其它费用',
-            ],
-            [
-                'key' => 'discount_fee',
-                'title' => '优惠金额',
-            ],
-            [
-                'key' => 'contract_fee',
-                'title' => '合同金额',
-            ],
-            [
-                'key' => 'contract_type',
-                'title' => '合同类型',
-            ],
-            [
-                'key' => 'pay_way',
-                'title' => '付款类型',
-            ],
-            [
-                'key' => 'send_state',
-                'title' => '发货状态',
-            ],
-            [
-                'key' => 'logistics_company',
-                'title' => '物流公司',
-            ],
-            [
-                'key' => 'logistics_number',
-                'title' => '物流单号',
-            ],
-            [
-                'key' => 'car_type',
-                'title' => '车型',
-            ],
-            [
-                'key' => 'year',
-                'title' => '年份',
-            ],
-            [
-                'key' => 'mileage',
-                'title' => '表显里程',
-            ],
-            [
-                'key' => 'color',
-                'title' => '外观内饰颜色',
-            ],
-            [
-                'key' => 'original_set',
-                'title' => '原装配置',
-            ],
-            [
-                'key' => 'processing',
-                'title' => '自有后加装产品',
+                'key' => 'business_type_title',
+                'title' => '业务类型',
             ],
             [
-                'key' => 'state',
-                'title' => '单据状态',
+                'key' => 'sale_type_title',
+                'title' => '销售类型',
             ],
-        ]
-    ],
-    [
-        'menu_id' => 43,
-        'menu_title' => '派单合同',
-        'children' => [
             [
-                'key' => 'sales_order_type',
-                'title' => '销售订单类型',
-            ],
-            [
-                'key' => 'model_type',
-                'title' => '销售订单模板',
-            ],
-            [
-                'key' => 'order_number',
-                'title' => '订单合同编号',
-            ],
-            [
-                'key' => 'sales_order_type',
-                'title' => '销售订单类型',
-            ],
-            [
-                'key' => 'title',
-                'title' => '合同名称',
+                'key' => 'plat_type_title',
+                'title' => '平台类型',
             ],
+//            [
+//                'key' => 'title',
+//                'title' => '合同名称',
+//            ],
             [
                 'key' => 'selling_price',
                 'title' => '含精品售价',
@@ -180,23 +42,23 @@ return [
                 'title' => '车架号',
             ],
             [
-                'key' => 'order_type',
+                'key' => 'order_type_title',
                 'title' => '订单类型',
             ],
             [
-                'key' => 'deal_type',
+                'key' => 'deal_type_title',
                 'title' => '成交类型',
             ],
             [
-                'key' => 'customer_id',
-                'title' => '客户id',
+                'key' => 'customer_title',
+                'title' => '客户名称',
             ],
             [
                 'key' => 'sign_time',
                 'title' => '签订日期',
             ],
             [
-                'key' => 'contract_state',
+                'key' => 'contract_state_title',
                 'title' => '合同状态',
             ],
             [
@@ -208,8 +70,8 @@ return [
                 'title' => '整单扣除率',
             ],
             [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
+                'key' => 'crt_name',
+                'title' => '创建人',
             ],
             [
                 'key' => 'crt_time',
@@ -244,15 +106,15 @@ return [
                 'title' => '合同金额',
             ],
             [
-                'key' => 'contract_type',
+                'key' => 'contract_type_title',
                 'title' => '合同类型',
             ],
             [
-                'key' => 'pay_way',
+                'key' => 'pay_way_title',
                 'title' => '付款类型',
             ],
             [
-                'key' => 'send_state',
+                'key' => 'send_state_title',
                 'title' => '发货状态',
             ],
             [
@@ -263,47 +125,197 @@ return [
                 'key' => 'logistics_number',
                 'title' => '物流单号',
             ],
-            [
-                'key' => 'car_type',
-                'title' => '车型',
-            ],
-            [
-                'key' => 'year',
-                'title' => '年份',
-            ],
-            [
-                'key' => 'mileage',
-                'title' => '表显里程',
-            ],
-            [
-                'key' => 'color',
-                'title' => '外观内饰颜色',
-            ],
-            [
-                'key' => 'original_set',
-                'title' => '原装配置',
-            ],
-            [
-                'key' => 'processing',
-                'title' => '自有后加装产品',
+//            [
+//                'key' => 'car_type',
+//                'title' => '车型',
+//            ],
+//            [
+//                'key' => 'year',
+//                'title' => '年份',
+//            ],
+//            [
+//                'key' => 'mileage',
+//                'title' => '表显里程',
+//            ],
+//            [
+//                'key' => 'color',
+//                'title' => '外观内饰颜色',
+//            ],
+//            [
+//                'key' => 'original_set',
+//                'title' => '原装配置',
+//            ],
+//            [
+//                'key' => 'processing',
+//                'title' => '自有后加装产品',
+//            ],
+            [
+                'key' => 'state_title',
+                'title' => '单据状态',
             ],
             [
-                'key' => 'state',
-                'title' => '单据状态',
+                'key' => 'dispatch_company',
+                'title' => '派遣公司',
             ],
         ]
     ],
+//    [
+//        'menu_id' => 43,
+//        'menu_title' => '派单合同',
+//        'children' => [
+//            [
+//                'key' => 'sales_order_type',
+//                'title' => '销售订单类型',
+//            ],
+//            [
+//                'key' => 'model_type',
+//                'title' => '销售订单模板',
+//            ],
+//            [
+//                'key' => 'order_number',
+//                'title' => '订单合同编号',
+//            ],
+//            [
+//                'key' => 'sales_order_type',
+//                'title' => '销售订单类型',
+//            ],
+//            [
+//                'key' => 'title',
+//                'title' => '合同名称',
+//            ],
+//            [
+//                'key' => 'selling_price',
+//                'title' => '含精品售价',
+//            ],
+//            [
+//                'key' => 'vin_no',
+//                'title' => '车架号',
+//            ],
+//            [
+//                'key' => 'order_type',
+//                'title' => '订单类型',
+//            ],
+//            [
+//                'key' => 'deal_type',
+//                'title' => '成交类型',
+//            ],
+//            [
+//                'key' => 'customer_id',
+//                'title' => '客户id',
+//            ],
+//            [
+//                'key' => 'sign_time',
+//                'title' => '签订日期',
+//            ],
+//            [
+//                'key' => 'contract_state',
+//                'title' => '合同状态',
+//            ],
+//            [
+//                'key' => 'product_total',
+//                'title' => '产品合计',
+//            ],
+//            [
+//                'key' => 'rate',
+//                'title' => '整单扣除率',
+//            ],
+//            [
+//                'key' => 'crt_id',
+//                'title' => '创建人ID',
+//            ],
+//            [
+//                'key' => 'crt_time',
+//                'title' => '创建时间',
+//            ],
+//            [
+//                'key' => 'mark',
+//                'title' => '备注',
+//            ],
+//            [
+//                'key' => 'construction_time',
+//                'title' => '施工日期',
+//            ],
+//            [
+//                'key' => 'handover_time',
+//                'title' => '交车日期',
+//            ],
+//            [
+//                'key' => 'expire_time',
+//                'title' => '到期日期',
+//            ],
+//            [
+//                'key' => 'other_fee',
+//                'title' => '其它费用',
+//            ],
+//            [
+//                'key' => 'discount_fee',
+//                'title' => '优惠金额',
+//            ],
+//            [
+//                'key' => 'contract_fee',
+//                'title' => '合同金额',
+//            ],
+//            [
+//                'key' => 'contract_type',
+//                'title' => '合同类型',
+//            ],
+//            [
+//                'key' => 'pay_way',
+//                'title' => '付款类型',
+//            ],
+//            [
+//                'key' => 'send_state',
+//                'title' => '发货状态',
+//            ],
+//            [
+//                'key' => 'logistics_company',
+//                'title' => '物流公司',
+//            ],
+//            [
+//                'key' => 'logistics_number',
+//                'title' => '物流单号',
+//            ],
+//            [
+//                'key' => 'car_type',
+//                'title' => '车型',
+//            ],
+//            [
+//                'key' => 'year',
+//                'title' => '年份',
+//            ],
+//            [
+//                'key' => 'mileage',
+//                'title' => '表显里程',
+//            ],
+//            [
+//                'key' => 'color',
+//                'title' => '外观内饰颜色',
+//            ],
+//            [
+//                'key' => 'original_set',
+//                'title' => '原装配置',
+//            ],
+//            [
+//                'key' => 'processing',
+//                'title' => '自有后加装产品',
+//            ],
+//            [
+//                'key' => 'state',
+//                'title' => '单据状态',
+//            ],
+//        ]
+//    ],
     [
         'menu_id' => 35,
         'menu_title' => '退换货单',
         'children' => [
             [
-                'key' => 'model_type',
+                'key' => 'model_type_title',
                 'title' => '退换货类型',
             ],
             [
-                'key' => 'data_id',
-                'title' => '关联单号ID',
+                'key' => 'data_title',
+                'title' => '关联单号',
             ],
             [
                 'key' => 'order_number',
@@ -318,21 +330,21 @@ return [
                 'title' => '备注',
             ],
             [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
+                'key' => 'crt_name',
+                'title' => '创建人',
             ],
             [
                 'key' => 'crt_time',
                 'title' => '创建时间',
             ],
             [
-                'key' => 'state',
+                'key' => 'state_title',
                 'title' => '单据状态',
             ],
-            [
-                'key' => 'storehouse_id',
-                'title' => '仓库ID',
-            ],
+//            [
+//                'key' => 'storehouse_title',
+//                'title' => '仓库',
+//            ],
         ]
     ],
     [
@@ -340,7 +352,7 @@ return [
         'menu_title' => '施工单',
         'children' => [
             [
-                'key' => 'model_type',
+                'key' => 'model_type_title',
                 'title' => '工单模板',
             ],
             [
@@ -352,24 +364,24 @@ return [
                 'title' => '施工单名称',
             ],
             [
-                'key' => 'customer_id',
-                'title' => '关联客户ID',
+                'key' => 'customer_title',
+                'title' => '关联客户',
             ],
             [
-                'key' => 'customer_contact_id',
+                'key' => 'customer_contact_title',
                 'title' => '客户联系人',
             ],
             [
-                'key' => 'install_method',
+                'key' => 'install_method_title',
                 'title' => '安装方式',
             ],
             [
-                'key' => 'install_position',
+                'key' => 'install_position_title',
                 'title' => '安装地点',
             ],
             [
-                'key' => 'sales_order_id',
-                'title' => '关联合同ID',
+                'key' => 'sales_order_number',
+                'title' => '关联合同',
             ],
             [
                 'key' => 'construction_fee',
@@ -380,8 +392,8 @@ return [
                 'title' => '服务价格',
             ],
             [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
+                'key' => 'crt_name',
+                'title' => '创建人',
             ],
             [
                 'key' => 'crt_time',
@@ -400,25 +412,25 @@ return [
                 'title' => '交车日期',
             ],
             [
-                'key' => 'urgency',
+                'key' => 'urgency_title',
                 'title' => '紧急程度',
             ],
             [
-                'key' => 'state',
+                'key' => 'state_title',
                 'title' => '单据状态',
             ],
-            [
-                'key' => 'storehouse_id',
-                'title' => '仓库ID',
-            ],
-            [
-                'key' => 'start_time',
-                'title' => '施工开始日期',
-            ],
-            [
-                'key' => 'end_time',
-                'title' => '施工结束日期',
-            ],
+//            [
+//                'key' => 'storehouse_id',
+//                'title' => '仓库ID',
+//            ],
+//            [
+//                'key' => 'start_time',
+//                'title' => '施工开始日期',
+//            ],
+//            [
+//                'key' => 'end_time',
+//                'title' => '施工结束日期',
+//            ],
         ]
     ],
     [
@@ -430,16 +442,16 @@ return [
                 'title' => '采购单编号',
             ],
             [
-                'key' => 'order_type',
+                'key' => 'order_type_title',
                 'title' => '单据类型',
             ],
             [
-                'key' => 'supplier',
-                'title' => '供应商ID',
+                'key' => 'supplier_title',
+                'title' => '供应商',
             ],
             [
-                'key' => 'purchase_id',
-                'title' => '采购人ID',
+                'key' => 'purchase_name',
+                'title' => '采购人',
             ],
             [
                 'key' => 'total',
@@ -458,12 +470,12 @@ return [
                 'title' => '采购总价',
             ],
             [
-                'key' => 'sales_order_id',
-                'title' => '关联合同ID',
+                'key' => 'sales_order_number',
+                'title' => '关联合同',
             ],
             [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
+                'key' => 'crt_name',
+                'title' => '创建人',
             ],
             [
                 'key' => 'crt_time',
@@ -474,13 +486,13 @@ return [
                 'title' => '备注',
             ],
             [
-                'key' => 'state',
+                'key' => 'state_title',
                 'title' => '单据状态',
             ],
-            [
-                'key' => 'storehouse_id',
-                'title' => '仓库ID',
-            ],
+//            [
+//                'key' => 'storehouse_id',
+//                'title' => '仓库ID',
+//            ],
         ]
     ],
     [
@@ -492,16 +504,16 @@ return [
                 'title' => '采购单编号',
             ],
             [
-                'key' => 'order_type',
+                'key' => 'order_type_title',
                 'title' => '单据类型',
             ],
             [
-                'key' => 'supplier',
-                'title' => '供应商ID',
+                'key' => 'supplier_title',
+                'title' => '供应商',
             ],
             [
-                'key' => 'purchase_id',
-                'title' => '采购人ID',
+                'key' => 'purchase_name',
+                'title' => '采购人',
             ],
             [
                 'key' => 'total',
@@ -520,12 +532,12 @@ return [
                 'title' => '采购总价',
             ],
             [
-                'key' => 'sales_order_id',
-                'title' => '关联合同ID',
+                'key' => 'sales_order_number',
+                'title' => '关联合同',
             ],
             [
-                'key' => 'crt_id',
-                'title' => '创建人ID',
+                'key' => 'crt_name',
+                'title' => '创建人',
             ],
             [
                 'key' => 'crt_time',
@@ -536,13 +548,13 @@ return [
                 'title' => '备注',
             ],
             [
-                'key' => 'state',
+                'key' => 'state_title',
                 'title' => '单据状态',
             ],
-            [
-                'key' => 'storehouse_id',
-                'title' => '仓库ID',
-            ],
+//            [
+//                'key' => 'storehouse_id',
+//                'title' => '仓库ID',
+//            ],
         ]
     ],
 ];

+ 11 - 0
routes/api.php

@@ -222,6 +222,14 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('BookingDetail', 'Api\BookingListController@customerDetail');
     $route->any('BookingConfirm', 'Api\BookingListController@customerConfirm');
 
+    //排班设置
+    $route->any('scheduleList', 'Api\ScheduleController@getList');
+    $route->any('scheduleEdit', 'Api\ScheduleController@edit');
+    $route->any('scheduleDetail', 'Api\ScheduleController@detail');
+    $route->any('scheduleAdd', 'Api\ScheduleController@add');
+    $route->any('scheduleDel', 'Api\ScheduleController@del');
+    $route->any('scheduleGetForConstruction', 'Api\ScheduleController@scheduleGetForConstruction');
+
     //现存量
     $route->any('productInventoryList', 'Api\ProductInventoryController@productInventoryList');
     //库存台账
@@ -250,4 +258,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
 
     //获取审核单据的详情
     $route->any('checkDetail', 'Api\CheckController@getOrderDetail');
+
+    //数据同步到U8
+    $route->any('dataToU8','Api\DataSyncToU8Controller@add');
 });