stanley-king 4 gadi atpakaļ
vecāks
revīzija
06cfed7847

+ 2 - 2
data/config/dev/base.ini.php

@@ -45,8 +45,8 @@ $config['gip'] 		= 0;
 $config['dbdriver'] = 'mysqli';
 $config['tablepre']	= 'lrlz_';
 
-define('SSH_TUNEL_PROD','local');
-//define('SSH_TUNEL_PROD','xyz');
+//define('SSH_TUNEL_PROD','local');
+define('SSH_TUNEL_PROD','xyz');
 //define('SSH_TUNEL_PROD','lingzh');
 
 if(SSH_TUNEL_PROD ==='local') {

+ 13 - 0
data/model/thrid_refill.model.php

@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=0);
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class thrid_refillModel extends Model
+{
+    public function getProviderProduct($store_id,$goods_id,$system_code)
+    {
+        return $this->table('third_proprice')->where(['store_id' => $store_id,'goods_id' => $goods_id,'system_code' => $system_code])->field('*')->find();
+    }
+}

+ 2 - 2
helper/refill/IRefill.php

@@ -128,7 +128,7 @@ abstract class IRefill
         return $this->mAmountTypes;
     }
 
-    public function goods($quality,int $amount,int $card_type)
+    public function goods($quality,int $amount,int $card_type,$other)
     {
         $maps = $this->mAmountTypes[$quality] ?? [];
         $key = "{$amount}-{$card_type}";
@@ -137,7 +137,7 @@ abstract class IRefill
             return [$params['goods_id'], round($params['price'],2)];
         }
         else {
-            return [];
+            return [0,0];
         }
     }
 

+ 2 - 2
helper/refill/RefillBase.php

@@ -281,8 +281,8 @@ class RefillBase
             Log::record("select channel name = {$channel_name}",Log::DEBUG);
 
             //通道价格大于客户价格,换通道.
-            [$goods_id, $price] = $provider->goods($quality,$amount,$card_type);
-            if ($price > $mch_amount) continue;
+            [$goods_id, $price] = $provider->goods($quality,$amount,$card_type,$third_params);
+            if ($price > $mch_amount || $goods_id <= 0) continue;
 
             Log::record("start create order",Log::DEBUG);
 

+ 14 - 9
helper/refill/api/lingzh/sctongqian/RefillPhone.php

@@ -14,16 +14,20 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    public function goods($quality,int $amount,int $card_type)
+    public function goods($quality,int $amount,int $card_type,$other)
     {
-        $maps = $this->mAmountTypes[$quality] ?? [];
-        $key = "{$amount}-{$card_type}";
-        if(array_key_exists($key,$maps)) {
-            $params = $maps[$key];
-            return [$params['goods_id'], round($params['price'],2)];
-        }
-        else {
-            return [];
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$other);
+        if($goods_id <= 0) return [0,0];
+
+        $store_id = $this->mStoreID;
+        $pcode = $other['product_code'];
+        $thrid_refill = Model('thrid_refill');
+        $product = $thrid_refill->getProviderProduct($store_id,$goods_id,$pcode);
+        if(empty($product)) {
+            Log::record("cannot find provider's produce where name={$this->mName}, goods_id = {$goods_id} pcode={$pcode}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($product['channel_amount'])];
         }
     }
 
@@ -169,4 +173,5 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['ProductCode'] . $params['TimesTamp'] . $params['Version'] . config::App_Secret;
         return strtoupper(md5($content));
     }
+
 }

+ 30 - 0
test/TestThirdRefill.php

@@ -0,0 +1,30 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+
+class TestThirdRefill extends TestCase
+{
+    public static function setUpBeforeClass() : void
+    {
+        Base::run_util();
+    }
+
+    public function testProviderPrice()
+    {
+        $thrid_refill = Model('thrid_refill');
+        $info = $thrid_refill->getProviderProduct(34,1000,'LZPLM100591');
+
+    }
+}