xiaoyu 3 år sedan
förälder
incheckning
00efacbc2c

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

@@ -1284,6 +1284,42 @@ $lingzhman48_phone = ['name' => 'lingzhman48', 'store_id' => 76, 'qualitys' => '
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$cangbu_phone = ['name' => 'cangbu', 'store_id' => 78,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6744, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6744, 'price' => 9.49, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 6745, 'price' => 19, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6745, 'price' => 18.89, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 6746, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6746, 'price' => 28.47, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 6747, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6747, 'price' => 47.45, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 6748, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6748, 'price' => 94.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 6749, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6749, 'price' => 188.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 6750, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6750, 'price' => 284.7, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 6751, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6751, 'price' => 474.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1335,7 +1371,8 @@ $phone_providers = [
     ['name' => 'yunlingds', 'cfg' => $yunlingds_phone],
     ['name' => 'lingzhman', 'cfg' => $lingzhman_phone],
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
-    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone]
+    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
+    ['name' => 'cangbu', 'cfg' => $cangbu_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 44 - 7
data/config/xyz/refill.ini.php

@@ -144,12 +144,12 @@ $feinimoshu_oil = ['name' => 'feinimoshu', 'store_id' => 57, 'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
-$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '5',
+$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '3',
     'amount' => [
-        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 5, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 5, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 5, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 5, 'card_type' => 'sinopec']]
+        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 3, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 3, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 3, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 3, 'card_type' => 'sinopec']]
     ],
     'period' => [], 'refill_type' => 'api'];
 
@@ -173,7 +173,7 @@ $config['oil_providers'] = $oil_providers;
 
 $beixt_phone = ['name' => 'beixt', 'store_id' => 8,'qualitys' => '1',
     'amount' => [
-        50  => [['goods_id' => 6295, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6295, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
         100 => [['goods_id' => 6296, 'price' => 97.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
         200 => [['goods_id' => 6297, 'price' => 195,  'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
@@ -1284,6 +1284,42 @@ $lingzhman48_phone = ['name' => 'lingzhman48', 'store_id' => 76, 'qualitys' => '
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$cangbu_phone = ['name' => 'cangbu', 'store_id' => 78,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6744, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6744, 'price' => 9.49, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 6745, 'price' => 19, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6745, 'price' => 18.89, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 6746, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6746, 'price' => 28.47, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 6747, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6747, 'price' => 47.45, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 6748, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6748, 'price' => 94.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 6749, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6749, 'price' => 188.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 6750, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6750, 'price' => 284.7, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 6751, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6751, 'price' => 474.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1335,7 +1371,8 @@ $phone_providers = [
     ['name' => 'yunlingds', 'cfg' => $yunlingds_phone],
     ['name' => 'lingzhman', 'cfg' => $lingzhman_phone],
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
-    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone]
+    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
+    ['name' => 'cangbu', 'cfg' => $cangbu_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 43 - 6
data/config/xyzadm/refill.ini.php

@@ -144,12 +144,12 @@ $feinimoshu_oil = ['name' => 'feinimoshu', 'store_id' => 57, 'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
-$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '5',
+$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '3',
     'amount' => [
-        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 5, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 5, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 5, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 5, 'card_type' => 'sinopec']]
+        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 3, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 3, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 3, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 3, 'card_type' => 'sinopec']]
     ],
     'period' => [], 'refill_type' => 'api'];
 
@@ -1284,6 +1284,42 @@ $lingzhman48_phone = ['name' => 'lingzhman48', 'store_id' => 76, 'qualitys' => '
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$cangbu_phone = ['name' => 'cangbu', 'store_id' => 78,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6744, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6744, 'price' => 9.49, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 6745, 'price' => 19, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6745, 'price' => 18.89, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 6746, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6746, 'price' => 28.47, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 6747, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6747, 'price' => 47.45, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 6748, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6748, 'price' => 94.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 6749, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6749, 'price' => 188.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 6750, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6750, 'price' => 284.7, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 6751, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6751, 'price' => 474.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1335,7 +1371,8 @@ $phone_providers = [
     ['name' => 'yunlingds', 'cfg' => $yunlingds_phone],
     ['name' => 'lingzhman', 'cfg' => $lingzhman_phone],
     ['name' => 'qijutang', 'cfg' => $qijutang_phone],
-    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone]
+    ['name' => 'lingzhman48', 'cfg' => $lingzhman48_phone],
+    ['name' => 'cangbu', 'cfg' => $cangbu_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

BIN
helper/refill/api/xyz/cangbu/APIdoc直冲.docx


+ 71 - 0
helper/refill/api/xyz/cangbu/RefillCallBack.php

@@ -0,0 +1,71 @@
+<?php
+namespace refill\cangbu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/cangbu/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)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if(false === $this->check_empty($val)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "key=".config::KEY;
+
+        return md5($content);
+    }
+
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['code']);
+        $order_sn = $params['tmporder'];
+        $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['voucher']) == 'null' ? '' : $params['voucher'];
+            $data['ch_trade_no'] = strtolower($params['orderno']) == 'null' ? '' : $params['orderno'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === -1) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 117 - 0
helper/refill/api/xyz/cangbu/RefillPhone.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace refill\cangbu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/cangbu/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['customerId'] = config::MCH_ID;
+        $params['timestamp'] = time();
+        $params['orderno'] = $order_sn;
+        $params['itemId'] = config::operator[$card_type];
+        $params['checkItemFacePrice'] = $amount;
+        $params['number'] = $phone;
+        $params['amt'] = 1;
+        $params['notify_url'] = config::NOTIFY_URL;
+        $params['overtime'] = 1;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, 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];
+            } elseif ($resp['code'] == 1) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['customerId'] = config::MCH_ID;
+        $params['timestamp'] = time();
+        $params['orderno'] = $refill_info['order_sn'];
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $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, '网络错误'];
+            }
+            if($resp['code'] == 1)
+            {
+                $status = $resp['data']['status'];
+                if ($status == 'success') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status == 'failed') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status == 'wait') {
+                    $order_state = ORDER_STATE_SEND;
+                }else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            }
+            elseif($resp['code'] == -1 && $resp['msg'] == '订单不存在')
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if(false === $this->check_empty($val)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "key=".config::KEY;
+
+        return md5($content);
+    }
+}

+ 6 - 0
helper/refill/api/xyz/cangbu/account.txt

@@ -0,0 +1,6 @@
+地址https://huadan.irecycle.top/   
+账户18500608333  
+密码123456
+
+mchid 112
+key zs53xG61NinhlrXskhR0xnAaOyM7yG

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

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace refill\cangbu;
+
+use mtopcard;
+class config
+{
+    //yd 950 dl949
+    const ORDER_URL = 'https://api.irecycle.top/queryBuy';
+    const QUERY_URL= 'https://api.irecycle.top/queryBizOrder';
+
+    const MCH_ID= '112';
+    const KEY = 'zs53xG61NinhlrXskhR0xnAaOyM7yG';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_cangbu.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'MOBILE',
+        mtopcard\ChinaUnicomCard  => 'UNICOM',
+        mtopcard\ChinaTelecomCard => 'TELECOM'
+    ];
+    const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded' , 'Accept: application/json;charset=UTF-8'];
+}

+ 4 - 0
mobile/callback/refill_cangbu.php

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

+ 10 - 0
test/TestRefill.php

@@ -485,6 +485,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('lingzhman48',$params);
     }
 
+    public function testcangbuPhone()
+    {
+        $providers = new refill\cangbu\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '35041626071052333060']);
+        $data = '{"customerId":"112","tmporder":"35041626071052333060","orderno":"s16260710607417944801112","number":"18500608333","money":"100","amount":"94.9000","code":"1","cardno":"","voucher":"110103307042107121424210550266","sign":"de463c3d389a4afe4a2c58257972121a"}';
+        $params = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('cangbu',$params);
+    }
+
     public function testTongluPhone()
     {
         $providers = new refill\tonglu\RefillPhone([]);