Revert "add 供销对接支付系统"
This reverts commit 04d478d8
This commit is contained in:
parent
2f99915481
commit
d2667977f9
@ -16,11 +16,8 @@ namespace app\api\controller;
|
|||||||
|
|
||||||
|
|
||||||
use app\api\validate\PayValidate;
|
use app\api\validate\PayValidate;
|
||||||
use app\common\enum\PayEnum;
|
|
||||||
use app\common\enum\user\UserTerminalEnum;
|
use app\common\enum\user\UserTerminalEnum;
|
||||||
use app\common\logic\PaymentLogic;
|
use app\common\logic\PaymentLogic;
|
||||||
use app\common\logic\PayRequestLogic;
|
|
||||||
use app\common\model\Company;
|
|
||||||
use app\common\service\pay\WeChatPayService;
|
use app\common\service\pay\WeChatPayService;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
|
|
||||||
@ -65,23 +62,13 @@ class PayController extends BaseApiController
|
|||||||
if (false === $order) {
|
if (false === $order) {
|
||||||
return $this->fail(PaymentLogic::getError(), $params);
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
}
|
}
|
||||||
// 请求支付系统
|
//支付流程
|
||||||
$companyInfo = Company::where(['id' => $this->userInfo['company_id']])->find();
|
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
||||||
$requestData = [
|
$result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
|
||||||
'street' => $companyInfo['street'],
|
|
||||||
'order_from' => 12,
|
|
||||||
'order_type' => 101,
|
|
||||||
'pay_user_role' => $this->userInfo['group_id'],
|
|
||||||
'pay_user_info' => $this->userInfo,
|
|
||||||
'business_order_no' => $order['sn'],
|
|
||||||
'total_fee' => intval(bcmul($order['order_amount'], 100)),
|
|
||||||
'business_callback_url' => (string)url('pay/notifyApp', [], false, true)
|
|
||||||
];
|
|
||||||
$result = PayRequestLogic::getPrePayId($requestData);
|
|
||||||
if (false === $result) {
|
if (false === $result) {
|
||||||
return $this->fail(PaymentLogic::getError(), $params);
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
}
|
}
|
||||||
return $this->success('', $result['data']);
|
return $this->success('', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -135,18 +122,18 @@ class PayController extends BaseApiController
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 支付系统回调
|
* @notes app支付回调
|
||||||
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||||
|
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws \Throwable
|
||||||
* @date 2023/2/28 14:21
|
* @date 2023/2/28 14:21
|
||||||
*/
|
*/
|
||||||
public function notifyApp()
|
public function notifyApp()
|
||||||
{
|
{
|
||||||
try {
|
return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify();
|
||||||
$param = $this->request->param();
|
|
||||||
Log::info(['支付系统回调', $param]);
|
|
||||||
(new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param);
|
|
||||||
return $this->success('ok');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->fail($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
// 更新充值订单状态
|
// 更新充值订单状态
|
||||||
$order->transaction_id = $extra['transaction_id'];
|
$order->transaction_id = $extra['transaction_id'];
|
||||||
$order->pay_status = $extra['pay_status'];;
|
$order->pay_status = PayEnum::ISPAID;
|
||||||
$order->pay_time = time();
|
$order->pay_time = time();
|
||||||
$order->save();
|
$order->save();
|
||||||
}
|
}
|
||||||
|
@ -354,15 +354,44 @@ class WeChatPayService extends BasePayService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 支付回调
|
* @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:20
|
||||||
*/
|
*/
|
||||||
public function notify($param=[])
|
public function notify()
|
||||||
{
|
{
|
||||||
Log::info(['支付回调', $param]);
|
$server = $this->app->getServer();
|
||||||
$extra['transaction_id'] = $param['transaction_id'];
|
// 支付通知
|
||||||
$extra['pay_status'] = $param['pay_status'];
|
$server->handlePaid(function (Message $message) {
|
||||||
PayNotifyLogic::handle('recharge', $param['out_trade_no'], $extra);
|
$data = ['trade_state' => $message['trade_state'] ?? '', 'out_trade_no' => $message['out_trade_no'] ?? '', 'transaction_id' => $message['transaction_id'] ?? '', 'attach' => $message['attach'] ?? ''];
|
||||||
|
Log::info('wechat pay notify: ' . var_export($data, true));
|
||||||
|
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 'recharge':
|
||||||
|
$order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty();
|
||||||
|
if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 退款通知
|
||||||
|
$server->handleRefunded(function (Message $message) {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return $server->serve();
|
||||||
|
}
|
||||||
|
|
||||||
public function configForPayment($prepayId, $appId)
|
public function configForPayment($prepayId, $appId)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user