174 lines
5.1 KiB
PHP
174 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\Gateway;
|
|
use App\Models\Merchant;
|
|
use App\Models\Order;
|
|
use App\Services\OrderStatisServices;
|
|
use App\Services\SearchServices;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Jenssegers\Date\Date;
|
|
|
|
class OrderController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '订单'
|
|
];
|
|
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->setTitle();
|
|
$location=request()->input('location');
|
|
if($location)
|
|
{
|
|
$this->setPageName('本站订单');
|
|
$this->setViewPath('','location');
|
|
}
|
|
return $this->display($this->indexData());
|
|
}
|
|
|
|
|
|
protected function postDataDb($request,$id='')
|
|
{
|
|
$data = $request->all();
|
|
return $data;
|
|
}
|
|
|
|
public function indexData()
|
|
{
|
|
$type = [
|
|
'pay_status' => config('adconfig.pay_status'),
|
|
'order_status'=>config('adconfig.order_status'),
|
|
'payfor_status'=>config('adconfig.payfor_status'),
|
|
'order_notify'=>config('adconfig.order_notify'),
|
|
'merchant'=>Merchant::get(),
|
|
'gateway'=>Gateway::where('is_checked',1)->get()
|
|
];
|
|
return $type;
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
|
|
$show = $this->setModel()->find($id);
|
|
|
|
|
|
//($pictrue);
|
|
|
|
|
|
return $this->display(['show' => $show ]);
|
|
}
|
|
|
|
|
|
public function shareData($show = '')
|
|
{
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setModel()
|
|
{
|
|
return new Order();
|
|
}
|
|
|
|
|
|
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_desc = $request->input('order', 'desc');
|
|
$debug = $request->input('debug', 0);
|
|
|
|
$guma=$request->input('guma');
|
|
|
|
|
|
$param=$request->all();
|
|
$param['out']=1;
|
|
$location=$request->input('location');
|
|
$order_type='order';
|
|
if($location)
|
|
{
|
|
$order_type='order_self';
|
|
}
|
|
if($guma)
|
|
{
|
|
$param['guma']=1;
|
|
}
|
|
|
|
$search =(new SearchServices($this->setModel(),$param,$order_type));
|
|
// $search->setTimeType('order');
|
|
// dump($search->echoWhere());
|
|
$model=$search->getList();
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->with('users','merchants','gateways')->orderBy($order_id, $order_type_desc)->orderBy('id', 'desc')->take($pagesize)->get();;
|
|
|
|
$narr = array();
|
|
|
|
foreach ($result as $k => $v) {
|
|
$v['pay_type_name']=config('adconfig.pay_type')[$v['pay_type']]??'未知';
|
|
$v['server_name']=$v->merchants['name'];
|
|
$v['order_status_name']=config('adconfig.order_status')[$v['status']];
|
|
$v['notify_status_name']=config('adconfig.order_notify')[$v['notify_status']];
|
|
//$v['payfor_status_name']=config('adconfig.payfor_status')[$v['pay_status']];
|
|
$v['update_pay_url']=admin_url('OrderHandleApi','handle',['order_id'=>$v->id,'type'=>'pay']);
|
|
$v['update_pay_post_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'payUpdate']);
|
|
$v['update_notify_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'notifyPost']);
|
|
//$v['update_payfor_url']=admin_url('OrderHandleApi','handle',['order_id'=>$v->id,'type'=>'payfor']);
|
|
//$v['update_payfor_post_url']=admin_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'payforUpdate']);
|
|
$v['show_url'] = $v->order_show_url;
|
|
$v['gateway_name']=$v->gateways['name'];
|
|
$v['gateway_mch_id']=$v->gateways['mch_id'];
|
|
$v['gateway_username']=$v->gateways['username'];
|
|
$v['gateway_bank_name']='<p>'.$v->gateways['bank_name'].'</p>';
|
|
|
|
$v['gateway_method_name']=array_key_exists($v['gateway_method'],config('adconfig.pay_client'))?config('adconfig.pay_client')[$v['gateway_method']]:'未知';
|
|
$v['order_status_name2']=$v->OrderStatusName2;
|
|
$v['ewm_info']='';
|
|
if(in_array($v['pay_type'],config('adconfig.guma_type')))
|
|
{
|
|
$v['ewm_info']='<p>备注:'.($v->ewm_mark??'无').'</p>'.'<p>账号:'.(($v->ewm_account)?($v->ewm_account):'无').'</p>';
|
|
if($v['ewm_name']){
|
|
$v['ewm_info'].='<p>付款人:'.($v->ewm_name).'</p>';
|
|
}
|
|
|
|
}
|
|
|
|
$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);
|
|
}
|
|
|
|
public function checkStatus(Request $request)
|
|
{
|
|
$id = $request->input('id');
|
|
return $this->getShow($id);
|
|
|
|
|
|
}
|
|
}
|