You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Wxserver.php

77 lines
2.4 KiB

8 months ago
<?php
8 months ago
declare (strict_types=1);
8 months ago
namespace app\api\controller;
8 months ago
use app\common\model\WxserverAccount;
8 months ago
use cores\BaseController;
8 months ago
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
8 months ago
8 months ago
class Wxserver extends BaseController
8 months ago
{
8 months ago
public function index()
{
8 months ago
$obj = new \app\common\library\wxserver\Server();
$data = $obj->getAllCategory('wxe3ed157849bd07b5');
8 months ago
return $this->renderSuccess($data);
8 months ago
}
8 months ago
public function verifyTicket()
{
8 months ago
$xmlData = file_get_contents("php://input");
$obj = new \app\common\library\wxserver\Server();
$obj->getVerifyTicket($xmlData);
8 months ago
echo 'success';
}
8 months ago
8 months ago
/**
* @notes:授权回调
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
8 months ago
public function redirect()
{
8 months ago
$authorization_code = $this->request->get('auth_code');
8 months ago
if ($authorization_code) {
$obj = new \app\common\library\wxserver\Server();
$obj->authorizationInfo($authorization_code);
}
8 months ago
echo 'success';
8 months ago
}
8 months ago
8 months ago
public function callback()
8 months ago
{
8 months ago
$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]);
}
}
}
}
8 months ago
echo 'success';
}
8 months ago
}