82 lines
2.0 KiB
PHP
Executable File
82 lines
2.0 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
namespace app\admin\controller\distribution;
|
|
|
|
|
|
use app\admin\logic\distribution\ApplyLogic;
|
|
use app\common\basics\AdminBase;
|
|
use app\common\server\JsonServer;
|
|
use think\facade\View;
|
|
|
|
class Apply extends AdminBase
|
|
{
|
|
/**
|
|
* @Notes: 分销申请列表
|
|
* @Author: 张无忌
|
|
*/
|
|
public function lists()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
$lists = ApplyLogic::lists($get);
|
|
return JsonServer::success('获取成功', $lists);
|
|
}
|
|
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* @Notes: 分销申请详细
|
|
* @Author: 张无忌
|
|
*/
|
|
public function detail()
|
|
{
|
|
$id = $this->request->get('id');
|
|
View::assign('detail', ApplyLogic::detail($id));
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* @Notes: 审核分销申请
|
|
* @Author: 张无忌
|
|
*/
|
|
public function audit()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
|
|
$result = $this->requestCompleteAudit($post['id']);
|
|
if ($result) {
|
|
if ($result['code'] == 0) {
|
|
return JsonServer::error($result['msg']);
|
|
}
|
|
} else {
|
|
return JsonServer::error('解析失败');
|
|
}
|
|
$res = ApplyLogic::audit($post);
|
|
if ($res === false) {
|
|
$message = ApplyLogic::getError() ?: '审核失败';
|
|
return JsonServer::error($message);
|
|
}
|
|
return JsonServer::success('审核成功');
|
|
}
|
|
|
|
return view();
|
|
}
|
|
|
|
private function requestCompleteAudit($id)
|
|
{
|
|
try {
|
|
$url = request()->domain() . '/api/gh/CompleteAudit?id=' . $id;
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
$response = curl_exec($ch);
|
|
curl_close($ch);
|
|
return json_decode($response, true);
|
|
} catch (\Exception $e) {
|
|
return false;
|
|
}
|
|
}
|
|
} |