Selaa lähdekoodia

add - 抖音商品

liugc 10 kuukautta sitten
vanhempi
commit
e7254e1a28

+ 1 - 1
app/api/controller/DouYinController.php

@@ -44,7 +44,7 @@ class DouYinController extends BaseApiController
 
 
     public function getClientToken()
     public function getClientToken()
     {
     {
-        $access_token = DouYinService::getClientToken();
+        $access_token = DouYinService::getClientToken($this->request->get()['isRefresh']??false);
         return $this->success('',['access_token'=>$access_token]);
         return $this->success('',['access_token'=>$access_token]);
     }
     }
     /**
     /**

+ 34 - 21
app/api/service/DouYinService.php

@@ -23,6 +23,8 @@ class DouYinService
 {
 {
     protected static int $terminal = \app\common\enum\user\UserTerminalEnum::DOUYIN;
     protected static int $terminal = \app\common\enum\user\UserTerminalEnum::DOUYIN;
     protected static int $external_platform_id = 6;
     protected static int $external_platform_id = 6;
+
+    // ********************************* 注册登录
     public static function register(array $params)
     public static function register(array $params)
     {
     {
         $userSn = User::createUserSn();
         $userSn = User::createUserSn();
@@ -77,6 +79,33 @@ class DouYinService
         }
         }
     }
     }
 
 
+    // **************************** 商品管理
+/*/product/save/ 先调
+goods/sku/batch_save/ 再调
+
+生成 产品组装
+生成  sku 组装
+生成对应的 attr_key_value_map 组装*/
+
+    public static function getProductParams($type,$params)
+    {
+        return [];
+    }
+    public static function getSkuParams($type,$params)
+    {
+        return [];
+    }
+
+
+    public static function getAttrKeyValueMapParams($type,$params)
+    {
+        return [];
+    }
+
+
+
+
+
     /**
     /**
      * 提交订单
      * 提交订单
      * @param array $params
      * @param array $params
@@ -505,24 +534,7 @@ class DouYinService
     {
     {
         Db::startTrans();
         Db::startTrans();
         try {
         try {
-            $douyinRefundOrder = DouyinRefundOrder::where('refund_number', $params['out_refund_no'])->findOrEmpty();
-            if($douyinRefundOrder->isEmpty()){
-                throw new \Exception('退款订单不存在');
-            }
-            if($douyinRefundOrder->refund_status == 0){
-                if($params['status'] === 'SUCCESS'){
-                    $douyinRefundOrder->refund_status = 3;
-                    DouyinOrder::where('order_number', $douyinRefundOrder->order_number)->update([
-                        'order_status' => 4,
-                        'pay_status' => 3,
-                    ]);
-                }elseif($params['status'] === 'FAIL'){
-                    $douyinRefundOrder->refund_status = 4;
-                }else{
-                    throw new \Exception('退款状态未知');
-                }
-                $douyinRefundOrder->save();
-            }
+
             Db::commit();
             Db::commit();
             return true;
             return true;
         } catch (\Exception $e) {
         } catch (\Exception $e) {
@@ -566,23 +578,24 @@ class DouYinService
         }
         }
         return $str;
         return $str;
     }
     }
-    public static function getClientToken() {
+    public static function getClientToken($isRefresh = false) {
         $url = config('douyin.host').'oauth/client_token/';
         $url = config('douyin.host').'oauth/client_token/';
         $cache_name = 'dy_client_token';
         $cache_name = 'dy_client_token';
         $cache_data = cache($cache_name);
         $cache_data = cache($cache_name);
-        if(empty($cache_data) || $cache_data == null){
+        if(empty($cache_data) || $cache_data == null || $isRefresh){
             $data = [
             $data = [
                 'client_key'=> config('douyin.appId'),
                 'client_key'=> config('douyin.appId'),
                 'client_secret'=> config('douyin.appSecret'),
                 'client_secret'=> config('douyin.appSecret'),
                 'grant_type'=> "client_credential"
                 'grant_type'=> "client_credential"
             ];
             ];
             $res = http_request($url,$data,['Content-Type' => 'application/json;charset=utf-8']);
             $res = http_request($url,$data,['Content-Type' => 'application/json;charset=utf-8']);
+            Log::info(json_encode($res));
             if($res['message'] === 'success'){
             if($res['message'] === 'success'){
                 cache($cache_name, json_encode($res['data']), (time()+$res['data']['expires_in']-1));
                 cache($cache_name, json_encode($res['data']), (time()+$res['data']['expires_in']-1));
                 $cache_data = $res['data'];
                 $cache_data = $res['data'];
             }
             }
         }
         }
-        return json_decode($cache_data, true)['access_token'];
+        return $cache_data['access_token'];
     }
     }
 
 
 
 

+ 1 - 1
config/cache.php

@@ -29,7 +29,7 @@ return [
             // 驱动方式
             // 驱动方式
             'type'   => 'redis',
             'type'   => 'redis',
             // 服务器地址
             // 服务器地址
-            'host'   => env('cache.host','like-redis'),
+            'host'   => env('cache.host','127.0.0.1'),
             // 端口
             // 端口
             'port'   => env('cache.port','6379'),
             'port'   => env('cache.port','6379'),
             // 密码
             // 密码