mark 3 years ago
parent
commit
d56ed997a0

+ 78 - 0
app/Http/Controllers/Buy/BuyController.php

@@ -232,4 +232,82 @@ class BuyController extends BaseController
         $data = BuyLogic::getGoodsSearchLogic();
         return $this->success($data);
     }
+
+    /**
+     * @SWG\Get(
+     *     path="/buy/transfer/goods",
+     *     tags={"电商导购"},
+     *     summary="淘宝分享商品详情页接口",
+     *     description="淘宝分享商品详情页接口",
+     *     produces={"application/json"},
+     *     @SWG\Parameter(
+     *          name="user_id",
+     *          in="query",
+     *          description="分享者用户ID",
+     *          type="string"
+     *     ),
+     *     @SWG\Parameter(
+     *          name="goods_id",
+     *          in="query",
+     *          description="商品ID",
+     *          type="string"
+     *     ),
+     *     @SWG\Response(
+     *         response="200",
+     *         description="success",
+     *          @SWG\Schema(
+     *              @SWG\Property(
+     *                  property="goods_name",
+     *                  type="string",
+     *                  description="商品名称"
+     *              ),
+     *              @SWG\Property(
+     *                  property="price",
+     *                  type="string",
+     *                  description="优惠价"
+     *              ),
+     *              @SWG\Property(
+     *                  property="market_price",
+     *                  type="string",
+     *                  description="市场价格"
+     *              ),
+     *              @SWG\Property(
+     *                  property="discount",
+     *                  type="string",
+     *                  description="优惠金额"
+     *              ),
+     *              @SWG\Property(
+     *                  property="commission",
+     *                  type="string",
+     *                  description="佣金"
+     *              ),
+     *              @SWG\Property(
+     *                  property="url",
+     *                  type="string",
+     *                  description="购买链接"
+     *              ),
+     *              @SWG\Property(
+     *                  property="goods_carousel_pictures",
+     *                  type="string",
+     *                  description="商品轮播图(数组)"
+     *              ),
+     *              @SWG\Property(
+     *                  property="goods_detail_pictures",
+     *                  type="string",
+     *                  description="商品详情图片(数组)"
+     *              ),
+     *          )
+     *     ),
+     *     @SWG\Response(
+     *         response="403",
+     *         description="fail",
+     *         @SWG\Schema(ref="#/definitions/ErrorBean")
+     *     )
+     * )
+     */
+    public function transferGoods()
+    {
+        $data = BuyLogic::transferGoodsLogic();
+        return $this->success($data);
+    }
 }

+ 34 - 0
app/Http/Logic/Buy/BuyLogic.php

@@ -160,4 +160,38 @@ class BuyLogic extends BaseLogic
             "list"=>$datas
         ];
     }
+
+    /**
+     * 获取淘宝商品的转链逻辑
+     */
+    public static function transferGoodsLogic()
+    {
+        $params = request()->all();
+        $userId = $params["user_id"];
+        $user = UserModel::findById($userId);
+        $platformSid = BaseUtil::getPlatformUserSpreadId(PlatformTypeEnum::PLATFORM_JUTUIKE,$userId);
+        $res = JutuikeUtil::convert($params["goods_id"],$platformSid);
+
+        $coupon_info = [];
+        if(isset($res["couponInfo"]["fav"])){
+            $coupon_info = [
+                "fav"=>$res["couponInfo"]["fav"],
+                "use_end_time"=>$res["couponInfo"]["useEndTime"],
+                "use_begin_time"=>$res["couponInfo"]["useBeginTime"],
+            ];
+        }
+        $data = [
+            "goods_name"=>$res["goodsName"],
+            "price"=>$res["price"],
+            "market_price"=>$res["marketPrice"],
+            "discount"=>$res["discount"],
+            "commission"=>round($res["commission"]*$user["user_commission_rate"]/100,2),
+            "url"=>$res["url"],
+            "goods_carousel_pictures"=>$res["goodsCarouselPictures"],
+            "goods_detail_pictures"=>$res["goodsDetailPictures"],
+            "coupon_info"=>$coupon_info
+
+        ];
+        return $data;
+    }
 }

+ 20 - 0
app/Http/Validate/Buy/BuyControllerValidate.php

@@ -92,4 +92,24 @@ class BuyControllerValidate extends BaseValidate
         }
         return true;
     }
+
+    /**
+     * 淘宝商品转链参数校验
+     * @param $data
+     */
+    public function transferGoods($data)
+    {
+        $validate = Validator::make($data,
+            [
+                "user_id"=>"required",
+                "goods_id"=>"required",
+            ]
+        );
+        if($validate->fails()){
+            //验证错误
+            $this->setError($validate->errors()->first());
+            return false;
+        }
+        return true;
+    }
 }

+ 79 - 0
public/swagger.json

@@ -207,6 +207,12 @@
                         "description": "\u6bcf\u9875\u6570\u91cf",
                         "type": "string"
                     },
+                    {
+                        "name": "sort",
+                        "in": "query",
+                        "description": "1-\u7efc\u5408\u6392\u5e8f,2-\u4ef7\u683c\u5347\u5e8f,3-\u9500\u91cf\u964d\u5e8f \u9ed8\u8ba41",
+                        "type": "string"
+                    },
                     {
                         "name": "source",
                         "in": "query",
@@ -230,6 +236,79 @@
                 }
             }
         },
+        "/buy/transfer/goods": {
+            "get": {
+                "tags": [
+                    "\u7535\u5546\u5bfc\u8d2d"
+                ],
+                "summary": "\u6dd8\u5b9d\u5206\u4eab\u5546\u54c1\u8be6\u60c5\u9875\u63a5\u53e3",
+                "description": "\u6dd8\u5b9d\u5206\u4eab\u5546\u54c1\u8be6\u60c5\u9875\u63a5\u53e3",
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "user_id",
+                        "in": "query",
+                        "description": "\u5206\u4eab\u8005\u7528\u6237ID",
+                        "type": "string"
+                    },
+                    {
+                        "name": "goods_id",
+                        "in": "query",
+                        "description": "\u5546\u54c1ID",
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "success",
+                        "schema": {
+                            "properties": {
+                                "goods_name": {
+                                    "description": "\u5546\u54c1\u540d\u79f0",
+                                    "type": "string"
+                                },
+                                "price": {
+                                    "description": "\u4f18\u60e0\u4ef7",
+                                    "type": "string"
+                                },
+                                "market_price": {
+                                    "description": "\u5e02\u573a\u4ef7\u683c",
+                                    "type": "string"
+                                },
+                                "discount": {
+                                    "description": "\u4f18\u60e0\u91d1\u989d",
+                                    "type": "string"
+                                },
+                                "commission": {
+                                    "description": "\u4f63\u91d1",
+                                    "type": "string"
+                                },
+                                "url": {
+                                    "description": "\u8d2d\u4e70\u94fe\u63a5",
+                                    "type": "string"
+                                },
+                                "goods_carousel_pictures": {
+                                    "description": "\u5546\u54c1\u8f6e\u64ad\u56fe(\u6570\u7ec4)",
+                                    "type": "string"
+                                },
+                                "goods_detail_pictures": {
+                                    "description": "\u5546\u54c1\u8be6\u60c5\u56fe\u7247(\u6570\u7ec4)",
+                                    "type": "string"
+                                }
+                            }
+                        }
+                    },
+                    "403": {
+                        "description": "fail",
+                        "schema": {
+                            "$ref": "#/definitions/ErrorBean"
+                        }
+                    }
+                }
+            }
+        },
         "/home/list": {
             "get": {
                 "tags": [

+ 3 - 1
routes/api.php

@@ -37,7 +37,7 @@ Route::get("/wechat/account/config","WechatController@accountConfig");
 Route::any("wechat/account/callback","WechatController@accountCallback");
 
 //根据链接获取转链链接
-Route::any("transfer/{userId}/{actId}","Home\HomeController@getTransferLinkurl");
+Route::any("transfer/{userId}/{actId}/{type?}","Home\HomeController@getTransferLinkurl");
 
 //定时任务
 Route::prefix("cron")->namespace("Cron")->group(function (){
@@ -115,6 +115,8 @@ Route::prefix("buy")->namespace("Buy")->middleware(["checkAuth"])->group(functio
     Route::get("goods/detail","BuyController@getGoodsDetail");
     //商品搜索接口
     Route::get("goods/search","BuyController@getGoodsSearch");
+    //获取分享淘宝商品的详情
+    Route::get("transfer/goods","BuyController@transferGoods");
 });