ソースを参照

Merge branch 'master' of http://101.200.220.49:8001/houxiaohua/playlet

houxiaohua 2 ヶ月 前
コミット
28880be86f
共有3 個のファイルを変更した19 個の追加6 個の削除を含む
  1. 7 0
      app/Http/Controllers/Admin/CallBackController.php
  2. 6 0
      app/Service/Order/FanQieService.php
  3. 6 6
      app/Service/wechatWorkService.php

+ 7 - 0
app/Http/Controllers/Admin/CallBackController.php

@@ -17,6 +17,7 @@ use App\Models\PlatformOrderConf;
17 17
 use App\RedisModel;
18 18
 use App\Service\CapacityService;
19 19
 use App\Service\DjOrderService;
20
+use App\Service\HttpService;
20 21
 use App\Service\MsgService;
21 22
 use App\Support\EmailQueue;
22 23
 use Illuminate\Http\Request;
@@ -324,6 +325,12 @@ class CallBackController extends Controller
324 325
 
325 326
         // 将接收到的数据保存的日志文件中
326 327
         Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [$platformId], 'platformOrder');
328
+        $taskId = $request->input('taskId', '');
329
+        $xurl = $request->input('xurl', '');
330
+        if(!empty($taskId)) {
331
+            # 主动同步下来的订单
332
+            return HttpService::httpGet('https://idea-ad.wenxingshuju.com/sunshine/orderList?'.http_build_query($request->all()));
333
+        }
327 334
 
328 335
         // 查询app_id对应的token
329 336
         $conf = PlatformOrderConf::getTokenByPlatformId($platformId);

+ 6 - 0
app/Service/Order/FanQieService.php

@@ -66,6 +66,12 @@ class FanQieService
66 66
         ], 'FanQieOrderList');
67 67
 
68 68
         $responseData = json_decode($response, 1);
69
+        if(isset($responseData['code']) && $responseData['code'] == 501 && $retry < 5) {
70
+            sleep(1);
71
+            $retry++;
72
+            return self::getOrderList($params, $retry);
73
+        }
74
+
69 75
         if(isset($responseData['code']) && $responseData['code'] != 200) {
70 76
             EmailQueue::rPush('获取番茄平台下的订单信息返回错误', $responseData['code'].':'.$responseData['message'], ['song.shen@kuxuan-inc.com'],
71 77
                 '猎羽');

+ 6 - 6
app/Service/wechatWorkService.php

@@ -404,7 +404,7 @@ class wechatWorkService
404 404
         while ($flag) {
405 405
             $accessToken = AuthorizeCorp::getAccessToken($corpid, '根据员工获取外部客户');
406 406
             try{
407
-                $result = wechatWorkService::getCustomerListMethod($params, $accessToken);
407
+                $result = wechatWorkService::getCustomerListMethod($params, $accessToken, $corpid);
408 408
 //                if($corpid == 'wwdfec0bcee287d5c5') {
409 409
 //                    Log::logInfo('同步客户', ['corpid' => $corpid, 'user_list' => $userList, 'res' =>$result], 'get_corp_customer_list');
410 410
 //                }
@@ -488,28 +488,28 @@ class wechatWorkService
488 488
     }
489 489
 
490 490
     // 根据内部员工获取外部联系客户具体方法
491
-    public static function getCustomerListMethod($params, $accessToken, $retry = 0)
491
+    public static function getCustomerListMethod($params, $accessToken, $corpid, $retry = 0)
492 492
     {
493 493
         $url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token='.$accessToken;
494 494
 
495 495
         $result = HttpService::httpPost($url, json_encode($params), true);
496 496
         $result = mb_convert_encoding($result, "UTF-8");
497 497
         $result = json_decode($result, 1);
498
-        if(empty($result) && $retry < 5) {
498
+        if((empty($result) || (isset($result['errcode']) && in_array($result['errcode'], [-1]))) && $retry < 5) {
499 499
             sleep(2);
500 500
             $retry++;
501
-            return self::getCustomerListMethod($params, $accessToken, $retry);
501
+            return self::getCustomerListMethod($params, $accessToken, $corpid, $retry);
502 502
         }
503 503
 
504 504
         if(isset($result['errcode']) && in_array($result['errcode'], [0, 701008, 60111])) {
505 505
             return $result;
506 506
         } else {
507 507
             // 请求失败,将响应数据写入日志
508
-            Log::logError('获取内部员工对应的外部联系人列表失败:URL'.$url.', 请求参数:'.json_encode($params),
508
+            Log::logError('获取内部员工对应的外部联系人列表失败:URL'.$url.', 请求参数:'.json_encode(array_merge($params, ['corpid' => $corpid])),
509 509
                 (array)$result, 'get_user_customer_list');
510 510
 
511 511
             EmailQueue::rPush('获取内部员工对应的外部联系人列表失败', json_encode([
512
-                'url' => $url, 'params' => $params, 'result' => (array)$result
512
+                'url' => $url, 'params' => array_merge($params, ['corpid' => $corpid]), 'result' => (array)$result
513 513
             ]), ['song.shen@kuxuan-inc.com'], '猎羽');
514 514
 
515 515
             return false;