pages = [ 'name' => '支付通道' ]; } public function postDataDb($request, $id = '') { $data=$request->all(); if($data['cert_private_type']==2) { $data['cert_key']= $data['cert_key2']; unset($data['cert_key2']); } if($data['cert_pub_type']==2) { $data['cert_pub']= $data['cert_pub2']; unset($data['cert_pub2']); } return $data; } public function checkRule( $id='') { if (!$id) { return [ 'name' => 'required', //'app_id'=> 'required', 'ename'=> 'required', ]; } return [ 'name' => 'required', //'app_id'=> 'required', 'ename'=> 'required' ]; } public function setErrorMsg(){ $messages = [ 'app_id.required'=>'appid不能为空' ]; return $messages; } public function shareData($id = '') { $data=[ 'pay_client'=>config('adconfig.pay_client'),'pay_type'=>config('adconfig.pay_type') ]; return $data; } public function saveAfter($request, $model, $id = '') { write_gateway();//写入配置文件 } public function statics(){ $this->title='通道统计'; // dump($config); $this->setTitle(); return $this->display([]); } public function statics_data(){ $requestData = request()->all(); if (isset($requestData['timeday'])) { $time = str_replace('~', ',', $requestData['timeday']); $time = explode(",", $time); $date['start_at'] = $time[0] ?? ''; $date['end_at'] = $time[1] ?? ''; } else { $date = DateServices::today(); } if (empty($date['start_at']) || empty($date['end_at'])) { $date = DateServices::today(); } $data = DB::select("select t.gateway_id,t.total,t.created_at ,t.order_money,g.`name`, (select sum(p.order_money) from orders p where p.gateway_id=t.gateway_id and pay_status='1' and p.created_at>='" . $date['start_at'] . "' and p.created_at <='" . $date['end_at'] . "') as ok_money, (select count(p.pay_status) from orders p where p.gateway_id=t.gateway_id and pay_status='1'and p.created_at>='" . $date['start_at'] . "' and p.created_at <='" . $date['end_at'] . "') as ok_total from (select count(pay_status) as total,sum(order_money)as order_money,gateway_id,created_at from orders where created_at>='" . $date['start_at'] . "' and created_at <='" . $date['end_at'] . "' group by gateway_id) t JOIN gateways g ON t.gateway_id=g.id ORDER BY order_money desc"); $json = [ "status"=>1, 'code'=>count($data)>0?0:1, 'msg'=>count($data)>0?'请求数据成功':'暂无数据', 'count' => count($data), 'data' => $data ]; return response()->json($json); } public function setModel() { return new Gateway(); } public function apiJson(Request $request) { $offset = $request->input('page', 1); $pagesize = $request->input('limit', 1); $offset = ($offset - 1) * $pagesize; $order_id = $request->input('sort', 'client_type'); $order_type = $request->input('order', 'desc'); $debug = $request->input('debug', 0); $model = $this->setModel(); $search_arr=[ ]; $model=$this->searchKey($model,$search_arr); $total = $model->count(); $result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();; $narr = array(); foreach ($result as $k => $v) { $v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]); $v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]); $v['thumb']=picurl($v['thumb']); $v['client_type_name']=$v->client_type_name; $v['ratio_name']=$v->ratio_name; $narr[] = $v; } $json = [ "status"=>1, 'code'=>$total>0?0:1, 'msg'=>$total>0?'请求数据成功':'暂无数据', 'count' => $total, 'data' => $narr ]; if ($debug) { return $this->jsonDebug($json); } return response()->json($json); } }