stanley-king 2 سال پیش
والد
کامیت
7530d4207e
4فایلهای تغییر یافته به همراه92 افزوده شده و 0 حذف شده
  1. 30 0
      data/logic/queue.logic.php
  2. 1 0
      data/model/refill_provider.model.php
  3. 50 0
      helper/refill/RefillBase.php
  4. 11 0
      test/TestRefillBalance.php

+ 30 - 0
data/logic/queue.logic.php

@@ -1456,4 +1456,34 @@ class queueLogic
             return callback(false, 'AysncChangePrice 参数为空');
         }
     }
+
+    public function OnRiskSN($params)
+    {
+        $store_id = intval($params['store_id']);
+        $channel_name = intval($params['channel_name']);
+
+        if($store_id <= 0 || empty($channel_name)) {
+            return callback(false, 'OnRiskSN 参数有空');
+        }
+
+        $mod_provider = Model('refill_provider');
+        $item = $mod_provider->getProviderInfo(['store_id' => $store_id,'name' => $channel_name]);
+
+        if (empty($item)) {
+            return callback(false, 'OnRiskSN 检查出多个通道');
+        }
+        else
+        {
+            $provider_id = intval($item['provider_id']);
+            $state = intval($item['opened']);
+            if ($state == 1) {
+                $mod_provider->editProvider(['opened' => 2], ['provider_id' => $provider_id]);
+
+                $publisher = new message\publisher();
+                $publisher->modify_refill_channel();
+            }
+        }
+
+        return callback(true, "OnRiskSN 成功禁用通道");
+    }
 }

+ 1 - 0
data/model/refill_provider.model.php

@@ -14,6 +14,7 @@ class refill_providerModel extends Model
     {
         return $this->where($cond)->find();
     }
+
     public function addProvider($insert){
         return $this->insert($insert);
     }

+ 50 - 0
helper/refill/RefillBase.php

@@ -561,6 +561,50 @@ class RefillBase
         return ($api_pay_amount == ncPriceFormat(0.0000));
     }
 
+    private function risksn_check($refill_info,$order_info)
+    {
+        $start_with = function ($haystack, $needle) {
+            $length = strlen($needle);
+            return (substr($haystack, 0, $length) === $needle);
+        };
+
+        $spcheker = function ($refill_info) use($start_with)
+        {
+            $official_sn = $refill_info['official_sn'];
+            $card_type = intval($refill_info['card_type']);
+
+            if(empty($official_sn)) return false;
+
+            if($card_type === mtopcard\ChinaMobileCard) {
+                if($start_with($official_sn,'0095')) {
+                    return true;
+                }
+            }
+            elseif($card_type === mtopcard\ChinaUnicomCard) {
+                if($start_with($official_sn,'SP')) {
+                    return true;
+                }
+                elseif($start_with($official_sn,'J98')) {
+                    return true;
+                }
+            }
+            elseif($card_type === mtopcard\ChinaTelecomCard) {
+                if($start_with($official_sn,'SP')) {
+                    return true;
+                }
+                elseif($start_with($official_sn,'WX')) {
+                    return true;
+                }
+            }
+
+            return false;
+        };
+
+        if($spcheker($refill_info)) {
+            QueueClient::async_push("OnRiskSN", ['store_id' => $order_info['store_id'],'channel_name' => $refill_info['channel_name']], 1);
+        }
+    }
+
     public function notify_merchant($order_id,$manual)
     {
         if ($order_id <= 0) {
@@ -593,6 +637,12 @@ class RefillBase
         if ($order_state !== ORDER_STATE_CANCEL && $order_state !== ORDER_STATE_SUCCESS) {
             return [false, "错误的订单状态,不能通知."];
         }
+
+        //流水号风险检测
+        if ($order_state === ORDER_STATE_SUCCESS && $refill_info['mch_notify_times'] < 1) {
+            $this->risksn_check($refill_info, $order_info);
+        }
+
         $resp = $this->mPolicy->notify($order_info,$refill_info);
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         if ($resp) {

+ 11 - 0
test/TestRefillBalance.php

@@ -20,6 +20,17 @@ class TestRefillBalance extends TestCase
         Base::run_util();
     }
 
+    public function testStartWith()
+    {
+        $start_with = function ($haystack, $needle) {
+            $length = strlen($needle);
+            return (substr($haystack, 0, $length) === $needle);
+        };
+
+        $x = $start_with('SP2022061805243705987437332339','SP');
+
+    }
+
     public function testAddBalance()
     {
         Log::short_name('testAddBalance');