xiaoyu před 3 roky
rodič
revize
b23a311a0a

+ 15 - 1
data/config/win/refill.ini.php

@@ -1350,6 +1350,19 @@ $tongykami_phone = ['name' => 'tongykami', 'store_id' => 79,'qualitys' => '3',
         ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi_phone = ['name' => 'zhenqi', 'store_id' => 82, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6761, 'price' => 9.85, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6762, 'price' => 19.7, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6763, 'price' => 29.55, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6764, 'price' => 49.25, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6765, 'price' => 98.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6766, 'price' => 197, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6767, 'price' => 295.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6768, 'price' => 492.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1403,7 +1416,8 @@ $phone_providers = [
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
     ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
-    ['name' => 'tongykami', 'cfg' => $tongykami_phone]
+    ['name' => 'tongykami', 'cfg' => $tongykami_phone],
+    ['name' => 'zhenqi', 'cfg' => $zhenqi_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
data/config/xyz/refill.ini.php

@@ -1350,6 +1350,19 @@ $tongykami_phone = ['name' => 'tongykami', 'store_id' => 79,'qualitys' => '3',
         ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi_phone = ['name' => 'zhenqi', 'store_id' => 82, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6761, 'price' => 9.85, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6762, 'price' => 19.7, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6763, 'price' => 29.55, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6764, 'price' => 49.25, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6765, 'price' => 98.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6766, 'price' => 197, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6767, 'price' => 295.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6768, 'price' => 492.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1403,7 +1416,8 @@ $phone_providers = [
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
     ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
-    ['name' => 'tongykami', 'cfg' => $tongykami_phone]
+    ['name' => 'tongykami', 'cfg' => $tongykami_phone],
+    ['name' => 'zhenqi', 'cfg' => $zhenqi_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
data/config/xyzadm/refill.ini.php

@@ -1350,6 +1350,19 @@ $tongykami_phone = ['name' => 'tongykami', 'store_id' => 79,'qualitys' => '3',
         ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi_phone = ['name' => 'zhenqi', 'store_id' => 82, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 6761, 'price' => 9.85, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6762, 'price' => 19.7, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6763, 'price' => 29.55, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6764, 'price' => 49.25, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6765, 'price' => 98.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6766, 'price' => 197, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6767, 'price' => 295.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6768, 'price' => 492.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1403,7 +1416,8 @@ $phone_providers = [
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
     ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
-    ['name' => 'tongykami', 'cfg' => $tongykami_phone]
+    ['name' => 'tongykami', 'cfg' => $tongykami_phone],
+    ['name' => 'zhenqi', 'cfg' => $zhenqi_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 58 - 0
helper/refill/api/xyz/zhenqi/RefillCallBack.php

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\zhenqi;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhenqi/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;
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v) {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= "app_secret=".config::APP_SECRET;
+        return strtoupper(md5($body));
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['out_trade_no'];
+        $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 === 1) {
+            $data['official_sn'] = strtolower($params['sp_order_no']) == 'null' ? '' : $params['sp_order_no'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 2) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 148 - 0
helper/refill/api/xyz/zhenqi/RefillPhone.php

@@ -0,0 +1,148 @@
+<?php
+
+namespace refill\zhenqi;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhenqi/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 $card_type, int $amount, string $order_sn)
+    {
+        $params['type'] = 1;
+        $params['account_type'] = 1;
+        $params['mobile'] = $phone;
+        $params['out_trade_no'] = $order_sn;
+        $params['product_id'] = config::product_code[$amount];
+        $params['time_stamp'] = time();
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
+        if(empty($params['product_id'])) {
+            return [false, '商品编号获取失败', false];
+        }
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+        $params = json_encode($params);
+        $params = $this->encrypt($params);
+
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } else {
+                $status = intval($resp['status']);
+                if($status === 1) {
+                    $data = $this->decrypt($resp['data']['json_data']);
+                    Log::record("zhenqi add status 0 data:{$data}", Log::DEBUG);
+                    $data = json_decode($data,true);
+                    return [true, $data['out_trade_no'], false];
+                } else {
+                    $sub_code = $resp['sub_code'];
+                    if(($sub_code >= 100 && $sub_code <= 200) || $sub_code == 102) {
+                        $data = $this->decrypt($resp['data']['json_data']);
+                        Log::record("zhenqi add status 1 sub_code:{$sub_code}, data:{$data}", Log::DEBUG);
+                        $data = json_decode($data,true);
+                        return [true, $data['out_trade_no'], false];
+                    }else {
+                        return [false, $resp['info'], false];
+                    }
+                }
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['out_trade_no'] = $refill_info['order_sn'];
+        $params['time_stamp'] = time();
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+        $params = $this->encrypt($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['status'] == 1)
+            {
+                $data = $this->decrypt($resp['data']['json_data']);
+                Log::record("zhenqi order query status 1 data:{$data}", Log::DEBUG);
+                $data = json_decode($data,true);
+                $status = intval($data['status']);
+                if ($status === 1) {
+                    $updata['official_sn'] = $data['sp_order_no'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 2) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['sub_code'] == 1210)
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['info']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v) {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= "app_secret=".config::APP_SECRET;
+        return strtoupper(md5($body));
+    }
+
+    //加密
+    private function encrypt($encrypt)
+    {
+        $key = substr(openssl_digest(openssl_digest(config::TOKEN, 'sha1', true), 'sha1', true), 0, 16);
+        $data = openssl_encrypt($encrypt, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
+        return base64_encode($data);
+    }
+
+    //解密
+    private function decrypt($decrypt)
+    {
+        $key = substr(openssl_digest(openssl_digest(config::TOKEN, 'sha1', true), 'sha1', true), 0, 16);
+        return openssl_decrypt($decrypt, 'AES-128-ECB', $key);
+    }
+}

+ 13 - 0
helper/refill/api/xyz/zhenqi/account.txt

@@ -0,0 +1,13 @@
+token = fa7bc0380c16f1f78c7ca1cd7bd3fe17
+
+secret = 6f1f78
+
+appkey :yezi 
+
+https://cainiaomerchant.stpetrol.com/
+
+yezi
+123456
+
+
+接口地址:https://www.showdoc.com.cn/fanlicainiao?page_id=6621636142087435

+ 22 - 0
helper/refill/api/xyz/zhenqi/config.php

@@ -0,0 +1,22 @@
+<?php
+namespace refill\zhenqi;
+
+class config
+{
+    //api https://www.showdoc.com.cn/fanlicainiao?page_id=6621636142087435
+    //985 2
+    const APP_KEY = 'yezi';
+    const ORDER_URL = 'https://cainiaoapi.fanli.com/cnapi/cebbank/getCouponCodeV2?app_key='.self::APP_KEY;
+    const QUERY_URL = 'https://cainiaoapi.fanli.com/cnapi/cebbank/getRechargeOrder?app_key='.self::APP_KEY;
+
+    const APP_SECRET = '6f1f78';
+    const TOKEN = 'fa7bc0380c16f1f78c7ca1cd7bd3fe17';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zhenqi.php";
+    const ExtHeaders = ['Content-Type: application/json; charset=utf-8'];
+
+    const product_code = [
+        50 => 'apihf_50',
+        100 => 'apihf_100',
+        200 => 'apihf_200',
+    ];
+}

+ 4 - 0
mobile/callback/refill_zhenqi.php

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

+ 10 - 0
test/TestRefill.php

@@ -636,6 +636,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('xiaoniu',$input);
     }
 
+    public function testZhenqi()
+    {
+        $providers = new refill\zhenqi\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->query(['order_sn' => '42611626267945146350']);
+        $data = '{"out_trade_no":"14001626266194932132","create_time":"1626266201","sp_order_no":"110103353232107142044550619272","status":"1","sign":"3C2F8ED40EEB9151D2117E2DA1FA64AA"}';
+        $input = json_decode($data, true);
+//        refill\RefillFactory::instance()->notify('zhenqi',$input);
+    }
+
     public function testPrice()
     {
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];