stanley-king 1 gadu atpakaļ
vecāks
revīzija
4e09b85358

+ 52 - 0
helper/refill/api/mh/suhu_normal/ReadMe.MD

@@ -0,0 +1,52 @@
+
+
+后台地址:http://merchant.sujiaofei.com:92
+用户编号:60907
+登录账号:15652921127
+登录密码:n82e471z9g
+签名密钥:xnx4uaqbmqg0f03e0ey62zn4zoxnackl
+
+
+
+
+全国移动话费100元的商品编号是:10010
+
+全国移动话费50元的商品编号是:10011
+
+全国移动话费30元的商品编号是:10012
+
+
+全国联通话费100元的商品编号是:10013
+
+全国联通话费50元的商品编号是:10014
+
+全国联通话费30元的商品编号是:10015
+
+全国联通话费20元的商品编号是:10016
+
+
+全国电信话费100元的商品编号是:10017
+
+全国电信话费50元的商品编号是:10018
+
+全国电信话费30元的商品编号是:10019
+
+
+#############################
+后台地址:http://merchant.sujiaofei.com:92
+用户编号:31899
+登录账号:13911220681
+登录密码:kwgfi6fm9e
+签名密钥:dvv0atra7egmbcji8wy07ba3dt0h7609
+
+
+沃支付产品编码:
+
+
+全国联通话费300元的商品编号是:10134
+
+全国联通话费200元的商品编号是:10133
+
+全国联通话费100元的商品编号是:10132
+
+全国联通话费50元的商品编号是:10131

+ 50 - 0
helper/refill/api/mh/suhu_normal/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\suhu_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/suhu_normal/config.php');
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = config::sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
+    public function notify($params): array
+    {
+
+        $order_sn = $params['merchant_no'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
+        $order_id = $order_info['order_id'];
+
+        $status = intval($params['recharge_status']);
+        if ($status === 3) {
+            $data['ch_trade_no'] = $params['order_no'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif (in_array($status,[4,5])) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_no']]);
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 191 - 0
helper/refill/api/mh/suhu_normal/RefillPhone.php

@@ -0,0 +1,191 @@
+<?php
+
+namespace refill\suhu_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/suhu_normal/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function add_params(int $phone, int $amount, string $order_sn, int $card_type): array
+    {
+        $signer = function ($params)
+        {
+            $body = "memberId={$params['memberId']}productId={$params['productId']}memberOrderId={$params['memberOrderId']}rechargeAccount={$params['rechargeAccount']}faceValue={$params['faceValue']}signkey=";
+            $body .= config::KEY;
+
+            return md5($body);
+        };
+
+        $sku_code = config::sku_code($card_type,$amount);
+        if(empty($sku_code)) {
+            return [];
+        }
+
+        $params = [
+            "memberId" => config::MEMBER_ID,
+            'productId' => $sku_code,
+            'memberOrderId' => $order_sn,
+            'rechargeAccount' => "$phone",
+            'faceValue' => "$amount"
+        ];
+
+        $params['sign'] = $signer($params);
+        return $params;
+    }
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
+
+        $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];
+            }
+
+            $code = $resp['code'];
+            if ($code === 100) {
+                return [true, $resp['rechargeOrderId'], false];
+            } elseif (in_array($code, config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif ($code === 999) {
+                $net_errno = "HTTP-$code";
+                return [false, $resp['msg'], true];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    private function query_params($refill_info)
+    {
+        $params = [
+            'memberId' => config::MEMBER_ID,
+            'memberOrderId' => $refill_info['order_sn'],
+            'requestDate' => date("Y-m-d H:i:s",time())
+        ];
+
+        $signer = function ($params)
+        {
+            $body = "memberId={$params['memberId']}rechargeOrderId=memberOrderId={$params['memberOrderId']}requestDate={$params['requestDate']}signkey=";
+            $body .= config::KEY;
+
+            return md5($body);
+        };
+
+        $params['sign'] = $signer($params);
+        return $params;
+    }
+
+    public function query($refill_info): array
+    {
+        $params = $this->query_params($refill_info);
+        $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, '系统错误', ''];
+            }
+
+            $official_sn = '';
+
+            $status = intval($resp['status']);
+            if($status === 1)
+            {
+                if(empty($resp['result'])) {
+                    return [false, '系统错误', ''];
+                }
+
+                $item = $resp['result'][0];
+
+                $code = $item['code'];
+                if($code == 200) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                elseif($code == 201) {
+                    $updata['official_sn'] = $item['supplyCert'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $official_sn = $item['supplyCert'];
+                    $order_state = ORDER_STATE_SUCCESS;
+                }
+                elseif(in_array($code,[202,203,204])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+            }
+            elseif($status === 2 and (time() - $refill_info['commit_time'] >= 600))
+            {
+                $order_state = ORDER_STATE_NOEXIST;
+            }
+            else {
+                return [false, $resp['msg']];
+
+            }
+
+            return [true, $order_state, $official_sn];
+        }
+    }
+
+    private function balance_params()
+    {
+        $params = [
+            'memberId' => config::MEMBER_ID,
+            'requestDate' => date("Y-m-d H:i:s", time())
+        ];
+
+        $signer = function ($params)
+        {
+            $body = "memberId={$params['memberId']}requestDate={$params['requestDate']}signkey=";
+            $body .= config::KEY;
+
+            return md5($body);
+        };
+
+        $params['sign'] = $signer($params);
+        return $params;
+    }
+    public function balance(): array
+    {
+        $params = $this->balance_params();
+        $resp = http_request(config::ORDER_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['status'] === 1) {
+                return [true, ncPriceFormat($resp['result']['money'])];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+}

+ 57 - 0
helper/refill/api/mh/suhu_normal/config.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace refill\suhu_normal;
+
+use mtopcard;
+
+class config
+{
+    const MEMBER_ID = '60907';
+    const KEY = 'xnx4uaqbmqg0f03e0ey62zn4zoxnackl';
+
+    const ORDER_URL = 'http://api2.sujiaofei.com/submitRechargeOrder';
+    const QUERY_URL = 'http://api2.sujiaofei.com/queryRechargeOrder';
+    const BALANCE_URL = 'http://api2.sujiaofei.com/queryRechargeMember';
+
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/suhu_normal.php";
+    const ERRCODES = [101, 102, 103, 104, 105, 106, 107, 108, 109];
+
+    private static $stStoreProducts = [
+        50  => [4 => 'G36211237846176976', 5 => 'G36211237856416056', 6 => 'G36211237851296016'],
+        100 => [4 => 'G36211237847712888', 5 => 'G36211237857952968', 6 => 'G36211237852832928'],
+        200 => [4 => 'G36211237849760104', 5 => 'G36211237859488880', 6 => 'G36211237854880144']
+    ];
+
+    public static function sign($params)
+    {
+        if (is_object($params)) { //对象转数组
+            $params = json_decode(json_encode($params), true);
+        }
+
+        $params['sign_key'] = config::KEY;
+        ksort($params);
+
+        $formatData = [];
+        foreach ($params as $k => $v) {
+            if (is_array($v) || is_object($v)) {
+                $v = json_encode($v, JSON_UNESCAPED_UNICODE);
+            }
+            if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
+                $formatData[] = "$k=$v";
+            }
+        }
+        $signStr = implode('&', $formatData);
+
+        return md5($signStr);
+    }
+
+    public static function sku_code($card_type, $amount)
+    {
+        if (array_key_exists($amount, self::$stStoreProducts)) {
+            if (array_key_exists($card_type, self::$stStoreProducts[$amount])) {
+                return self::$stStoreProducts[$amount][$card_type];
+            }
+        }
+        return false;
+    }
+}

BIN
helper/refill/api/mh/suhu_normal/速缴费话费下游充值接口文档V1.5.pdf