232 lines
6.8 KiB
PHP
232 lines
6.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
use App\Models\Order;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Jenssegers\Date\Date;
|
|
|
|
class OrderController2 extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '订单'
|
|
];
|
|
|
|
}
|
|
|
|
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')
|
|
];
|
|
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_sn = $request->input('order_sn', '');
|
|
$out_trade_no = $request->input('out_trade_no', '');
|
|
$pay_order_sn = $request->input('pay_order_sn', '');
|
|
$user_id = $request->input('user_id', '');
|
|
$out_user_id = $request->input('out_user_id', '');
|
|
|
|
|
|
$pay_status = $request->input('pay_status', '');
|
|
$notify_status = $request->input('notify_status', '');
|
|
$out_notify_status = $request->input('out_notify_status', '');
|
|
$success_status = $request->input('success_status', '');
|
|
|
|
$day = $request->input('day', '');
|
|
|
|
$month = $request->input('month', '');
|
|
|
|
$time = $request->input('time', '');
|
|
$start_at = '';
|
|
$end_at = '';
|
|
if ($time) {
|
|
$time = str_replace('~', ',', $time);
|
|
$time = explode(",", $time);
|
|
$start_at = isset($time[0]) ? $time[0] : '';
|
|
$end_at = isset($time[1]) ? $time[1] : '';
|
|
$month = '';
|
|
}
|
|
|
|
|
|
$merchant_id = $request->input('merchant_id', '');
|
|
$order_id = $request->input('sort', 'id');
|
|
$order_type = $request->input('order', 'desc');
|
|
$debug = $request->input('debug', 0);
|
|
$status = $request->input('status', '');
|
|
$model = $this->setModel();
|
|
$search_arr = [
|
|
'order_sn' => [
|
|
'type' => '=',
|
|
'value' => $order_sn
|
|
],
|
|
'out_trade_no' => [
|
|
'type' => '=',
|
|
'value' => $out_trade_no
|
|
],
|
|
'pay_order_sn' => [
|
|
'type' => '=',
|
|
'value' => $pay_order_sn
|
|
],
|
|
'local_user_id' => [
|
|
'type' => '=',
|
|
'value' => $user_id
|
|
],
|
|
'out_user_id' => [
|
|
'type' => '=',
|
|
'value' => $out_user_id
|
|
],
|
|
|
|
|
|
];
|
|
$search_arr2 = [
|
|
'pay_status' => [
|
|
'type' => '=',
|
|
'value' => $pay_status
|
|
],
|
|
'notify_status' => [
|
|
'type' => '=',
|
|
'value' => $notify_status
|
|
],
|
|
'out_notify_status' => [
|
|
'type' => '=',
|
|
'value' => $out_notify_status
|
|
],
|
|
|
|
'merchant_id' => [
|
|
'type' => '=',
|
|
'value' => $merchant_id
|
|
]
|
|
|
|
|
|
];
|
|
$model = $this->searchKey($model, $search_arr, 2);
|
|
$model = $this->searchKey($model, $search_arr2, 1);
|
|
|
|
if ($status != '') {
|
|
$model = $model->where('status', $status);
|
|
}
|
|
//天
|
|
if ($day != '') {
|
|
if ($day <= 0) {
|
|
$day_at = (new Date($day . "day"))->format('Y-m-d');
|
|
$start_at = $day_at . ' 00:00:00';
|
|
if ($day == -1) {
|
|
$end_at = $day_at . ' 23:59:59';
|
|
} else {
|
|
$end_at = (new Date('0 day'))->format('Y-m-d') . ' 23:59:59';
|
|
}
|
|
}
|
|
$month = '';
|
|
}
|
|
//月
|
|
if ($month != '') {
|
|
$date = date('Y-m-d H:i:s', strtotime($month . 'month'));
|
|
$month_at = get_month($date);
|
|
if (count($month_at) > 0) {
|
|
|
|
$start_at = $month_at[0];
|
|
if ($month == 0 || $month == '-1') {
|
|
$end_at = $month_at[1];
|
|
} else {
|
|
$end_at = get_month('', 1, 1);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//时间范围
|
|
if ($start_at) {
|
|
$model = $model->whereRaw('(order_at>=? and order_at<=?) or (pay_ok_at>=? and pay_ok_at<=?)', [($start_at), ($end_at), ($start_at), ($end_at)]);
|
|
}
|
|
|
|
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->with('users', 'merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
|
$narr = array();
|
|
$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;
|
|
$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);
|
|
|
|
|
|
}
|
|
}
|