diff --git a/app/Services/Gateway/AbstractPayment.php b/app/Services/Gateway/AbstractPayment.php index 039f8013..b9efdd81 100644 --- a/app/Services/Gateway/AbstractPayment.php +++ b/app/Services/Gateway/AbstractPayment.php @@ -16,7 +16,9 @@ use App\Services\Config; use App\Utils\Telegram; abstract class AbstractPayment -{ +{ function randFloat($min = 0, $max = 1) { + return $min + mt_rand() / mt_getrandmax() * ($max - $min); +} abstract public function purchase($request, $response, $args); abstract public function notify($request, $response, $args); @@ -39,6 +41,9 @@ abstract class AbstractPayment $p->save(); $user = User::find($p->userid); $user->money += $p->total; + if (Config::get("double_probability")>$this->randFloat()){ + $user->money += rand(0,$p->total); + } $user->save(); $codeq = new Code(); $codeq->code = $method; diff --git a/config/.config.example.php b/config/.config.example.php index 44588cf1..82da63f0 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -113,7 +113,7 @@ $_ENV['enable_bought_reset']='true'; //购买时是否重置流量 $_ENV['enable_bought_extend']='true'; //购买时是否延长等级期限(同等级配套) $_ENV['port_price']='-1'; //用户随机重置端口所需要的价格,价格小于0时视为不开放购买 $_ENV['port_price_specify']='-1'; //用户指明钦定端口所需要的价格,价格小于0时视为不开放购买 - +$_ENV['double_probability'] = 0.0; #高级 $_ENV['class_expire_reset_traffic']='0'; //等级到期时重置为的流量值,单位GB,小于0时不重置 $_ENV['account_expire_delete_days']='-1'; //账户到期几天之后会删除账户,小于0时不删除