Browse Source

Merge branch 'rch' into raccount

zhaoming 1 year ago
parent
commit
df353191a2

+ 39 - 4
data/config/xyz/refill.ini.php

@@ -3621,8 +3621,8 @@ $yiqian_phone = ['name' => 'yiqian', 'store_id' => 158,'qualitys' => '2',
     'amount' => [
         10 => [
             ['goods_id' => 7333, 'price' => 10.315, 'quality' => 2, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7333, 'price' => 10.07, 'quality' => 2, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 7333, 'price' => 9.985, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7333, 'price' => 10.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7333, 'price' => 10.6, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
         20 => [
@@ -3633,7 +3633,7 @@ $yiqian_phone = ['name' => 'yiqian', 'store_id' => 158,'qualitys' => '2',
 
         30 => [
             ['goods_id' => 7335, 'price' => 30.69, 'quality' => 2, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7335, 'price' => 30.12, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7335, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7335, 'price' => 30.648, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
@@ -3663,7 +3663,7 @@ $yiqian_phone = ['name' => 'yiqian', 'store_id' => 158,'qualitys' => '2',
 
         500 => [
             ['goods_id' => 7340, 'price' => 511.5, 'quality' => 2, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7340, 'price' => 500.75, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7340, 'price' => 502.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7340, 'price' => 503, 'quality' => 2, 'card_type' => 'chinatelecom']
         ]
     ],
@@ -9885,6 +9885,39 @@ $yeyekami_phone = ['name' => 'yeyekami', 'store_id' => 376, 'qualitys' => '3',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yiqiandq_phone = ['name' => 'yiqiandq', 'store_id' => 377,'qualitys' => '2',
+    'amount' => [
+//        10 => [['goods_id' => 8953, 'price' => 10.6, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+//        20 => [['goods_id' => 8954, 'price' => 19.97, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+//        30 => [['goods_id' => 8955, 'price' => 30.648, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+//        50 => [['goods_id' => 8956, 'price' => 50.5, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+        100 => [['goods_id' => 8957, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+        200 => [['goods_id' => 8958, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+        300 => [['goods_id' => 8959, 'price' => 300.3, 'quality' => 2, 'card_type' => 'chinatelecom']],
+
+        500 => [['goods_id' => 8960, 'price' => 500.5, 'quality' => 2, 'card_type' => 'chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$yiqiandq_fs_phone = ['name' => 'yiqiandq_fs', 'store_id' => 378, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 8961, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        20 => [['goods_id' => 8962, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        30 => [['goods_id' => 8963, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        50 => [['goods_id' => 8964, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        100 => [['goods_id' => 8965, 'price' => 100, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        200 => [['goods_id' => 8966, 'price' => 200, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        300 => [['goods_id' => 8967, 'price' => 300, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']],
+        500 => [['goods_id' => 8968, 'price' => 500, 'quality' => 2, 'card_type' => 'chinamobile, chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10182,6 +10215,8 @@ $phone_providers = [
     ['name' => 'kainuo_60m', 'cfg' => $kainuo_60m_phone],
     ['name' => 'yuntian_high', 'cfg' => $yuntian_high_phone],
     ['name' => 'yeyekami', 'cfg' => $yeyekami_phone],
+    ['name' => 'yiqiandq', 'cfg' => $yiqiandq_phone],
+    ['name' => 'yiqiandq_fs', 'cfg' => $yiqiandq_fs_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 13 - 0
helper/refill/api/xyz/yiqiandq/API.MD

@@ -0,0 +1,13 @@
+
+## 壹谦(电渠)
+
+- 商户号:M00631eKXy
+- 登陆密码 :SJ5iHpH7
+- MD5KEY :hGcGrZQwbBIbtHqy2BSqu8YxiMXuDM9w
+- 接口文档地址: http://118.31.46.58:8080/doc/api.html
+- 生产服务器地址: http://118.31.46.58:8080/
+- 客户后台地址: http://47.114.180.82:7777/#
+
+## 店铺
+- 账号:yiqiandq
+- 密码:yiqiandq67890

+ 46 - 0
helper/refill/api/xyz/yiqiandq/RefillCallBack.php

@@ -0,0 +1,46 @@
+<?php
+namespace refill\yiqiandq;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqiandq/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params): string
+    {
+        $content = $params['extOrderId'] . $params['orderId'] . $params['state'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params): array
+    {
+        $status = intval($params['state']);
+        $order_sn = $params['extOrderId'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status === 4) {
+            $official_sn = $params['exchangeTraded'];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['orderId']]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 5) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 136 - 0
helper/refill/api/xyz/yiqiandq/RefillPhone.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace refill\yiqiandq;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqiandq/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $card_no, int $card_type, string $order_sn, int $amount): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $params['amt'] = $amount;
+        $params['phone'] = $card_no;
+        $operator = config::operator[$card_type] ?? false;
+        if ($operator === false){
+            return [];
+        }
+
+        $params['phoneBelong'] = $operator;
+        $params['extOrderId'] = $order_sn;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+        $params['sourceType'] = '全国';
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->req_params($card_no, $card_type, $params['order_sn'], $amount);
+        if (empty($params)) {
+            return [false, '非电渠', false];
+        }
+
+        $sign = $this->sign($params);
+        $params['md5'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $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];
+            } elseif ($resp['code'] === 0) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $params['extOrderId'] = $refill_info['order_sn'];
+        $content = $params['extOrderId'] . $params['merchantId'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST');
+        if (empty($resp)) {
+            return [false, '网络错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            elseif ($resp['code'] === 0)
+            {
+                $offical_sn = '';
+                $status = intval($resp['data']);
+                if ($status === 4) {
+                    $offical_sn = $resp['ext']['exchangeTraded'];
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 5) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === -1 && time() - $refill_info['commit_time'] > 900){
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $status, $offical_sn];
+                }
+
+                return [true, $order_state, $offical_sn];
+            }
+            else
+            {
+                return [false, $resp['msg'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $content = $params['merchantId'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if ($resp['code'] === 0) {
+                return [true, $resp['ext']['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params): string
+    {
+        $content = $params['amt'] . $params['extOrderId'] . $params['merchantId'] . $params['notifyUrl'] . $params['phone'];
+        $content .= config::KEY;
+        return md5($content);
+    }
+}

+ 17 - 0
helper/refill/api/xyz/yiqiandq/config.php

@@ -0,0 +1,17 @@
+<?php
+namespace refill\yiqiandq;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://118.31.46.58:8080/api/huafei/makeOrder';
+    const QUERY_URL = 'http://118.31.46.58:8080/api/queryOrder';
+    const BALANCE_URL = 'http://118.31.46.58:8080/api/queryBalance';
+
+    const MCH_ID = 'M00631eKXy';
+    const KEY = 'hGcGrZQwbBIbtHqy2BSqu8YxiMXuDM9w';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yiqiandq.php";
+    const operator = [
+        mtopcard\ChinaTelecomCard => '电信'
+    ];
+}

BIN
helper/refill/api/xyz/yiqiandq_fs/20231016河南电信调价函.png


BIN
helper/refill/api/xyz/yiqiandq_fs/20231016移动调价函.png


+ 13 - 0
helper/refill/api/xyz/yiqiandq_fs/API.MD

@@ -0,0 +1,13 @@
+
+## 壹谦分省
+
+- 商户号:M00632CPeH
+- 登陆密码 :crxG5AM2
+- MD5KEY :x3zrHw9KY2aNGcgIDIrwzEUzTHp5rdTG
+- 接口文档地址: http://118.31.46.58:8080/doc/api.html
+- 生产服务器地址: http://118.31.46.58:8080/
+- 客户后台地址: http://47.114.180.82:7777/#
+- 
+## 店铺
+- 账号:yiqiandq_fs
+- 密码:yiqiandq_fs67890

+ 46 - 0
helper/refill/api/xyz/yiqiandq_fs/RefillCallBack.php

@@ -0,0 +1,46 @@
+<?php
+namespace refill\yiqiandq_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqiandq_fs/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params): string
+    {
+        $content = $params['extOrderId'] . $params['orderId'] . $params['state'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params): array
+    {
+        $status = intval($params['state']);
+        $order_sn = $params['extOrderId'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status === 4) {
+            $official_sn = $params['exchangeTraded'];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['orderId']]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 5) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 140 - 0
helper/refill/api/xyz/yiqiandq_fs/RefillPhone.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace refill\yiqiandq_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqiandq_fs/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function goods($quality, int $amount, int $card_type, $regin_no, $other): array
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
+        if($goods_id <= 0) return [0,0];
+        $key = "{$card_type}-{$amount}-{$regin_no}";
+        $price = config::Price[$key];
+        if(empty($price)) {
+            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($price)];
+        }
+    }
+
+    private function req_params(int $card_no, int $card_type, string $order_sn, int $amount): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $params['amt'] = $amount;
+        $params['phone'] = $card_no;
+        $params['phoneBelong'] = config::operator[$card_type];
+        $params['extOrderId'] = $order_sn;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->req_params($card_no, $card_type, $params['order_sn'], $amount);
+        $sign = $this->sign($params);
+        $params['md5'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $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];
+            } elseif ($resp['code'] === 0) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $params['extOrderId'] = $refill_info['order_sn'];
+        $content = $params['extOrderId'] . $params['merchantId'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST');
+        if (empty($resp)) {
+            return [false, '网络错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            elseif ($resp['code'] === 0)
+            {
+                $offical_sn = '';
+                $status = intval($resp['data']);
+                if ($status === 4) {
+                    $offical_sn = $resp['ext']['exchangeTraded'];
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 5) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === -1 && time() - $refill_info['commit_time'] > 900){
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $status, $offical_sn];
+                }
+
+                return [true, $order_state, $offical_sn];
+            }
+            else
+            {
+                return [false, $resp['msg'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['merchantId'] = config::MCH_ID;
+        $content = $params['merchantId'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if ($resp['code'] === 0) {
+                return [true, $resp['ext']['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params): string
+    {
+        $content = $params['amt'] . $params['extOrderId'] . $params['merchantId'] . $params['notifyUrl'] . $params['phone'];
+        $content .= config::KEY;
+        return md5($content);
+    }
+}

+ 31 - 0
helper/refill/api/xyz/yiqiandq_fs/config.php

@@ -0,0 +1,31 @@
+<?php
+namespace refill\yiqiandq_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://118.31.46.58:8080/api/huafei/makeOrder';
+    const QUERY_URL = 'http://118.31.46.58:8080/api/queryOrder';
+    const BALANCE_URL = 'http://118.31.46.58:8080/api/queryBalance';
+
+    const MCH_ID = 'M00632CPeH';
+    const KEY = 'x3zrHw9KY2aNGcgIDIrwzEUzTHp5rdTG';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yiqiandq_fs.php";
+    const operator = [
+        mtopcard\ChinaMobileCard => '移动',
+        mtopcard\ChinaUnicomCard => '联通',
+        mtopcard\ChinaTelecomCard => '电信'
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-10-6" => 9.78, "4-20-6" => 19.56, "4-30-6" => 29.34, "4-50-6" => 48.9, "4-100-6" => 97.8, "4-200-6" => 195.6, "4-300-6" => 293.4, "4-500-6" => 489,//辽宁 6
+        "4-30-19" => 30.03, "4-50-19" => 50.05, "4-100-19" => 100.1, "4-200-19" => 200.2, "4-300-19" => 300.3, "4-500-19" => 500.5,//广东 19
+        "4-10-29" => 9.89, "4-20-29" => 19.78, "4-30-29" => 29.67, "4-50-29" => 49.45, "4-100-29" => 98.9, "4-200-29" => 197.8, "4-300-29" => 296.7, "4-500-29" => 494.5,//青海 29
+        "4-10-24" => 10.12, "4-20-24" => 20.12, "4-30-24" => 30.18, "4-50-24" => 50.05, "4-100-24" => 100.1, "4-200-24" => 200.2, "4-300-24" => 300.3, "4-500-24" => 500.5,//贵州 24
+
+        //电信
+        "6-10-16" => 10.3, "6-20-16" => 20.3, "6-30-16" => 30.3, "6-50-16" => 50.3, "6-100-16" => 100.3, "6-200-16" => 200.3, "6-300-16" => 300.3, "6-500-16" => 500.3,//河南 16
+    ];
+}

+ 4 - 0
mobile/callback/refill_yiqiandq.php

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

+ 4 - 0
mobile/callback/refill_yiqiandq_fs.php

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

+ 15 - 0
test/TestRefill.php

@@ -5705,6 +5705,21 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('yeyekami');
         $resp = $provider->balance();
     }
+
+    public function testyiqiandq()
+    {
+        $provider = $this->getProvider('yiqiandq');
+//        $resp = $provider->balance();
+        $resp = $provider->add(18074608795, 6, 10, ['order_sn' => $this->make_sn()]);
+    }
+
+    public function testyiqiandq_fs()
+    {
+        $provider = $this->getProvider('yiqiandq_fs');
+//        $resp = $provider->balance();
+        $resp = $provider->add(18074608795, 6, 10, ['order_sn' => $this->make_sn()]);
+    }
+
 }