getDataFromSqlServer($data); if(! $status) return [false, $return]; //数据校验以及填充 list($status,$msg) = $this->orderRule($return); if(!$status) return [$status,$msg]; try{ DB::beginTransaction(); $keys = array_unique(array_column($return,'out_order_no')); $map = array_fill_keys($keys, 0); $orders = $return_stock_detail_map = []; foreach ($return as $key => $value){ if(! empty($map[$value['out_order_no']])){ $order_no = $map[$value['out_order_no']]; }else{ $order_no = $this->setOrderNo(); $map[$value['out_order_no']] = $order_no; $orders[] = [ 'order_no' => $order_no, 'out_order_no' => $value['out_order_no'], 'crt_time' => time() ]; } $return[$key]['order_no'] = $order_no; $return[$key]['crt_id'] = $user['id']; $return[$key]['crt_time'] = time(); // $keys = $order_no . ($value['technology_name'] ?? '' ) . ; } Orders::insert($orders); SaleOrdersProduct::insert($return); DB::commit(); }catch (\Exception $e){ DB::rollBack(); return [false,$e->getLine().':'.$e->getMessage()]; } return [true,'保存成功!']; } public function del($data){ if($this->isEmpty($data,'id')) return [false,'ID不能为空!']; Orders::whereIn('id',$data['id'])->update([ 'del_time' => time() ]); SaleOrdersProduct::where('id',$data['id'])->update([ 'del_time'=>time() ]); return [true,'删除成功']; } public function orderDetail($data){ return [200,'']; } public function orderList($data){ $model = SaleOrdersProduct::where('del_time',0) ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','product_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time') ->orderBy('id','desc'); if(! empty($data['order_no'])) $model->where('order_no', 'LIKE', '%'.$data['order_no'].'%'); if(! empty($data['out_order_no'])) $model->where('out_order_no', 'LIKE', '%'.$data['out_order_no'].'%'); if(! empty($data['customer_name'])) $model->where('customer_name', 'LIKE', '%'.$data['customer_name'].'%'); if(! empty($data['product_title'])) $model->where('product_title', 'LIKE', '%'.$data['product_title'].'%'); if(! empty($data['product_size'])) $model->where('product_size', 'LIKE', '%'.$data['product_size'].'%'); if(! empty($data['technology_material'])) $model->where('technology_material', 'LIKE', '%'.$data['technology_material'].'%'); if(! empty($data['technology_name'])) $model->where('technology_name', 'LIKE', '%'.$data['technology_name'].'%'); if(! empty($data['wood_name'])) $model->where('wood_name', 'LIKE', '%'.$data['wood_name'].'%'); if(! empty($data['process_mark'])) $model->where('process_mark', 'LIKE', '%'.$data['process_mark'].'%'); if(! empty($data['table_header_mark'])) $model->where('table_header_mark', 'LIKE', '%'.$data['table_header_mark'].'%'); if(! empty($data['table_body_mark'])) $model->where('table_body_mark', 'LIKE', '%'.$data['table_body_mark'].'%'); if(! empty($data['out_checker_man'])) $model->where('out_checker_man', 'LIKE', '%'.$data['out_checker_man'].'%'); if(! empty($data['out_crt_man'])) $model->where('out_crt_man', 'LIKE', '%'.$data['out_crt_man'].'%'); if(! empty($data['out_checker_time'][0]) && ! empty($data['out_checker_time'][1])) $model->whereBetween('out_checker_time',[$data['out_checker_time'][0],$data['out_checker_time'][1]]); if(! empty($data['out_order_no_time'][0]) && ! empty($data['out_order_no_time'][1])) $model->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]]); if(isset($data['status'])) $model->where('status',$data['status']); $list = $this->limit($model,'',$data); return [true, $list]; } public function orderRule($data){ $result = Orders::where('del_time',0) ->whereIn('out_order_no',array_column($data,'out_order_no')) ->select('out_order_no') ->get()->toArray(); if(! empty($result)){ $out_order_no_exists = array_column($result,'out_order_no'); return [false,'下列销售订单号已存在:'. implode(',',$out_order_no_exists)]; } return [true,'']; } public function fyyRefreshOnHandQuantity($data){ return [true,'']; } }