59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\enum\PayEnum;
|
|
use app\common\enum\user\UserTerminalEnum;
|
|
use app\common\logic\PayNotifyLogic;
|
|
use app\common\model\retail\Cashierclass;
|
|
use app\common\service\pay\WeChatPayService;
|
|
use app\Request;
|
|
use Error;
|
|
use support\Log;
|
|
use Webman\Config;
|
|
use Yansongda\Pay\Pay;
|
|
|
|
/**
|
|
* 支付
|
|
* Class PayController
|
|
* @package app\api\controller
|
|
*/
|
|
class PayController extends BaseApiController
|
|
{
|
|
|
|
public $notNeedLogin = ['notifyMnp', 'aa'];
|
|
|
|
/**
|
|
* @notes 小程序支付回调
|
|
* @return \Psr\Http\Message\ResponseInterface
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
|
* @throws \ReflectionException
|
|
* @throws \Throwable
|
|
* @author 段誉
|
|
* @date 2023/2/28 14:21
|
|
*/
|
|
public function notifyMnp()
|
|
{
|
|
$config = Config::get('payment');
|
|
Pay::config($config);
|
|
$message = Pay::wechat()->callback();
|
|
if ($message['trade_state'] === 'SUCCESS') {
|
|
$extra['transaction_id'] = $message['transaction_id'];
|
|
$attach = $message['attach'];
|
|
$message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18);
|
|
switch ($attach) {
|
|
case 'cashierclass':
|
|
$order = Cashierclass::where(['number' => $message['out_trade_no']])->findOrEmpty();
|
|
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
|
return true;
|
|
}
|
|
PayNotifyLogic::handle('cashierclass', $message['out_trade_no'], $extra);
|
|
break;
|
|
}
|
|
return Pay::wechat()->success();
|
|
}
|
|
// return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify();
|
|
}
|
|
}
|