stanley-king 4 年 前
コミット
499940c5d3

+ 9 - 0
helper/mtopcard/mtopcard.php

@@ -79,6 +79,15 @@ function scard_type($card_type)
     elseif ($card_type == SinopecCard) { //中石化
         return 'sinopec';
     }
+    elseif ($card_type == ChinaMobileCard) { //中石化
+        return 'chinamobile';
+    }
+    elseif($card_type == ChinaUnicomCard ) { //手机卡
+        return 'chinaunicom';
+    }
+    elseif($card_type == ChinaTelecomCard) { //手机卡
+        return 'chinatelecom';
+    }
     elseif($card_type == PhoneCard) { //手机卡
         return 'phone';
     }

+ 17 - 11
helper/refill/ProviderManager.php

@@ -18,10 +18,7 @@ use Exception;
 
 class ProviderManager
 {
-    protected $mOilProvider;
-    protected $mPhoneProvider;
     protected $mProviderNames;
-
     protected $mAllQMapPTS;
     protected $mProviders;
     protected $mSpecTypes;
@@ -216,16 +213,25 @@ class ProviderManager
 
     public function goods()
     {
-        global $config;
+        //$this->mSpecTypes[$quality]["{$type}-{$spec}"][] = $name;
+        $result = [];
+        foreach ($this->mSpecTypes as $qMaps)
+        {
+            foreach ($qMaps as $type_spec => $names) {
+                $data = explode('-',$type_spec);
+                $type = intval($data[0]);
+                $spec = intval($data[1]);
+
+                $result[$type][] = $spec;
+            }
+        }
 
-        $oil = $this->combine_goods($config['oil_providers'], 1);
-        $phone = $this->combine_goods($config['phone_providers'], 2);
+        $type_specs = [];
+        foreach ($result as $type => $value) {
+            $type_specs[$type] = array_unique($value);
+        }
 
-        return array_merge($oil, $phone);
-    }
-    public function providers()
-    {
-        return ['oil' => $this->mOilProvider,'phone' => $this->mPhoneProvider];
+        return $type_specs;
     }
 
     public function getCaller($chname)

+ 0 - 5
helper/refill/RefillBase.php

@@ -43,11 +43,6 @@ class RefillBase
         return $this->mPolicy->goods();
     }
 
-    public function providers()
-    {
-        return $this->mPolicy->providers();
-    }
-
     public function notify($chname, $input)
     {
         $caller = $this->mPolicy->getCaller($chname);

+ 24 - 27
mobile/control/merchant_refill.php

@@ -15,23 +15,24 @@ class merchant_refillControl extends mbMerchantControl
     {
         $goods = refill\RefillFactory::instance()->goods();
 
-        $oil_amount = $phone_amount = [];
-        foreach ($goods as $type => $amounts)
+        $result = [];
+        foreach ($goods as $type => $specs)
         {
-            if($type == 'sinopec' || $type == 'petrochina') {
-                $oil_amount = array_merge($oil_amount,$amounts);
-            }
-            elseif($type == 'chinamobile' || $type == 'chinaunicom' || $type == 'chinatelecom'){
-                $phone_amount = array_merge($phone_amount,$amounts);
+            if($type == mtopcard\SinopecCard || $type == mtopcard\PetroChinaCard) {
+                foreach ($specs as $spec) {
+                    $result['oil_amount'][] = $spec;
+                }
             }
             else {
-                Log::record("goods err type:{$type}",Log::ERR);
+                foreach ($specs as $spec) {
+                    $result['phone_amount'][] = $spec;
+                }
             }
         }
 
-        $oil_amount = array_unique($oil_amount);
+        $oil_amount = array_unique($result['oil_amount']);
         sort($oil_amount);
-        $phone_amount = array_unique($phone_amount);
+        $phone_amount = array_unique($result['phone_amount']);
         sort($phone_amount);
 
         return self::outsuccess(['oil_amount' => $oil_amount,'phone_amount' => $phone_amount]);
@@ -53,16 +54,6 @@ class merchant_refillControl extends mbMerchantControl
             return [false,'卡类型无法识别'];
         }
 
-//        if($card_type === mtopcard\PetroChinaCard)
-//        {
-//            if(empty($params['idcard'])) {
-//                return [false,'中石油需要参数没有包含身份证号码:idcard'];
-//            }
-//            if(empty($params['card_name'])) {
-//                return [false,'参数没有包含身份证姓名:card_name'];
-//            }
-//        }
-
         return [true,""];
     }
 
@@ -84,9 +75,6 @@ class merchant_refillControl extends mbMerchantControl
             return self::outerr(errcode::ErrParamter, "卡号格式错误或未上传");
         }
 
-        $idcard = $params['idcard'] ?? '';
-        $card_name = $params['card_name'] ?? '';
-
         //成功个数、失败个数
         $success_no = $error_no = 0;
         $data = [];
@@ -103,13 +91,22 @@ class merchant_refillControl extends mbMerchantControl
             }
             else
             {
-                [$state, $err] = refill\RefillFactory::instance()->add($mchid, $merchant_info['admin_id'], $amount, $no, '', $idcard, $card_name, '',1,time(),0);
-                $arr['state'] = $state;
-                $arr['err'] = $err;
-                if($state === true) {
+                $params = [ 'mchid' => $this->mchid(),
+                    'buyer_id' => $this->adminid(),
+                    'amount' => $amount,
+                    'card_no' => $card_no,
+                    'mch_order' => "",
+                    'notify_url' => ""];
+
+                $ret = refill\util::push_add($params);
+                if($ret) {
+                    $arr['state'] = $ret;
+                    $arr['err'] = '';
                     $success_no++;
                 }
                 else {
+                    $arr['state'] = 202;
+                    $arr['err'] = '提交失败';
                     $error_no++;
                 }
             }

+ 1 - 0
mobile/util/errcode.php

@@ -115,6 +115,7 @@ class errcode //extends SplEnum
 
     const ErrSafeIp = 21000;
     const ErrOperation = 22000;
+    const ErrPushQueue = 23000;
 
     static function msg($code)
     {

+ 20 - 0
test/TestDispatcher.php

@@ -66,6 +66,26 @@ class TestDispatcher extends TestCase
         }
     }
 
+    public function testGoods()
+    {
+        $goods = refill\RefillFactory::instance()->goods();
+
+        $result = [];
+        foreach ($goods as $type => $specs)
+        {
+            if($type == mtopcard\SinopecCard || $type == mtopcard\PetroChinaCard) {
+                foreach ($specs as $spec) {
+                    $result['oil_amount'][] = $spec;
+                }
+            }
+            else {
+                $result['phone_amount'][] = $spec;
+            }
+        }
+
+        return $result;
+    }
+
     private function make_order()
     {
         $mchid = $this->mMchid;