Pārlūkot izejas kodu

refill beixt notify callback update

ayHaru 4 gadi atpakaļ
vecāks
revīzija
e74d963bc6

+ 2 - 0
helper/refill/RefillFactory.php

@@ -123,6 +123,8 @@ class RefillFactory
     {
         if($chname == "suhc") {
             $caller = new suhc\RefillCallBack();
+        }elseif ($chname == 'beixt'){
+            $caller = new beixt\RefillCallBack();
         }
         else {
             return false;

+ 30 - 2
helper/refill/beixt/RefillCallBack.php

@@ -4,6 +4,7 @@
 namespace refill\beixt;
 
 use refill;
+use refill\beixt\config;
 
 
 class RefillCallBack implements refill\IRefillCallBack
@@ -11,11 +12,38 @@ class RefillCallBack implements refill\IRefillCallBack
 
     public function verify($params) : bool
     {
-        return true;
+        $sign = $this->sign($params);
+        if($params['sign'] == $sign) {
+            return true;
+        }
+        else {
+            return false;
+        }
     }
 
-    public function notify($params)
+    private function sign($params)
     {
+        $body = $params['order_number'];
+        $body .= $params['shipping_status'];
+        $body .= $params['tradeNo'];
+        $body .= config::API_CERT;
+        return strtolower(md5($body));
+    }
 
+    public function notify($params)
+    {
+        $status = intval($params['shipping_status']);
+        $order_sn = $params['order_number'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if(empty($order_info)) {
+            return [false,false];
+        }
+
+        $order_id = $order_info['order_id'];
+        if($status === 0) {
+            return [$order_id,true];
+        } else {
+            return [$order_id,false];
+        }
     }
 }

+ 1 - 1
helper/refill/beixt/config.php

@@ -9,6 +9,6 @@ class config
     const REQUEST_URL = 'http://8.129.76.127/APIHfKc/v2/';
     const API_USER_NAME= '2cf54e1fcd1944e102114c56cf9fe4ca';
     const API_CERT = '2f889d471d2e34a8219dce36e51621c8';
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_beixt.php";
     const API_IP = '111.193.234.45';
 }

+ 8 - 0
mobile/refill_beixt.php

@@ -0,0 +1,8 @@
+<?php
+
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('beixt',$_POST);
+
+echo ('ok');
+