1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-20 19:07:03 +08:00
koogua cbc2e5762a !11 阶段性合并
* 根据app需要作出相应调整
* 路由增加命名name,增加app应用管理
* 完成基本API,增加h5和小程序支付定义
2020-11-10 10:25:16 +08:00

88 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Api\Controllers;
use App\Http\Api\Services\Trade as TradeService;
use App\Services\Logic\Trade\TradeInfo as TradeInfoService;
/**
* @RoutePrefix("/api/trade")
*/
class TradeController extends Controller
{
/**
* @Get("/info", name="api.trade.info")
*/
public function infoAction()
{
$sn = $this->request->getQuery('sn', 'string');
$service = new TradeInfoService();
$trade = $service->handle($sn);
return $this->jsonSuccess(['trade' => $trade]);
}
/**
* @Get("/h5/pay", name="api.trade.h5_pay")
*/
public function h5PayAction()
{
$sn = $this->request->getQuery('sn', 'string');
$service = new TradeService();
$response = $service->h5Pay($sn);
if (!$response) {
echo "H5支付跳转失败请回退重试";
}
$response->send();
exit();
}
/**
* @Post("/h5/create", name="api.trade.h5_create")
*/
public function createH5TradeAction()
{
$service = new TradeService();
$trade = $service->createH5Trade();
$service = new TradeInfoService();
$trade = $service->handle($trade->sn);
return $this->jsonSuccess(['trade' => $trade]);
}
/**
* @Post("/mp/create", name="api.trade.mp_create")
*/
public function createMpTradeAction()
{
$service = new TradeService();
$content = $service->createMpTrade();
return $this->jsonSuccess($content);
}
/**
* @Post("/app/create", name="api.trade.app_create")
*/
public function createAppTradeAction()
{
$service = new TradeService();
$content = $service->createMpTrade();
return $this->jsonSuccess($content);
}
}