Bläddra i källkod

fix timeout check when left time only support one time submit

stanley-king 3 år sedan
förälder
incheckning
b0c0cbb711

+ 20 - 20
helper/refill/policy/mratio_control.php

@@ -318,7 +318,6 @@ class mratio_control
                 }
 
 //                Log::record("quality={$quality},card_type ={$card_type},spec={$spec}",Log::DEBUG);
-
                 $prices = $this->getPrice($mchid, $org_quality, $card_type, $spec);
                 $out_price = $prices[$org_quality];
                 $in_price = $prices[$quality] ?? false;
@@ -341,19 +340,8 @@ class mratio_control
             return $cur_pratio > $profit_ratio;
         };
 
-        $spec_max = function ($mchid,$qtsex, $org_quality, $qualities, $low_ratio,$period)
+        $spec_max = function ($mchid, $qtsex, $org_quality, $qualities, $low_ratio, $period)
         {
-            $specs = [];
-            $spec_qt = [];
-            foreach ($qtsex as $qts) {
-                [$quality, $card_type, $spec] = $qts;
-                $specs[] = $spec;
-                $spec_qt[$spec][] = [$quality,$card_type];
-            }
-
-            $specs = array_unique($specs);
-            sort($specs);
-
             $ratio_calc = function ($mchid, $specs, $spec_qt, $max_spec, $org_quality, $qualities, $period)
             {
                 $all_succ = 0;
@@ -363,9 +351,9 @@ class mratio_control
                 {
                     $qts = $spec_qt[$spec];
                     if($max_spec >= $spec) {
-                        $fHigtRatio = true;
+                        $fHighRatio = true; //此时采用面额中最高成功率计算
                     } else {
-                        $fHigtRatio = false;
+                        $fHighRatio = false;
                     }
 
                     $card_types = [];
@@ -380,13 +368,13 @@ class mratio_control
                     }
 
                     $detail_ratios = $this->detail_ratios($mchid, $qualities,$card_type, $spec, $period);
-                    if($fHigtRatio)
+                    if($fHighRatio)
                     {
                         $all = 0;
                         $ratios = [];
                         foreach ($detail_ratios as $quality => $sfr) {
                             [$succ,$fail,$ratio] = $sfr;
-//                            Log::record("high succ={$succ},fail={$fail},ratio = {$ratio}",Log::DEBUG);
+                            Log::record("high succ={$succ},fail={$fail},ratio = {$ratio}",Log::DEBUG);
                             $ratios[] = $ratio;
                             $all += $succ;
                             $all += $fail;
@@ -404,7 +392,7 @@ class mratio_control
                         foreach ($detail_ratios as $quality => $sfr)
                         {
                             [$succ,$fail,$ratio] = $sfr;
-//                            Log::record("normal succ={$succ},fail={$fail},ratio = {$ratio}",Log::DEBUG);
+                            Log::record("normal succ={$succ},fail={$fail},ratio = {$ratio}",Log::DEBUG);
                             $all_succ += $succ;
                             $all_fail += $fail;
                         }
@@ -415,11 +403,23 @@ class mratio_control
                 return round($ratio,4);
             };
 
+            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
+            $specs = [];
+            $spec_qt = [];
+            foreach ($qtsex as $qts) {
+                [$quality, $card_type, $spec] = $qts;
+                $specs[] = $spec;
+                $spec_qt[$spec][] = [$quality,$card_type];
+            }
+
+            $specs = array_unique($specs);
+            sort($specs);
+
             for ($i = 0; $i < count($specs); $i++)
             {
                 $max_spec = $specs[$i];
                 $ratio = $ratio_calc($mchid, $specs, $spec_qt, $max_spec, $org_quality, $qualities, $period);
-//                Log::record("spec={$max_spec},ratio={$ratio},low_ratio={$low_ratio}",Log::DEBUG);
+                Log::record("spec={$max_spec},ratio={$ratio},low_ratio={$low_ratio}",Log::DEBUG);
                 if($ratio >= $low_ratio) {
                     break;
                 }
@@ -434,7 +434,7 @@ class mratio_control
         if($can_next)
         {
             $max_spec = $spec_max($mchid,$qtsex, $org_quality, $qualities, $low_ratio,$period);
-            Log::record("max_spec={$max_spec}",Log::DEBUG);
+            Log::record("mchid={$mchid} max_spec={$max_spec}",Log::DEBUG);
             if($max_spec >= $spec) {
                 return false;
             } else {

+ 4 - 1
helper/refill/policy/quaility.php

@@ -286,14 +286,17 @@ class Quality
                     if($qsecs == false) continue;
 
                     if($left_time - $qsecs > 0) {
+                        //时间满足该质量配置
                         $left_time -= $qsecs;
                         $result[] = $quality;
                     }
                     elseif($left_time - $per_secs > 0) {
-                        $left_time -= $per_secs;
+                        //时间够跑一次,不能再找其它质量
                         $result[] = $quality;
+                        break;
                     }
                     else {
+                        //时间完全不够跑一次
                         break;
                     }
 

+ 1 - 1
rdispatcher/proxy.php

@@ -42,7 +42,7 @@ class proxy
             refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND);
             $refill_order->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]);
         }
-        Log::record("proxy::add times={$order->commit_times()} mch_order={$mch_order} card_no = {$order->card_no()} regin_no={$order->region_no()} org_quality={$org_quality} quality={$quality}",Log::DEBUG);
+        Log::record("proxy::add times={$order->commit_times()} mch_order={$mch_order} card_no = {$order->card_no()} regin_no={$order->region_no()} org_quality={$order->org_quality()} quality={$order->cur_quality()}",Log::DEBUG);
 
         if ($this->canceled($mchid, $mch_order)) {
             return $this->onEerror($order, '订单被拦截');

+ 7 - 0
util/shtest/var.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+
+slave_hosts=$XYZ_SLAVE_HOSTS
+echo $slave_hosts
+
+vdb=$(df -h | grep /dev/vdb1 | awk 'BEGIN{OFS=","}{print $1,$2,$3,$4}')