add 对接支付系统,回调改造

This commit is contained in:
chenbo 2023-11-21 10:40:34 +08:00
parent cdde963325
commit 78b7c8ea0a
3 changed files with 15 additions and 40 deletions

View File

@ -145,9 +145,13 @@ class PayController extends BaseApiController
*/ */
public function notifyApp() public function notifyApp()
{ {
$param = $this->request->param(); try {
return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param); $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());
}
} }
} }

View File

@ -67,6 +67,7 @@ class PayNotifyLogic extends BaseLogic
$order = RechargeOrder::where('sn', $orderSn)->findOrEmpty(); $order = RechargeOrder::where('sn', $orderSn)->findOrEmpty();
if ($order && isset($order['extend']['type']) && $order['extend']['type'] == 1) { if ($order && isset($order['extend']['type']) && $order['extend']['type'] == 1) {
// ***** 小组服务团队-入股任务逻辑 已废弃 *****
$find = Task::where('id', $order['extend']['task_id'])->find(); $find = Task::where('id', $order['extend']['task_id'])->find();
$extend=$find['extend']; $extend=$find['extend'];
$extend['shareholder']['order_sn']=$order->sn; $extend['shareholder']['order_sn']=$order->sn;
@ -112,7 +113,7 @@ class PayNotifyLogic extends BaseLogic
// 更新充值订单状态 // 更新充值订单状态
$order->transaction_id = $extra['transaction_id']; $order->transaction_id = $extra['transaction_id'];
$order->pay_status = PayEnum::ISPAID; $order->pay_status = $extra['pay_status'];;
$order->pay_time = time(); $order->pay_time = time();
$order->save(); $order->save();
} }

View File

@ -354,44 +354,14 @@ 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($param)
{ {
Log::info(['支付回调', $param]); 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'] ?? '']; return true;
// 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;
// }
// 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)