gogs 11 月之前
父节点
当前提交
493c137249
共有 3 个文件被更改,包括 78 次插入4 次删除
  1. 76 3
      app/Http/Controllers/Api/DwyController.php
  2. 1 1
      app/Service/DwyService.php
  3. 1 0
      routes/api.php

+ 76 - 3
app/Http/Controllers/Api/DwyController.php

@@ -10,14 +10,16 @@ use App\Service\SysMenuService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Str;
+use Obs\ObsClient;
 
 class DwyController extends BaseController
 {
 
 
-    public function advertisement()
+    public function advertisement(Request $request)
     {
 
+
         return ['status' => 200, 'data' => [
             'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
                 'https://clouddevice.qingyaokeji.com/2.mp4'],
@@ -27,6 +29,77 @@ class DwyController extends BaseController
             ],
             'limit_time' => 10
         ]];
+        $data = $request->all();
+        file_put_contents('dwy1.txt', json_encode(['data'=>$data,'header']) . PHP_EOL, 8);
+        $url = 'https://tm.dwycloud.com/jbl/api/module-data/poster/poster/diy/device_code';
+        $token = $data['token'];
+        $param = ['device_code'=>$data['mac']];
+        $header = [
+            'Content-Type:application/json',
+            'Authorization: ' . $token,
+        ];
+        $box_data = $this->post_helper($url, json_encode($param), $header);
+        $box_data = json_decode($box_data, true);
+        dd($box_data);
+        if(isset($box_data)&&$box_data['status'] === 'success'){
+            $return = [
+                'video' => [],
+                'img' => [],
+                'limit_time' => 10
+            ];
+            foreach ($box_data['data'] as $v){
+                if(isset($v['poster_attachment']['picture_attachment']['attachFile'])){
+                    foreach ($v['poster_attachment']['picture_attachment']['attachFile'] as $vv){
+                        $return['img'][] = $vv['url'].'.'.$vv['typeEk'];
+                    }
+                }
+                if(isset($v['poster_attachment']['attachment']['attachFile'])){
+                    foreach ($v['poster_attachment']['attachment']['attachFile'] as $vv){
+
+                        $return['video'][] = $vv['url'].'.'.$vv['typeEk'];
+                    }
+                }
+
+
+            }
+//            var_dump($return);die;
+        }else{
+            $return  = [
+                'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
+                    'https://clouddevice.qingyaokeji.com/2.mp4'],
+                'img' => [
+                    'https://clouddevice.qingyaokeji.com/3.jpeg',
+                    'https://clouddevice.qingyaokeji.com/3.jpeg',
+                ],
+                'limit_time' => 10
+            ];
+        }
+
+        return ['status' => 200, 'data' => $return];
+    }
+
+    public function getObsUrl(){
+        $obsClient = new ObsClient([
+            'key' => 'RN0XF4M0LJDJOVAUGPNK',
+            'secret' => 'eCH4ga2kEgQBD2I6niIZkkjxLWIAPKotS5mhwNTE',
+            'endpoint' => 'https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com'
+        ]);
+        // 设置桶名和对象名
+        $bucketName = 'shangbiaoji';
+        $objectKey = '20240621/E1F5AF36B011AEBAACB7246DD15F5E1E.mp4'; // 例如:path/to/video.mp4
+        // 设置过期时间(以秒为单位)
+        $expires = 3600; // URL的有效期为1小时
+        // 生成预签名URL
+        $response = $obsClient->createSignedUrl([
+            'Method' => 'GET', // 请求方法
+            'Bucket' => $bucketName,
+            'Key' => $objectKey,
+            'Expires' => $expires
+        ]);
+        // 获取预签名URL
+        $signedUrl = $response['SignedUrl'];
+        $obsClient->close();
+        var_dump($signedUrl);die;
     }
 
     public function openCommand(Request $request)
@@ -685,7 +758,7 @@ class DwyController extends BaseController
 
         }
         $box_list = [
-            6,7
+            1,2
         ];
        foreach ($box_list as $v){
            $v = $v+3;
@@ -719,7 +792,7 @@ class DwyController extends BaseController
         $list = $param['list'];
         $mac = $param['mac'];
 //        if($mac === '28f1e65c8cfd496f'){
-//
+////
 //            return $this->test();
 //        }
         $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';

+ 1 - 1
app/Service/DwyService.php

@@ -284,7 +284,7 @@ class DwyService extends Service
 
         foreach ($data['list'] as $value){
             $key = $value['order_item_id'] . hash('md5', $value['title']);
-            $bool = $this->limitingSendRequestBackg($key, $value['num'], 3600);
+            $bool = $this->limitingSendRequestBackg($key, $value['num'], 600);
             if(! $bool) return [false, '同一产品相同商标限制同时操作,请稍后操作!'];
         }
 

+ 1 - 0
routes/api.php

@@ -60,6 +60,7 @@ Route::any('tttt', 'Api\DwyController@tttt');
 Route::any('getBoxTrademark', 'Api\DwyController@getBoxTrademark');
 Route::any('aaaa', 'Api\DwyController@setBoxTrademark');
 Route::any('boxOut', 'Api\JobController@labelDeal');
+Route::any('getObsUrl', 'Api\JobController@getObsUrl');
 
 Route::group(['middleware'=> []],function ($route){
     $route->any('menuAdd', 'Api\SysMenuController@add');