|
@@ -16,16 +16,19 @@ class policy extends ProviderManager implements IPolicy
|
|
|
const high_time_out = 60;
|
|
|
|
|
|
protected $mChannelControl;
|
|
|
+ protected $mMchctl;
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
|
$this->mChannelControl = new chctl();
|
|
|
+ $this->mMchctl = new mchctl();
|
|
|
}
|
|
|
|
|
|
public function load()
|
|
|
{
|
|
|
parent::load();
|
|
|
$this->mChannelControl->load();
|
|
|
+ $this->mMchctl->load();
|
|
|
}
|
|
|
|
|
|
public function find_providers(int $spec, int $card_type,int $quality): array
|
|
@@ -81,33 +84,56 @@ class policy extends ProviderManager implements IPolicy
|
|
|
return $providers;
|
|
|
}
|
|
|
|
|
|
- public function can_retry(array $refill_info, array $order_info) : bool
|
|
|
+ public function can_retry(array $refill_info, array $order_info) : array
|
|
|
{
|
|
|
- $checker = function ($refill, $order)
|
|
|
+ $checker = function ($refill, $order,$time_out,$quality)
|
|
|
{
|
|
|
$state = intval($order['order_state']);
|
|
|
if ($state !== ORDER_STATE_SEND) {
|
|
|
Log::record("retry false:order_state != send", Log::DEBUG);
|
|
|
- return false;
|
|
|
+ return [false,0];
|
|
|
}
|
|
|
|
|
|
$times = intval($refill['commit_times']);
|
|
|
if ($times > policy::normal_times) {
|
|
|
- return false;
|
|
|
+ return [false,0];
|
|
|
}
|
|
|
|
|
|
$period = time() - $refill['order_time'];
|
|
|
- if ($period >= policy::normle_time_out) {
|
|
|
+ if ($period >= $time_out) {
|
|
|
Log::record("retry false:time > 15m", Log::DEBUG);
|
|
|
- return false;
|
|
|
+ return [false,0];
|
|
|
+ }
|
|
|
+ elseif($period + 60 > $time_out && $quality == 3) {
|
|
|
+ return [true,2];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return [true,$quality];
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
};
|
|
|
|
|
|
- return $checker($refill_info, $order_info);
|
|
|
+ $mchid = $refill_info['mchid'];
|
|
|
+ [$sucdess,$quality,$time_out] = $this->mMchctl->getCtls($mchid);
|
|
|
+
|
|
|
+ if($sucdess) {
|
|
|
+ return $checker($refill_info, $order_info,$time_out,$quality);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return $checker($refill_info, $order_info,policy::normle_time_out,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function first_quality($mchid): int
|
|
|
+ {
|
|
|
+ [$sucdess,$quality,$time_out] = $this->mMchctl->getCtls($mchid);
|
|
|
+ if($sucdess) {
|
|
|
+ return $quality;
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public function allow($mchid,$card_type,$amount,$quality) : bool
|
|
|
{
|
|
|
$reader = function () {
|