|
@@ -70,14 +70,18 @@ class proxy
|
|
|
|
|
|
private function need_transfer(refill\order $order)
|
|
private function need_transfer(refill\order $order)
|
|
{
|
|
{
|
|
- if($order->match_ratio()) return false;
|
|
|
|
-
|
|
|
|
- $order_time = $order->order_time();
|
|
|
|
$mchid = $order->mchid();
|
|
$mchid = $order->mchid();
|
|
$card_type = $order->card_type();
|
|
$card_type = $order->card_type();
|
|
- $ret = refill\transfer::instance()->need_transfer($mchid,$order_time,$card_type);
|
|
|
|
|
|
|
|
- return $ret;
|
|
|
|
|
|
+ $ret = refill\transfer::instance()->need_transfer($mchid,$card_type,$lowest_ratio);
|
|
|
|
+ if($ret) {
|
|
|
|
+ $cur_ratio = refill\RefillFactory::instance()->merchant_ratio($mchid);
|
|
|
|
+ Log::record("mchid=$mchid cur_ratio=$cur_ratio lowest_ratio=$lowest_ratio",Log::DEBUG);
|
|
|
|
+
|
|
|
|
+ return $lowest_ratio > $cur_ratio;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
private function need_transfer_timeout(refill\order $order)
|
|
private function need_transfer_timeout(refill\order $order)
|
|
@@ -213,8 +217,17 @@ class proxy
|
|
[$org_quality, $quality] = refill\RefillFactory::instance()->find_quality($order, $skip);
|
|
[$org_quality, $quality] = refill\RefillFactory::instance()->find_quality($order, $skip);
|
|
$order->set_quality($org_quality,$quality);
|
|
$order->set_quality($org_quality,$quality);
|
|
|
|
|
|
- if($quality == 0) {
|
|
|
|
- return $this->onEerror($order, $need_callback,'找不到合适质量的通道');
|
|
|
|
|
|
+ if($quality == 0)
|
|
|
|
+ {
|
|
|
|
+ if($order->first_commit()) {
|
|
|
|
+ return $this->onEerror($order, $need_callback,'找不到合适质量的通道');
|
|
|
|
+ }
|
|
|
|
+ elseif ($this->need_transfer($order) && $this->transfer($order)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return $this->onEerror($order, $need_callback,'再也找不到可用质量的通道');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if($this->region_intercept($order)) {
|
|
if($this->region_intercept($order)) {
|
|
@@ -248,9 +261,7 @@ class proxy
|
|
refill\util::onEventSubmit($order);
|
|
refill\util::onEventSubmit($order);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- elseif ($this->need_transfer($order) && $this->transfer($order)) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
$reAdder = function(refill\order $order,$order_id,$order_time,$mod_refill)
|
|
$reAdder = function(refill\order $order,$order_id,$order_time,$mod_refill)
|
|
{
|
|
{
|