| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | 
							- <?php
 
- namespace App\Service;
 
- use App\Model\Employee;
 
- use App\Model\SalesOrderInfo;
 
- use Illuminate\Support\Facades\DB;
 
- class DeleteService extends Service
 
- {
 
-     public function getMan($data,$user){
 
-         if(empty($data['id']) || empty($data['type']) || empty($data['man_type'])) return [false, '必填参数不能为空!'];
 
-         $return = [];
 
-         if($data['type'] == 1){
 
-             $return = $this->getSaleOrderMan($data);
 
-         }
 
-         return [true, $return];
 
-     }
 
-     public function delete($data,$user){
 
-         if(empty($data['id']) || empty($data['type']) || empty($data['man_type']) || empty($data['man'])) return [false, '必填参数不能为空!'];
 
-         try {
 
-             DB::beginTransaction();
 
-             if($data['type'] == 1){
 
-                 $this->delSaleOrderMan($data);
 
-             }
 
-             DB::commit();
 
-         }catch (\Exception $exception){
 
-             DB::rollBack();
 
-             return [false,$exception->getMessage()];
 
-         }
 
-         return [true,''];
 
-     }
 
-     public function getSaleOrderMan($data){
 
-         $man_id = SalesOrderInfo::where('del_time',0)
 
-             ->where('sales_order_id',$data['id'])
 
-             ->where('type',$data['man_type'])
 
-             ->get('data_id')->toArray();
 
-         $man_id = array_column($man_id,'data_id');
 
-         return Employee::whereIn('id',$man_id)->select('id', 'emp_name')->get()->toArray();
 
-     }
 
-     public function delSaleOrderMan($data){
 
-          $time = time();
 
-          SalesOrderInfo::where('del_time',0)
 
-              ->where('sales_order_id',$data['id'])
 
-              ->where('type',$data['man_type'])
 
-              ->update(['del_time' => $time]);
 
-          if(! empty($data['man'])){
 
-              $insert = [];
 
-              foreach ($data['man'] as $value){
 
-                  $insert[] = [
 
-                      'sales_order_id' => $data['id'],
 
-                      'data_id' => $value,
 
-                      'type' => $data['man_type'],
 
-                      'crt_time' => $time,
 
-                  ];
 
-              }
 
-              SalesOrderInfo::insert($insert);
 
-          }
 
-     }
 
- }
 
 
  |