xiaoyu 3 yıl önce
ebeveyn
işleme
ae147ce56c

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

@@ -1376,6 +1376,15 @@ $yunsuoyaofs_phone = ['name' => 'yunsuoyaofs', 'store_id' => 83, 'qualitys' => '
         500 => [['goods_id' => 6776, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
+    'amount' => [
+        30 => [['goods_id' => 6777, 'price' => 29.88, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6778, 'price' => 49.8, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6779, 'price' => 99.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6780, 'price' => 199.2, '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],
@@ -1431,7 +1440,8 @@ $phone_providers = [
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
     ['name' => 'tongykami', 'cfg' => $tongykami_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
-    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone]
+    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
+    ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1376,6 +1376,15 @@ $yunsuoyaofs_phone = ['name' => 'yunsuoyaofs', 'store_id' => 83, 'qualitys' => '
         500 => [['goods_id' => 6776, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
+    'amount' => [
+        30 => [['goods_id' => 6777, 'price' => 29.88, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6778, 'price' => 49.8, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6779, 'price' => 99.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6780, 'price' => 199.2, '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],
@@ -1431,7 +1440,8 @@ $phone_providers = [
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
     ['name' => 'tongykami', 'cfg' => $tongykami_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
-    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone]
+    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
+    ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1376,6 +1376,15 @@ $yunsuoyaofs_phone = ['name' => 'yunsuoyaofs', 'store_id' => 83, 'qualitys' => '
         500 => [['goods_id' => 6776, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$zhenqi1m_phone = ['name' => 'zhenqi1m', 'store_id' => 84, 'qualitys' => '2',
+    'amount' => [
+        30 => [['goods_id' => 6777, 'price' => 29.88, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6778, 'price' => 49.8, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6779, 'price' => 99.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6780, 'price' => 199.2, '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],
@@ -1431,7 +1440,8 @@ $phone_providers = [
     ['name' => 'cangbu', 'cfg' => $cangbu_phone],
     ['name' => 'tongykami', 'cfg' => $tongykami_phone],
     ['name' => 'zhenqi', 'cfg' => $zhenqi_phone],
-    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone]
+    ['name' => 'yunsuoyaofs', 'cfg' => $yunsuoyaofs_phone],
+    ['name' => 'zhenqi1m', 'cfg' => $zhenqi1m_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\zhenqi1m;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhenqi1m/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];
+        }
+    }
+}

+ 150 - 0
helper/refill/api/xyz/zhenqi1m/RefillPhone.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace refill\zhenqi1m;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zhenqi1m/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);
+            $status = intval($resp['status']);
+
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            }
+            elseif ($status === 1) {
+                return [true, '', false];
+            }
+            else
+            {
+                $sub_code = $resp['sub_code'];
+                if (($sub_code >= 100 && $sub_code <= 200)) {
+                    return [true, '', 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']);
+                $info   = $resp['info'];
+
+                if ($resp['sub_code'] != 0) {
+                    return [false, $info];
+                }
+
+                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, $info];
+                }
+                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);
+    }
+}

+ 12 - 0
helper/refill/api/xyz/zhenqi1m/account.txt

@@ -0,0 +1,12 @@
+token = 63644a7ae53218e7900f755265acf96a
+secret = e53218
+
+appkey = yezi1
+
+https://cainiaomerchant.stpetrol.com/
+
+yezi1
+123456
+
+
+接口地址:https://www.showdoc.com.cn/fanlicainiao?page_id=6621636142087435

+ 23 - 0
helper/refill/api/xyz/zhenqi1m/config.php

@@ -0,0 +1,23 @@
+<?php
+namespace refill\zhenqi1m;
+
+class config
+{
+    //api https://www.showdoc.com.cn/fanlicainiao?page_id=6621636142087435
+    //996 2
+    const APP_KEY = 'yezi1';
+    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 = 'e53218';
+    const TOKEN = '63644a7ae53218e7900f755265acf96a';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zhenqi1m.php";
+    const ExtHeaders = ['Content-Type: application/json; charset=utf-8'];
+
+    const product_code = [
+        30 => 'apihf_30',
+        50 => 'apihf_50',
+        100 => 'apihf_100',
+        200 => 'apihf_200',
+    ];
+}

+ 4 - 0
mobile/callback/refill_zhenqi1m.php

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

+ 10 - 0
test/TestRefill.php

@@ -656,6 +656,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('yunsuoyaofs',$input);
     }
 
+    public function testZhenqi1m()
+    {
+        $providers = new refill\zhenqi1m\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '45611626334593130605']);
+        $data = '{"out_trade_no":"45611626334593130605","create_time":"1626334606","sp_order_no":"202107152200117311004426885635","status":"1","sign":"CF8EB902F60B76591C898C991361BB4D"}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('zhenqi1m',$input);
+    }
+
     public function testPrice()
     {
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];