Browse Source

get mobile

xieruidong 2 years ago
parent
commit
5bf7fd9369

+ 1 - 1
application/index/controller/Index.php

@@ -35,6 +35,6 @@ class Index extends Frontend
     public function test(){
         //dd(MobileComputer::setMobile(input('no'))->filter());
         $order=ByteDancePay::setInfo('aaaaa',0.1,'test')->get();
-        dd($order);
+        dd($order->order_id);
     }
 }

+ 14 - 2
application/service/byte_dance/ByteDancePay.php

@@ -2,6 +2,7 @@
 namespace app\service\byte_dance;
 
 use think\Cache;
+use think\Collection;
 
 class ByteDancePay implements ByteDanceInterface {
     protected $data=[
@@ -40,7 +41,12 @@ class ByteDancePay implements ByteDanceInterface {
     {
         $data=$this->data;
         $data['sign']=$this->sign($data);
-        return ByteDance::httpPost('https://developer.toutiao.com/api/apps/ecpay/v1/create_order',$data);
+        $order=ByteDance::httpPost('https://developer.toutiao.com/api/apps/ecpay/v1/create_order',$data);
+        $obj=new ByteDanceResult();
+        foreach ($order as $key=>$item){
+            $obj->offsetSet($key,$item);
+        }
+        return $obj;
     }
 
     protected function sign($map) {
@@ -61,4 +67,10 @@ class ByteDancePay implements ByteDanceInterface {
         sort($rList, 2);
         return md5(implode('&', $rList));
     }
-}
+}
+/**
+ * @property string $order_id
+ * @property string $order_token
+ * @property string $url
+ */
+class ByteDanceResult extends Collection {}

+ 5 - 0
thinkphp/library/think/Collection.php

@@ -464,4 +464,9 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
     {
         return $items instanceof self ? $items->all() : (array) $items;
     }
+
+    public function __get($name)
+    {
+        return $this->offsetGet($name);
+    }
 }