stanley-king 4 роки тому
батько
коміт
3e6058c928
3 змінених файлів з 38 додано та 21 видалено
  1. 24 16
      data/config/prod/refill.ini.php
  2. 4 3
      helper/request_helper.php
  3. 10 2
      test/TestRefill.php

+ 24 - 16
data/config/prod/refill.ini.php

@@ -1,29 +1,37 @@
 <?php
 
-$suhc_oil = ['name' => 'suhc','store_id' => 7,'card_type' => ['sinopec'],
-    'amount' => [100 => ['goods_id' => 6290,'price' => 96.8],
-        200 => ['goods_id' => 6291,'price' => 193.6],
-        500 => ['goods_id' => 6292,'price' => 484],
-        1000=> ['goods_id' => 6293,'price' => 968],
-        2000=> ['goods_id' => 6294,'price' => 1936]],
-    'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
+$suhc_oil = ['name' => 'suhc', 'store_id' => 7, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6290, 'price' => 96.8],
+        200 => ['goods_id' => 6291, 'price' => 193.6],
+        500 => ['goods_id' => 6292, 'price' => 484],
+        1000 => ['goods_id' => 6293, 'price' => 968],
+        2000 => ['goods_id' => 6294, 'price' => 1936]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'api'];
 
 $oil_providers = ['suhc' => $suhc_oil];
 $config['oil_providers'] = $oil_providers;
 
 
-$beixt_phone = ['name' => 'beixt','store_id' => 8,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6295,'price' => 48.75],
-        100 => ['goods_id' => 6296,'price' => 97.5],
-        200 => ['goods_id' => 6297,'price' => 195]],
+$beixt_phone = ['name' => 'beixt', 'store_id' => 8, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6295, 'price' => 48.75],
+        100 => ['goods_id' => 6296, 'price' => 97.5],
+        200 => ['goods_id' => 6297, 'price' => 195]],
     'refill_type' => 'api'];
 
-$bxtwt_phone = ['name' => 'bxtwt','store_id' => 10,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6298,'price' => 48],
-        100 => ['goods_id' => 6299,'price' => 96],
-        200 => ['goods_id' => 6300,'price' => 192]],
+$bxtwt_phone = ['name' => 'bxtwt', 'store_id' => 10, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6298, 'price' => 48],
+        100 => ['goods_id' => 6299, 'price' => 96],
+        200 => ['goods_id' => 6300, 'price' => 192]],
     'refill_type' => 'api'];
 
 
-$phone_providers = ['beixt' => $beixt_phone , 'bxtwt' => $bxtwt_phone];
+$bjb_phone = ['name' => 'bjb', 'store_id' => 12, 'card_type' => ['chinaunicom', 'chinatelecom'],
+    'amount' => [30 => ['goods_id' => 6301, 'price' => 28.65],
+        50 => ['goods_id' => 6302, 'price' => 47.75],
+        100 => ['goods_id' => 6303, 'price' => 95.5],
+        200 => ['goods_id' => 6304, 'price' => 191]],
+    'refill_type' => 'api'];
+
+
+$phone_providers = ['beixt' => $beixt_phone, 'bxtwt' => $bxtwt_phone]; //'bjb' => $bjb_phone
 $config['phone_providers'] = $phone_providers;

+ 4 - 3
helper/request_helper.php

@@ -268,10 +268,11 @@ class request_helper
         $content_type = strtolower(self::content_type());
         Log::record("type = {$content_type}, content={$content}",Log::DEBUG);
 
-        $formtypes = ['application/x-www-form-urlencoded','text/xml','text/html'];
-        if(empty($content_type) || in_array($content_type,$formtypes)) {
+//        $formtypes = ['application/x-www-form-urlencoded','text/xml','text/html'];
+
+//        if(empty($content_type) || in_array($content_type,$formtypes)) {
             self::parse_formurl($squery,$method);
-        }
+//        }
     }
 
     static private function parse_formurl($squery,$method)

+ 10 - 2
test/TestRefill.php

@@ -44,12 +44,20 @@ class TestRefill extends TestCase
     {
         $providers = refill\RefillFactory::instance();
     }
+    private function make_sn()
+    {
+        return mt_rand(1000,9999)
+            . sprintf('%010d',time())
+            . sprintf('%06d', (float) microtime() * 1000000);
+    }
 
     public function testBJBAddPhone()
     {
-        global $config;
         $providers = new refill\bjb\RefillPhone([]);
-        $resp = $providers->add(18500608333,4,50,['order_sn' => '350662047177951150']);
+        for ($i = 5; $i > 0; --$i)
+        {
+            $resp = $providers->add(18500608333,4,30,['order_sn' => $this->make_sn()]);
+        }
     }
 
     public function testRefillPhone()