stanley-king 4 лет назад
Родитель
Сommit
21ae7365a5

+ 1 - 1
data/config/win/base.ini.php

@@ -11,7 +11,7 @@ define('USE_BONUS_RATE',false);
 define('SERVER_TYPE','panda');
 define('CROSS_DOAMIN',true);
 define('COOKIE_DOMAIN','192.168.1.195');
-define('NET_IP','111.193.234.45');
+define('NET_IP','124.64.84.75');
 
 $SRV_HOST = 'http://192.168.1.195';
 $REMOTE_IMG_HOST = $SRV_HOST;

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

@@ -17,5 +17,14 @@ $beixt_phone = ['name' => 'beixt','store_id' => 9,'card_type' => ['chinamobile',
         100 => ['goods_id' => 6232,'price' => 97.5],
         200 => ['goods_id' => 6233,'price' => 195]],
     'refill_type' => 'api'];
-$phone_providers = ['beixt' => $beixt_phone];
+
+$xc_phone = ['name' => 'xc','store_id' => 10 , 'card_type' => ['chinamobile','chinaunicom','chinatelecom']];
+
+$beixts_phone = ['name' => 'beixts','store_id' => 11,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6231,'price' => 48.75],
+        100 => ['goods_id' => 6232,'price' => 97.5],
+        200 => ['goods_id' => 6233,'price' => 195]],
+    'refill_type' => 'api'];
+
+$phone_providers = ['beixt' => $beixt_phone , 'xc' => $xc_phone , 'beixts' => $beixts_phone];
 $config['phone_providers'] = $phone_providers;

+ 5 - 0
helper/refill/RefillFactory.php

@@ -16,6 +16,9 @@ require_once(BASE_HELPER_PATH . '/refill/CalcMerchantPrice.php');
 
 require_once(BASE_HELPER_PATH . '/refill/beixt/RefillPhone.php');
 require_once(BASE_HELPER_PATH . '/refill/beixt/RefillCallBack.php');
+
+require_once(BASE_HELPER_PATH . '/refill/beixts/RefillPhone.php');
+require_once(BASE_HELPER_PATH . '/refill/beixts/RefillCallBack.php');
 use Log;
 use mtopcard;
 use QueueClient;
@@ -163,6 +166,8 @@ class RefillFactory
             $caller = new suhc\RefillCallBack();
         }elseif ($chname == 'beixt'){
             $caller = new beixt\RefillCallBack();
+        }elseif ($chname == 'beixts'){
+            $caller = new beixts\RefillCallBack();
         }
         else {
             return false;

+ 47 - 0
helper/refill/beixts/RefillCallBack.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\beixts;
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+
+    public function verify($params) : bool
+    {
+        $sign = $this->sign($params);
+        if($params['sign'] == $sign) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $body = $params['order_number'];
+        $body .= $params['shipping_status'];
+        $body .= $params['tradeNo'];
+        $body .= config::API_CERT;
+        return strtolower(md5($body));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['shipping_status']);
+        $order_sn = $params['tradeNo'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if(empty($order_info)) {
+            return [false,false];
+        }
+
+        $order_id = $order_info['order_id'];
+        if($status === 1 || $status === 2) {
+            return [$order_id,true];
+        } else {
+            return [$order_id,false];
+        }
+    }
+}

+ 97 - 0
helper/refill/beixts/RefillPhone.php

@@ -0,0 +1,97 @@
+<?php
+namespace refill\beixts;
+
+require_once(BASE_HELPER_PATH . '/refill/beixts/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 ,string $order_sn)
+    {
+        $params['phone'] = $phone;
+        $params['product_id'] = $amount;
+        $params['tradeNo'] = $order_sn;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return json_encode($params);
+    }
+
+    public function add($card_no, $card_type,$amount,$params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no,$amount,$order_sn);
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: OrderCreate",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+        $resp = http_post_data(config::REQUEST_URL,$params,$header);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['ack'] == 'success') {
+                return [true,$resp['message']['order_number']];
+            }
+            else {
+                return [false,$resp['message']];
+            }
+        }
+    }
+
+    public function OrderQuery($order_number,$tradeNo){
+        $params['order_number'] = $order_number;
+        $params['tradeNo'] = $tradeNo;
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: OrderQuery",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+        $resp = http_post_data(config::REQUEST_URL,$params,$header);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['ack'] == 'success') {
+                return [true,$resp['message']];
+            }
+            else {
+                return [false,$resp['message']];
+            }
+        }
+    }
+
+    private function sign($time)
+    {
+        $ip = config::API_IP;
+        $cert = config::API_CERT;
+        $content = $ip.$time.$cert;
+
+        return md5($content);
+    }
+}

+ 14 - 0
helper/refill/beixts/config.php

@@ -0,0 +1,14 @@
+<?php
+
+
+namespace refill\beixts;
+
+
+class config
+{
+    const REQUEST_URL = 'http://8.129.76.127/APIHfKc/v2/';
+    const API_USER_NAME= '08aa9b2e2ef44b14bc6ac53fe8253b36';
+    const API_CERT = '44143b70ec8cca16cdb533e3c637f410';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const API_IP = NET_IP;
+}

+ 55 - 0
helper/refill/xc/RefillCallBack.php

@@ -0,0 +1,55 @@
+<?php
+
+
+namespace refill\xc;
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+
+    public function verify($params) : bool
+    {
+        $sign = $this->sign($params);
+        if($params['sign'] == $sign) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $body[] = $params['wt_orderid'];
+        $body[] = $params['Pay_iphone'];
+        $body[] = $params['wt_orderid'];
+        $body[] = $params['Pay_money'];
+
+        ksort($body);
+        $str = '';
+        foreach ($body as $key => $vo){
+            $str .= $vo . '&';
+        }
+        $str = strtolower(md5(rtrim($str,'&')));
+        $content = $str . config::KEY;
+        return strtolower(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['Pay_orderid'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if(empty($order_info)) {
+            return [false,false];
+        }
+
+        $order_id = $order_info['order_id'];
+        if($status === 1 || $status === 2) {
+            return [$order_id,true];
+        } else {
+            return [$order_id,false];
+        }
+    }
+}

+ 89 - 0
helper/refill/xc/RefillPhone.php

@@ -0,0 +1,89 @@
+<?php
+namespace refill\xc;
+
+require_once(BASE_HELPER_PATH . '/refill/xc/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 ,string $order_sn)
+    {
+//        $params['pay_iphone'] = $phone;
+//        $params['pay_orderid'] = $order_sn;
+//        $params['pay_memberid'] = config::NUMBER_ID;
+//        $params['pay_money'] = $amount;
+//        $params['pay_notify'] = config::NOTIFY_URL;
+        $params['pay_iphone'] = 1;
+        $params['pay_orderid'] = 520;
+        $params['pay_memberid'] = 10002;
+        $params['pay_money'] = 30;
+        $params['pay_notify'] = 'www.baidu.com';
+        return $params;
+    }
+
+    public function add($card_no, $card_type,$amount,$params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no,$amount,$order_sn);
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::ORDER_URL,$params,'POST');
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['code'] == 200 && $resp['result'] == 'success') {
+                return [true,$resp['result']];
+            }
+            else {
+                return [false,$resp['result']];
+            }
+        }
+    }
+
+    public function OrderQuery($order_number,$tradeNo){
+        $params['order_number'] = $order_number;
+        $params['pay_memberid'] = config::NUMBER_ID;
+        $sign = $this->sign($params);
+
+
+        $resp = http_post_data(config::QUERY_ORDER_URL,$params);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['ack'] == 'success') {
+                return [true,$resp['message']];
+            }
+            else {
+                return [false,$resp['message']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $str = '';
+        foreach ($params as $value){
+            $str .= $value;
+        }
+
+        $str = md5($str);
+        $content = $str . config::KEY;
+        return md5($content);
+    }
+}

+ 14 - 0
helper/refill/xc/config.php

@@ -0,0 +1,14 @@
+<?php
+
+
+namespace refill\xc;
+
+
+class config
+{
+    const ORDER_URL = 'http://180.215.207.83/pay/order/upload';
+    const QUERY_ORDER_URL = 'http://180.215.207.83/api/order/queryStatus';
+    const NUMBER_ID= '10019';
+    const KEY = '346ab585a7cbeccd4f11e54ffaf5fe1c';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_xc.php";
+}

+ 56 - 46
mobile/control/merchant_info.php

@@ -1,115 +1,125 @@
 <?php
-require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
+require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
 
-class merchant_infoControl extends merchant_baseControl
+class merchant_infoControl extends mbMerchantControl
 {
     public function __construct()
     {
         parent::__construct();
-
     }
+
     public function indexOp()
     {
         $model_merchant = Model('merchant');
-        $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']],'mchid,name,alarm_amount,ip_white_list');
+        $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']], 'mchid,name,alarm_amount,ip_white_list,is_key');
         $model_member = Model('member');
-        $member_info = $model_member->getMemberInfo(
-            array(
-                'member_id' => $merchant_info['admin_id']
-            ),
-            'available_predeposit'
-        );
+        $member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
         $merchant_info['member'] = $member_info;
-        $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
+
+        if (empty($merchant_info['ip_white_list'])) {
+            $merchant_info['ips'] = [];
+        } else {
+            $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
+        }
         return self::outsuccess($merchant_info);
     }
 
     public function addipOp()
     {
         $ip = $_POST['ip'];
-        if (empty($ip)){
-            return self::outerr(errcode::ErrParamter , "参数错误" );
+        if (empty($ip)) {
+            return self::outerr(errcode::ErrParamter, "参数错误");
         }
         $ip = trim($ip);
-        if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
             $model_merchant = Model('merchant');
             $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']]);
-            $ips = unserialize($merchant_info['ip_white_list']);
+            if (empty($merchant_info['ip_white_list'])) {
+                $ips = [];
+            } else {
+                $ips = unserialize($merchant_info['ip_white_list']);
+            }
+
             $ips[] = $ip;
             $ips = array_unique($ips);
-            $model_merchant->editMerchant(array('ip_white_list'=>serialize($ips)), ['mchid' => $merchant_info['mchid']]);
+
+            $model_merchant->editMerchant(['ip_white_list' => serialize($ips)], ['mchid' => $merchant_info['mchid']]);
             return self::outsuccess([]);
-        }
-        else {
-            return self::outerr(errcode::ErrParamter , "ip地址错误" );
+        } else {
+            return self::outerr(errcode::ErrParamter, "ip地址错误");
         }
     }
-    public function ipdelOp(){
+
+    public function ipdelOp()
+    {
         $ip = $_POST['ip'];
-        if (empty($ip)){
-            return self::outerr(errcode::ErrParamter , "参数错误" );
+        if (empty($ip)) {
+            return self::outerr(errcode::ErrParamter, "参数错误");
         }
         $ip = trim($ip);
         $model_merchant = Model('merchant');
-        $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
+        $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']]);
         $ips = unserialize($merchant_info['ip_white_list']);
         $new_ips = [];
-        foreach ($ips as $value){
-            if($value != $ip){
+        foreach ($ips as $value) {
+            if ($value != $ip) {
                 $new_ips[] = $value;
             }
         }
-        $model_merchant->editMerchant(array('ip_white_list'=>serialize($new_ips)), array('mchid' => $merchant_info['mchid']));
+        $model_merchant->editMerchant(['ip_white_list' => serialize($new_ips)], ['mchid' => $merchant_info['mchid']]);
         return self::outsuccess([]);
     }
-    public function setkeyOp(){
+
+    public function setkeyOp()
+    {
         $secure_key = $_POST['secure_key'];
-        if (empty($_POST['secure_key'])){
-            return self::outerr(errcode::ErrParamter , "参数错误" );
+        if (empty($secure_key)) {
+            return self::outerr(errcode::ErrParamter, "参数错误");
         }
         $model_merchant = Model('merchant');
-        $ret = $model_merchant->editMerchant(array('secure_key'=>$_POST['secure_key']), array('mchid' => $_SESSION['mch_id']));
-        if($ret){
+        $ret = $model_merchant->editMerchant(['secure_key' => $secure_key, 'is_key' => 1], ['mchid' => $secure_key]);
+        if ($ret) {
             return self::outsuccess([]);
-        }else{
+        } else {
             return self::outerr(errcode::ErrOperation, "系统错误.");
         }
     }
+
     public function modifypwOp()
     {
         $new_pw = $_POST['new_pw'];
         $new_pw2 = $_POST['new_pw2'];
-        if (trim($new_pw) !== trim($new_pw2)){
-            return self::outerr(errcode::ErrPasswd , "密码错误" );
+        if (trim($new_pw) !== trim($new_pw2)) {
+            return self::outerr(errcode::ErrPasswd, "密码错误");
         }
         $model_merchant = Model('merchant');
-        $merchant_info = $model_merchant->getMerchantInfo(array('mchid' => $_SESSION['mch_id']));
-        if(!$merchant_info){
+        $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $_SESSION['mch_id']]);
+        if (!$merchant_info) {
             return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
         }
         $pwd = trim($new_pw);
-        if(md5($pwd) == $merchant_info['password']){
+        if (md5($pwd) == $merchant_info['password']) {
             return self::outsuccess([]);
         }
-        $ret = $model_merchant->editMerchant(array('password'=>md5($pwd)), array('mchid' => $merchant_info['mchid']));
-        if($ret){
+        $ret = $model_merchant->editMerchant(['password' => md5($pwd)], ['mchid' => $merchant_info['mchid']]);
+        if ($ret) {
             return self::outsuccess([]);
-        }else{
+        } else {
             return self::outerr(errcode::ErrOperation, "系统错误.");
         }
     }
-    public function pdlogOp(){
+
+    public function pdlogOp()
+    {
         $model_pd = Model('merchant');
-        $condition = array();
         $condition['lg_member_id'] = $_SESSION['member_id'];
-        if ($_GET['lg_type'] != '')
-        {
+        if (empty($_GET['lg_type'])) {
             $condition['lg_type'] = $_GET['lg_type'];
         }
-        if($_GET['start_time'] && $_GET['end_time']){
+        if ($_GET['start_time'] && $_GET['end_time']) {
             $condition['lg_add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
         }
-        $list = $model_pd->getPdlog($condition,$this->page,'*','lg_id desc',10);
+        $list = $model_pd->getPdlog($condition, $this->page, '*', 'lg_id desc');
         $result['data'] = $list;
         $result['total'] = $model_pd->gettotalpage();
         return self::outsuccess($result);

+ 22 - 13
mobile/control/merchant_login.php

@@ -1,9 +1,9 @@
 <?php
 
-require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
+require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
 
 //商户后台登录
-class merchant_loginControl extends merchant_baseControl
+class merchant_loginControl extends merchantwebControl
 {
     public function __construct()
     {
@@ -16,21 +16,29 @@ class merchant_loginControl extends merchant_baseControl
         $pwd = md5($_POST['password']);
         $model_merchant = Model('merchant');
 
-        $mch_info = $model_merchant->getMerchantInfo(['name' => $name]);
-        if(!empty($mch_info))
+        $mch_info = $model_merchant->getMerchantInfo(['name' => $name], 'mchid,name,admin_id,alarm_amount,ip_white_list,password,org_pwd');
+        if (!empty($mch_info))
         {
-            if($mch_info['password'] != $pwd){
-                return self::outerr(errcode::ErrPasswd , "密码错误" );
+            if ($mch_info['password'] != $pwd) {
+                return self::outerr(errcode::ErrPasswd, "密码错误");
             }
+            unset($mch_info['org_pwd']);
+            unset($mch_info['password']);
+
             $client_ip = $_SERVER['REMOTE_ADDR'];
-            $model_merchant->editMerchant(['last_login_time' => TIMESTAMP,'last_login_ip' => $client_ip], ['mchid' => $mch_info['mchid']]);
+            $model_merchant->editMerchant(['last_login_time' => time(), 'last_login_ip' => $client_ip], ['mchid' => $mch_info['mchid']]);
+
             $model_member = Model('member');
-            $member_info = $model_member->getMemberInfo(['member_id' => $mch_info['admin_id']],'mchid,name,alarm_amount,ip_white_list');
+            $member_info = $model_member->getMemberInfo(['member_id' => $mch_info['admin_id']], 'available_predeposit');
 
+            $mch_info['member'] = $member_info;
+            if (empty($mch_info['ip_white_list'])) {
+                $mch_info['ips'] = [];
+            } else {
+                $mch_info['ips'] = unserialize($mch_info['ip_white_list']);
+            }
             $_SESSION['mch_id'] = $mch_info['mchid'];
-            $_SESSION['member_id'] = $member_info['member_id'];
-            $_SESSION['member_name'] = $member_info['member_name'];
-            $_SESSION['member_email'] = $member_info['member_email'];
+            $_SESSION['member_id'] = $mch_info['admin_id'];
 
             return self::outsuccess($mch_info);
         } else {
@@ -38,8 +46,9 @@ class merchant_loginControl extends merchant_baseControl
         }
     }
 
-    public function logoutOp() {
-        setNcCookie('MPHPSESSID',0,-3600);
+    public function logoutOp()
+    {
+        setNcCookie('MPHPSESSID', 0, -3600);
         return self::outsuccess([]);
     }
 }

+ 13 - 10
mobile/control/merchant_order.php

@@ -1,24 +1,27 @@
 <?php
-require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
+require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
 
-class merchant_orderControl extends merchant_baseControl
+class merchant_orderControl extends mbMerchantControl
 {
     public function __construct()
     {
         parent::__construct();
     }
 
-    public function listOp(){
+    public function listOp()
+    {
         $model_vr_order = Model('refill_order');
-        $condition = [];
-        if ($_GET['card_type'] != '' && $_GET['card_type'] != 0)
-        {
-            $condition['refill_order.card_type'] = $_GET['card_type'];
+
+        $cond['mchid'] = $this->mchid();
+        if (!empty($_GET['card_type'])) {
+            $cond['refill_order.card_type'] = $_GET['card_type'];
         }
-        if($_GET['start_time'] && $_GET['ent_time']){
-            $condition['refill_order.order_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
+        if ($_GET['start_time'] && $_GET['ent_time']) {
+            $cond['refill_order.order_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
         }
-        $order_list = $model_vr_order->getMerchantOrderList($condition, $this->page, '*', 'refill_order.order_id desc');
+
+        $order_list = $model_vr_order->getMerchantOrderList($cond, $this->page, '*', 'refill_order.order_id desc');
+
         $result['data'] = $order_list;
         $result['total'] = $model_vr_order->gettotalpage();
         return self::outsuccess($result);

+ 19 - 17
mobile/control/merchant_recharge.php

@@ -1,39 +1,41 @@
 <?php
-require_once(BASE_ROOT_PATH . '/mobile/control/merchant_base.php');
+require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
 
-class merchant_rechargeControl extends merchant_baseControl
+class merchant_rechargeControl extends mbMerchantControl
 {
     public function __construct()
     {
         parent::__construct();
     }
 
-    public function indexOp(){
+    public function indexOp()
+    {
         $model_merchant = Model('merchant');
-        $condition = array();
+        $condition = [];
         $condition['mch_id'] = $_SESSION['mch_id'];
-        if($_GET['start_time'] && $_GET['end_time']){
+        if ($_GET['start_time'] && $_GET['end_time']) {
             $condition['add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
         }
-        $list = $model_merchant->getRechargeApply($condition,$this->page,'*','apply_id desc',10);
+        $list = $model_merchant->getRechargeApply($condition, $this->page, '*', 'apply_id desc', 10);
         $result['data'] = $list;
         $result['total'] = $model_merchant->gettotalpage();
         return self::outsuccess($result);
     }
 
-    public function addOp(){
+    public function addOp()
+    {
         $params = $_POST;
-        if($params['amount'] == '' || $params['amount'] < 0){
-            return self::outerr(errcode::ErrParamter , "充值金额错误" );
+        if ($params['amount'] == '' || $params['amount'] < 0) {
+            return self::outerr(errcode::ErrParamter, "充值金额错误");
         }
-        if(!isset($params['bank_username']) || empty($params['bank_username'])){
-            return self::outerr(errcode::ErrParamter , "开户人姓名有误" );
+        if (!isset($params['bank_username']) || empty($params['bank_username'])) {
+            return self::outerr(errcode::ErrParamter, "开户人姓名有误");
         }
-        if(!isset($params['bank_name']) || empty($params['bank_name'])){
-            return self::outerr(errcode::ErrParamter , "银行名称有误" );
+        if (!isset($params['bank_name']) || empty($params['bank_name'])) {
+            return self::outerr(errcode::ErrParamter, "银行名称有误");
         }
-        if(!isset($params['voucher']) || empty($params['voucher'])){
-            return self::outerr(errcode::ErrParamter , "凭证名称有误" );
+        if (!isset($params['voucher']) || empty($params['voucher'])) {
+            return self::outerr(errcode::ErrParamter, "凭证名称有误");
         }
         $ins['amount'] = $params['amount'];
         $ins['bank_username'] = $params['bank_username'];
@@ -44,9 +46,9 @@ class merchant_rechargeControl extends merchant_baseControl
         $ins['add_time'] = time();
         $model_merchant = Model('merchant');
         $ret = $model_merchant->addRechargeApply($ins);
-        if($ret){
+        if ($ret) {
             return self::outsuccess([]);
-        }else{
+        } else {
             return self::outerr(errcode::ErrOperation, "系统错误.");
         }
     }

+ 164 - 152
mobile/control/merchant_base.php

@@ -1,153 +1,165 @@
-<?php
-
-require_once (BASE_HELPER_PATH . "/session_helper.php");
-
-class merchant_baseControl
-{
-    //列表默认分页数
-    protected $page;
-    protected $cur_page;
-
-    public function __construct()
-    {
-        $_SESSION['client_type'] = $_GET['client_type'];
-        if($_GET['act'] != 'merchant_login'){
-            if (empty($_SESSION['mch_id'])) {
-                throw new UnloginException();
-            }
-        }
-        if (is_numeric($_GET['page']) && intval(trim($_GET['page'])) > 0) {
-            $this->page = intval(trim($_GET['page']));
-        } else {
-            $this->page = 10;
-        }
-
-        if (is_numeric($_GET['curpage']) && intval(trim($_GET['curpage'])) > 0) {
-            $this->cur_page = intval(trim($_GET['curpage']));
-        } else {
-            $this->cur_page = 1;
-        }
-        $this->initpage($this->page, $this->cur_page);
-    }
-
-
-    public static function outerr($code, $msg = '', $page = '', $type = 'ajax')
-    {
-        static $json_clients = ['android', 'ios','mini'];
-
-        if(!empty($type)) {
-            $show_type = $type;
-        } else {
-            $show_type = $_SESSION['client_type'];
-        }
-
-        if (in_array($show_type, $json_clients))
-        {
-            joutput_error($code, $msg);
-        }
-        elseif ($show_type == 'wap')
-        {
-            Tpl::clear();
-            Tpl::output("error", $msg);
-            if (!empty($page)) {
-                Tpl::showpage($page);
-            }
-        }
-        elseif ($show_type == 'ajax')
-        {
-            $callback = $_GET['callback'];
-            if(!isset($callback) || empty($callback)) {
-                joutput_error($code, $msg);
-            } else {
-                echo "{$callback}(";
-                joutput_error($code, $msg);
-                echo ");";
-            }
-        }
-        else
-        {
-            if(empty($msg)) {
-                $msg = errcode::msg($code);
-            }
-            $start = microtime(true);
-            echo joutput_error($code, $msg, 'web') . "<br/>";
-            perfor_period("joutput",$start,"web");
-
-            echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
-            echo "性能关键统计:<br/><br/>";
-            performance_helper::format_log();
-
-            $sqls = Log::sql_log();
-            echo "sql count = " . count($sqls) . "<br/><br/>";
-            foreach ($sqls as $sql) {
-                echo "{$sql}<br/>";
-            }
-        }
-        return true;
-    }
-
-    public static function outsuccess($data, $page = '', $type = NULL)
-    {
-        static $json_clients = ['android', 'ios','mini'];
-
-        if(!empty($type)) {
-            $show_type = $type;
-        } else {
-            $show_type = $_SESSION['client_type'];
-        }
-
-        if (in_array($show_type, $json_clients))
-        {
-            joutput_data($data);
-        }
-        elseif ($show_type == 'wap')
-        {
-            Tpl::clear();
-            if (is_array($data)) {
-                foreach ($data as $key => $val) {
-                    Tpl::output($key, $val);
-                }
-            }
-            if (!empty($page)) {
-                Tpl::showpage($page);
-            }
-        }
-        elseif ($show_type == 'ajax')
-        {
-            $callback = $_GET['callback'];
-            if(!isset($callback) || empty($callback)) {
-                joutput_data($data);
-            } else {
-                echo "{$callback}(";
-                joutput_data($data);
-                echo ");";
-            }
-        }
-        else
-        {
-            echo 'success: return data=<br/>';
-            $start = microtime(true);
-            joutput_data($data, 'web');
-            perfor_period("joutput",$start,"web");
-
-            echo "<br/><br/>";
-            echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
-            echo "性能关键统计:<br/><br/>";
-            performance_helper::format_log();
-            $sqls = Log::sql_log();
-            echo "sql count = " . count($sqls) . "<br/><br/>";
-
-            foreach ($sqls as $sql) {
-                echo "{$sql}<br/>";
-            }
-        }
-
-        return true;
-    }
-
-    protected function initpage($page_size,$cur_page)
-    {
-        pagecmd('seteachnum', $page_size);
-        pagecmd('setnowpage', $cur_page);
-    }
+<?php
+
+require_once (BASE_HELPER_PATH . "/session_helper.php");
+
+class merchantwebControl
+{
+    //列表默认分页数
+    protected $page;
+    protected $cur_page;
+
+    public function __construct()
+    {
+        $_SESSION['client_type'] = $_GET['client_type'];
+        if (is_numeric($_GET['page']) && intval(trim($_GET['page'])) > 0) {
+            $this->page = intval(trim($_GET['page']));
+        } else {
+            $this->page = 10;
+        }
+
+        if (is_numeric($_GET['curpage']) && intval(trim($_GET['curpage'])) > 0) {
+            $this->cur_page = intval(trim($_GET['curpage']));
+        } else {
+            $this->cur_page = 1;
+        }
+        $this->initpage($this->page, $this->cur_page);
+    }
+
+
+    public static function outerr($code, $msg = '', $page = '', $type = 'ajax')
+    {
+        static $json_clients = ['android', 'ios','mini'];
+
+        if(!empty($type)) {
+            $show_type = $type;
+        } else {
+            $show_type = $_SESSION['client_type'];
+        }
+
+        if (in_array($show_type, $json_clients))
+        {
+            joutput_error($code, $msg);
+        }
+        elseif ($show_type == 'wap')
+        {
+            Tpl::clear();
+            Tpl::output("error", $msg);
+            if (!empty($page)) {
+                Tpl::showpage($page);
+            }
+        }
+        elseif ($show_type == 'ajax')
+        {
+            $callback = $_GET['callback'];
+            if(!isset($callback) || empty($callback)) {
+                joutput_error($code, $msg);
+            } else {
+                echo "{$callback}(";
+                joutput_error($code, $msg);
+                echo ");";
+            }
+        }
+        else
+        {
+            if(empty($msg)) {
+                $msg = errcode::msg($code);
+            }
+            $start = microtime(true);
+            echo joutput_error($code, $msg, 'web') . "<br/>";
+            perfor_period("joutput",$start,"web");
+
+            echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
+            echo "性能关键统计:<br/><br/>";
+            performance_helper::format_log();
+
+            $sqls = Log::sql_log();
+            echo "sql count = " . count($sqls) . "<br/><br/>";
+            foreach ($sqls as $sql) {
+                echo "{$sql}<br/>";
+            }
+        }
+        return true;
+    }
+
+    public static function outsuccess($data, $page = '', $type = NULL)
+    {
+        static $json_clients = ['android', 'ios','mini'];
+
+        if(!empty($type)) {
+            $show_type = $type;
+        } else {
+            $show_type = $_SESSION['client_type'];
+        }
+
+        if (in_array($show_type, $json_clients))
+        {
+            joutput_data($data);
+        }
+        elseif ($show_type == 'wap')
+        {
+            Tpl::clear();
+            if (is_array($data)) {
+                foreach ($data as $key => $val) {
+                    Tpl::output($key, $val);
+                }
+            }
+            if (!empty($page)) {
+                Tpl::showpage($page);
+            }
+        }
+        elseif ($show_type == 'ajax')
+        {
+            $callback = $_GET['callback'];
+            if(!isset($callback) || empty($callback)) {
+                joutput_data($data);
+            } else {
+                echo "{$callback}(";
+                joutput_data($data);
+                echo ");";
+            }
+        }
+        else
+        {
+            echo 'success: return data=<br/>';
+            $start = microtime(true);
+            joutput_data($data, 'web');
+            perfor_period("joutput",$start,"web");
+
+            echo "<br/><br/>";
+            echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
+            echo "性能关键统计:<br/><br/>";
+            performance_helper::format_log();
+            $sqls = Log::sql_log();
+            echo "sql count = " . count($sqls) . "<br/><br/>";
+
+            foreach ($sqls as $sql) {
+                echo "{$sql}<br/>";
+            }
+        }
+
+        return true;
+    }
+
+    protected function initpage($page_size,$cur_page)
+    {
+        pagecmd('seteachnum', $page_size);
+        pagecmd('setnowpage', $cur_page);
+    }
+}
+
+class mbMerchantControl extends merchantwebControl
+{
+    public $err_code = errcode::Success;
+
+    public function __construct()
+    {
+        parent::__construct();
+
+        if (empty($_SESSION['mch_id'])) {
+            throw new UnloginException();
+        }
+    }
+    public function mchid() {
+        return intval($_SESSION['mch_id']);
+    }
 }

+ 7 - 5
test/TestRefill.php

@@ -14,6 +14,7 @@ require_once(BASE_CORE_PATH . '/framework/function/http.php');
 require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 require_once(BASE_HELPER_PATH . '/refill/beixt/RefillCallBack.php');
+require_once(BASE_HELPER_PATH . '/refill/beixts/RefillPhone.php');
 
 class TestRefill extends TestCase
 {
@@ -39,20 +40,21 @@ class TestRefill extends TestCase
 
     public function testRefillPhone()
     {
-//        $providers = new \refill\beixt\RefillPhone();
-//        $resp = $providers->add(18500608333,50,'200649600557718888');
+//        global $config;
+//        $providers = new \refill\beixts\RefillPhone($config['phone_providers']['beixts']);
+//        $resp = $providers->add(13699279618,4,50,['order_sn' => '200649600557718886']);
 
         //{"ack":"success","message":{"order_number":13281474,"charged_amount":"48.750","shipping_status":"5","shipping_status_desc":"未发货"}}
         //$_POST='{"order_number":13281474,"shipping_status":1,"shipping_status_desc":"已发货","shipping_status_message":"","sign":"05863f9931ed69a70e456222f057dfdd","voucher":"110103307162012081746340295254","vouchertype":"","voucherurl":"","tradeNo":"200649600557718888"}';
-        $params['order_number'] = 13281474;
+        $params['order_number'] = 15566432;
         $params['shipping_status'] = 1;
         $params['shipping_status_desc'] = '已发货';
         $params['shipping_status_message'] = '';
-        $params['sign'] = '05863f9931ed69a70e456222f057dfdd';
+        $params['sign'] = '53aaf3dee6b0dd17b081073a0df7019c';
         $params['voucher'] = '110103307162012081746340295254';
         $params['vouchertype'] = '';
         $params['voucherurl'] = '';
-        $params['tradeNo'] = '200649600557718888';
+        $params['tradeNo'] = '200649600557718887';
         $ret = refill\RefillFactory::instance()->notify('beixt',$params);
     }