1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 12:09:09 +08:00
koogua 7636a8af1c !20 验证更新h5支付
* 更新H5支付方式
* Merge remote-tracking branch 'remotes/gitee/master' into develop
* !19 v1.2.0阶段性合并
* update app/Http/Admin/Controllers/UploadController.php.
* Merge branch 'develop' of https://gitee.com/koogua/course-tencent-cloud
* Merge branch 'master' of https://gitee.com/koogua/course-tencent-cloud
* add LICENSE.
* 删除文件 LICENSE
* !14 修正点击退款404
* !13 修正退款项目空白以及弹窗自适应
* !12 修正退款项目空白以及弹窗自适应
* Merge branch 'master' of https://gitee.com/koogua/course-tencent-cloud
* !9 修正插入数据不一致以及后台菜单参数类型报错
* !7 纠正迁移文件和代码实际使用字段不一致
* Merge branch 'master' of https://gitee.com/koogua/course-tencent-cloud
* !6 develop->master 1.1.0
2020-12-02 11:01:00 +08:00

141 lines
3.0 KiB
PHP

<?php
namespace App\Http\Home\Controllers;
use App\Library\CsrfToken as CsrfTokenService;
use App\Repos\Upload as UploadRepo;
use App\Services\LiveNotify as LiveNotifyService;
use App\Services\Pay\Alipay as AlipayService;
use App\Services\Pay\Wxpay as WxpayService;
use App\Services\Storage as StorageService;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use PHPQRCode\QRcode;
class PublicController extends \Phalcon\Mvc\Controller
{
use ResponseTrait;
use SecurityTrait;
/**
* @Get("/download/{md5}", name="home.download")
*/
public function downloadAction($md5)
{
$repo = new UploadRepo();
$file = $repo->findByMd5($md5);
if ($file) {
$service = new StorageService();
$location = $service->getFileUrl($file->path);
$this->response->redirect($location, true);
} else {
$this->response->setStatusCode(404);
return $this->response;
}
}
/**
* @Get("/qrcode", name="home.qrcode")
*/
public function qrcodeAction()
{
$text = $this->request->getQuery('text', 'string');
$level = $this->request->getQuery('level', 'int', 0);
$size = $this->request->getQuery('size', 'int', 5);
$url = urldecode($text);
QRcode::png($url, false, $level, $size);
$this->response->send();
exit;
}
/**
* @Post("/token/refresh", name="home.refresh_token")
*/
public function refreshTokenAction()
{
$this->checkCsrfToken();
$service = new CsrfTokenService();
$token = $service->getToken();
return $this->jsonSuccess(['token' => $token]);
}
/**
* @Get("/alipay/callback", name="home.alipay_callback")
*/
public function alipayCallbackAction()
{
return $this->response->redirect('/h5/#/pages/uc/orders', true);
}
/**
* @Get("/wxpay/callback", name="home.wxpay_callback")
*/
public function wxpayCallbackAction()
{
return $this->response->redirect('/h5/#/pages/uc/orders', true);
}
/**
* @Post("/alipay/notify", name="home.alipay_notify")
*/
public function alipayNotifyAction()
{
$service = new AlipayService();
$response = $service->notify();
if (!$response) exit;
$response->send();
exit;
}
/**
* @Post("/wxpay/notify", name="home.wxpay_notify")
*/
public function wxpayNotifyAction()
{
$service = new WxpayService();
$response = $service->notify();
if (!$response) exit;
$response->send();
exit;
}
/**
* @Post("/live/notify", name="home.live_notify")
*/
public function liveNotifyAction()
{
$service = new LiveNotifyService();
if ($service->handle()) {
return $this->jsonSuccess();
} else {
$this->response->setStatusCode(403);
}
}
}