wang hou sheng 8 months ago
parent e6989c5366
commit fb38c8aab5
  1. 36
      app/admin/controller/Wxserve.php
  2. 45
      app/common/library/wxserver/Server.php

@ -194,4 +194,40 @@ class Wxserve extends Controller
}
return $this->renderError('操作失败');
}
/**
* @notes:提交正式版审核
* @return Json
* @author: wanghousheng
*/
public function audit(): Json
{
$appid = $this->request->get('appid');
if ($appid) {
$obj = new Server();
if ($obj->submitAudit($appid)) {
return $this->renderSuccess('success');
}
}
return $this->renderError('操作失败');
}
/**
* @notes:发布正式版前检查
* @return Json
* @author: wanghousheng
*/
public function auditBeforeCheck(): Json
{
$msg = '操作失败';
$appid = $this->request->get('appid');
if ($appid) {
$obj = new Server();
$msg = $obj->privacyInfo($appid);
if ($msg == 'ok') {
return $this->renderSuccess('success');
}
}
return $this->renderError($msg);
}
}

@ -513,6 +513,51 @@ class Server
return 0;
}
public function submitAudit($appid): bool
{
$access_token = $this->authorizerAccessToken($appid);
if ($access_token) {
$url = 'https://api.weixin.qq.com/wxa/submit_audit?access_token=' . $access_token;
$data['item_list'] = $this->getAllCategory($appid);
$result = $this->curlPost($url, json_encode($data));
$result = json_decode($result, true);
if (!empty($result) && intval($result['errcode']) == 0 && !empty($result['auditid'])) {
$model = new WxserverAccount();
$up['audit_status'] = 1;
$up['audit_time'] = date('Y-m-d H:i:s');
$up['audit_id'] = $result['auditid'];
$model->update($up, ['appid' => $appid]);
return true;
}
}
return false;
}
private function getAllCategory($appid): array
{
$data = [];
$access_token = $this->authorizerAccessToken($appid);
if ($access_token) {
$url = 'https://api.weixin.qq.com/wxa/get_category?access_token=' . $access_token;
$result = $this->curlGet($url);
$result = json_decode($result, true);
if ($result && !empty($result['category_list'])) {
$category_list = $result['category_list'];
foreach ($category_list as $value) {
$data[] = [
'first_class' => $value['first_class'],
'second_class' => $value['second_class'],
'third_class' => $value['third_class'],
'first_id' => $value['first_id'],
'second_id' => $value['second_id'],
'third_id' => $value['third_id'],
];
}
}
}
return $data;
}
private function curlPost($url, $post_data, $timeout = 5)
{
$ch = curl_init();

Loading…
Cancel
Save