Selaa lähdekoodia

xiaoniu doubi

xiaoyu 3 vuotta sitten
vanhempi
commit
bdc66167e6

+ 8 - 1
data/config/win/refill.ini.php

@@ -3236,11 +3236,18 @@ $yanhao = ['name' => 'yanhao', 'store_id' => 151,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xiaoniu_doubi = ['name' => 'xiaoniu_doubi', 'store_id' => 156,'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 7324, 'price' => 99, 'quality' => 1, 'card_type' => 'third']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $third_providers = [
     ['name' => 'lingzhthird', 'cfg' => $lingzhthird],
     ['name' => 'jumithird', 'cfg' => $jumithird],
     ['name' => 'santi', 'cfg' => $santi],
-    ['name' => 'yanhao', 'cfg' => $yanhao]
+    ['name' => 'yanhao', 'cfg' => $yanhao],
+    ['name' => 'xiaoniu_doubi', 'cfg' => $xiaoniu_doubi]
 ];
 $config['third_providers'] = $third_providers;
 

+ 8 - 1
data/config/xyz/refill.ini.php

@@ -3236,11 +3236,18 @@ $yanhao = ['name' => 'yanhao', 'store_id' => 151,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xiaoniu_doubi = ['name' => 'xiaoniu_doubi', 'store_id' => 156,'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 7324, 'price' => 99, 'quality' => 1, 'card_type' => 'third']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $third_providers = [
     ['name' => 'lingzhthird', 'cfg' => $lingzhthird],
     ['name' => 'jumithird', 'cfg' => $jumithird],
     ['name' => 'santi', 'cfg' => $santi],
-    ['name' => 'yanhao', 'cfg' => $yanhao]
+    ['name' => 'yanhao', 'cfg' => $yanhao],
+    ['name' => 'xiaoniu_doubi', 'cfg' => $xiaoniu_doubi]
 ];
 $config['third_providers'] = $third_providers;
 

+ 8 - 1
data/config/xyzadm/refill.ini.php

@@ -3236,11 +3236,18 @@ $yanhao = ['name' => 'yanhao', 'store_id' => 151,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xiaoniu_doubi = ['name' => 'xiaoniu_doubi', 'store_id' => 156,'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 7324, 'price' => 99, 'quality' => 1, 'card_type' => 'third']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $third_providers = [
     ['name' => 'lingzhthird', 'cfg' => $lingzhthird],
     ['name' => 'jumithird', 'cfg' => $jumithird],
     ['name' => 'santi', 'cfg' => $santi],
-    ['name' => 'yanhao', 'cfg' => $yanhao]
+    ['name' => 'yanhao', 'cfg' => $yanhao],
+    ['name' => 'xiaoniu_doubi', 'cfg' => $xiaoniu_doubi]
 ];
 $config['third_providers'] = $third_providers;
 

+ 33 - 0
helper/refill/api/xyz/xiaoniu_doubi/RefillPhone.php

@@ -14,6 +14,34 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
+    public function goods($quality, int $amount, int $card_type, $regin_no, $other)
+    {
+        [$goods_id, $price] = parent::goods($quality, $amount, $card_type, $regin_no, $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'])];
+        }
+    }
+
+    private function getProductAmount($sys_pcode)
+    {
+        $thrid_refill = Model('thrid_refill');
+        $product = $thrid_refill->getProduct(['system_code' => $sys_pcode]);
+        if (empty($product)) {
+            return false;
+        } else {
+            return $product['refill_amount'];
+        }
+    }
+
     private function req_params(int $phone, int $amount, string $order_sn)
     {
         $params['mId'] = config::MCH_ID;
@@ -29,7 +57,12 @@ class RefillPhone extends refill\IRefillPhone
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
+        $amount = $this->getProductAmount($params['product_code']);
+        if(empty($amount)) {
+            return [false, '产品未开启', false];
+        }
         $params = $this->req_params($card_no, $amount, $params['order_sn']);
+
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 

+ 1 - 2
helper/refill/api/xyz/xiaoniu_doubi/config.php

@@ -9,7 +9,6 @@ class config
 
     const MCH_ID = 'xn210709006';
     const Key = '6bfdcb765af3434b886e48fa609c6ec4';
-//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xiaoniu_doubi.php";
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xiaoniu_doubi.php";
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 }

+ 14 - 0
test/TestRefill.php

@@ -1389,6 +1389,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testXiaoniu_doubi()
+    {
+//        $provider = $this->getProvider('xiaoniu_doubi');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(61841435, 7, 100, ['order_sn' => $this->make_sn(), 'product_code' => 'XYZ100747']);
+//        $resp = $provider->query(['order_sn' => '22971637223235623767']);
+
+        $body = '{"content":"","realAmt":"92.0000","status":"1","timestamp":"20211118161507","sign":"28598a6c4674294aecb0337ef20b4e02","orderNo":"XN20211118161400122361716","mOrderNo":"22971637223235623767"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('xiaoniu_doubi','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);