正在显示
3 个修改的文件
包含
74 行增加
和
3 行删除
@@ -247,7 +247,7 @@ class Common | @@ -247,7 +247,7 @@ class Common | ||
247 | * 商品列表 | 247 | * 商品列表 |
248 | * @ApiInternal | 248 | * @ApiInternal |
249 | */ | 249 | */ |
250 | - public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc'){ | 250 | + public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc',$flag = ''){ |
251 | $arr = []; | 251 | $arr = []; |
252 | //默认未登录 | 252 | //默认未登录 |
253 | $is_news = self::is_new($uid); | 253 | $is_news = self::is_new($uid); |
@@ -286,7 +286,11 @@ class Common | @@ -286,7 +286,11 @@ class Common | ||
286 | $arr['data'] = $res; | 286 | $arr['data'] = $res; |
287 | //总页数 | 287 | //总页数 |
288 | $arr['total_page'] = Common::countSoft('goods',$where); | 288 | $arr['total_page'] = Common::countSoft('goods',$where); |
289 | - return $arr; | 289 | + if(empty($flag)){ |
290 | + return $arr; | ||
291 | + }else{ | ||
292 | + return $res; | ||
293 | + } | ||
290 | } | 294 | } |
291 | 295 | ||
292 | /** | 296 | /** |
@@ -9,7 +9,7 @@ use think\Validate; | @@ -9,7 +9,7 @@ use think\Validate; | ||
9 | */ | 9 | */ |
10 | class Goods extends Api | 10 | class Goods extends Api |
11 | { | 11 | { |
12 | - protected $noNeedLogin = ['*']; | 12 | + protected $noNeedLogin = ['goodsDetail','otherBrowseGoodsList','sortGoodsList']; |
13 | protected $noNeedRight = ['*']; | 13 | protected $noNeedRight = ['*']; |
14 | protected $uid = ''; | 14 | protected $uid = ''; |
15 | public function _initialize() | 15 | public function _initialize() |
@@ -317,4 +317,71 @@ class Goods extends Api | @@ -317,4 +317,71 @@ class Goods extends Api | ||
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | + /** | ||
321 | + * @ApiTitle (其他推荐商品列表) | ||
322 | + * @ApiSummary (其他推荐商品列表) | ||
323 | + * @ApiMethod (GET) | ||
324 | + * @ApiRoute (/api/goods/otherRecommendGoodsList) | ||
325 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
326 | + * | ||
327 | + * @ApiParams (name="order_id", type="inter", required=true, description="订单id") | ||
328 | + * | ||
329 | + * @ApiReturn({ | ||
330 | + "code": 1, | ||
331 | + "msg": "成功", | ||
332 | + "time": "1574941706", | ||
333 | + "data": [ | ||
334 | + { | ||
335 | + "id": 7,//商品id | ||
336 | + "image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片路径 | ||
337 | + "name": "MONENT 动感系列",//商品名称 | ||
338 | + "tag": [//商品标签 | ||
339 | + "日式简约", | ||
340 | + "隐秘乡奢", | ||
341 | + "家庭情侣" | ||
342 | + ], | ||
343 | + "style": [//商品规格 | ||
344 | + "主餐匙,茶匙各1件", | ||
345 | + "古堡灰" | ||
346 | + ], | ||
347 | + "sale_price": 2299//销售价格 | ||
348 | + "expense_price": //运费(0:显示包运费标签) | ||
349 | + "is_new_tag": 0//新人价格标签(0:不显示,1:显示) | ||
350 | + }, | ||
351 | + { | ||
352 | + "id": 4, | ||
353 | + "image": "http://jinglong.springchunjia.cn/uploads/20191128/93971e55b83d1a09c1831f8197514305.png", | ||
354 | + "name": "MONENT 动感系列", | ||
355 | + "tag": [ | ||
356 | + "AB级", | ||
357 | + "ABX级", | ||
358 | + "ABN级" | ||
359 | + ], | ||
360 | + "new_price": 2499, | ||
361 | + "sale_price": 2599 | ||
362 | + }, | ||
363 | + ], | ||
364 | + }) | ||
365 | + */ | ||
366 | + public function otherRecommendGoodsList(){ | ||
367 | + if($this->request->isGet()){ | ||
368 | + $order_id = $this->request->get('order_id'); | ||
369 | + $rule = config('verify.order_detail'); | ||
370 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
371 | + if (!$validate->check(['order_id'=>$order_id])) { | ||
372 | + $this->error($validate->getError()); | ||
373 | + } | ||
374 | + //查询订单的商品所属品类id,品牌id | ||
375 | + $res_o_goods = Common::selectSoftWhereData('ogoods',['o_id'=>$order_id],'id,g_id'); | ||
376 | + $goods_id_s = array_column($res_o_goods,'g_id'); | ||
377 | + $res_goods = Common::selectSoftWhereData('goods',['id'=>['in',$goods_id_s]],'id,t_id'); | ||
378 | + $t_id_s = array_column($res_goods,'t_id'); | ||
379 | + $limit = config('verify.goods_limit'); | ||
380 | + $arr = Common::goodsList(['t_id'=>['in',$t_id_s]],1,$this->uid,$limit,'hots desc',1); | ||
381 | + $this->success('成功',$arr); | ||
382 | + }else{ | ||
383 | + $this->error('请求方式错误'); | ||
384 | + } | ||
385 | + } | ||
386 | + | ||
320 | } | 387 | } |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论