Browse Source

afandeng update

ayHaru 4 years ago
parent
commit
7b6e937fce

+ 8 - 6
data/config/xyz/refill.ini.php

@@ -234,12 +234,14 @@ $afand_phone = ['name' => 'afand', 'store_id' => 26,
 
 $afandeng_phone = ['name' => 'afandeng', 'store_id' => 27,
     'amount' => [
-        30 => [['goods_id' => 6380, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6381, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6382, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6383, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 6384, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 6385, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile']]
+        10 => [['goods_id' => 6406, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6407, 'price' => 19, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6380, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6381, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6382, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6383, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6384, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6385, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 8 - 12
helper/refill/api/xyz/afandeng/RefillCallBack.php

@@ -13,7 +13,7 @@ class RefillCallBack implements refill\IRefillCallBack
     public function verify($params): bool
     {
         $sign = $this->sign($params);
-        if ($params['signstr'] == $sign) {
+        if ($params['sgn'] == $sign) {
             return true;
         } else {
             return false;
@@ -22,30 +22,26 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $content = $params['code'] . $params['tradeNoThird'] .$params['msg'] . $params['tradeNo'] . config::KEY;
-        if(empty($params['tradeNo'])) {
-            $content = $params['code'] . $params['tradeNoThird'] .$params['msg'] . config::KEY;
-        }
-        return md5($content);
+        $content = $params['ord'] . $params['state'] . config::KEY;
+        return strtoupper(md5($content));
     }
 
     public function notify($params)
     {
-        $status = intval($params['code']);
-        $order_sn = $params['tradeNoThird'];
+        $status = intval($params['state']);
+        $order_sn = $params['ord'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
         $order_id = $order_info['order_id'];
-        
-        $data['official_sn'] = strtolower($params['tradeNo']) == 'null' ? '' : $params['tradeNo'];
+        $data['official_sn'] = $params['bz'];
 
-        if ($status === 200) {
+        if ($status === 1) {
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false,true];
         }
-        elseif ($status === 300) {
+        elseif ($status === 2) {
             return [$order_id, false, true,true];
         }
         else {

+ 50 - 35
helper/refill/api/xyz/afandeng/RefillPhone.php

@@ -17,58 +17,73 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, string $order_sn)
     {
-        $params['merchantId'] = config::MCHID;
-        $params['orderType'] = 1;
-        $params['mobile'] = $phone;
-        $params['tradeNoThird'] = $order_sn;
-        $params['amount'] = sprintf("%.2f" , $amount);
-        $params['notifyUrl'] = config::NOTIFY_URL;
-
+        $params['usr'] = config::USR;
+        $params['mob'] = $phone;
+        $params['amt'] = $amount;
+        $params['ord'] = $order_sn;
+        $params['tim'] = date("YmdHis");
+        $params['yysid'] = 0;
+        $params['hmlx'] = 0;
         return $params;
+
     }
 
     public function add($card_no, $card_type, $amount, $params)
     {
-        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no,$amount,$order_sn);
         $sign = $this->sign($params);
-        $params['signstr'] = $sign;
+        $params['sgn'] = $sign;
+        $resp = http_request(config::PAY_PHONE_URL,$params,'GET');
+        if($resp === false) {
+            return [false,'系统错误',true];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = ltrim($resp , '|');
 
-        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders);
-        if ($resp === false) {
-            return [false, '系统错误', true];
-        } else {
-            Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
-            if ($resp['code'] == 200) {
-                return [true, $resp['body']['tradeNoSelf'], false];
-            } else {
-                return [false, $resp['msg'], false];
+            $resp = explode('|' , $resp);
+            if(count($resp) != 3) {
+                return [false,'返回值错误', false];
+            }
+            elseif($resp[0] == 0) {
+                return [true,'', false];
+            }
+            else {
+                return [false,$resp[1], false];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['merchantId'] = config::MCHID;
-        $params['tradeNoThird'] = $refill_info['order_sn'];
-        $content = $params['merchantId'] . $params['tradeNoThird'] . config::KEY;
-        $params['signstr'] = md5($content);
-        $resp = http_request(config::QUERY_URL, $params , 'GET' , false);
-        if ($resp === false) {
-            return [false, '系统错误'];
-        } else {
-            Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
+        $params['ord'] = $refill_info['order_sn'];
+        $params['usr'] = config::USR;
+        $content = $params['usr'] . $params['ord'] . config::KEY;
+        $params['sgn'] = strtoupper(md5($content));
+        $resp = http_request(config::QUERY_URL,$params);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = ltrim($resp , '|');
+            $resp = explode('|' , $resp);
+            if(count($resp) != 3) {
+                return [false,'返回值错误'];
+            }
             $order_state = -1;
-            if ($resp['code'] == 200) {
+            if ($resp[0] == 1) {
                 $order_state = ORDER_STATE_SUCCESS;
-            } elseif ($resp['code'] == 604) {
+            } elseif ($resp[0] == 2) {
                 $order_state = ORDER_STATE_CANCEL;
-            } elseif ($resp['code'] == 603){
+            } elseif ($resp[0] == 0){
                 $order_state = ORDER_STATE_SEND;
             }
             if ($order_state == -1) {
-                return [false, $resp['msg']];
+                return [false, $resp[0]];
             }
             return [true, $order_state];
         }
@@ -77,7 +92,7 @@ class RefillPhone extends refill\IRefillPhone
     private function sign($params)
     {
         $key = config::KEY;
-        $content = $params['merchantId'] . $params['orderType'] . $params['mobile'] . $params['tradeNoThird'] . $params['amount'] . $params['notifyUrl'] . $key;
-        return md5($content);
+        $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'] . $key;
+        return strtoupper(md5($content));
     }
 }

+ 4 - 7
helper/refill/api/xyz/afandeng/config.php

@@ -6,11 +6,8 @@ namespace refill\afandeng;
 
 class config
 {
-    const ORDER_URL = 'http://8.135.117.151:8124/supply/order/orderCheck';
-    const QUERY_URL = 'http://8.135.117.151:8124/supply/order/getSupplyOrderStatus';
-
-    const MCHID = 131;
-    const KEY = '4356f096d6ff947da4918e40bedc444e';
-    const NOTIFY_URL =  BASE_SITE_URL."/mobile/refill_afandeng.php";
-    const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
+    const PAY_PHONE_URL = 'http://8.140.101.13:806/webInface/PayPhone.ashx';
+    const QUERY_URL= 'http://8.140.101.13:806/webInface/GetOrderState.ashx';
+    const USR= 'afandeng';
+    const KEY = 'd54e3cac95dec6839e74313740ce2ab1';
 }

+ 9 - 2
test/TestRefill.php

@@ -18,7 +18,7 @@ require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 const LocalTest = 1;
 const NetTest = 2;
 
-const CurrentTest = NetTest;
+const CurrentTest = LocalTest;
 
 class TestRefill extends TestCase
 {
@@ -232,6 +232,12 @@ class TestRefill extends TestCase
 //        refill\RefillFactory::instance()->notify('amingyd',$data);
     }
 
+    public function testChukaPhone()
+    {
+        $providers = new refill\chuka\RefillPhone([]);
+        $resp = $providers->add('18500608333', 5, 20, ['order_sn' => $this->make_sn()]);
+    }
+
     public function testWeisPhone()
     {
         $providers = new refill\weisyd\RefillPhone([]);
@@ -256,7 +262,8 @@ class TestRefill extends TestCase
     public function testAfandengPhone()
     {
         $providers = new refill\afandeng\RefillPhone([]);
-        $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->add(18500608333, 4, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '83941616065521341004']);
     }