170 lines
4.4 KiB
PHP
170 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\AdminLog;
|
|
use App\Models\Merchant;
|
|
use App\Models\MerchantCommission;
|
|
use App\Models\MerchantMoneyLog;
|
|
use App\Models\Sms;
|
|
use App\Models\SmsLog;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class MerchantCommissionController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$title = request()->input('title','代理佣金');
|
|
|
|
$this->pages = [
|
|
'name' => $title
|
|
];
|
|
}
|
|
public function indexData()
|
|
{
|
|
$status=config('adconfig.commission_status');
|
|
return ['status'=>$status,'merchant'=>Merchant::get()];
|
|
}
|
|
|
|
public function checkRule($id = '')
|
|
{
|
|
}
|
|
|
|
public function setErrorMsg()
|
|
{
|
|
$messages = [
|
|
|
|
];
|
|
return $messages;
|
|
}
|
|
|
|
public function setModel()
|
|
{
|
|
return new MerchantCommission();
|
|
}
|
|
|
|
public function apiJson(Request $request)
|
|
{
|
|
$offset = $request->input('page', 1);
|
|
$pagesize = $request->input('limit', 1);
|
|
$offset = ($offset - 1) * $pagesize;
|
|
$merchant_id = $request->input('merchant_id', '');
|
|
$from_merchant_id = $request->input('from_merchant_id', '');
|
|
$order_sn = $request->input('order_sn', '');
|
|
$order_id = $request->input('sort', 'id');
|
|
$order_type = $request->input('order', 'desc');
|
|
$debug = $request->input('debug', 0);
|
|
$status = $request->input('status', 0);
|
|
$model = $this->setModel();
|
|
|
|
$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='';
|
|
}
|
|
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<=? )',[($start_at),($end_at)]);
|
|
}
|
|
|
|
|
|
|
|
$search_arr = [
|
|
'merchant_id' => [
|
|
'value' => $merchant_id,
|
|
'type' => '='
|
|
],
|
|
'order_sn' => [
|
|
'value' => $order_sn,
|
|
'type' => '='
|
|
],
|
|
'from_merchant_id'=>[
|
|
'value'=>$from_merchant_id,
|
|
'type'=>'='
|
|
]
|
|
|
|
];
|
|
$model = $this->searchKey($model, $search_arr, 2);
|
|
|
|
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->with('merchants','fromMerchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
|
$narr = array();
|
|
|
|
foreach ($result as $k => $v) {
|
|
$v['status_name'] = $v->status_name;
|
|
$v['name']=$v->merchants->name;
|
|
$v['tname']=$v->fromMerchants['name'];
|
|
$v['ratio']=($v['ratio']/10).'%';
|
|
$v['show_url']=admin_url('Order','show',['id'=>$v->order_id]);
|
|
|
|
$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);
|
|
}
|
|
}
|