wang hou sheng 9 months ago
parent ba507edcb8
commit b51787b657
  1. 30
      app/api/controller/Wxserver.php
  2. 11
      app/common/library/wxserver/Server.php

@ -3,6 +3,7 @@ declare (strict_types=1);
namespace app\api\controller;
use app\common\model\WxserverAccount;
use cores\BaseController;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -42,8 +43,35 @@ class Wxserver extends BaseController
echo 'success';
}
public function callback($appid)
public function callback()
{
$query = $this->request->query();
$xmlData = file_get_contents("php://input");
if ($query) {
$arr = explode('/', $query);
$appid = end($arr);
if ($xmlData && $appid) {
$obj = new \app\common\library\wxserver\Server();
$data = $obj->decryptXml($xmlData);
if (!empty($data['MsgType']) && $data['MsgType'] == 'event' && !empty($data['Event'])) {
$up = [];
if ($data['Event'] == 'weapp_audit_success') {
$up['audit_status'] = 2;
} elseif ($data['Event'] == 'weapp_audit_fail') {
$up['audit_status'] = 3;
} elseif ($data['Event'] == 'weapp_audit_delay') {
$up['audit_status'] = 4;
}
if (!empty($data['Reason'])) {
$up['audit_reason'] = $data['Reason'];
}
if ($up) {
$model = new WxserverAccount();
$model->update($up, ['appid' => $appid]);
}
}
}
}
echo 'success';
}
}

@ -47,6 +47,17 @@ class Server
return $ticket;
}
public function decryptXml($xml)
{
$data = [];
$xmlData = $this->crypt->fromXml($xml);
if (!empty($xmlData['Encrypt'])) {
$encryptXml = $this->crypt->decryptMsg($xmlData['Encrypt']);
$data = $this->crypt->fromXml($encryptXml);
}
return $data;
}
public function getStableAccessToken()
{
$url = 'https://api.weixin.qq.com/cgi-bin/stable_token';

Loading…
Cancel
Save