Kaynağa Gözat

lingzh provider juzhuo oil

ayHaru 3 yıl önce
ebeveyn
işleme
4d38dbbddd

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

@@ -23,9 +23,19 @@ $haohao_oil = ['name' => 'haohao', 'store_id' => 58,'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$juzhuo_oil = ['name' => 'juzhuo', 'store_id' => 59,'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 146, 'price' => 97, 'quality' => 1, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 147, 'price' => 194, 'quality' => 1, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 148, 'price' => 485, 'quality' => 1, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 149, 'price' => 970, 'quality' => 1, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 //充值渠道配置表
 $oil_providers = [
     ['name' => 'haohao', 'cfg' => $haohao_oil],
+    ['name' => 'juzhuo', 'cfg' => $juzhuo_oil],
 ];
 $config['oil_providers'] = $oil_providers;
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 363 - 607
data/config/win/refill.ini.php


+ 75 - 0
helper/refill/api/lingzh/juzhuo/RefillCallBack.php

@@ -0,0 +1,75 @@
+<?php
+
+
+namespace refill\juzhuo;
+
+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 check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+
+        $body = "";
+        $i = 0;
+        foreach ($params as $k => $v) {
+            if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
+                if ($i == 0) {
+                    $body .= "{$k}" . "=" . urldecode($v);
+                } else {
+                    $body .= "&" . "{$k}" . "=" . urldecode($v);
+                }
+                $i++;
+            }
+        }
+
+        $body .= "&key=" . config::KEY;
+        return md5($body);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['onlystr'];
+
+        $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) {
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, false, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 104 - 0
helper/refill/api/lingzh/juzhuo/RefillOil.php

@@ -0,0 +1,104 @@
+<?php
+namespace refill\juzhuo;
+
+require_once(BASE_HELPER_RAPI_PATH . '/juzhuo/config.php');
+
+use refill;
+
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(string $card_no,int $card_type,int $amount,array $other)
+    {
+        $params['channelsort'] = 'OIL_CARD';
+        $params['cardtype'] = config::operator[$card_type];
+        $params['orgid'] = config::ORGID;
+        $params['amt'] = $amount;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        $params['onlystr'] = $other['order_sn'];
+        $params['cardno'] = $card_no;
+        return $params;
+    }
+
+    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);
+    }
+
+    public function add($card_no,$card_type,$amount,$input)
+    {
+        $params = $this->req_params($card_no,$card_type,$amount,$input);
+        $sign = $this->sign($params);
+        $params['sign'] = $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['state'] == 0) {
+                return [true, $resp['data'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orgid'] = config::ORGID;
+        $params['onlystr'] = $refill_info['order_sn'];
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_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,'系统错误'];
+            }
+            elseif($resp['state'] == 0)
+            {
+                $status = $resp['data']['status'];
+                if ($status == 2) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status == 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status == 0){
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+}

+ 18 - 0
helper/refill/api/lingzh/juzhuo/config.php

@@ -0,0 +1,18 @@
+<?php
+namespace refill\juzhuo;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://120.25.107.85/order/createOrder.html';
+    const ORDER_QUERY_URL = 'http://120.25.107.85/order/queryOrderInfo.html';
+
+    const KEY = '0lIIdRQbvKdpQgyJ5TCryj';
+    const ORGID = 6095171500;
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/juzhuo.php";
+    const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded'];
+    const operator = [
+        mtopcard\PetroChinaCard  => 'PetroChina',
+        mtopcard\SinopecCard  => 'Sinoepc',
+    ];
+}

+ 4 - 0
helper/refill/api/lingzh/juzhuo/开户资料.txt

@@ -0,0 +1,4 @@
+后台:http://120.25.107.85
+账户:15756480554
+密码:LZ88888888
+秘钥:0lIIdRQbvKdpQgyJ5TCryj

BIN
helper/refill/api/lingzh/juzhuo/接口文档.docx


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

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

+ 10 - 0
test/TestRefill.php

@@ -396,6 +396,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('haohao',$data);
     }
 
+    public function testJuzhuoOil()
+    {
+        $providers = new refill\juzhuo\RefillOil([]);
+//        $resp = $providers->add(1000111100021211884, 2, 200, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->query(['order_sn' => '20121621578185774451']);
+        $data = '{"channelsort":"OIL_CARD","channelno":"185176855832","onlystr":"20121621578185774451","channel":"JD","sign":"34dce9329fef7997c134987247ac6ee1","amt":"200","notifyurl":"https:\/\/www.xyzshops.cn\/mobile\/signature.php","cardtype":"Sinoepc","cardno":"1000111100021211884","orgid":"6095171500","account":"","status":"2"}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('juzhuo',$input);
+    }
+
     public function testZeheng()
     {
         $providers = new refill\zeheng\RefillOil([]);