| xqd
@@ -4,8 +4,10 @@
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
|
+use App\Models\PaymentLogModel;
|
|
|
use App\Services\PayService;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
+use PHPUnit\Util\Exception;
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
|
class PayNotifyController extends Controller
|
| xqd
@@ -15,10 +17,16 @@ class PayNotifyController extends Controller
|
|
|
*/
|
|
|
public function wx_notify(){
|
|
|
$wxpay = Pay::wechat(PayService::wx_config());
|
|
|
- $data = $wxpay->verify();
|
|
|
- Log::info($data);
|
|
|
-
|
|
|
- return $wxpay->success();
|
|
|
+ try{
|
|
|
+ $data = $wxpay->verify();
|
|
|
+ Log::info($data);
|
|
|
+ $order_no = $data->out_trade_no;
|
|
|
+ $this->order_do_sth($order_no);
|
|
|
+ Log::debug('Wechat notify', $data->all());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::info($e->getMessage());
|
|
|
+ }
|
|
|
+ return $wxpay->success();
|
|
|
}
|
|
|
|
|
|
/**
|
| xqd
@@ -26,15 +34,29 @@ class PayNotifyController extends Controller
|
|
|
*/
|
|
|
public function ali_notify(){
|
|
|
$alipay = Pay::alipay(PayService::ali_config());
|
|
|
- $data = $alipay->verify();
|
|
|
- Log::info($data);
|
|
|
+ try{
|
|
|
+ $data = $alipay->verify();
|
|
|
+ Log::info($data);
|
|
|
+ $order_no = $data->out_trade_no;
|
|
|
+ $this->order_do_sth($order_no);
|
|
|
+ Log::debug('Wechat notify', $data->all());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::info($e->getMessage());
|
|
|
+ }
|
|
|
return $alipay->success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 支付回调业务处理
|
|
|
*/
|
|
|
- public function order_do_sth($order){
|
|
|
+ public function order_do_sth($order_no){
|
|
|
+ $order = PaymentLogModel::query()->where(['order_no'=>$order_no])->first();
|
|
|
+ if(!$order){
|
|
|
+ throw new Exception("订单不存在");
|
|
|
+ }
|
|
|
+ if($order['status']==1){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|