liugc 9 달 전
부모
커밋
31055d0137
1개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 28 0
      app/api/service/DouYinService.php

+ 28 - 0
app/api/service/DouYinService.php

@@ -678,6 +678,8 @@ class DouYinService
                 $order->save();
                 //工单完结
                 self::paymentSuccessful(['sn'=>$rechargeOrder->sn,'pay_way'=>4]);
+                //抖音履约完成
+                self::pushDelivery($order->order_number);
                 return true;
             }
         }elseif ($params['status'] === 'CANCEL' && $params['message'] == 'TIME_OUT'){
@@ -730,6 +732,32 @@ class DouYinService
             throw new \Exception($e->getMessage());
         }
     }
+    // 工单不同状态履约 - 发送抖音 同步履约状态即核销
+    public static function pushDelivery($order_number)
+    {
+        try {
+            // $params['order_number']
+            $order = DouyinOrder::where('order_number', $order_number)->findOrEmpty();
+            if($order->isEmpty()){
+                throw new \Exception('订单不存在');
+            }
+            $orderInfo = $order->toArray();
+            $book_info = json_decode($orderInfo['book_info']?:'{}',true);
+            $url = 'api/apps/trade/v2/fulfillment/push_delivery/';
+            $data = [
+                "book_id" => (string)$book_info['open_book_info']['book_id'],
+                "use_all" => true,
+                "out_order_no" => $order_number,
+                "delivery_status" => 2,
+            ];
+            $resData = self::toDyRequestUrl($url,$data);
+            Log::info('pushDelivery:'.formatLogData($resData));
+            return true;
+        } catch (\Exception $e) {
+            Log::info('pushDelivery-error:'.$e->getMessage());
+            return false;
+        }
+    }
     // ++++++++++++++++++++ 尾款创单 end