150 lines
3.8 KiB
PHP
150 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Merchant;
|
|
|
|
use App\Services\SearchServices;
|
|
use App\Models\Merchant;
|
|
use App\Models\Order;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Jenssegers\Date\Date;
|
|
|
|
class OrderController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '我的订单'
|
|
];
|
|
|
|
}
|
|
|
|
protected function postDataDb($request,$id='')
|
|
{
|
|
$data = $request->all();
|
|
return $data;
|
|
}
|
|
|
|
public function indexData()
|
|
{
|
|
|
|
$this->pages = [
|
|
'name' => '订单'
|
|
];
|
|
$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::whereIn('id',Merchant::subAllMerchant(\merchant('id')))->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 = $request->input('order', 'desc');
|
|
$debug = $request->input('debug', 0);
|
|
$model = $this->setModel();
|
|
|
|
$agent=$request->input('agent',0);
|
|
|
|
$param=$request->all();
|
|
$search =(new SearchServices($model,$param,'order_merchant'));
|
|
|
|
$model=$search->getList();
|
|
if($this->isProxy())
|
|
{
|
|
if($agent)
|
|
{
|
|
|
|
$model=$model->whereIn('merchant_id',Merchant::subAllMerchant($this->getMerchantId()));
|
|
}else
|
|
{
|
|
$model=$model->where('merchant_id',$this->getMerchantId());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
$model=$model->where('merchant_id',$this->getMerchantId());
|
|
}
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->with('users','merchants')->orderBy($order_id, $order_type)->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['success_status']];
|
|
$v['update_notify_url']=admin_merchant_url('OrderHandleApi','handlePost',['order_id'=>$v->id,'type'=>'notifyPost','agent'=>$agent]);
|
|
$v['show_url'] = $v->order_show_url2;
|
|
$v['gateway_method_name']=array_key_exists($v['gateway_method'],config('adconfig.pay_client'))?config('adconfig.pay_client')[$v['gateway_method']]:'未知';
|
|
$v['level']=merchant('level');
|
|
$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);
|
|
|
|
|
|
}
|
|
}
|