275 lines
7.3 KiB
PHP
275 lines
7.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
use App\Models\Merchant;
|
|
use App\Models\Order;
|
|
use App\Models\Server;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class PayForController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '订单结算'
|
|
];
|
|
|
|
}
|
|
|
|
protected function postDataDb($request,$id='')
|
|
{
|
|
$data = $request->all();
|
|
return $data;
|
|
}
|
|
|
|
public function indexData()
|
|
{
|
|
$type = [
|
|
'server'=>Merchant::pluck('name','id')
|
|
];
|
|
return $type;
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
|
|
$show = $this->setModel()->find($id);
|
|
|
|
$show->pay_type_name = $show->pay_type ? config('adconfig.pay_type')[$show->pay_type] : '未支付';
|
|
$log = $show->logs->pluck('created_at', 'to_status')->toArray();
|
|
|
|
$logistics = count($show->logistics)>0 ? $show->logistics->first()->toArray() : [];
|
|
$comment=$show->comments?$show->comments->first():[];
|
|
|
|
|
|
$pictrue = $show->pictures;
|
|
if ($show->pictures) {
|
|
$pictrue->thumbs = $pictrue->thumbs ? json_decode(urldecode($pictrue->thumbs), true) : [];
|
|
$pictrue->user_thumbs = $pictrue->user_thumbs ? json_decode(urldecode($pictrue->user_thumbs), true) : [];
|
|
$pictrue->look_thumbs = $pictrue->look_thumbs ? json_decode(urldecode($pictrue->look_thumbs), true) : [];
|
|
}
|
|
|
|
|
|
//($pictrue);
|
|
|
|
|
|
return $this->display(['show' => $show, 'logs' => $log,
|
|
'pictrue' => $pictrue, 'logistics' => $logistics,'comment'=>$comment]);
|
|
}
|
|
|
|
|
|
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', '');
|
|
$server_sn = $request->input('server_sn', '');
|
|
$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='';
|
|
}
|
|
|
|
|
|
|
|
$server_id = $request->input(' server_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
|
|
],
|
|
'server_sn' => [
|
|
'type' => '=',
|
|
'value' => $server_sn
|
|
],
|
|
'pay_order_sn' => [
|
|
'type' => '=',
|
|
'value' => $pay_order_sn
|
|
],
|
|
'local_user_id' => [
|
|
'type' => '=',
|
|
'value' => $user_id
|
|
],
|
|
'out_user_id' => [
|
|
'type' => '=',
|
|
'value' => $out_user_id
|
|
],
|
|
'server_id' => [
|
|
'type' => '=',
|
|
'value' => $server_id
|
|
],
|
|
'pay_status' => [
|
|
'type' => '=',
|
|
'value' =>$pay_status
|
|
],
|
|
'notify_status' => [
|
|
'type' => '=',
|
|
'value' =>$notify_status
|
|
],
|
|
'out_notify_status' => [
|
|
'type' => '=',
|
|
'value' =>$out_notify_status
|
|
],
|
|
'success_status' => [
|
|
'type' => '=',
|
|
'value' =>$success_status
|
|
]
|
|
|
|
|
|
];
|
|
$search_arr2 = [
|
|
'pay_status' => [
|
|
'type' => '=',
|
|
'value' =>$pay_status
|
|
],
|
|
'notify_status' => [
|
|
'type' => '=',
|
|
'value' =>$notify_status
|
|
],
|
|
'out_notify_status' => [
|
|
'type' => '=',
|
|
'value' =>$out_notify_status
|
|
],
|
|
'success_status' => [
|
|
'type' => '=',
|
|
'value' =>$success_status
|
|
]
|
|
|
|
|
|
];
|
|
$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('(pay_ok_at>=? and pay_ok_at<=?)',[($start_at),($end_at)]);
|
|
}
|
|
|
|
|
|
$model=$model->selectRaw(
|
|
'DATE_FORMAT(pay_ok_at,"%Y-%m-%d") as pay_at,
|
|
sum(order_money) as order_money, sum(pay_money)
|
|
as pay_money, sum(total_money) as total_money, sum(pay_rate) as pay_rate, CONCAT_WS("%",ROUND(ratio/10,1),"") as ratio,merchant_id,merchant_name'
|
|
)->groupBy('pay_ok_at')->groupBy('merchant_id');
|
|
$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['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);
|
|
|
|
|
|
}
|
|
}
|