소스 검색

for lingzh

stanley-king 4 년 전
부모
커밋
bd6f313fa4

+ 2 - 2
data/config/dev/refill.ini.php

@@ -85,7 +85,7 @@ $config['refill_specs'] = [
 $oil_providers = [];
 $config['oil_providers'] = $oil_providers;
 
-$baidu_phone = ['name' => 'baidu', 'store_id' => 8,
+$baidu_phone = ['name' => 'baizeyd', 'store_id' => 8,
     'amount' => [
         10 => [['goods_id' => 6245, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
                ['goods_id' => 6245, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
@@ -96,5 +96,5 @@ $baidu_phone = ['name' => 'baidu', 'store_id' => 8,
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
-    ['name' => 'baidu', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
+    ['name' => 'baizeyd', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
 $config['phone_providers'] = $phone_providers;

+ 2 - 2
helper/refill/RefillBase.php

@@ -118,7 +118,7 @@ class RefillBase
 
     private function retry(array $refill_info, array $order_info)
     {
-        if($this->mPolicy->can_retry($refill_info,$order_info)) {
+        if(!$this->mPolicy->can_retry($refill_info,$order_info)) {
             return false;
         }
 
@@ -355,7 +355,7 @@ class RefillBase
         }
 
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-        $order_state = $order_info['order_state'];
+        $order_state = intval($order_info['order_state']);
         if ($order_state !== ORDER_STATE_CANCEL && $order_state !== ORDER_STATE_SUCCESS) {
             return [false, "错误的订单状态,不能通知."];
         }

+ 1 - 1
helper/refill/api/lingzh/baizeyd/RefillCallBack.php

@@ -28,7 +28,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
     public function notify($params)
     {
-        $status = $params['status'];
+        $status = intval($params['status']);
         $order_sn = $params['orderId'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {

+ 2 - 1
helper/refill/api/lingzh/baizeyd/config.php

@@ -11,6 +11,7 @@ class config
 
     const APP_KEY = 'uECmTOFAY6RPCTtI';
     const APP_SECRET = 'jrzXEliY7FA8kP2reziMxlvBv9FgkJa6';
-    const NOTIFY_URL = "https://121.89.212.167/racc/callback/baizeyd.php";
+    const NOTIFY_URL = "http://121.89.212.167/racc/callback/baizeyd.php";
+//    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
     const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
 }

+ 1 - 4
helper/refill/policy/lingzh/policy.php

@@ -84,15 +84,13 @@ class policy extends ProviderManager implements IPolicy
         $mchid = $refill_info['mchid'];
         $mch_info = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
 
-
         [$params, $sign] = $this->body($state, $refill_info, $mch_info);
         $params['sgn'] = $sign;
 
         $notify_url = $refill_info['notify_url'];
-
         $resp = http_request($notify_url, $params, 'GET');
 
-        return $resp == "SUCCESS";
+        return $resp == "ok";
     }
 
     private function body($state, $refill_info, $mch_info)
@@ -112,7 +110,6 @@ class policy extends ProviderManager implements IPolicy
     private function sign($params, $key)
     {
         $body = "{$params['ord']}{$params['state']}{$key}";
-
         Log::record("notify body={$body}",Log::DEBUG);
         return strtoupper(md5($body));
     }

+ 7 - 1
test/TestDispatcher.php

@@ -53,9 +53,15 @@ class TestDispatcher extends TestCase
         }
     }
 
+    public function testNotify()
+    {
+        $logic = Logic('queue');
+        $logic->NotifyMerchantComplete(['order_id' => 6462,'manual' => true]);
+    }
+
     public function testAddoil()
     {
-        foreach (range(1,10,1) as $i) {
+        foreach (range(1,1,1) as $i) {
             queue\DispatcherClient::instance()->push('add',$this->make_order());
         }
     }

+ 45 - 11
test/TestRefill.php

@@ -100,23 +100,57 @@ class TestRefill extends TestCase
         }
     }
 
+
     public function testBaizePhone()
     {
 //        $providers = new refill\baizeyd\RefillPhone([]);
 //        $resp = $providers->add(17801048874, 5, 10, ['order_sn' => $this->make_sn()]);
-        $str = 'amount=10.00&orderId=92391614943913061206&phone=17801048874&payTime=2021-03-05+19%3A31%3A55&sign=bef6ae50319fb1e8cb3f21302f0abef8&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
-        $input['amount'] = 10.00;
-        $input['orderId'] = '92391614943913061206';
-        $input['phone'] = 17801048874;
-        $input['payTime'] = '2021-03-05 19:31:55';
-        $input['sign'] = 'bef6ae50319fb1e8cb3f21302f0abef8';
-        $input['appKey'] = 'uECmTOFAY6RPCTtI';
-        $input['payUrl'] = '';
-        $input['statusDes'] = '支付失败';
-        $input['status'] = 7;
+        $str = 'amount=10.00&orderId=720668384771999671&phone=13911129867&payTime=2021-03-06+22%3A26%3A12&sign=94dfe83221f7768650e70cce08879b60&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
+        $input = $this->parse_request($str);
+
+//        $input['amount'] = 10.00;
+//        $input['orderId'] = '92391614943913061206';
+//        $input['phone'] = 17801048874;
+//        $input['payTime'] = '2021-03-05 19:31:55';
+//        $input['sign'] = 'bef6ae50319fb1e8cb3f21302f0abef8';
+//        $input['appKey'] = 'uECmTOFAY6RPCTtI';
+//        $input['payUrl'] = '';
+//        $input['statusDes'] = '支付失败';
+//        $input['status'] = 7;
         refill\RefillFactory::instance()->notify('baizeyd',$input);
     }
 
+    private function parse_request($squery)
+    {
+        if(empty($squery)) return [];
+
+        $result = [];
+        $params = preg_split('/&/', $squery);
+        foreach ($params as $pair)
+        {
+            if(empty($pair)) continue;
+
+            $kv = explode('=', $pair);
+            $count = count($kv);
+            if($count === 1) {
+                $key = $kv[0];
+                $val = "";
+            }
+            elseif($count === 2) {
+                $key = $kv[0];
+                $val = urldecode($kv[1]);
+            }
+            else {
+                continue;
+            }
+
+            if(!empty($key)) {
+                $result[$key] = $val;
+            }
+        }
+        return $result;
+    }
+
     public function testAmPhone()
     {
 //        $providers = new refill\aming\RefillPhone([]);
@@ -916,7 +950,7 @@ class TestRefill extends TestCase
         return $result;
     }
 
-    public function testNotify()
+    public function testNotifyx()
     {
         $mch_cache = rcache("merchant-notify" , 'refill-');
         $caches = empty($mch_cache['data']) ? [] : unserialize($mch_cache['data']);