Procházet zdrojové kódy

add qianqian channel

stanley-king před 4 roky
rodič
revize
2036d35584

+ 24 - 0
data/config/xyz/refill.ini.php

@@ -631,6 +631,29 @@ $jumi_phone = ['name' => 'jumi', 'store_id' => 47, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$qianqian_phone = ['name' => 'qianqian', 'store_id' => 48, 'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 73, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        20 => [
+            ['goods_id' => 74, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        30 => [
+            ['goods_id' => 75, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 76, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 77, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 78, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -660,5 +683,6 @@ $phone_providers = [
     ['name' => 'weiyiman', 'cfg' => $weiyiman_phone],
     ['name' => 'yonghe', 'cfg' => $yonghe_phone],
     ['name' => 'jumi', 'cfg' => $jumi_phone],
+    ['name' => 'qianqian', 'cfg' => $qianqian_phone],
 ];
 $config['phone_providers'] = $phone_providers;

+ 39 - 0
helper/refill/api/xyz/qianqian/RefillCallBack.php

@@ -0,0 +1,39 @@
+<?php
+
+
+namespace refill\qianqian;
+
+require_once(BASE_HELPER_RAPI_PATH . '/qianqian/config.php');
+
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+       return true;
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['consumerNo'];
+
+        $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 === '001') {
+            $data['official_sn'] = strtolower($params['voucherNo']) == 'null' ? '' : $params['voucherNo'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif (in_array($status,config::NotifyErrCodes)) {
+            return [$order_id, false, false, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 106 - 0
helper/refill/api/xyz/qianqian/RefillPhone.php

@@ -0,0 +1,106 @@
+<?php
+
+namespace refill\qianqian;
+
+require_once(BASE_HELPER_RAPI_PATH . '/qianqian/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, string $order_sn)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['consumerNo'] = $order_sn;
+        $params['mobile'] = $phone;
+        $params['timestamp'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $params['order_sn']);
+        $params['flowCode'] = config::ProductIDS[$card_type][$amount];
+        if (empty($params['flowCode'])) {
+            return [false, '产品编号错误', false];
+        }
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params);
+
+        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['status'] === '001') {
+                return [true, $resp['orderNo'], false];
+            } else {
+                return [false, $resp['status'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['consumerNo'] = $refill_info['order_sn'];
+        $params['account'] = config::ACCOUNT;
+        $params['timestamp'] = date("YmdHis");
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+
+            $status = $resp['status'];
+            if ($status === '001') {
+                $order_state = ORDER_STATE_SUCCESS;
+                $save['official_sn'] = strtolower($resp['voucherNo']) == 'null' ? '' : $resp['voucherNo'];
+                Model('refill_order')->edit($refill_info['order_id'], $save);
+            } elseif (in_array($status,config::QueryErrCodes)) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif ($status === '002') {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $status];
+            }
+
+            return [true, $order_state];
+        }
+    }
+
+    private function sign($params)
+    {
+        $data['account'] = $params['account'];
+        $data['timestamp'] = $params['timestamp'];
+        $data['secret'] = config::KEY;
+        asort($data);
+        $content = '';
+        foreach ($data as $key => $val){
+            $content .= $val;
+        }
+        return sha1($content);
+    }
+}

+ 42 - 0
helper/refill/api/xyz/qianqian/config.php

@@ -0,0 +1,42 @@
+<?php
+
+
+namespace refill\qianqian;
+use mtopcard;
+
+class config
+{
+    const ORDER_URL = 'http://47.99.65.204/flow-receiver/fee/recharge';
+    const QUERY_URL = 'http://47.99.65.204/flow-receiver/fee/query/single';
+    const NOTIFY_URL = BASE_SITE_URL . '/mobile/callback/qianqian.php';
+
+    const ACCOUNT = 'lz16888';
+    const KEY = '5ea089c7f54a4ee692cfe8a84fcaee4b';
+
+    const ProductIDS = [
+        mtopcard\ChinaMobileCard  => [
+            10 => 'CMCCALLr10r', 20 => 'CMCCALLr20r', 30 => 'CMCCALLr30r',
+            50 => 'CMCCALLr50r', 100 => 'CMCCALLr100r', 200 => 'CMCCALLr200r'
+        ],
+        mtopcard\ChinaUnicomCard  => [
+            10 => 'CUCCALLr10r', 20 => 'CUCCALLr20r', 30 => 'CUCCALLr30r',
+            50 => 'CUCCALLr50r', 100 => 'CUCCALLr100r', 200 => 'CUCCALLr200r'
+        ],
+        mtopcard\ChinaTelecomCard => [
+            10 => 'CTCCALLr10r', 20 => 'CTCCALLr20r', 30 => 'CTCCALLr30r',
+            50 => 'CTCCALLr50r', 100 => 'CTCCALLr100r', 200 => 'CTCCALLr200r'
+        ]
+    ];
+
+    const AddErrCodes = [
+        '003','004','005','006','007','008','009','010','011','012','013','014','015','016','017','018','019','020','021','022','023','024','025','027','028','098','099'
+    ];
+
+    const NotifyErrCodes = [
+        '003','004','005','006','007','008','015','016','017','018','019','020','021','022','023','025','027','028','098','099'
+    ];
+
+    const QueryErrCodes = [
+        '003','004','005','006','007','008','015','016','017','018','019','020','021','022','023','024','025','026','027','028','098','099'
+    ];
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 3 - 0
helper/refill/api/xyz/qianqian/琳珠网络科技话费接口充值协议.doc


binární
helper/refill/api/xyz/qianqian/琳珠网络科技话费接口状态码详解.docx


+ 10 - 0
mobile/callback/qianqian.php

@@ -0,0 +1,10 @@
+<?php
+
+$content = $_SERVER['post_content'];
+
+$inputs = json_decode($content,true);
+foreach ($inputs as $input) {
+    refill\util::push_notify('qianqian',$input);
+}
+
+echo ('SUCCESS');