|
|
@ -23,8 +23,8 @@ class MiniProgramAuditStatus extends RowAction |
|
|
public function __construct($title = null, $action = 1) |
|
|
public function __construct($title = null, $action = 1) |
|
|
{ |
|
|
{ |
|
|
parent::__construct($title); |
|
|
parent::__construct($title); |
|
|
$this->action = $action; //$action:1=通过;2=拒绝
|
|
|
|
|
|
$this->title = $action == 1 ? '审核状态' : '拒绝'; |
|
|
|
|
|
|
|
|
$this->action = $action; |
|
|
|
|
|
$this->title = $action == 1 ? '审核状态' : '审核撤销'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected function html() |
|
|
protected function html() |
|
|
@ -36,14 +36,18 @@ class MiniProgramAuditStatus extends RowAction |
|
|
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
|
|
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function handle(Request $request) |
|
|
|
|
|
|
|
|
public function handle() |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->action == 1 ? $this->auditStatus() : $this->undoAudit(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function auditStatus() |
|
|
{ |
|
|
{ |
|
|
$agent = Agent::find($this->getKey()); |
|
|
$agent = Agent::find($this->getKey()); |
|
|
if (empty($agent->appid)) { |
|
|
if (empty($agent->appid)) { |
|
|
return $this->response()->error('该代理商未注册过小程序,请先注册'); |
|
|
return $this->response()->error('该代理商未注册过小程序,请先注册'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// $template_id = MiniProgramTemplate::max('template_id');
|
|
|
|
|
|
$log = MiniProgramUploadLog::where(['agent_id' => $agent->id])->orderBy('id', 'desc')->first(); |
|
|
$log = MiniProgramUploadLog::where(['agent_id' => $agent->id])->orderBy('id', 'desc')->first(); |
|
|
if (!$log) { |
|
|
if (!$log) { |
|
|
return $this->response()->error('该代理商未上传及发布过最新版本的小程序'); |
|
|
return $this->response()->error('该代理商未上传及发布过最新版本的小程序'); |
|
|
@ -95,6 +99,60 @@ class MiniProgramAuditStatus extends RowAction |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function undoAudit() |
|
|
|
|
|
{ |
|
|
|
|
|
$agent = Agent::find($this->getKey()); |
|
|
|
|
|
if (empty($agent->appid)) { |
|
|
|
|
|
return $this->response()->error('该代理商未注册过小程序,请先注册'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$log = MiniProgramUploadLog::where(['agent_id' => $agent->id])->orderBy('id', 'desc')->first(); |
|
|
|
|
|
if (!$log) { |
|
|
|
|
|
return $this->response()->error('该代理商未上传及发布过最新版本的小程序'); |
|
|
|
|
|
} else if (!$log->audit_id) { |
|
|
|
|
|
return $this->response()->error('未找到审核记录audit_id'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
$openPlatform = new OpenPlatform(); |
|
|
|
|
|
$refreshToken = $openPlatform->refreshToken($agent->appid); |
|
|
|
|
|
if (!$refreshToken) { |
|
|
|
|
|
return $this->response()->error('获取refresh_token失败'); |
|
|
|
|
|
} |
|
|
|
|
|
/** @var Client $code */ |
|
|
|
|
|
$code = $openPlatform->code($agent->appid, $refreshToken); |
|
|
|
|
|
if (!$code) { |
|
|
|
|
|
return $this->response()->error('获取code失败'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$res = $code->withdrawAudit(); |
|
|
|
|
|
if (isset($res['errcode'], $res['errmsg']) && $res['errcode'] == 0 && $res['errmsg'] == 'ok') { |
|
|
|
|
|
//保存审核状态为已撤回
|
|
|
|
|
|
$log->is_success = 3; |
|
|
|
|
|
$log->save(); |
|
|
|
|
|
|
|
|
|
|
|
return $this->response()->success("撤回最后审核单成功")->refresh(); |
|
|
|
|
|
} else if (isset($res['errcode']) && $res['errcode'] != 0) { |
|
|
|
|
|
$error = [ |
|
|
|
|
|
-1 => '腾讯内部系统错误', |
|
|
|
|
|
87013 => '撤回次数达到上限(每天5次,每个月 10 次)', |
|
|
|
|
|
]; |
|
|
|
|
|
return $this->response()->error(isset($error[$res['errcode']]) ? $error[$res['errcode']] : ($res['errmsg'] ?? join(',', $res))); |
|
|
|
|
|
} else { |
|
|
|
|
|
return $this->response()->error($res['errmsg'] ?? join(',', $res)); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (InvalidConfigException | GuzzleException | \Exception $e) { |
|
|
|
|
|
return $this->response()->error($e->getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function confirm() |
|
|
|
|
|
{ |
|
|
|
|
|
if ($this->action == 2) { |
|
|
|
|
|
return ['撤回次数每天最多5次,每个月最多10次,是否继续?', '']; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function parameters() |
|
|
public function parameters() |
|
|
{ |
|
|
{ |
|
|
return ['action' => $this->action]; |
|
|
return ['action' => $this->action]; |
|
|
|