stanley-king 1 tahun lalu
induk
melakukan
563f105ef2

+ 7 - 4
helper/refill/RefillBase.php

@@ -443,9 +443,12 @@ class RefillBase
 
         $mchid = $order->mchid();
         $mch_order = $order->mch_order();
+
         [$providers, $overload] = $this->mPolicy->find_providers($order);
-        $chfilters = new channel_filter($mchid,$mch_order,$order->cur_quality(),$order->card_type());
-        $providers = $chfilters->getProviders($providers);
+
+        $chfilters = $order->filter();
+        $cur_quality = $order->cur_quality();
+        $providers = $chfilters->getProviders($cur_quality,$providers);
 
         if (empty($providers)) {
             Log::record("canot find any providers", Log::DEBUG);
@@ -524,7 +527,7 @@ class RefillBase
             if ($state)
             {
                 $commit_time = time();
-                $chfilters->add_channel($channel_name,true);
+                $chfilters->add_channel($cur_quality,$channel_name,true);
                 util::monitor_commit($channel_name, $spec, $card_type, $channel_amount, $commit_time);
                 util::onEventCommit($order,$channel_name);
 
@@ -562,7 +565,7 @@ class RefillBase
             }
             else
             {
-                $chfilters->add_channel($channel_name,false);
+                $chfilters->add_channel($cur_quality, $channel_name, false);
                 if(!empty($neterr) && util::need_check($net_errno)) {
                     $mod_refill->partition(util::part_refill($order_time))->edit($order_id, ['commit_time' => time(),'neterr' => 1,'err_msg' => "neterr=$net_errno"]);
                     util::monitor_netchk($channel_name,false);

+ 3 - 3
helper/refill/api/xyz/bodian_yd/RefillCallBack.php

@@ -50,7 +50,7 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function add_filter($order_id,$can_commit)
+    private function add_filter($order_id, $can_commit)
     {
         $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
         if(!empty($refill_info)) {
@@ -58,8 +58,8 @@ class RefillCallBack implements refill\IRefillCallBack
             $card_type = intval($refill_info['card_type']);
             $mchid = intval($refill_info['mchid']);
             $mch_order = $refill_info['mch_order'];
-            $chfilters = new refill\channel_filter($mchid,$mch_order,$quality,$card_type);
-            $chfilters->add_channel('bodian_yd',$can_commit);
+            $chfilters = new refill\channel_filter($mchid, $mch_order, $card_type);
+            $chfilters->add_channel($quality, 'bodian_yd', $can_commit);
         }
     }
 }

+ 10 - 0
helper/refill/order.php

@@ -36,6 +36,7 @@ class order
     private $mThirdPorductType;
     private $mThirdCardType; // 三方充值账号类型
     private $mThirdExtes = [];  //三方扩展参数
+    private $mChannelFilter = null;
 
     public function __construct()
     {
@@ -248,6 +249,8 @@ class order
                 $this->mThirdExtes['province'] = $third_info['province'];
             }
         }
+
+        $this->mChannelFilter = new channel_filter($this->mMchid,$this->mMchOrder,$this->mCardType);
     }
 
     public function is_third()
@@ -275,6 +278,11 @@ class order
         return "{$this->mMchid}-{$this->mMchOrder}";
     }
 
+    public function filter()
+    {
+        return $this->mChannelFilter;
+    }
+
     private function setParams($params)
     {
         $this->mMchid = intval($params['mchid']);
@@ -343,6 +351,8 @@ class order
                 $this->mCardState = $params['cardno_state'];
                 $this->mIsValidate = $params['is_validate'] == 1;
             }
+
+            $this->mChannelFilter = new channel_filter($this->mMchid,$this->mMchOrder,$this->mCardType);
         }
     }
 

+ 7 - 4
helper/refill/policy/channel_filter.php

@@ -11,11 +11,12 @@ class channel_filter
     private $mCardType;
 
     private $mDatas;
-    public function __construct($mchid,$mch_order,$quality,$card_type)
+
+    public function __construct($mchid, $mch_order, $card_type)
     {
         $this->mMchid = $mchid;
         $this->mMchOrder = $mch_order;
-        $this->mQuality = $quality;
+        $this->mQuality = 0;
         $this->mCardType = $card_type;
 
         if($this->mCardType != mtopcard\ThirdRefillCard) {
@@ -30,12 +31,13 @@ class channel_filter
         }
     }
 
-    public function add_channel($name,$succ)
+    public function add_channel($cur_quality, $name, $succ)
     {
         if ($this->mCardType == mtopcard\ThirdRefillCard) {
             return;
         }
 
+        $this->mQuality = $cur_quality;
         if (!array_key_exists($this->mQuality, $this->mDatas)) {
             $this->mDatas[$this->mQuality] = [];
         }
@@ -63,8 +65,9 @@ class channel_filter
         }
     }
 
-    public function getProviders($inProviders)
+    public function getProviders($cur_quality,$inProviders)
     {
+        $this->mQuality = $cur_quality;
         if ($this->mCardType == mtopcard\SinopecCard || $this->mCardType == mtopcard\PetroChinaCard) {
             return $this->diff($inProviders);
         } elseif ($this->mCardType == mtopcard\ThirdRefillCard) {

+ 3 - 3
helper/refill/policy/xyz/policy.php

@@ -413,7 +413,7 @@ class policy extends ProviderManager implements IPolicy
 
             $price = $this->mPrices->price($mchid,$card_type,$spec,$quality,$pcode);
             if($price === false) {
-                Log::record("{$mchid} 没有协商 quality = {$quality} 价格",Log::DEBUG);
+                Log::record("{$mchid} 没有协商 quality = $quality 价格",Log::DEBUG);
                 continue;
             }
 
@@ -439,11 +439,11 @@ class policy extends ProviderManager implements IPolicy
             if (!empty($names)) {
                 return [$org_quality, $quality];
             } else {
-                Log::record("Policy::find_quality fail: mchid={$mchid} {$quality}-{$spec}-{$card_type}", Log::DEBUG);
+                Log::record("Policy::find_quality fail: mchid=$mchid $quality-$spec-$card_type", Log::DEBUG);
             }
         }
 
-        Log::record("Policy::find_quality fail: mchid={$mchid} {$spec}-{$card_type}", Log::DEBUG);
+        Log::record("Policy::find_quality fail: mchid=$mchid $spec-$card_type", Log::DEBUG);
         return [$org_quality,0];
     }
 

+ 7 - 3
helper/refill/todo.MD

@@ -1,5 +1,9 @@
 
 ### 20231221 升级
-1,从通道列表配置中读,失败次数和提交次数。
-2,对channel_filter 升级,增加质量和提单次数。
-3,
+
+1,从通道列表配置中读,失败次数和提交次数。  
+2,对channel_filter 升级,增加质量和提单次数。 
+方案:    
+    1,更换redis字段名称为 order_channels。  
+  
+3,对通道的时间和次数控制,进行重新优化。  

+ 5 - 5
helper/refill/util.php

@@ -484,7 +484,7 @@ class util
     {
         $ins = Cache::getInstance('cacheredis');
         $name = 'order_channels';
-        $key = "{$mchid}-{$mchorder}";
+        $key = "$mchid-$mchorder";
         $ins->hset($name, '', [$key => serialize($datas)]);
     }
 
@@ -493,7 +493,7 @@ class util
         //old-name oil_exclude_channels
         $ins = Cache::getInstance('cacheredis');
         $name = 'order_channels';
-        $key = "{$mchid}-{$mchorder}";
+        $key = "$mchid-$mchorder";
 
         $chnames = $ins->hget($name, '', $key);
         $chnames = unserialize($chnames);
@@ -509,7 +509,7 @@ class util
     {
         $ins = Cache::getInstance('cacheredis');
         $name = 'order_channels';
-        $key = "{$mchid}-{$mchorder}";
+        $key = "$mchid-$mchorder";
 
         $ins->hdel($name, '', $key);
     }
@@ -519,7 +519,7 @@ class util
     {
         $ins = Cache::getInstance('cacheredis');
         $name = 'order_cancel_hash';
-        $key = "{$mchid}-{$mch_order}";
+        $key = "$mchid-$mch_order";
 
         $ins->hset($name, '', [$key=> 1]);
     }
@@ -548,7 +548,7 @@ class util
     {
         $ins = Cache::getInstance('cacheredis');
         $name = 'order_next_hash';
-        $key = "{$mchid}-{$mch_order}";
+        $key = "$mchid-$mch_order";
 
         $ins->hset($name, '', [$key=> 1]);
     }