Browse Source

对接hitpay

lizhen_gitee 1 year ago
parent
commit
13a4e117dc

+ 1 - 1
application/api/controller/Demo.php

@@ -40,7 +40,7 @@ class Demo extends Api
      */
     public function test(){
         $out_trade_no = createUniqueNo('Test');
-        $money = '0.3';
+        $money = '1';
         $notifyurl = config('notify_cdnurl');
         $rs = $this->hitpay_payment($out_trade_no,$money,$notifyurl);
         dump($rs);

+ 5 - 3
application/api/controller/Lesson.php

@@ -414,9 +414,11 @@ class Lesson extends Api
 
         Db::commit();
 
-        unset($hitpay_return['status']);
-        unset($hitpay_return['msg']);
-        $this->success(1,$hitpay_return);
+        $return = [
+            'url' => $hitpay_return['url'],
+            'id'  => $hitpay_return['id'],
+        ];
+        $this->success(1,$return);
 
     }
 

+ 14 - 7
application/api/controller/Notify.php

@@ -1,13 +1,13 @@
 <?php
 namespace app\api\controller;
 
-use app\common\controller\Api;
+use think\Controller;
 use think\Db;
-use addons\epay\library\Service;
+
 /**
  * 订单支付回调
  */
-class Notify extends Api
+class Notify extends Controller
 {
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
@@ -48,7 +48,7 @@ class Notify extends Api
     public function recharge_notify_base(){
 
         //日志
-        $paytype = input('paytype','hitpay');
+        $paytype = 'hitpay';
         $notify_file = $this->notify_log_start($paytype);
 
         //接参
@@ -72,9 +72,14 @@ class Notify extends Api
         }
 
         //验证,拿订单号等信息
-        $out_trade_no = $notify_data['reference_number'];
+        $out_trade_no       = $notify_data['reference_number'];
+        $payment_request_id = $notify_data['payment_request_id'];
         //订单查询
-        $info = Db::name('pay_order')->where('out_trade_no',$out_trade_no)->find();
+        $map = [
+            'out_trade_no'       => $out_trade_no,
+            'payment_request_id' => $payment_request_id,
+        ];
+        $info = Db::name('pay_order')->where($map)->find();
 
         if(empty($info)){
             echo 'success';
@@ -155,7 +160,7 @@ class Notify extends Api
                 'paytime'      => $time,
                 'updatetime'   => $time,
             ];
-            $rs = Db::name('package_order')->where('order_no',$orderInfo['out_trade_no'])->update($update); //这里不用id,是因为另有赠品单
+            $rs = Db::name('package_order')->where('order_no',$orderInfo['out_trade_no'])->update($update); //这里不用id,是因为另有赠品单,两个一起更新
             if($rs === false){
                 Db::rollback();
                 return false;
@@ -200,6 +205,8 @@ class Notify extends Api
                         Db::rollback();
                         return false;
                     }
+                }else{
+                    //新买的课时不足以支撑这次的报名人数,不处理
                 }
             }