stanley-king 3 tahun lalu
induk
melakukan
351d310e80

+ 3 - 1
helper/refill/api/xyz/lingzhthird/RefillPhone.php

@@ -5,6 +5,7 @@ require_once(BASE_HELPER_RAPI_PATH . '/lingzhthird/config.php');
 
 use refill;
 use Log;
+use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -76,6 +77,7 @@ class RefillPhone extends refill\IRefillPhone
 
         $params = $this->req_params($order_sn,$product_code,$quantity);
         $params['mob'] = $card_no;
+        $params['amt'] = refill\util::ThirdRefillAmount;
         $params['card_type'] = 1;//账号类型1 手机号,2 QQ号,3 微信号
 
         $sign = $this->sign($params);
@@ -167,7 +169,7 @@ class RefillPhone extends refill\IRefillPhone
     private function sign($params)
     {
         $key = config::KEY;
-        $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'] . $key;
+        $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['product_code'] . $params['tim'] . $key;
         return strtoupper(md5($content));
     }
 

+ 79 - 0
mobile/control/refill.php

@@ -125,6 +125,85 @@ class refillControl extends merchantControl
         }
     }
 
+    private function check_third($params)
+    {
+        if(empty($params['product_code'])) {
+            return [false,'参数没有包含product_code'];
+        }
+
+        $pcode = $params['product_code'];
+        if($this->check_pcode($pcode)) {
+            return [false,"对应的产品编码{$pcode}"];
+        }
+
+        if(empty($params['quantity']) || intval($params['quantity']) < 1) {
+            return [false,"购买数量参数不存在,或者小于0"];
+        }
+
+        if(empty($params['notifyurl'])) {
+            return [false,'参数没有包含notifyurl'];
+        }
+        if(empty($params['order_sn'])) {
+            return [false,'参数没有包含贵方唯一订单号:order_sn'];
+        }
+
+        return [true,""];
+    }
+
+    private function check_pcode($pcode)
+    {
+        $mod_third = Model('thrid_refill');
+        $product = $mod_third->getProduct(['system_code' => $pcode]);
+        return !empty($product);
+    }
+
+    public function add_thirdOp()
+    {
+        [$success,$error] = $this->check_third($_GET);
+        if($success === false) {
+            return self::outerr(201,$error);
+        }
+
+        $amount = refill\util::ThirdRefillAmount;
+        $notify_url = $_GET['notifyurl'];
+        $mch_order = $_GET['order_sn'];   //对方的order编号
+
+        $product_code = $_GET['product_code'];
+        $card_no = $_GET['cardno'] ?? '';
+        $quantity = $_GET['quantity'];
+        $third_card_type = $_GET['card_type'] ?? 1;
+
+        //三方充值没有质量
+        $quality = 1;
+        $card_type = mtopcard\ThirdRefillCard;
+
+        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
+            return self::outerr(205,"客户订单号重复或者为空.");
+        }
+
+        $params = ['mchid' => $this->mchid(),
+            'buyer_id' => $this->adminid(),
+            'amount' => $amount,
+            'mch_order' => $mch_order,
+            'notify_url' => $notify_url,
+            'org_quality' => $quality,
+            'card_type' => $card_type,
+            'card_no' => $card_no,
+            'product_code' => $product_code,
+            'quantity' => $quantity,
+            'third_card_type' => $third_card_type
+        ];
+
+        $state = refill\util::push_addthird($params);
+        if ($state === true) {
+            return self::outsuccess(['state' => true]);
+        } else {
+            $code = $state;
+            return self::outerr($code, '提交失败');
+        }
+    }
+
+
     private function can_refill($cardno)
     {
         $card_info = refill\util::read_card($cardno);

+ 3 - 0
racc/control/lzbase.php

@@ -83,6 +83,9 @@ class lzbaseControl
         elseif($op == 'query') {
             $content = $params['usr'] . $params['ord'];
         }
+        elseif($op == 'add_third') {
+            $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['product_code'] . $params['tim'];
+        }
         else {
             $content = 'error';
         }

+ 2 - 1
rdispatcher/codispatcher.php

@@ -20,7 +20,8 @@ require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
 require_once(BASE_PATH . '/processor.php');
 require_once(BASE_PATH . '/proxy.php');
 
-Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL]);
+//Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL]);
+Co::set(['hook_flags' => 0]);
 if (empty($_SERVER['argv'][1])) exit('parameter error');
 $process_count = intval($_SERVER['argv'][1]);
 

+ 1 - 1
test/TestRefillThird.php

@@ -66,7 +66,7 @@ class TestRefillThird extends TestCase
     public function testPushXYZThird()
     {
         $params = [ 'mchid' => 1092,
-            'buyer_id' => 6,
+            'buyer_id' => 60221,
             'amount' => refill\util::ThirdRefillAmount,
             'mch_order' => $this->make_sn(),
             'notify_url' => '',