ayHaru 4 年之前
父節點
當前提交
9bc1e1d16c

+ 1 - 2
core/framework/libraries/model.php

@@ -62,8 +62,7 @@ class trans_wapper
     public function __destruct()
     {
         if($this->mState <= 1) {
-            $msg = sprintf("trans_wapper uncommit or unrollback {$this->mName} state={$this->mState} use_time=%.6f",
-                microtime(true) - $this->mStart);
+            $msg = sprintf("trans_wapper uncommit or unrollback {$this->mName} state={$this->mState} use_time=%.6f",microtime(true) - $this->mStart);
             Log::record($msg,Log::ERR);
         }
     }

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

@@ -44,7 +44,7 @@ $config['gip'] 		= 0;
 $config['dbdriver'] = 'mysqli';
 $config['tablepre']	= 'lrlz_';
 
-define('SSH_TUNEL_PROD',true);
+define('SSH_TUNEL_PROD',false);
 
 if(SSH_TUNEL_PROD === false) {
     $config['db'][1]['dbhost']       = MASTER_DBHOST;

+ 21 - 53
data/config/dev/refill.ini.php

@@ -1,49 +1,17 @@
 <?php
 
-//define('ZERO_GOODS_ID', 6245);
-//
-//$config['refill_oil_specs'] = [100, 200, 500, 1000, 2000];
-//$config['refill_phone_specs'] = [10, 20, 30, 50, 100, 200, 300, 500];
-//
-////充值额度基本表
-//$config['refill_specs'] = [
-//    'petrochina' => $config['refill_oil_specs'],
-//    'sinopec' => $config['refill_oil_specs'],
-//    'chinamobile' => $config['refill_phone_specs'],
-//    'chinaunicom' => $config['refill_phone_specs'],
-//    'chinatelecom' => $config['refill_phone_specs']
-//];
-//
-//
-////充值渠道配置表
-//$oil_providers = [];
-//$config['oil_providers'] = $oil_providers;
-//
-//$baidu_phone = ['name' => 'baizeyd', 'store_id' => 8,
-//    'amount' => [
-//        10 => [['goods_id' => 6245, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
-//               ['goods_id' => 6245, 'price' => 9.61, 'quality' => 1, 'card_type' => 'chinamobile'],
-//               ['goods_id' => 6245, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
-//
-//        20 => [['goods_id' => 6247, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
-//        30 => [['goods_id' => 6249, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],
-//        50 => [['goods_id' => 6250, 'price' => 47.55, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-//        100 => [['goods_id' => 6251, 'price' => 95.1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-//    ],
-//    'official_sn' => true, 'refill_type' => 'api'];
-//$phone_providers = [
-//    ['name' => 'baizeyd', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
-//$config['phone_providers'] = $phone_providers;
+define('ZERO_GOODS_ID', 6245);
+
+$config['refill_oil_specs'] = [100, 200, 500, 1000, 2000];
+$config['refill_phone_specs'] = [10, 20, 30, 50, 100, 200, 300, 500];
 
-$config['refill_oil_specs'] = [100 , 200 , 500 , 1000 , 2000];
-$config['refill_phone_specs'] = [10 , 20 , 30 , 50 , 100 , 200 , 300 , 500];
 //充值额度基本表
 $config['refill_specs'] = [
-    'petrochina'    => $config['refill_oil_specs'],
-    'sinopec'       => $config['refill_oil_specs'],
-    'chinamobile'   => $config['refill_phone_specs'],
-    'chinaunicom'   => $config['refill_phone_specs'],
-    'chinatelecom'  => $config['refill_phone_specs']
+    'petrochina' => $config['refill_oil_specs'],
+    'sinopec' => $config['refill_oil_specs'],
+    'chinamobile' => $config['refill_phone_specs'],
+    'chinaunicom' => $config['refill_phone_specs'],
+    'chinatelecom' => $config['refill_phone_specs']
 ];
 
 
@@ -51,21 +19,21 @@ $config['refill_specs'] = [
 $oil_providers = [];
 $config['oil_providers'] = $oil_providers;
 
-define('ZERO_GOODS_ID', 6386);
-
 $baidu_phone = ['name' => 'baizeyd', 'store_id' => 8,
     'amount' => [
-        10 => [['goods_id' => 6386, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
-            ['goods_id' => 6386, 'price' => 9.61, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 6386, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
-
-        20 => [['goods_id' => 6387, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6388, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],
-        50 => [['goods_id' => 6389, 'price' => 47.55, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6390, 'price' => 95.1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+        10 => [['goods_id' => 6245, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
+               ['goods_id' => 6245, 'price' => 9.61, 'quality' => 1, 'card_type' => 'chinamobile'],
+               ['goods_id' => 6245, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
+
+        20 => [['goods_id' => 6247, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6249, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],
+        50 => [['goods_id' => 6250, 'price' => 47.55, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6251, 'price' => 95.1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
-
 $phone_providers = [
     ['name' => 'baizeyd', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
-$config['phone_providers'] = $phone_providers;
+$config['phone_providers'] = $phone_providers;
+
+$config['refill_oil_specs'] = [100 , 200 , 500 , 1000 , 2000];
+$config['refill_phone_specs'] = [10 , 20 , 30 , 50 , 100 , 200 , 300 , 500];

+ 1 - 2
data/logic/vr_order.logic.php

@@ -215,8 +215,7 @@ class vr_orderLogic
                 'exp_membername' => $order_info['buyer_name'],
                 'orderprice' => $order_info['order_amount'],
                 'order_sn' => $order_info['order_sn'],
-                'order_id' => $order_info['order_id']],
-            true);
+                'order_id' => $order_info['order_id']]);
 
         return callback(true, '更新成功');
     }

+ 1 - 0
helper/fcgisrv/RAccServer.php

@@ -11,6 +11,7 @@ require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/sensitive_word/dfa.php');
 require_once(BASE_ROOT_PATH . '/helper/exceptionex.php');
 require_once(BASE_PATH . '/control/merchant.php');
+require_once(BASE_PATH . '/control/lzbase.php');
 
 use Log;
 use Base;

+ 47 - 26
helper/refill/RefillBase.php

@@ -61,46 +61,53 @@ class RefillBase
                 $mod_order = Model('vr_order');
                 $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
                 $order_state = intval($order_info['order_state']);
-
                 if ($order_state != ORDER_STATE_SEND) {
                     return false;
                 }
 
                 $logic_vr_order = Logic("vr_order");
-                if ($success) {
-                    $logic_vr_order->changeOrderStateSuccess($order_id);
-                }
-                elseif ($can_try)
+                $mod_refill = Model('refill_order');
+
+                try
                 {
-                    try
+                    $tran = new trans_wapper($mod_order,'notify change order state trans');
+                    $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
+                    $order_state = intval($order_info['order_state']);
+                    if ($order_state != ORDER_STATE_SEND) {
+                        $tran->commit();
+                        return false;
+                    }
+
+                    if ($success) {
+                        $logic_vr_order->changeOrderStateSuccess($order_id);
+                    }
+                    elseif ($can_try)
                     {
-                        $mod_refill = Model('refill_order');
-                        $trans = new trans_wapper($mod_refill, __METHOD__);
                         $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id,'inner_status' => 0]);
                         if(!empty($refill_info))
                         {
                             $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,正在重试");
                             if ($this->retry($refill_info, $order_info)) {
-                                $mod_refill->edit($order_id, ['inner_status' => 1, 'notify_time' => time(), 'notify_state' => 1]);
-                                $trans->commit();
+                                $mod_refill->edit($order_id, ['is_retrying' => 1]);
+                                $tran->commit();
                                 return true;
                             }
                         }
-                        $trans->commit();
                     }
-                    catch (Exception $ex) {
-                        $trans->rollback();
-                        Log::record("Error:" . $ex->getMessage(),Log::ERR);
+                    else {
+                        $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.");
                     }
+                    $tran->commit();
                 }
-                else {
-                    $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.");
+                catch (Exception $ex) {
+                    $tran->rollback();
+                    Log::record("Error:" . $ex->getMessage(), Log::ERR);
                 }
 
-                $mod_refill = Model('refill_order');
                 $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
                 QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
-            } else {
+            }
+            else {
                 Log::record("系统无此订单ID:{$order_id}", Log::ERR);
             }
         }
@@ -127,7 +134,8 @@ class RefillBase
             'idcard' => $refill_info['idcard'] ?? '',
             'card_name' => $refill_info['card_name'] ?? '',
             'order_time' => $refill_info['order_time'],
-            'commit_times' => $refill_info['commit_times'] + 1
+            'commit_times' => $refill_info['commit_times'] + 1,
+            'order_id' => $refill_info['order_id']
         ];
 
         return util::push_add($params);
@@ -194,13 +202,19 @@ class RefillBase
     //     其它情况,则需要判断订单ID
     public function add($mchid, $buyer_id, $amount, $card_no,
                         $mch_order, $idcard, $card_name, $notify_url,$quality,
-                        $order_time, $commit_times)
+                        $order_time, $commit_times,$last_orderid = 0)
     {
         $card_type = mtopcard\card_type($card_no);
-        $providers = $this->mPolicy->find_providers($amount,$card_type,$quality);
+        [$providers,$overload] = $this->mPolicy->find_providers($amount,$card_type,$quality);
 
-        if (empty($providers)) {
-            return [errcode::CANNOT_MATCH_PROVIDER, "匹配不到合适的充值通道",0,false];
+        if (empty($providers))
+        {
+            if($overload) {
+                return [errcode::PROVIDER_OVERLOAD, "匹配不到合适的充值通道",0,false];
+            }
+            else {
+                return [errcode::CANNOT_MATCH_PROVIDER, "匹配不到合适的充值通道",0,false];
+            }
         }
 
         if (empty($notify_url)) {
@@ -219,6 +233,7 @@ class RefillBase
 
         $refill_state = false;
         $order_success = false;
+
         foreach ($providers as $provider)
         {
             $channel_name = $provider->name();
@@ -244,6 +259,11 @@ class RefillBase
                 $order_sn = $result['data']['order_sn'];
                 $order_id = $result['data']['order_id'];
 
+                if($last_orderid > 0) {
+                    $mod_refill->edit($last_orderid, ['inner_status' => 1]);
+                }
+                $last_orderid = $order_id;
+
                 if(!$this->pay_completed($order_sn)) {
                     $logic_vr_order = Logic("vr_order");
                     $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
@@ -264,11 +284,12 @@ class RefillBase
                     'card_type' => $card_type, 'card_no' => $card_no,'quality' => $quality];
                 $mod_refill->add_refill($orderext);
             } else {
+                Log::record("{$result['msg']}",Log::ERR);
                 continue;
             }
 
             $order_success = true;
-            util::incr_order($channel_name,$card_type,$amount);
+            util::incr_order($channel_name,$card_type,$amount,$quality);
             $params = ['order_sn' => $order_sn, 'idcard' => $idcard, 'card_name' => $card_name];
             [$state, $errmsg,$neterr] = $provider->add($card_no, $card_type, $amount, $params);
 
@@ -298,7 +319,8 @@ class RefillBase
                 $logic_vr_order = Logic("vr_order");
                 $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
                 $logic_vr_order->changeOrderStateCancel($order_info, '', "调用{$channel_name}接口失败");
-                $mod_refill->edit($order_id, ['commit_time' => time(), 'inner_status' => 1]);
+
+                $mod_refill->edit($order_id, ['commit_time' => time()]);
             }
         }
 
@@ -355,7 +377,6 @@ class RefillBase
             return [false, "错误的订单状态,不能通知."];
         }
         $resp = $this->mPolicy->notify($order_info,$refill_info);
-
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         if ($resp) {
             $refill_order->edit($order_id, ['mch_notify_state' => 1, 'mch_notify_times' => ['exp', 'mch_notify_times+1']]);

+ 1 - 1
helper/refill/errcode.php

@@ -9,6 +9,6 @@ class errcode
     const CANNOT_MATCH_PROVIDER = 202;
     const MERCHANT_SHORT_MONEY = 203;
     const MERCHANT_REFILL_ERROR = 204;
-
+    const PROVIDER_OVERLOAD = 205;
 
 }

+ 18 - 7
helper/refill/policy/lingzh/chctl.php

@@ -46,7 +46,7 @@ class chctl
                     $speed = $item['speed'];
 
                     $key = $this->prefix($name,$amount,$card_type,$quality);
-                    $this->mSpeedtable[$key] = new ctl_item($name,$card_type,$amount,$speed,$sort,0,$opened);
+                    $this->mSpeedtable[$key] = new ctl_item($name,$card_type,$amount,$speed,$sort,0,$opened,$quality);
                 }
             }
         }
@@ -54,6 +54,7 @@ class chctl
 
     public function match($names,int $spec, int $card_type,int $quality)
     {
+        $overload = false;
 
         $ctl_items = [];
         foreach ($names as $name)
@@ -65,7 +66,7 @@ class chctl
         }
 
         if(empty($ctl_items)) {
-            return $names;
+            return [$names,$overload];
         }
 
         $usable_items = [];
@@ -82,8 +83,14 @@ class chctl
             $lover = $l->speed_overload() ? 1 : 0;
             $rover = $r->speed_overload() ? 1 : 0;
 
-            if($lover == $rover) {
-                return $lproity < $rproity ? -1 : 1;
+            if($lover == $rover)
+            {
+                if($lover) {
+                    return $lproity > $rproity ? -1 : 1; //如果都过载保优先级高的
+                }
+                else {
+                    return $lproity < $rproity ? -1 : 1;
+                }
             }
             else {
                 return $lover < $rover ? -1 : 1;
@@ -92,11 +99,15 @@ class chctl
         usort($usable_items, $ascending);
 
         $result = [];
-        foreach ($usable_items as $item) {
-            $result[] = $item->name();
+        foreach ($usable_items as $item)
+        {
+            if(!$item->speed_overload()) {
+                $result[] = $item->name();
+            }
         }
 
-        return $result;
+        $overload = count($result) == 0;
+        return [$result,$overload];
     }
 
     private function prefix($name,$spec,$card_type,$quality)

+ 3 - 3
helper/refill/policy/lingzh/ctl_item.php

@@ -23,9 +23,9 @@ class ctl_item
     private $mStorge;
     private $mOpened;
 
-    public function __construct($chname,$card_type,$amount,$max_speed,$priority,$storge,$opened)
+    public function __construct($chname,$card_type,$amount,$max_speed,$priority,$storge,$opened,$quality)
     {
-        $this->mPrefix = "speed-{$chname}-{$card_type}-{$amount}-";
+        $this->mPrefix = "speed-{$chname}-{$quality}-{$card_type}-{$amount}-";
 
         $this->mName = $chname;
         $this->mCardType = $card_type;
@@ -45,7 +45,7 @@ class ctl_item
         $end = time();
 
         for($time = $start_time; $time <= $end; $time++) {
-            $key = $this->mPrefix . "-{$time}";
+            $key = $this->mPrefix . "{$time}";
             $val = $ins->get_org($key);
             $val = $val == false ? 0 : $val;
             $this->mRecords[$time] = $val;

+ 4 - 3
helper/refill/policy/lingzh/policy.php

@@ -31,14 +31,15 @@ class policy extends ProviderManager implements IPolicy
     {
         $providers = parent::find_providers($spec,$card_type,$quality);
         if(empty($providers)) {
-            return $providers;
+            return [$providers,false];
         }
 
         $names = [];
         foreach ($providers as $provider) {
             $names[] = $provider->name();
         }
-        $names = $this->mChannelControl->match($names,$spec,$card_type,$quality);
+
+        [$names,$overload] = $this->mChannelControl->match($names,$spec,$card_type,$quality);
 
         $result = [];
         foreach ($names as $name)
@@ -51,7 +52,7 @@ class policy extends ProviderManager implements IPolicy
             }
         }
 
-        return $result;
+        return [$result,$overload];
     }
 
     public function can_retry(array $refill_info, array $order_info): bool

+ 5 - 5
helper/refill/util.php

@@ -171,28 +171,28 @@ class util
         queue\DispatcherClient::instance()->push('notify_mechant',$params);
     }
 
-    public static function incr_order($chname,$card_type,$amout)
+    public static function incr_order($chname,$card_type,$amout,$quality)
     {
         $ins = Cache::getInstance('cacheredis');
 
         $sec = time();
         $min = $sec - $sec % 60;
 
-        $key = "storge-push-{$chname}-{$card_type}-{$amout}-{$min}";
+        $key = "storge-push-{$chname}-{$quality}-{$card_type}-{$amout}-{$min}";
         $ins->incr($key);
 
-        $key = "speed-{$chname}-{$card_type}-{$amout}-{$sec}";
+        $key = "speed-{$chname}-{$quality}-{$card_type}-{$amout}-{$sec}";
         $ins->incr($key);
     }
 
-    public static function decr_order($chname,$card_type,$amout)
+    public static function decr_order($chname,$card_type,$amout,$quality)
     {
         $ins = Cache::getInstance('cacheredis');
 
         $sec = time();
         $min = $sec - $sec % 60;
 
-        $key = "storge-pop-{$chname}-{$card_type}-{$amout}-{$min}";
+        $key = "storge-pop-{$chname}-{$quality}-{$card_type}-{$amout}-{$min}";
         $ins->decr($key);
     }
 }

+ 18 - 3
racc/control/lzbase.php

@@ -18,8 +18,11 @@ class lzbaseControl
             $this->mAdminid = intval($mchinfo['admin_id']);
         }
 
-        $minfo = new member_info($this->adminid());
-        $this->available = $minfo->available_predeposit();
+        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
+
+        $mod_member = Model('member');
+        $minfo = $mod_member->getMemberInfo(['member_id' => $this->mAdminid], '*', true);
+        $this->available = $minfo['available_predeposit'];
 
         if ($mchinfo['merchant_state'] != 1) {
             throw new LzException(self::text_content(-7,$this->available));
@@ -67,7 +70,19 @@ class lzbaseControl
 
     private function sign_body($params)
     {
-        $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'];
+        $op = $params['op'];
+        if($op == 'add_mob') {
+            $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'];
+        }
+        elseif($op == 'balance') {
+            $content = $params['usr'];
+        }
+        elseif($op == 'query') {
+            $content = $params['usr'] . $params['ord'];
+        }
+        else {
+            $content = 'error';
+        }
         return $content;
     }
 

+ 9 - 4
racc/control/lzrefill.php

@@ -32,7 +32,7 @@ class lzrefillControl extends lzbaseControl
             return -9;
         }
 
-        $card_no = $_GET['cardno'];
+        $card_no = $params['mob'];
         if(!preg_match('/^1\d{10}$/',$card_no,$matches)) {
             return -11;
         }
@@ -74,6 +74,7 @@ class lzrefillControl extends lzbaseControl
         $card_no = $_GET['mob'];
         $notify_url = $_GET['notifyurl'];
         $mch_order = $_GET['ord']; //对方的order编号
+        $quality = $_GET['quality'];
 
         if($amount > $this->available) {
             return self::outerr(4,$this->available);
@@ -92,9 +93,10 @@ class lzrefillControl extends lzbaseControl
             'amount' => $amount,
             'card_no' => $card_no,
             'mch_order' => $mch_order,
-            'notify_url' => $notify_url];
-        $ret = refill\util::push_add($params);
+            'notify_url' => $notify_url,
+            'quality' => $quality];
 
+        $ret = refill\util::push_add($params);
         if($ret) {
             return self::outsuccess($this->available);
         }
@@ -129,7 +131,10 @@ class lzrefillControl extends lzbaseControl
         $uid = $this->adminid();
         $minfo = new member_info($uid);
         $available = $minfo->available_predeposit();
-        return self::outsuccess(['balance' => $available]);
+
+        $content = "0|".ncPriceFormat($available)."|0.00";
+        echo $content;
+        return true;
     }
 
     private function format($order_info,$refill_info)

+ 2 - 5
racc/racc.php

@@ -10,7 +10,6 @@ require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_PATH . '/index.php');
 
-
 require_once(BASE_ROOT_PATH . '/helper/http_header.php');
 require_once(BASE_ROOT_PATH . '/helper/session.php');
 require_once(BASE_ROOT_PATH . '/helper/img_helper.php');
@@ -36,12 +35,10 @@ require_once(BASE_ROOT_PATH . '/helper/fcode/present_manager.php');
 require_once(BASE_ROOT_PATH . '/helper/url_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
 require_once(BASE_HELPER_PATH . '/fcgisrv/RAccServer.php');
-
-use fcgisrv;
-
+require_once(BASE_HELPER_PATH . '/refill/util.php');
 
 function all_channels() {
-    return ['ch_index','activity','goods','refill'];
+    return ['refill'];
 }
 
 Base::mobile_init();

+ 6 - 12
rdispatcher/proxy.php

@@ -25,25 +25,25 @@ class proxy
 
         $order_time = $params['order_time'] ?? time();
         $commit_times = $params['commit_times'] ?? 0;
+        $last_order_id = $params['order_id'] ?? 0;
 
         [$errcode, $errmsg,$order_id,$neterr] = refill\RefillFactory::instance()->add($mchid, $buyer_id, $amount, $card_no,
-            $mch_order, $idcard, $card_name, $notify_url,$quality, $order_time, $commit_times);
+            $mch_order, $idcard, $card_name, $notify_url,$quality, $order_time, $commit_times,$last_order_id);
+
         $params['commit_times'] += 1;
         $commit_times += 1;
 
         if($errcode !== true)
         {
             $fNotify = true;
-            if($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr)
+            if(($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr) || $errcode == refill\errcode::PROVIDER_OVERLOAD)
             {
                 if(refill\RefillFactory::instance()->can_nettry($quality,$order_time,$commit_times))
                 {
                     $fNotify = false;
-                    if($order_id > 0) {
-                        $this->set_trying($refill_order,$mchid,$mch_order,$order_id);
-                    }
-
+                    $params['order_id'] = $order_id;
                     refill\util::push_add($params);
+                    $refill_order->edit($order_id, ['is_retrying' => 1]);
                 }
             }
 
@@ -66,12 +66,6 @@ class proxy
         }
     }
 
-    private function set_trying($refill_order,$mchid,$mch_order,$order_id)
-    {
-        $refill_order->table('refill_order')->where(['mchid' => $mchid,'mch_order' => $mch_order])->update(['is_retrying' => 0]);
-        $refill_order->edit($order_id,['is_retrying' => 1]);
-    }
-
     private function latest_order($refill_order,$mchid,$mch_order)
     {
         $orders = $refill_order->getOrderInfo(['mchid' => $mchid,'mch_order' => $mch_order]);

+ 3 - 2
test/TestDispatcher.php

@@ -61,7 +61,7 @@ class TestDispatcher extends TestCase
 
     public function testAddoil()
     {
-        foreach (range(1,200000,1) as $i) {
+        foreach (range(1,2000,1) as $i) {
             queue\DispatcherClient::instance()->push('add',$this->make_order());
         }
     }
@@ -100,7 +100,8 @@ class TestDispatcher extends TestCase
 
     private function make_order()
     {
-        $mchid = 1092;//$this->mMchid;
+//        $mchid = 1092;//
+        $mchid = $this->mMchid;
         $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
         $buyer_id = intval($mchinfo['admin_id']);