|
@@ -22,10 +22,10 @@ class chctl
|
|
|
['quality'=> 2,'name' => 'channel-ctl-phone-fast-limit'],
|
|
|
['quality'=> 3,'name' => 'channel-ctl-phone-card-limit'],
|
|
|
['quality'=> 4,'name' => 'channel-ctl-phone-third-limit'],
|
|
|
- ['quality'=> 5,'name' => 'channel-ctl-phone-slow-limit'], //24 hour
|
|
|
- ['quality'=> 6,'name' => 'channel-ctl-phone-slow6-limit'],//6 hour
|
|
|
+ ['quality'=> 5,'name' => 'channel-ctl-phone-slow-limit'], //24 hour
|
|
|
+ ['quality'=> 6,'name' => 'channel-ctl-phone-slow6-limit'], //6 hour
|
|
|
['quality'=> 7,'name' => 'channel-ctl-phone-slow2-limit'], //2 hour
|
|
|
- ['quality'=> 8,'name' => 'channel-ctl-phone-slow48-limit'], //48 hour
|
|
|
+ ['quality'=> 8,'name' => 'channel-ctl-phone-slow48-limit'],//48 hour
|
|
|
['quality'=> 9,'name' => 'channel-ctl-phone-slow72-limit'] //72 hour
|
|
|
];
|
|
|
|
|
@@ -112,23 +112,38 @@ class chctl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function match($names,int $spec, int $card_type,int $quality)
|
|
|
+ public function match($names, int $spec, int $card_type, int $quality, $max_inprice)
|
|
|
{
|
|
|
$trace = new scope_trace(__METHOD__);
|
|
|
if ($card_type == mtopcard\ThirdRefillCard) {
|
|
|
return $names;
|
|
|
}
|
|
|
|
|
|
- $ctl_items = [];
|
|
|
- foreach ($names as $name)
|
|
|
+ $pThis = $this;
|
|
|
+ $price_filter = function ($names,$spec,$card_type,$quality) use($pThis,$max_inprice)
|
|
|
{
|
|
|
- $key = $this->prefix($name,$spec,$card_type,$quality);
|
|
|
- if(array_key_exists($key,$this->mSpeedtable)) {
|
|
|
- $ctl_items[] = $this->mSpeedtable[$key];
|
|
|
- } else {
|
|
|
- Log::record("unavaliable key={$key}",Log::DEBUG);
|
|
|
+ $ctls = [];
|
|
|
+ foreach ($names as $name)
|
|
|
+ {
|
|
|
+ $key = $pThis->prefix($name,$spec,$card_type,$quality);
|
|
|
+ if(array_key_exists($key,$pThis->mSpeedtable))
|
|
|
+ {
|
|
|
+ $item = $pThis->mSpeedtable[$key];
|
|
|
+
|
|
|
+ $inPrice = $item->price();
|
|
|
+ if ($max_inprice !== false && $inPrice > $max_inprice) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ $ctls[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record("auto_match speed table key={$key} is empty.",Log::DEBUG);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ return $ctls;
|
|
|
+ };
|
|
|
+ $ctl_items = $price_filter($names,$spec,$card_type,$quality);
|
|
|
|
|
|
$chooser = function ($ctl_items)
|
|
|
{
|
|
@@ -355,7 +370,7 @@ class chctl
|
|
|
return [$feeds,$profits];
|
|
|
}
|
|
|
|
|
|
- public function auto_match($names, int $spec, int $card_type, int $quality, $out_price, $left_time) : array
|
|
|
+ public function auto_match($names, int $spec, int $card_type, int $quality, $out_price, $max_inprice, $left_time): array
|
|
|
{
|
|
|
$formater = function ($val) {
|
|
|
return number_format($val,10,'.','');
|
|
@@ -462,16 +477,23 @@ class chctl
|
|
|
|
|
|
|
|
|
$pThis = $this;
|
|
|
- $speed_locker = function ($names,$spec,$card_type,$quality) use($pThis)
|
|
|
+ $price_filter = function ($names,$spec,$card_type,$quality) use($pThis,$max_inprice)
|
|
|
{
|
|
|
$ctls = [];
|
|
|
foreach ($names as $name)
|
|
|
{
|
|
|
$key = $pThis->prefix($name,$spec,$card_type,$quality);
|
|
|
- if(array_key_exists($key,$pThis->mSpeedtable)) {
|
|
|
+ if(array_key_exists($key,$pThis->mSpeedtable))
|
|
|
+ {
|
|
|
$item = $pThis->mSpeedtable[$key];
|
|
|
$item->calc_speed();
|
|
|
- $ctls[] = $item;
|
|
|
+
|
|
|
+ $inPrice = $item->price();
|
|
|
+ if ($max_inprice !== false && $inPrice > $max_inprice) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ $ctls[] = $item;
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
Log::record("auto_match speed table key={$key} is empty.",Log::DEBUG);
|
|
@@ -492,7 +514,7 @@ class chctl
|
|
|
Log::record("auto_match outprice= {$out_price} names=" . implode(',', $names), Log::DEBUG);
|
|
|
|
|
|
$can_feed = true;
|
|
|
- $ctls = $speed_locker($names,$spec,$card_type,$quality);
|
|
|
+ $ctls = $price_filter($names,$spec,$card_type,$quality);
|
|
|
[$sleeps,$wakeups] = $this->knockout($ctls,$out_price);
|
|
|
|
|
|
$logger($sleeps,'sleeps');
|