|
@@ -169,7 +169,7 @@ class channel_filter
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function getProviders($cur_quality,$inProviders)
|
|
|
+ public function getProviders($cur_quality, $inProviders, $ch_times)
|
|
|
{
|
|
|
$this->mQuality = $cur_quality;
|
|
|
if ($this->mCardType == mtopcard\SinopecCard || $this->mCardType == mtopcard\PetroChinaCard) {
|
|
@@ -177,16 +177,70 @@ class channel_filter
|
|
|
} elseif ($this->mCardType == mtopcard\ThirdRefillCard) {
|
|
|
return $inProviders;
|
|
|
} elseif ($this->mQuality == Quality::Normal) {
|
|
|
- return $this->asc($inProviders,1,10);
|
|
|
+ return $this->ascex($inProviders, $ch_times);
|
|
|
} elseif ($this->mQuality == Quality::Quick) {
|
|
|
- return $this->asc($inProviders,1,10);
|
|
|
+ return $this->ascex($inProviders, $ch_times);
|
|
|
} elseif ($this->mQuality == Quality::CardKey) {
|
|
|
- return $this->asc($inProviders,1,1);
|
|
|
+ return $this->ascex($inProviders, $ch_times);
|
|
|
} else {
|
|
|
- return $this->asc($inProviders,1,1);
|
|
|
+ return $this->ascex($inProviders,$ch_times);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function ascex($inProviders, $ch_times)
|
|
|
+ {
|
|
|
+ if(array_key_exists($this->mQuality,$this->mDatas)) {
|
|
|
+ $ch_infos = $this->mDatas[$this->mQuality];
|
|
|
+ } else {
|
|
|
+ $ch_infos = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $filter = function ($ch_infos) use ($ch_times)
|
|
|
+ {
|
|
|
+ $fail = [];
|
|
|
+ $good = [];
|
|
|
+ $enough = [];
|
|
|
+
|
|
|
+ foreach ($ch_infos as $name => $item)
|
|
|
+ {
|
|
|
+ [$fails, $succs] = $ch_times->get_times($name);
|
|
|
+ if($item['fail'] >= 0 or $item['succ'] >= $fails) {
|
|
|
+ $fail[] = $name;
|
|
|
+ }
|
|
|
+ elseif($item['succ'] >= $succs) {
|
|
|
+ $enough[] = $name;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $good[] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [$good,$enough,$fail];
|
|
|
+ };
|
|
|
+
|
|
|
+ [$good,$enough,$fail] = $filter($ch_infos);
|
|
|
+
|
|
|
+ $fail_providers = [];
|
|
|
+ $enough_providers = [];
|
|
|
+ $good_providers = [];
|
|
|
+
|
|
|
+ foreach ($inProviders as $provider)
|
|
|
+ {
|
|
|
+ $name = $provider->name();
|
|
|
+ if(in_array($name,$fail)) {
|
|
|
+ $fail_providers[] = $provider;
|
|
|
+ }
|
|
|
+ elseif(in_array($name,$enough)) {
|
|
|
+ $enough_providers[] = $provider;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $good_providers[] = $provider;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result = array_merge($good_providers,$enough_providers);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
private function asc($inProviders,$fails,$succs)
|
|
|
{
|
|
|
if(array_key_exists($this->mQuality,$this->mDatas)) {
|