Parcourir la source

add protuct card_type match refill card type

stanley-king il y a 2 ans
Parent
commit
37396b5860

+ 8 - 6
helper/rbridge/fulu/Bridge.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_PATH . '/rbridge/fulu/config.php');
 
 use rbridge\IBridge;
 use refill;
-use refill_proxy;
 use Log;
 use StatesHelper;
 
@@ -23,13 +22,15 @@ class Bridge implements IBridge
             global $fulu_product;
             if(empty($fulu_product)) return config::DEFAULT_MCHID;
 
-            foreach ($fulu_product as $mchid => $goods_ids)
+            foreach ($fulu_product as $mchid => $product_infos)
             {
-                if(in_array($product_num, $goods_ids)){
-                    return $mchid;
+                if(array_key_exists($product_num, $product_infos)) {
+                    $card_type = $product_infos[$product_num];
+                    return [$mchid,$card_type];
                 }
             }
-            return config::DEFAULT_MCHID;
+            
+            return [config::DEFAULT_MCHID,0];
         };
 
         $params = $this->aes_decrypt($params);
@@ -38,7 +39,7 @@ class Bridge implements IBridge
         }
 
         $SupProductId = $params['SupProductId'];
-        $mchid = $dispatcher($SupProductId);
+        [$mchid,$mch_card_type] = $dispatcher($SupProductId);
         $chargeType = intval($params['OrderType']);
 
         //订单类型:1话费 2流量 3卡密 4直充,
@@ -55,6 +56,7 @@ class Bridge implements IBridge
             'amount' => $params['SupProductFaceValue'],
             'card_no' => $params['ChargeAccount'],
             'mch_order' => $params['Id'],
+            'mch_card_type' => $mch_card_type,
             'notify_url' => config::MCH_NOTIFY_URL];
 
         $code = refill\util::push_add($input);

+ 12 - 12
helper/rbridge/fulu/product.php

@@ -6,22 +6,22 @@ global $fulu_product;
 $fulu_product = [
     10300 => [
         //移动
-        500081315,
-        500081172,
-        500081316,
-        500081298,
+        500081315 => 4,
+        500081172 => 4,
+        500081316 => 4,
+        500081298 => 4,
 
         //联通
-        500081303,
-        500081193,
-        500081304,
-        500081302,
+        500081303 => 5,
+        500081193 => 5,
+        500081304 => 5,
+        500081302 => 5,
 
         //电信
-        500081305,
-        500081213,
-        500081306,
-        500081214
+        500081305 => 6,
+        500081213 => 6,
+        500081306 => 6,
+        500081214 => 6
     ]
 ];
 

+ 15 - 1
helper/refill/order.php

@@ -19,6 +19,7 @@ class order
     private $mLastOrderID;
     private $mOriginQuality;
     private $mCurQuality;
+    private $mMchCardType; //用于产品和卡类型绑定的充值机构.
 
     private $mCardType;
     private $mRegionNo;
@@ -41,6 +42,7 @@ class order
         $this->mProductCode = '';
         $this->mThirdPorductType = 0;
         $this->mMatchRatio = false;
+        $this->mMchCardType = 0;
     }
 
     public function mchid() {
@@ -65,7 +67,7 @@ class order
     public function set_match($match) {
         $this->mMatchRatio = $match;
     }
-    public function match() {
+    public function match_ratio() {
         return $this->mMatchRatio;
     }
 
@@ -125,6 +127,17 @@ class order
             'third_card_type' => $this->mThirdCardType];
         return $third_params;
     }
+
+    public function match_card_type()
+    {
+        if($this->mMchCardType === 0) {
+            return true;
+        }
+        else {
+            return $this->mMchCardType === $this->card_type();
+        }
+    }
+
     public function is_transfer() {
         return $this->mIsTransfer;
     }
@@ -205,6 +218,7 @@ class order
         $this->mQuantity   = $params['quantity'] ?? 1;
         $this->mOriginQuality = intval($params['org_quality']) ?? 0;
         $this->mMatchRatio = $params['match_ratio'] ?? false;
+        $this->mMchCardType = $params['mch_card_type'] ?? 0;
 
         $card_type = intval($params['card_type']) ?? 0;
         if($card_type == mtopcard\ThirdRefillCard)

+ 8 - 3
rdispatcher/proxy.php

@@ -29,7 +29,7 @@ class proxy
 
     private function need_transfer(refill\order $order)
     {
-        if($order->match()) return false;
+        if($order->match_ratio()) return false;
 
         $order_time = $order->order_time();
         $mchid = $order->mchid();
@@ -140,8 +140,13 @@ class proxy
             return $this->onEerror($order, '运营商维护被全局拦截.');
         }
 
-        if($order->first_commit()) {
-            refill\util::incr_user_commit($mchid,$order->card_type(),$order->spec(),$org_quality);
+        if($order->first_commit())
+        {
+            if (!$order->match_card_type()) {
+                return $this->onEerror($order, '卡类型和产品类型不符.');
+            } else {
+                refill\util::incr_user_commit($mchid, $order->card_type(), $order->spec(), $org_quality);
+            }
         }
         elseif($this->need_transfer($order) && $this->transfer($order)) {
             return true;