Browse Source

add phone refill

stanley-king 4 years ago
parent
commit
1fbb81d537

+ 0 - 4
data/config/dev/base.ini.php

@@ -10,15 +10,11 @@ define('BONUS_EXPIRY_DATE',true);
 define('USE_BONUS_RATE',false);
 define('SERVER_TYPE','panda');
 
-//define('COOKIE_DOMAIN','xyzshops.cn');
-//$SRV_HOST = 'https://www.xyzshops.cn';
-
 define('COOKIE_DOMAIN','192.168.1.220');
 
 $SRV_HOST = 'http://192.168.1.220';
 $REMOTE_IMG_HOST = $SRV_HOST;
 
-
 $config = [];
 $config['base_site_url']        = $SRV_HOST;
 $config['client_site_url']      = $SRV_HOST;

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

@@ -9,15 +9,13 @@ $suhc_oil = ['name' => 'suhc','store_id' => 8,'card_type' => ['sinopec'],
         2000=> ['goods_id' => 6230,'price' => 1976]],
     'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
 $oil_providers = ['suhc' => $suhc_oil];
-
 $config['oil_providers'] = $oil_providers;
 
 
-$suhc_oil = ['name' => 'beixt','store_id' => 9,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
+$beixt_phone = ['name' => 'beixt','store_id' => 9,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
     'amount' => [50 => ['goods_id' => 6231,'price' => 48.75],
         100 => ['goods_id' => 6232,'price' => 97.5],
         200 => ['goods_id' => 6233,'price' => 195]],
     'refill_type' => 'api'];
-$phone_providers = ['beixt' => $suhc_oil];
-
+$phone_providers = ['beixt' => $beixt_phone];
 $config['phone_providers'] = $phone_providers;

+ 0 - 2
helper/refill/IRefillOil.php

@@ -8,8 +8,6 @@ use Log;
 
 abstract class IRefillOil extends IRefill
 {
-    protected $mCardType = [];
-
     public function __construct($cfgs)
     {
         parent::__construct($cfgs);

+ 1 - 3
helper/refill/IRefillPhone.php

@@ -9,8 +9,6 @@ use Log;
 
 abstract class IRefillPhone extends IRefill
 {
-    protected $mCardType = [];
-
     public function __construct($cfgs)
     {
         parent::__construct($cfgs);
@@ -23,7 +21,7 @@ abstract class IRefillPhone extends IRefill
             } elseif ($ctype == "chinaunicom") {
                 $this->mCardType[] = mtopcard\ChinaUnicomCard;
             } elseif($ctype == "chinatelecom") {
-                $this->mCardType = mtopcard\ChinaTelecomCard;
+                $this->mCardType[] = mtopcard\ChinaTelecomCard;
             } else {
                 Log::record("Phone Provider has no name", Log::ERR);
             }

+ 6 - 3
helper/refill/RefillFactory.php

@@ -64,7 +64,7 @@ class RefillFactory
                 $this->mPhoneProvider[] = $provider;
             }
             else {
-                Log::record("Oil Provider has no name",Log::ERR);
+                Log::record("Phone Provider has no name",Log::ERR);
 
             }
         }
@@ -86,7 +86,7 @@ class RefillFactory
     private function find_oil(int $amount,int $card_type) : array
     {
         $providers = [];
-        foreach ($this->mPhoneProvider as $provider)
+        foreach ($this->mOilProvider as $provider)
         {
            $name = $provider->name();
            [$success,$err]  = $provider->check($amount,$card_type);
@@ -104,7 +104,7 @@ class RefillFactory
     private function find_phone(int $amount,int $card_type) : array
     {
         $providers = [];
-        foreach ($this->mOilProvider as $provider)
+        foreach ($this->mPhoneProvider as $provider)
         {
             $name = $provider->name();
             [$success,$err]  = $provider->check($amount,$card_type);
@@ -124,6 +124,9 @@ class RefillFactory
         if($chname == "suhc") {
             $caller = new suhc\RefillCallBack();
         }
+        elseif($chname == "beixt") {
+            $caller = new beixt\RefillCallBack();
+        }
         else {
             return false;
         }

+ 6 - 1
helper/refill/beixt/RefillPhone.php

@@ -6,8 +6,13 @@ require_once(BASE_HELPER_PATH . '/refill/beixt/config.php');
 use refill;
 use Log;
 
-class RefillPhone extends refill\IRefillOil
+class RefillPhone extends refill\IRefillPhone
 {
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
     private function req_params(int $phone, int $amount ,string $order_sn)
     {
         $params['phone'] = $phone;

+ 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';
 }

+ 0 - 4
mobile/beixt_notify.php

@@ -1,4 +0,0 @@
-<?php
-Log::record('notify receive',Log::DEBUG);
-Log::record("post data : {$_POST}" , Log::DEBUG);
-echo ('ok');

+ 6 - 0
mobile/refill_beixt.php

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

+ 14 - 3
test/TestRefill.php

@@ -26,7 +26,6 @@ class TestRefill extends TestCase
         $providers = refill\RefillFactory::instance()->find_providers(100,mtopcard\SinopecCard);
         if(empty($providers)) return false;
 
-
         $input = [
             'order_sn' => '200649600557717656',
             'notifyurl' => "https://www.xyzshops.cn/mobile/signature.php"
@@ -48,15 +47,27 @@ class TestRefill extends TestCase
     public function testAddoil()
     {
         $params = ['mchid' => 1,
-            'cardno' => '1000111100021211884',
+            'cardno' => '1000111100020445281',
             'amount' => "100",
             "act"=>"refill",
-            "op"=>"addoil",
+            "op"=>"add",
             'order_sn' => "13281474",
             'notifyurl'=> BASE_SITE_URL . "/mobile/suhc_notify.php"];
         $this->send($params);
     }
 
+    public function testAddPhoe()
+    {
+        $params = ['mchid' => 1,
+            'cardno' => '15120035568',
+            'amount' => "100",
+            "act"=>"refill",
+            "op"=>"add",
+            'order_sn' => "13281475",
+            'notifyurl'=> BASE_SITE_URL . "/mobile/beixt_notify.php"];
+        $this->send($params);
+    }
+
     public function testSuhcCB()
     {
         $notifyurl = BASE_SITE_URL . "/mobile/refill_suhc.php";