174 lines
4.7 KiB
PHP
174 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Merchant;
|
|
|
|
use App\Models\MerchantRegistToken;
|
|
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;
|
|
use Yansongda\Supports\Str;
|
|
|
|
class MerchantRegistTokenController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '注册推广'
|
|
];
|
|
|
|
}
|
|
public function checkRule($id = '')
|
|
{
|
|
|
|
return [
|
|
'type' => 'required',
|
|
];
|
|
}
|
|
|
|
public function setErrorMsg()
|
|
{
|
|
$messages = [
|
|
'draw_money.required' => '提现金额不能为空',
|
|
'money.required' => '到账金额不能为空',
|
|
'fee_money.required' => '手续费不能为空',
|
|
'bank_realname.required' => '收款人不能为空',
|
|
];
|
|
return $messages;
|
|
}
|
|
|
|
protected function postDataDb($request,$id='')
|
|
{
|
|
if(merchant('level')==3)
|
|
{
|
|
return false;
|
|
}
|
|
$data = $request->all();
|
|
$data['merchant_id']=merchant('id');
|
|
$data['regist_token']=date('YmdHis').Str::random(20);
|
|
if($data['type']==1)
|
|
{
|
|
$merchant_regist_has_ratio=config_cache_default('merchant_config.merchant_regist_has_ratio',10);
|
|
$data['ratio']=merchant('ratio')+$merchant_regist_has_ratio;
|
|
}else
|
|
{
|
|
$ratio=config_cache_default('merchant_config.merchant_regist_min_ratio',20);
|
|
$data['ratio']=merchant('ratio')+$ratio;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
public function addOutData($id='')
|
|
{
|
|
$model=$this->store_model;
|
|
|
|
return [
|
|
'url'=>route('web.merchant.regist',['token'=>$model->regist_token])
|
|
];
|
|
}
|
|
|
|
public function indexData()
|
|
{
|
|
|
|
$this->pages = [
|
|
'name' => '订单'
|
|
];
|
|
|
|
return [];
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
|
|
$show = $this->setModel()->find($id);
|
|
|
|
//($pictrue);
|
|
|
|
|
|
return $this->display(['show' => $show ]);
|
|
}
|
|
|
|
|
|
public function shareData($show = '')
|
|
{
|
|
|
|
|
|
$money=config_cache_default('merchant_config.merchant_regist_money_list');
|
|
$money=explode("\n",$money);
|
|
$money=is_array($money)?$money:[];
|
|
$ratio=config_cache_default('merchant_config.merchant_regist_min_ratio',20);
|
|
$merchant_regist_has_ratio=config_cache_default('merchant_config.merchant_regist_has_ratio',10);
|
|
|
|
//最低注册金额
|
|
$min_money=config_cache_default('merchant_config.merchant_regist_min_money',500);
|
|
return [
|
|
'money'=>$money,
|
|
'ratio'=>$ratio,
|
|
'min_money'=>$min_money,
|
|
'merchant_regist_has_ratio'=>$merchant_regist_has_ratio
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setModel()
|
|
{
|
|
return new MerchantRegistToken();
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checkStatus(Request $request)
|
|
{
|
|
$id = $request->input('id');
|
|
return $this->getShow($id);
|
|
|
|
}
|
|
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();
|
|
|
|
$model=$model->where('merchant_id',$this->getMerchantId());
|
|
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
|
$narr = array();
|
|
|
|
foreach ($result as $k => $v) {
|
|
$v['edit_url']=action($this->route['controller_name'] . '@edit', ['id' => $v->id]);
|
|
$v['edit_post_url']=action($this->route['controller_name'] . '@update', ['id' => $v->id]);
|
|
$v['type_name']=$v->type==1?'<span class="text-red">注册费</span>':'注册费率';
|
|
$v['money_info']=$v->type==1?$v->money:($v->ratio/10).'%';
|
|
$v['url']=route('web.merchant.regist',['token'=>$v->regist_token]);
|
|
$level=config('adconfig.merchant_level');
|
|
$v['level_name']='<span class="layui-btn layui-btn-sm '.($v->level==2?'layui-btn-danger':'').'">'.$level[$v->level].'</span>';
|
|
$v['ratio']=($v['ratio']/10).'%';
|
|
$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);
|
|
}
|
|
}
|