Kaynağa Gözat

lz weishengyjd

ayHaru 3 yıl önce
ebeveyn
işleme
532aa0024c

+ 30 - 0
data/config/lingzh/refill.ini.php

@@ -466,6 +466,35 @@ $weishengywt_phone = ['name' => 'weishengywt', 'store_id' => 54, 'qualitys' => '
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$weishengyjd_phone = ['name' => 'weishengyjd', 'store_id' => 56, 'qualitys' => '5',
+    'amount' => [
+        10 => [
+            ['goods_id' => 124, 'price' => 8.8, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        20 => [
+            ['goods_id' => 125, 'price' => 17.6, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        30 => [
+            ['goods_id' => 126, 'price' => 26.4, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 127, 'price' => 44, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 128, 'price' => 88, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 129, 'price' => 176, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        300 => [
+            ['goods_id' => 130, 'price' => 264, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        500 => [
+            ['goods_id' => 131, 'price' => 440, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
     ['name' => 'baizeyd', 'cfg' => $baizeyd],
     ['name' => 'aming', 'cfg' => $aming_phone],
@@ -485,5 +514,6 @@ $phone_providers = [
     ['name' => 'shengying', 'cfg' => $shengying_phone],
     ['name' => 'amingjdman', 'cfg' => $amingjdman_phone],
     ['name' => 'weishengywt', 'cfg' => $weishengywt_phone],
+    ['name' => 'weishengyjd', 'cfg' => $weishengyjd_phone],
 ];
 $config['phone_providers'] = $phone_providers;

+ 2 - 1
helper/fcgisrv/LZRAccServer.php

@@ -30,7 +30,8 @@ class LZRAccServer extends BaseServer
             'callback/lingzh/amingyd.php','callback/lingzh/chuka.php'  ,'callback/lingzh/amingjd.php',
             'callback/lingzh/legou.php'  ,'callback/lingzh/feiniao.php','callback/lingzh/fensheng.php',
             'callback/lingzh/riying.php' ,'callback/lingzh/wailing.php','callback/lingzh/weishengy.php',
-            'callback/lingzh/shengying.php','callback/lingzh/amingjdman.php','callback/lingzh/weishengywt.php'
+            'callback/lingzh/shengying.php','callback/lingzh/amingjdman.php','callback/lingzh/weishengywt.php',
+            'callback/lingzh/weishengyjd.php'
         ];
 
         $this->setExFiles($exfiles);

+ 50 - 0
helper/refill/api/lingzh/weishengyjd/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\weishengyjd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weishengyjd/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
+        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['nFlag']);
+        $order_sn = $params['szOrderId'];
+        $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['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, false,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 102 - 0
helper/refill/api/lingzh/weishengyjd/RefillPhone.php

@@ -0,0 +1,102 @@
+<?php
+
+namespace refill\weishengyjd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weishengyjd/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['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['nProductClass'] = 1;
+        $params['nProductType'] = 1;
+        $params['szTimeStamp'] = date("Y-m-d H:i:s");
+        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['szVerifyString'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, 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['nRtn'] == 0) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['szRtnCode'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            $status = intval($resp['nRtn']);
+            if ($status === 5012) {
+                $updata['official_sn'] = $resp['szRtnMsg'];
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($status === 5013) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($status, [5011,5019])) {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $status];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
+        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        return md5($content);
+    }
+}

+ 12 - 0
helper/refill/api/lingzh/weishengyjd/api.txt

@@ -0,0 +1,12 @@
+下单地址:http://47.96.251.76:10186/plat/api/old/submitorder
+
+查询地址:http://47.96.251.76:10186/plat/api/old/queryorder
+
+查询余额地址:http://47.96.251.76:10186/plat/api/old/queryBalance
+
+用户名:17335762432
+账户ID:200050
+密码 :123456
+秘钥:d906a871ca28442baecaa041d84a13f2
+
+http://47.96.251.76:10186/plat/index

+ 21 - 0
helper/refill/api/lingzh/weishengyjd/config.php

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace refill\weishengyjd;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.96.251.76:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.96.251.76:10186/plat/api/old/queryorder';
+
+    const USER_ID= '200050';
+    const KEY = 'd906a871ca28442baecaa041d84a13f2';
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/weishengyjd.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

BIN
helper/refill/api/lingzh/weishengyjd/增值业务接口文档V2.3.docx


BIN
helper/refill/api/lingzh/weishengyjd/接口状态码映射表.docx


+ 1 - 1
helper/refill/api/lingzh/weishengywt/RefillCallBack.php

@@ -41,7 +41,7 @@ class RefillCallBack implements refill\IRefillCallBack
             return [$order_id, true, false,true];
         }
         elseif ($status === 3) {
-            return [$order_id, false, true,true];
+            return [$order_id, false, false,true];
         }
         else {
             return [$order_id, false, false,false];

+ 4 - 0
racc/callback/lingzh/weishengyjd.php

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

+ 8 - 0
test/TestRefill.php

@@ -307,6 +307,14 @@ class TestRefill extends TestCase
 //        refill\RefillFactory::instance()->notify('weiyi',$params);
     }
 
+    public function testWeiyimanPhone()
+    {
+        $providers = new refill\weiyiman\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->query(['order_sn' => '47591620898269370373']);
+
+    }
+
     public function testTongluPhone()
     {
         $providers = new refill\tonglu\RefillPhone([]);