Browse Source

Merge branch 'refill_queue' of 39.97.239.116:gyfl/xyzshop into refill_queue

stanley-king 4 years ago
parent
commit
5d256c5edc

+ 17 - 18
data/config/win/refill.ini.php

@@ -16,27 +16,12 @@ $config['refill_specs'] = [
 $oil_providers = [];
 $config['oil_providers'] = $oil_providers;
 
-define('ZERO_GOODS_ID', 8);
 
-$baidu_phone = ['name' => 'baizeyd', 'store_id' => 32,
-    'amount' => [
-        10 => [['goods_id' => 1, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
-            ['goods_id' => 1, 'price' => 9.61, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 1, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
-
-        20 => [['goods_id' => 2, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 3, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],
-        50 => [['goods_id' => 4, 'price' => 47.55, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 5,'price' => 95.1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$baidu_phone = ['name' => 'baizeyd', 'store_id' => 32,
+$baizeyd = ['name' => 'baizeyd', 'store_id' => 32,
     'amount' => [
 //        10 => [['goods_id' => 1, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 1, 'price' => 9.61, 'quality' => 1, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 1, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
-
         30 => [['goods_id' => 3, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 3, 'price' => 28.8, 'quality' => 2, 'card_type' => 'chinamobile']],
         50 => [['goods_id' => 4, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -51,7 +36,7 @@ $baidu_phone = ['name' => 'baizeyd', 'store_id' => 32,
 
 $aming_phone = ['name' => 'aming', 'store_id' => 34,
     'amount' => [
-        10 => [['goods_id' => 9, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        10 => [['goods_id'  => 9, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
             ['goods_id' => 9, 'price' => 9.6, 'quality' => 2, 'card_type' => 'chinaunicom,chinatelecom']],
         20 => [['goods_id' => 10, 'price' => 19, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
             ['goods_id' => 10, 'price' => 19.2, 'quality' => 2, 'card_type' => 'chinaunicom,chinatelecom']],
@@ -133,11 +118,25 @@ $wuchen_phone = ['name' => 'wuchen', 'store_id' => 37,
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yibaoyd = ['name' => 'yibao', 'store_id' => 32,
+    'amount' => [
+        30 => [['goods_id' => 3, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 3, 'price' => 28.8, 'quality' => 2, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 4, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 4, 'price' => 48, 'quality' => 2, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 5, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 5, 'price' => 96, 'quality' => 2, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 6, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6, 'price' => 192, 'quality' => 2, 'card_type' => 'chinamobile']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
-    ['name' => 'baizeyd', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'baizeyd', 'cfg' => $baizeyd, 'opened' => true, 'sort' => 1],
     ['name' => 'aming', 'cfg' => $aming_phone, 'opened' => true, 'sort' => 1],
     ['name' => 'binghc', 'cfg' => $binghc_phone, 'opened' => true, 'sort' => 1],
     ['name' => 'ruishun', 'cfg' => $ruishun_phone, 'opened' => true, 'sort' => 1],
     ['name' => 'wuchen', 'cfg' => $wuchen_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'yibao', 'cfg' => $yibaoyd, 'opened' => true, 'sort' => 1],
 ];
 $config['phone_providers'] = $phone_providers;

+ 24 - 8
helper/refill/api/lingzh/yibao/RefillCallBack.php

@@ -12,7 +12,9 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -22,14 +24,16 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $content  = $params['result'] . $params['msg'];
-        if(is_null($params['order'])) {
-            $content .= "null";
-        }else{
-            $content .= $params['order'];
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if (false === $this->check_empty($val) && "@" != substr($val, 0, 1)) {
+                $content .= "{$key}={$val}&";
+            }
         }
-        $content .= $params['phone_no'] . $params['amount'] . $params['op_no'] . config::KEY;
-        return md5($content);
+        $content .= "key=".config::KEY;
+
+        return strtoupper(md5($content));
     }
 
 
@@ -56,4 +60,16 @@ class RefillCallBack implements refill\IRefillCallBack
             return [$order_id, false, false,false];
         }
     }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
 }

+ 2 - 2
helper/refill/api/lingzh/yibao/RefillPhone.php

@@ -51,7 +51,7 @@ class RefillPhone extends refill\IRefillPhone
 
     public function query($refill_info)
     {
-        $params['orderNo'] = $refill_info['order_sn'];
+        $params['tradeNo'] = $refill_info['ch_trade_no'];
         $params['appId'] = config::APP_ID;
         $params['sign'] = $this->sign($params);
 
@@ -95,7 +95,7 @@ class RefillPhone extends refill\IRefillPhone
         }
         $content .= "key=".config::KEY;
 
-        return md5($content);
+        return strtoupper(md5($content));
     }
 
     private function getproductNo(int $amount)

+ 5 - 2
test/TestRefill.php

@@ -214,8 +214,11 @@ class TestRefill extends TestCase
     public function testYibaoPhone()
     {
         $providers = new refill\yibao\RefillPhone([]);
-        $resp = $providers->add('13699279618', 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $providers->query(['order_sn' => '790668630498425006']);
+//        $resp = $providers->add('13699279618', 5, 30, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->query(['ch_trade_no' => '31215002972142736']);
+//        $str = '{"amount":"30","carrierOrderNo":null,"mobile":"13699279618","orderNo":"27961615532426088043","orderStatus":3,"sign":"012BA0B093A0473D7DD1634A8356DCB1","tradeNo":"31215002972142736"}';
+//        $data = json_decode($str,true);
+//        refill\RefillFactory::instance()->notify('yibao',$data);
     }
 
     public function testWeisPhone()