初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
56
app/Http/Controllers/Wx/ThemeController.php
Normal file
56
app/Http/Controllers/Wx/ThemeController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wx;
|
||||
|
||||
use App\BaseApp\BaseController;
|
||||
use App\Service\wx\WxPayService;
|
||||
use App\Service\wx\WxThemeService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* 小程序主题下发与支付回调(均免鉴权)
|
||||
*/
|
||||
class ThemeController extends BaseController
|
||||
{
|
||||
protected array $exceptRoute = ['list', 'option', 'detail', 'create', 'update', 'delete'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->service = WxThemeService::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前主题
|
||||
* @Method GET
|
||||
*/
|
||||
public function theme(): JsonResponse
|
||||
{
|
||||
return jok($this->service->current((string) request()->get('code', '')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 可选风格
|
||||
* @Method GET
|
||||
*/
|
||||
public function themeGallery(): JsonResponse
|
||||
{
|
||||
return jok($this->service->gallery());
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
*
|
||||
* 必须用原始报文验签:先 json_decode 再 encode 回去,字节顺序变了签名就对不上。
|
||||
* @Method POST
|
||||
*/
|
||||
public function payNotify(): JsonResponse
|
||||
{
|
||||
$headers = [];
|
||||
foreach (['wechatpay-timestamp', 'wechatpay-nonce', 'wechatpay-signature', 'wechatpay-serial'] as $key) {
|
||||
$headers[$key] = (string) request()->header($key, '');
|
||||
}
|
||||
$result = WxPayService::getInstance()->handleNotify($headers, request()->getContent());
|
||||
return response()->json($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user