liugc hai 10 meses
pai
achega
edfe2156b3
Modificáronse 2 ficheiros con 26 adicións e 35 borrados
  1. 7 4
      app/api/controller/DouYinController.php
  2. 19 31
      app/api/service/DouYinService.php

+ 7 - 4
app/api/controller/DouYinController.php

@@ -145,7 +145,7 @@ class DouYinController extends BaseApiController
      * @author liugc <466014217@qq.com>
      * @date 2025/5/22 14:35
      */
-    public function submitOrder()
+    /*public function submitOrder()
     {
         try {
             $params = $this->request->post();
@@ -158,15 +158,18 @@ class DouYinController extends BaseApiController
         } catch (\Exception $e) {
             return $this->fail($e->getMessage());
         }
-    }
+    }*/
 
     public function submitOrderNotify()
     {
         try {
             $params = $this->request->post();
             $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true);
-            if(DouYinService::submitOrderNotify($msg)){
-                return json(["err_no"=>0,"err_tips"=>"success"], 200);
+            $msg['user_id'] = $this->userId;
+            $msg['user_info'] = $this->userInfo;
+            $res = DouYinService::submitOrderNotify($msg);
+            if($res){
+                return json(["err_no"=>0,"err_tips"=>"success","data"=>$res], 200);
             }
         } catch (\Exception $e) {
             return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200);

+ 19 - 31
app/api/service/DouYinService.php

@@ -230,45 +230,33 @@ class DouYinService
     /**
      * 扩展点回调提交订单
      * @param $params
-     * @return bool
      * @throws \Exception
      * @author liugc <466014217@qq.com>
      * @date 2025/6/4 14:03
      */
     public static function submitOrderNotify($params)
     {
-        Db::startTrans();
         try {
             // order_id goods  total_amount discount cp_extra create_order_time phone_num contact_name open_id
-
-            /*$params
-
-            "order_id": "614167279916",
-            "goods": [
-                {
-                    "img_url": "http://xxx",
-                    "title": "xxx",
-                    "sub_title": "xxx",
-                    "labels": "过期退|随时退",
-                    "date_rule": "xxx",
-                    "origin_price": 800,
-                    "price": 750,
-                    "quantity": 2,
-                    "poi_id": "",
-                    "goods_id": "xxx",
-                    "item_order_id_list": [
-                        "1xxx",
-                        "2xxx"
-                    ]
-                }
-            ],*/
-
-
-
-            Db::commit();
-            return true;
+            if(empty($params['user_info']['mobile'])){
+                throw new \Exception('手机号不能为空!');
+            }
+            // goods_id  user_info.mobile  user_id quantity
+            $order_number = self::submitOrder([
+                'goods_id'=>$params['goods'][0]['goods_id'],
+                'user_id'=>$params['user_id'],
+                'user_info'=>$params['user_info'],
+                'quantity'=>$params['goods'][0]['quantity']
+            ]);
+            return [
+                "outOrderNo" => $order_number,
+                "orderEntrySchema" => [
+                    "path" => "page/index/index",
+                    "params" => json_encode(['order_number' => $order_number])
+                ],
+                "payNotifyUrl" => config('douyin.payNotifyUrl')
+            ];
         } catch (\Exception $e) {
-            Db::rollback();
             throw new \Exception($e->getMessage());
         }
     }
@@ -277,7 +265,7 @@ class DouYinService
 
     /**
      * 提交订单
-     * @param array $params
+     * @param array $params goods_id  user_info.mobile  user_id quantity
      * @return array|false
      */
     public static function submitOrder($params)