|
@@ -234,7 +234,8 @@ class mratio_control
|
|
|
private function gross_ratio($mchid, $period)
|
|
|
{
|
|
|
$mratios = $this->mGrossRatios;
|
|
|
- if (array_key_exists($mchid, $mratios)) {
|
|
|
+ if (array_key_exists($mchid, $mratios))
|
|
|
+ {
|
|
|
$mratios = $mratios[$mchid];
|
|
|
if (array_key_exists($period, $mratios)) {
|
|
|
return $mratios[$period];
|
|
@@ -271,7 +272,7 @@ class mratio_control
|
|
|
return $this->mTimesConfig[$mchid]['profit_formula'] ?? 'qts';
|
|
|
}
|
|
|
|
|
|
- //return true 表示不可以补充。
|
|
|
+ //return true 表示当前质量满足条件。
|
|
|
public function ratio_match($mchid, $org_quality, $cur_quality, $card_type, $spec, $qualities)
|
|
|
{
|
|
|
if(count($qualities) <= 1) {
|
|
@@ -304,13 +305,13 @@ class mratio_control
|
|
|
|
|
|
private function all_checker($mchid, $org_quality, $spec, $qualities, $period, $header, $low_ratio)
|
|
|
{
|
|
|
- $qtsex = $this->mMchQTS[$mchid];
|
|
|
- $profit_judger = function ($mchid, $qtsex, $org_quality, $period, $profit_ratio, $header)
|
|
|
+ $qtses = $this->mMchQTS[$mchid];
|
|
|
+ $profit_judger = function ($mchid, $qtses, $org_quality, $period, $profit_ratio, $header)
|
|
|
{
|
|
|
$profit = 0;
|
|
|
$amount = 0;
|
|
|
|
|
|
- foreach ($qtsex as $qts)
|
|
|
+ foreach ($qtses as $qts)
|
|
|
{
|
|
|
[$quality,$card_type,$spec] = $qts;
|
|
|
if($quality == $org_quality) {
|
|
@@ -329,12 +330,11 @@ class mratio_control
|
|
|
$profit += $succ * ($out_price - $in_price);
|
|
|
$amount += $succ * $spec;
|
|
|
|
|
|
-// Log::record("out_price = {$out_price},in_price={$in_price} profit={$profit} amount={$amount}",Log::DEBUG);
|
|
|
+// Log::record("out_price = {$out_price},in_price={$in_price} profit={$profit} amount={$amount}",Log::DEBUG);
|
|
|
}
|
|
|
|
|
|
$cur_pratio = round(($profit + 0.00001) / ($amount + 0.00001),4);
|
|
|
$profit_ratio = round($profit_ratio,4);
|
|
|
- $profit_ratio = round($profit_ratio,4);
|
|
|
|
|
|
Log::record("{$header} all_checker cur_pratio = {$cur_pratio},profit_ratio={$profit_ratio}",Log::DEBUG);
|
|
|
return $cur_pratio > $profit_ratio;
|
|
@@ -429,11 +429,11 @@ class mratio_control
|
|
|
};
|
|
|
|
|
|
$profit_ratio = $this->profit_ratio($mchid);
|
|
|
- $can_next = $profit_judger($mchid, $qtsex, $org_quality, $period, $profit_ratio, $header);
|
|
|
+ $can_next = $profit_judger($mchid, $qtses, $org_quality, $period, $profit_ratio, $header);
|
|
|
|
|
|
if($can_next)
|
|
|
{
|
|
|
- $max_spec = $spec_max($mchid,$qtsex, $org_quality, $qualities, $low_ratio,$period);
|
|
|
+ $max_spec = $spec_max($mchid,$qtses, $org_quality, $qualities, $low_ratio,$period);
|
|
|
Log::record("mchid={$mchid} max_spec={$max_spec}",Log::DEBUG);
|
|
|
if($max_spec >= $spec) {
|
|
|
return false;
|