stanley-king 2 lat temu
rodzic
commit
3723bdd28f

+ 0 - 1
helper/refill/LZRefillFactory.php

@@ -12,7 +12,6 @@ require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/try_judge.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
-require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchoilctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/times_caller.php');

+ 4 - 24
helper/refill/RefillBase.php

@@ -181,9 +181,6 @@ class RefillBase
             if ($success) {
                 $logic_vr_order->changeOrderStateSuccess($order_id,true);
                 $tran->commit();
-
-                util::incr_notify($chname, $card_type, $spec, $quality, true);
-                util::incr_user_success($mchid,$card_type, $spec,$quality);
                 util::onOrderSuccess($refill_info,$order_info);
                 util::monitor_callback($mchid, $spec,$card_type,$refill_info['mch_amount'], $refill_info['channel_amount'], true,$order_time);
             }
@@ -193,10 +190,6 @@ class RefillBase
                 $mod_refill->edit($order_id, ['is_retrying' => 1,'notify_time' => time()]);
                 $tran->commit();
 
-
-                util::incr_notify($chname, $card_type, $spec, $quality, false);
-                util::incr_amount_lock($mchid,$card_type,$spec);
-
                 [$can_retry,$params] = $this->retry($refill_info, $order_info);
                 if ($can_retry)
                 {
@@ -204,16 +197,11 @@ class RefillBase
                         return true;
                     }
                 }
-                util::incr_user_fail($mchid,$card_type, $spec,$quality);
                 util::monitor_callback($mchid, $spec, $card_type, $refill_info['mch_amount'], 0, false, $order_time);
             }
             else {
                 $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.",true,true);
                 $tran->commit();
-
-                util::incr_notify($chname, $card_type, $spec, $quality, false);
-                util::incr_amount_lock($mchid,$card_type,$spec);
-                util::incr_user_fail($mchid,$card_type, $spec,$quality);
                 util::monitor_callback($mchid, $spec, $card_type, $refill_info['mch_amount'], 0, false, $order_time);
             }
 
@@ -294,6 +282,8 @@ class RefillBase
             $logic_vr_order = Logic("vr_order");
             $logic_vr_order->changeOrderStateSuccess($order_id,true);
             $mod_refill->edit($order_id, ['commit_time' => time(),'notify_time' => time(), 'is_retrying' => 0,'notify_state' => 1]);
+            util::monitor_callback($mchid, $order->spec(), $order->card_type(), $mch_amount, $channel_amount, true, $order->order_time());
+
             return [true,$order_id,''];
         }
     }
@@ -439,11 +429,7 @@ class RefillBase
             $last_orderid = $order_id;
             if(!$order_success) continue;
 
-            util::incr_commit_pre($channel_name, $order->card_type(), $order->spec(), $order->cur_quality());
-            util::decr_amount_lock($mchid, $order->card_type(), $order->spec());
-
             $start = microtime(true);
-
             $net_errno = "";
             $params = $order->channel_params($order_id,$order_sn,$goods_id);
 
@@ -459,10 +445,9 @@ class RefillBase
             {
                 $commit_time = time();
                 $chfilters->add_channel($channel_name,true);
-                util::incr_commit($channel_name,$card_type,$spec,$quality,true);
-                util::monitor_commit($channel_name, $spec, $card_type, $channel_amount,$commit_time);
-                $trade_no = $errmsg;
+                util::monitor_commit($channel_name, $spec, $card_type, $channel_amount, $commit_time);
 
+                $trade_no = $errmsg;
                 $refill_type = $provider->refill_type();
                 if ($refill_type == 'api') {
                     $logic_vr_order = Logic("vr_order");
@@ -505,9 +490,6 @@ class RefillBase
                     $net_errno = 0;
                 }
 
-                util::incr_commit($channel_name,$card_type,$spec,$order->cur_quality(),false);
-                util::incr_amount_lock($mchid,$card_type,$spec);
-
                 Log::record("channel:{$channel_name} err:{$errmsg}");
                 $logic_vr_order = Logic("vr_order");
                 $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
@@ -517,7 +499,6 @@ class RefillBase
                     $errmsg = "{$errmsg}";
                 }
                 $mod_refill->edit($order_id, ['commit_time' => time(), 'err_msg' => $errmsg]);
-//                $mod_refill->edit($order_id, ['commit_time' => time(), 'notify_time' => time(), 'err_msg' => $errmsg]);
             }
         }
 
@@ -528,7 +509,6 @@ class RefillBase
         } else {
             //订单创建失败,不需要再重试了,可能已经是数据库等系统错误
             return [errcode::MERCHANT_REFILL_ERROR, "充值失败", $last_orderid, false, 0];
-//            return [errcode::MERCHANT_REFILL_ERROR, "充值失败", $last_orderid, false, 'ORDER_CREATE_FAIL'];
         }
     }
 

+ 0 - 1
helper/refill/XYZRefillFactory.php

@@ -15,7 +15,6 @@ require_once(BASE_HELPER_PATH . '/refill/policy/xyz/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/try_judge.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctlex.php');
-require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/ctl_itemex.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/mchoilctl.php');

+ 0 - 216
helper/refill/policy/ctl_item.php

@@ -1,216 +0,0 @@
-<?php
-
-namespace refill;
-
-use Log;
-
-class ctl_item
-{
-    const speed_secs = 60;
-    const USE_BIGDATA = true;
-
-    private $mName;
-    private $mCardType;
-    private $mAmount;
-    private $mQuality;
-
-    private $mMaxSpeed;
-    private $mPrefix;
-    private $mLastReadTime;
-    private $mRecords;
-
-    private $mPriority;
-    private $mStorge;
-    private $mOpened;
-    private $mPrice;
-
-    private $mCommitSucc;
-    private $mCommitFail;
-    private $mNotifySucc;
-    private $mNotifyFail;
-    private $mLazySpeed;
-
-    private $mSleepTime;
-    private $mSleeping;
-
-    public function __construct($chname, $card_type, $amount, $max_speed, $priority, $storge, $opened, $quality)
-    {
-        $this->mPrefix = "{$chname}-{$quality}-{$card_type}-{$amount}";
-
-        $this->mName = $chname;
-        $this->mCardType = $card_type;
-        $this->mAmount = $amount;
-        $this->mQuality = $quality;
-
-        $this->mMaxSpeed = $max_speed;
-        $this->mPriority = $priority;
-        $this->mStorge = $storge;
-        $this->mOpened = $opened;
-        $this->mRecords = [];
-        $this->mPrice = 0.0;
-
-        $this->mCommitSucc = 0;
-        $this->mCommitFail = 0;
-        $this->mNotifySucc = 0;
-        $this->mNotifyFail = 0;
-        $this->mLazySpeed = 0;
-
-        $this->mSleepTime = 0;
-        $this->mSleeping = false;
-
-        if(!self::USE_BIGDATA) {
-            $this->load(time() - ctl_item::speed_secs + 1);
-        }
-    }
-
-    private function load($start_time)
-    {
-        $end = time();
-        for ($time = $start_time; $time <= $end; $time++) {
-            $val = util::hget_commit_pre_sec($this->mName, $this->mCardType, $this->mAmount, $this->mQuality, $time);
-            $this->mRecords[$time] = $val;
-        }
-        $this->mLastReadTime = $end;
-
-        $min = $end - ctl_item::speed_secs + 1;
-        $rmkeys = [];
-        foreach ($this->mRecords as $time => $val) {
-            if ($time < $min) {
-                $rmkeys[] = $time;
-            }
-        }
-
-        foreach ($rmkeys as $key) {
-            unset($this->mRecords[$key]);
-        }
-    }
-
-    public function set_speed($speed)
-    {
-        $this->mLazySpeed = $speed;
-    }
-
-    public function cur_speed(): int
-    {
-        if(self::USE_BIGDATA) {
-            return $this->mLazySpeed;
-        } else {
-            $this->load($this->mLastReadTime);
-            $speed = array_sum($this->mRecords);
-            return $speed;
-        }
-    }
-
-    public function speed_overload(): bool
-    {
-        if ($this->mMaxSpeed < 0) {
-            return false;
-        } elseif ($this->mMaxSpeed == 0) {
-            return true;
-        } else {
-            return $this->lazy_speed() >= $this->mMaxSpeed;
-        }
-    }
-
-    public function calc_speed()
-    {
-        if(!self::USE_BIGDATA) {
-            $this->mLazySpeed = $this->cur_speed();
-        }
-//        Log::record("{$this->mPrefix} calc_speed:{$this->mLazySpeed}",Log::DEBUG);
-    }
-
-    public function lazy_speed()
-    {
-        return $this->mLazySpeed;
-    }
-
-    public function name()
-    {
-        return $this->mName;
-    }
-
-    public function priority()
-    {
-        return $this->mPriority;
-    }
-
-    public function storge()
-    {
-        return $this->mStorge;
-    }
-    public function opened()
-    {
-        return $this->mOpened;
-    }
-    public function max_speed()
-    {
-        return $this->mMaxSpeed;
-    }
-    public function quality()
-    {
-        return $this->mQuality;
-    }
-    public function spec()
-    {
-        return $this->mAmount;
-    }
-    public function card_type()
-    {
-        return $this->mCardType;
-    }
-    public function set_price($price)
-    {
-        $this->mPrice = $price;
-    }
-    public function price()
-    {
-        return $this->mPrice;
-    }
-    public function prefix() {
-        return $this->mPrefix;
-    }
-
-    public function set_ratio($ratio)
-    {
-        $this->mCommitSucc = $ratio[0];
-        $this->mCommitFail = $ratio[1];
-        $this->mNotifySucc = $ratio[2];
-        $this->mNotifyFail = $ratio[3];
-    }
-    public function commit_statics()
-    {
-        $count = $this->mCommitSucc + $this->mCommitFail;
-        return [$count, $this->mCommitSucc];
-    }
-    public function notify_statics()
-    {
-        $count = $this->mNotifySucc + $this->mNotifyFail;
-        return [$count, $this->mNotifySucc];
-    }
-
-    public function notify_ratio()
-    {
-        $count = $this->mNotifySucc + $this->mNotifyFail;
-        if ($count > 0) {
-            return [$count, $this->mNotifySucc / $count];
-        } else {
-            return [$count, 0];
-        }
-    }
-
-    public function sleeping()
-    {
-        return [$this->mSleeping, $this->mSleepTime];
-    }
-    public function sleep()
-    {
-        $this->mSleeping = true;
-        $this->mSleepTime = time();
-    }
-    public function wakeup()
-    {
-        $this->mSleeping = false;
-        $this->mSleepTime = 0;
-    }
-}

+ 0 - 140
helper/refill/util.php

@@ -382,145 +382,6 @@ class util
         return $ins->lLen('REFILL_MONITOR_QUEUE');
     }
 
-    //统计提交订单数据
-    public static function incr_commit_pre($chname, $card_type, $spec, $quality)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'commit_speed_monitor';
-        $sec = time();
-        $key_sec = "{$chname}-{$quality}-{$card_type}-{$spec}-{$sec}";
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function hget_commit_pre_sec($chname, $card_type, $spec, $quality, $time_stamp)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'commit_speed_monitor';
-        $key_sec = "{$chname}-{$quality}-{$card_type}-{$spec}-{$time_stamp}";
-        $value = $ins->hget($name, '', $key_sec);
-
-        return intval($value);
-    }
-
-    //统计用户提交数据
-    public static function incr_user_commit($mchid,$card_type, $spec,$quality)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'user_monitor_commit';
-        $sec = time();
-        $key_sec = "{$mchid}-{$quality}-{$card_type}-{$spec}-{$sec}";
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function incr_user_success($mchid,$card_type, $spec,$quality)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'user_monitor_success';
-        $sec = time();
-        $key_sec = "{$mchid}-{$quality}-{$card_type}-{$spec}-{$sec}";
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function incr_user_fail($mchid,$card_type, $spec,$quality)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'user_monitor_fail';
-        $sec = time();
-        $key_sec = "{$mchid}-{$quality}-{$card_type}-{$spec}-{$sec}";
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function incr_commit($chname, $card_type, $spec, $quality, $fsuccess = true)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'channel_monitor_commit';
-        $sec = time();
-
-        if ($fsuccess) {
-            $key_sec = "succ-{$chname}-{$quality}-{$card_type}-{$spec}-{$sec}";
-        } else {
-            $key_sec = "fail-{$chname}-{$quality}-{$card_type}-{$spec}-{$sec}";
-        }
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function hget_commit_sec($chname, $card_type, $spec, $quality, $time_stamp, $fsuccess = true)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'channel_monitor_commit';
-        if ($fsuccess) {
-            $key_sec = "succ-{$chname}-{$quality}-{$card_type}-{$spec}-{$time_stamp}";
-        } else {
-            $key_sec = "fail-{$chname}-{$quality}-{$card_type}-{$spec}-{$time_stamp}";
-        }
-        $value = $ins->hget($name, '', $key_sec);
-
-        return intval($value);
-    }
-
-    //统计回调通知数据
-    public static function incr_notify($chname, $card_type, $spec, $quality, $fsuccess = true)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'channel_monitor_notify';
-        $sec = time();
-
-        if ($fsuccess) {
-            $key_sec = "succ-{$chname}-{$quality}-{$card_type}-{$spec}-{$sec}";
-        } else {
-            $key_sec = "fail-{$chname}-{$quality}-{$card_type}-{$spec}-{$sec}";
-        }
-
-        $ins->hIncrBy($name, $key_sec, 1);
-    }
-
-    public static function hget_notify_sec($chname, $card_type, $spec, $quality, $time_stamp, $fsuccess = true)
-    {
-        $ins = Cache::getInstance('cacheredis');
-
-        $name = 'channel_monitor_notify';
-        if ($fsuccess) {
-            $key_sec = "succ-{$chname}-{$quality}-{$card_type}-{$spec}-{$time_stamp}";
-        } else {
-            $key_sec = "fail-{$chname}-{$quality}-{$card_type}-{$spec}-{$time_stamp}";
-        }
-        $value = $ins->hget($name, '', $key_sec);
-
-        return intval($value);
-    }
-
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    public static function incr_amount_lock($mchid, $card_type, $spec)
-    {
-        if ($card_type == mtopcard\SinopecCard || $card_type == mtopcard\PetroChinaCard) {
-            refill\rlock::incr_sys_storage($card_type,$spec,1);
-            refill\rlock::incr_mch_total_storage($mchid,$card_type,$spec);
-            refill\rlock::incr_mch_storage($mchid,$card_type,$spec,1);
-        }
-    }
-
-    public static function decr_amount_lock($mchid, $card_type, $spec)
-    {
-        if ($card_type == mtopcard\SinopecCard || $card_type == mtopcard\PetroChinaCard) {
-            refill\rlock::decr_sys_storage($card_type,$spec,1);
-            refill\rlock::decr_mch_total_storage($mchid,$card_type,$spec);
-            refill\rlock::decr_mch_storage($mchid,$card_type,$spec,1);
-        }
-    }
-
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static function monitor_submit($mchid, $spec, $card_type, $mch_amount, $time)
     {
@@ -904,7 +765,6 @@ class util
                 return [false, $errmsg];
             }
 
-            refill\util::incr_user_success($mchid,$order->card_type(), $order->spec(),$order->cur_quality());
             $mod_refill->edit($success_order_id, ['mch_notify_state' => 1, 'mch_notify_times' => ['exp', 'mch_notify_times+1']]);
             $mod_refill->edit($order_id, ['is_retrying' => 0]);
             if($manual_recharge_amount > 0) {

+ 3 - 12
rdispatcher/proxy.php

@@ -89,7 +89,6 @@ class proxy
             return false;
         }
 
-        refill\util::incr_user_success($mchid,$order->card_type(), $order->spec(),$order->cur_quality());
         refill\util::pop_queue_order($mchid, $mch_order);
         QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => false]);
 
@@ -160,7 +159,6 @@ class proxy
                 return $this->onEerror($order, '没有协商商品购买价格.');
             }
             else {
-                refill\util::incr_user_commit($mchid, $order->card_type(), $order->spec(), $org_quality);
                 refill\util::monitor_submit($order->mchid(), $order->spec(), $order->card_type(), $mch_amount,$order->order_time());
             }
         }
@@ -266,10 +264,6 @@ class proxy
         Model('refill_order')->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]);
 
         [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($order);
-        if($order->first_commit()) {
-            refill\util::incr_user_commit($mchid,$order->card_type(),$order->spec(),$org_quality);
-        }
-
         Log::record("proxy::add mch_order={$mch_order} card_no = {$order->card_no()} regin_no={$order->region_no()} org_quality={$org_quality} quality={$quality}",Log::DEBUG);
         $order_id = refill\RefillFactory::instance()->zero_order($order,"手动0元订单");
 
@@ -318,19 +312,16 @@ class proxy
 
         $mchid = $order->mchid();
         $mch_order = $order->mch_order();
-        $org_quality = $order->org_quality();
 
         $refill_order = Model('refill_order');
         refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND);
         $refill_order->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]);
 
         $mch_amount = refill\RefillFactory::instance()->mch_amount($order);
-        if($mch_amount === false) {
+        if ($mch_amount === false) {
             return $this->onEerror($order, '没有协商商品购买价格.');
-        }
-        else {
-            refill\util::incr_user_commit($mchid, $order->card_type(), $order->spec(), $org_quality);
-            refill\util::monitor_submit($order->mchid(), $order->spec(), $order->card_type(), $mch_amount,$order->order_time());
+        } else {
+            refill\util::monitor_submit($order->mchid(), $order->spec(), $order->card_type(), $mch_amount, $order->order_time());
         }
 
         [$errcode, $errmsg, $order_id, $neterr,$net_errno] = refill\RefillFactory::instance()->add($order);

+ 0 - 8
test/TestRedis.php

@@ -171,14 +171,6 @@ class TestRedis extends TestCase
         $x = rcache('card_expired','','1000119000003695610');
     }
 
-    public function testSpeed()
-    {
-        for ($i = 0; $i < 1000000; ++$i) {
-            refill\util::incr_commit('lingzh',1,100,1,true);
-            $ret = refill\util::hget_commit_sec('lingzh',1,100,1,time(),true);
-        }
-    }
-
     public function testOrderSn()
     {
         $order_sn = $this->_makeOrderSn();