xxxrrrdddd 3 jaren geleden
bovenliggende
commit
605572f014
3 gewijzigde bestanden met toevoegingen van 12 en 19 verwijderingen
  1. 3 0
      addons/epay/library/Service.php
  2. 2 0
      application/common/service/Jdpay.php
  3. 7 19
      application/index/controller/Payment.php

+ 3 - 0
addons/epay/library/Service.php

@@ -301,5 +301,8 @@ class Service
     public static function notifyUrl($type,$order_no){
         return request()->domain()."/index/payment/notify/type/{$type}/order_no/$order_no";
     }
+    public static function notifyUrlJd($order_no){
+        return request()->domain()."/index/payment/notify_jd/order_no/$order_no";
+    }
 
 }

+ 2 - 0
application/common/service/Jdpay.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\common\service;
 
+use addons\epay\library\Service;
 use jdpay\com\jdjr\pay\demo\common\SignUtil;
 use jdpay\com\jdjr\pay\demo\common\TDESUtil;
 
@@ -26,6 +27,7 @@ class Jdpay{
             'sourcePlat'=>'h5',
             'tradeName'=>$desc,
             'outTradeIp'=>request()->ip(),
+            'successNotifyUrl'=>Service::notifyUrlJd($orderNo),
             'expireTime'=>'3600',
             'outTradePort'=>(string)request()->port(),
         ];

+ 7 - 19
application/index/controller/Payment.php

@@ -63,36 +63,25 @@ class Payment extends Frontend
     /**
      * 支付成功回调
      */
-    public function notify_jd($type,$order_no)
+    public function notify_jd($order_no)
     {
-        $data=Service::checkNotify($type);
-        if (!$data) {
-            echo '签名错误';
-            return;
-        }
-
-        $name="pay/$type/{$order_no}";
-        user_log($name,compact('type','order_no','data'));
+        $name="pay/jd/{$order_no}";
+        user_log($name,compact('type','order_no'));
         Db::startTrans();
         $order=MobileOrder::where('order_no',$order_no)->lock(true)->find();
         if(!$order){
             user_log($name,"订单没找到");
             Db::rollback();
-            return '订单没找到';
+            return 'success';
         }
         if($order['pay_time']){
             user_log($name,"订单已支付");
             Db::rollback();
-            return '订单已支付';
+            return 'success';
         }
         $order['pay_time']=time();
         $order['status']=MobileOrder::STATUS_WAIT_SEND;
-        if($type=='wechat'){
-            $order['pay_type']=1;
-            $order['pay_no']=$data['transaction_id'];
-        }else{
-            $order['pay_type']=2;
-        }
+        $order['pay_type']=3;
         if(!$order->save()){
             user_log($name,"保存失败");
             Db::rollback();
@@ -102,7 +91,6 @@ class Payment extends Frontend
 
         //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能
         //下面这句必须要执行,且在此之前不能有任何输出
-        echo "success";
-        return;
+        return 'success';
     }
 }