114 lines
2.9 KiB
PHP
114 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\Bank;
|
|
use App\Models\Gateway;
|
|
use App\Models\GatewayWind;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class GatewayWindController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '风控设置'
|
|
];
|
|
}
|
|
|
|
public function shareData($id = '')
|
|
{
|
|
return ['payway'=>Gateway::get()];
|
|
}
|
|
|
|
|
|
public function checkRule( $id='')
|
|
{
|
|
if (!$id) {
|
|
return [
|
|
'max_total' => 'required',
|
|
|
|
];
|
|
}
|
|
return [
|
|
'max_total' => 'required',
|
|
|
|
|
|
];
|
|
}
|
|
public function setErrorMsg(){
|
|
$messages = [
|
|
'max_total.required'=>'每天交易总额'
|
|
];
|
|
return $messages;
|
|
}
|
|
public function setModel()
|
|
{
|
|
return new GatewayWind();
|
|
}
|
|
public function saveAfter($request, $model, $id = '')
|
|
{
|
|
if($model->day==date('Y-m-d')){
|
|
//如果交易总额小于最低限额,则开启,否认关闭
|
|
if($model->amount_total<=$model->max_total)
|
|
{
|
|
//开启这个通道
|
|
Gateway::where('id',$model->gateway_id)->update(['is_checked'=>1]);
|
|
|
|
}else
|
|
{
|
|
Gateway::where('id',$model->gateway_id)->update(['is_checked'=>0]);
|
|
|
|
}
|
|
write_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', 'id');
|
|
$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)->with('pays')->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['gateway_name']=$v->pays['name'].'('.$v->pays['mch_id'].')';
|
|
$v['gateway_type']=config('adconfig.pay_client')[$v->pays['client_type']];
|
|
$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);
|
|
}
|
|
}
|