Parcourir la source

Merge branch 'iOIL' of 39.97.239.116:gyfl/xyzshop into iOIL

stanley-king il y a 4 ans
Parent
commit
c414f7f35b

+ 26 - 0
helper/refill/beixt/RefillCallBack.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace refill\beixt;
+
+use refill;
+
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+
+    public function verify($params) : bool
+    {
+        return true;
+    }
+
+    public function onOil($params)
+    {
+
+    }
+
+    public function onPhone($params)
+    {
+        // TODO: Implement onPhone() method.
+    }
+}

+ 60 - 0
helper/refill/beixt/RefillPhone.php

@@ -0,0 +1,60 @@
+<?php
+namespace refill\beixt;
+
+require_once(BASE_HELPER_PATH . '/refill/beixt/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone
+{
+    private function req_params(int $phone, int $amount ,string $order_sn)
+    {
+        $params['phone'] = $phone;
+        $params['product_id'] = $amount;
+        $params['tradeNo'] = $order_sn;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return json_encode($params);
+    }
+
+    public function add($phone,$amount,$order_sn)
+    {
+        $params = $this->req_params($phone,$amount,$order_sn);
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: OrderCreate",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+        $resp = http_post_data(config::REQUEST_URL,$params,$header);
+        if($resp === false) {
+            return [false,'系统错误'];
+        }
+        else
+        {
+            Log::record($resp,Log::DEBUG);
+            $resp = json_decode($resp,true);
+            if($resp['state'] == 0) {
+                return [true,$resp['data']];
+            }
+            else {
+                return [false,$resp['msg']];
+            }
+        }
+    }
+
+    private function sign($time)
+    {
+        $ip = config::API_IP;
+        $cert = config::API_CERT;
+        $content = $ip.$time.$cert;
+
+        return md5($content);
+    }
+}

+ 14 - 0
helper/refill/beixt/config.php

@@ -0,0 +1,14 @@
+<?php
+
+
+namespace refill\beixt;
+
+
+class config
+{
+    const REQUEST_URL = 'http://8.129.76.127/APIHfKc/v2/';
+    const API_USER_NAME= '2cf54e1fcd1944e102114c56cf9fe4ca';
+    const API_CERT = '2f889d471d2e34a8219dce36e51621c8';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const API_IP = '111.193.234.45';
+}

+ 4 - 0
mobile/beixt_notify.php

@@ -0,0 +1,4 @@
+<?php
+Log::record('notify receive',Log::DEBUG);
+Log::record("post data : {$_POST}" , Log::DEBUG);
+echo ('ok');

+ 7 - 0
mobile/control/merchant_base.php

@@ -0,0 +1,7 @@
+<?php
+
+
+class merchant_base
+{
+
+}

+ 7 - 0
mobile/control/merchant_info.php

@@ -0,0 +1,7 @@
+<?php
+
+
+class merchant_info
+{
+
+}

+ 7 - 0
mobile/control/merchant_order.php

@@ -0,0 +1,7 @@
+<?php
+
+
+class merchant_order
+{
+
+}

+ 9 - 0
test/TestRefill.php

@@ -14,6 +14,7 @@ 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');
 
+require_once(BASE_HELPER_PATH . '/refill/beixt/RefillPhone.php');
 class TestRefill extends TestCase
 {
     public static function setUpBeforeClass(): void
@@ -37,6 +38,14 @@ class TestRefill extends TestCase
         }
     }
 
+    public function testRefillPhone()
+    {
+        $providers = new \refill\beixt\RefillPhone();
+        $resp = $providers->add(18500608333,50,'200649600557718888');
+        //{"ack":"success","message":{"order_number":13281474,"charged_amount":"48.750","shipping_status":"5","shipping_status_desc":"未发货"}}
+        // content={"order_number":13281474,"shipping_status":1,"shipping_status_desc":"已发货","shipping_status_message":"","sign":"05863f9931ed69a70e456222f057dfdd","voucher":"110103307162012081746340295254","vouchertype":"","voucherurl":"","tradeNo":"200649600557718888"}
+    }
+
     public function testAddoil()
     {
         $params = ['mchid' => 1,'cardno' => '1000111100021211884','amount' => "100","act"=>"refill","op"=>"addoil",