Explorar o código

fengye provider

ayHaru %!s(int64=4) %!d(string=hai) anos
pai
achega
94117739f8

+ 10 - 10
data/config/win/refill.ini.php

@@ -658,16 +658,16 @@ $qianqian_phone = ['name' => 'qianqian', 'store_id' => 48, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
-$fengye_phone = ['name' => 'fengye', 'store_id' => 44, 'qualitys' => '1',
-    'amount' => [
-        10 => [['goods_id' => 6504, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6505, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6506, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6507, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6508, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6509, 'price' => 189, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6510, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6511, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+$fengye_phone = ['name' => 'fengye', 'store_id' => 49, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6533, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6534, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6535, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6536, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6537, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6538, 'price' => 189, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6539, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6540, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 10 - 9
data/config/xyz/refill.ini.php

@@ -658,16 +658,16 @@ $qianqian_phone = ['name' => 'qianqian', 'store_id' => 48, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
-$fengye_phone = ['name' => 'fengye', 'store_id' => 44, 'qualitys' => '1',
+$fengye_phone = ['name' => 'fengye', 'store_id' => 49, 'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 6504, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6505, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6506, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6507, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6508, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6509, 'price' => 189, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6510, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6511, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+        10 => [['goods_id' => 6533, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6534, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6535, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6536, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6537, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6538, 'price' => 189, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6539, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6540, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
@@ -701,5 +701,6 @@ $phone_providers = [
     ['name' => 'yonghe', 'cfg' => $yonghe_phone],
     ['name' => 'jumi', 'cfg' => $jumi_phone],
     ['name' => 'qianqian', 'cfg' => $qianqian_phone],
+    ['name' => 'fengye', 'cfg' => $fengye_phone],
 ];
 $config['phone_providers'] = $phone_providers;

+ 72 - 0
helper/refill/api/xyz/fengye/RefillCallBack.php

@@ -0,0 +1,72 @@
+<?php
+
+
+namespace refill\fengye;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fengye/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($data)
+    {
+        $str = "";
+        ksort($data);
+        $data['queryUrl'] = urlencode($data['queryUrl']);
+        foreach($data as $k => $v){
+            if($this->check_empty($v) === false){
+                $str .= $v;
+            }
+        }
+        return md5($str.config::KEY);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['orderNo'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+        $order_id = $order_info['order_id'];
+
+        if ($status === 2) {
+            $data['official_sn'] = strtolower($params['ticketNo']) == 'null' ? '' : $params['ticketNo'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif (in_array($status, [0,1,3])) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 111 - 0
helper/refill/api/xyz/fengye/RefillPhone.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace refill\fengye;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fengye/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    {
+        $params['supplierId'] = config::USER_ID;
+        $params['orderNo'] = $order_sn;
+        $params['company'] = config::operator[$card_type];
+        $params['amount'] = $amount;
+        $params['phoneNo'] = $phone;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $card_type, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === 200) {
+                return [true, $resp['data']['orderId'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['supplierId'] = config::USER_ID;
+        $params['orderNo'] = $refill_info['order_sn'];
+        $params['phoneNo'] = $refill_info['card_no'];
+        $params['company'] = config::operator[$refill_info['card_type']];
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['code'] == 200)
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 2) {
+                    $updata['official_sn'] = $resp['data']['ticketNo'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0,1])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+
+        }
+    }
+
+    private function sign($data)
+    {
+        $str = "";
+        ksort($data);
+        foreach($data as $k => $v){
+            if($this->check_empty($v) === false){
+                $str .= $v;
+            }
+        }
+        return md5($str.config::KEY);
+    }
+}

+ 3 - 0
helper/refill/api/xyz/fengye/api.txt

@@ -0,0 +1,3 @@
+后台:http://47.118.36.120/supplier/
+账号:yzdz02    
+密码:12345678

+ 21 - 0
helper/refill/api/xyz/fengye/config.php

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace refill\fengye;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.118.36.120:9009/prod-produce/api/provide';
+    const QUERY_URL = 'http://47.118.36.120:9009/prod-produce/api/query';
+
+    const USER_ID = '13';
+    const KEY = '2579695a64e30345e23fdb53aebb7b6c';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_fengye.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+}

+ 4 - 0
mobile/callback/refill_fengye.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('fengye',$_POST);
+echo ('success');

+ 5 - 2
test/TestRefill.php

@@ -562,8 +562,11 @@ class TestRefill extends TestCase
     public function testFengyePhone()
     {
         $providers = new refill\fengye\RefillPhone([]);
-        $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
-        $resp = $providers->query(['order_sn' => '12161619768293529384']);
+//        $resp = $providers->add(18074608795, 6, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '53511620355988978053', 'card_no' => 18074608795, 'card_type' => 6]);
+        $data = '{"amount":"50.00","orderNo":"53511620355988978053","supplierId":"13","orderId":"S20210507105309202749918513","notifyTime":"1620356062365","sign":"371260b007f2e64d86873ce3ede67fa3","discountAmount":"2.50","phoneNo":"18074608795","queryUrl":"https:\/\/www.189.cn\/client\/wap\/wapproject\/wapclient\/feecharge\/feecharge_result.html?sessionid=e896e66c2e134ba3b469b26df34d12d1","payType":"wechat","ticketNo":"1000000083421050710397228882","company":"dx","status":"2"}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('fengye',$input);
     }
 
     public function testLuqianPhone()