liugc 9 tháng trước cách đây
mục cha
commit
73b8b9abf2
3 tập tin đã thay đổi với 33 bổ sung5 xóa
  1. 18 3
      app/api/controller/DouYinController.php
  2. 2 2
      app/api/service/DouYinService.php
  3. 13 0
      app/common.php

+ 18 - 3
app/api/controller/DouYinController.php

@@ -34,8 +34,13 @@ use think\facade\Log;
 class DouYinController extends BaseApiController
 {
 
-    public array $notNeedLogin = ['testNotify','getClientToken','register','account','getAllGoods','getGoodsDetail','submitOrderNotify','payNotify'];
-
+    public array $notNeedLogin = ['testNotify','getClientToken','register','account','getAllGoods','getGoodsDetail','submitOrderNotify','payNotify','payTailNotify'];
+    public function testNotify()
+    {
+        $params = $this->request->post();
+        Log::info('testNotify'.formatLogData($params));
+        return $this->success();
+    }
     /**
      * 手机号注册
      * @author liugc <466014217@qq.com>
@@ -99,6 +104,16 @@ class DouYinController extends BaseApiController
 
 
     // ******************************** 列表详情 _商品 _订单 _退款
+    /*
+     * 商品审核结果回调
+     */
+    public function goodsNotify()
+    {
+        $params = $this->request->post();
+        Log::info('goodsNotify:'.formatLogData($params));
+        return $this->success();
+    }
+
     /**
      * 所有商品
      * @return \think\response\Json
@@ -170,7 +185,7 @@ class DouYinController extends BaseApiController
             $params = $this->request->post();
             $params['user_id'] = $this->userId;
             $params['user_info'] = $this->userInfo;
-            $requestOrderData = DouYinService::getPluginCreateOrderData($params['goods_id']??'',$params['quantity']??1,$params['douyin_order_id']??'',$params);
+            $requestOrderData = DouYinService::getPluginCreateOrderData($params['goods_id']??'',$params['quantity']??1,$params['dy_order_id']??'',$params);
             return $this->success('',$requestOrderData);
         } catch (\Exception $e) {
             return $this->fail($e->getMessage());

+ 2 - 2
app/api/service/DouYinService.php

@@ -243,11 +243,11 @@ class DouYinService
             ];
 
             if($douyinOrderId){ // 说明是来自首单订单即要创建尾款
-                $data['callbackUrl'] = '';
+                $data['callbackUrl'] = env('douyin.pay_tail_notify_url')??'';
                 $data['tradeOption'] = [
                     "life_trade_flag" => 1,
                     "order_relation_info" => [
-                        "related_order_id" => '', // 加价时上个订单号
+                        "related_order_id" => $douyinOrderId?:0, // 加价时上个订单号
                         "relation_type" => 'multi_buy_as_one'
                     ]
                 ];

+ 13 - 0
app/common.php

@@ -751,4 +751,17 @@ function decrypt($data, $key) {
         // 捕获并处理异常
         throw new Exception('参数不合规: ' . $e->getMessage());
     }
+}
+
+/**
+ * 日志格式化
+ * @param $data
+ * @return false|string|void
+ * @author liugc <466014217@qq.com>
+ */
+function formatLogData($data){
+    if(is_array($data)) return json_encode($data);
+    if(is_object($data)) return json_encode((array)$data);
+    if(is_bool($data)) return $data?'true':'false';
+    if(is_string($data)) return $data;
 }