作者 jinglong
1 个管道 的构建 通过 耗费 2 秒

增加其他推荐商品列表

... ... @@ -247,7 +247,7 @@ class Common
* 商品列表
* @ApiInternal
*/
public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc'){
public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc',$flag = ''){
$arr = [];
//默认未登录
$is_news = self::is_new($uid);
... ... @@ -286,7 +286,11 @@ class Common
$arr['data'] = $res;
//总页数
$arr['total_page'] = Common::countSoft('goods',$where);
return $arr;
if(empty($flag)){
return $arr;
}else{
return $res;
}
}
/**
... ...
... ... @@ -9,7 +9,7 @@ use think\Validate;
*/
class Goods extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['goodsDetail','otherBrowseGoodsList','sortGoodsList'];
protected $noNeedRight = ['*'];
protected $uid = '';
public function _initialize()
... ... @@ -317,4 +317,71 @@ class Goods extends Api
}
}
/**
* @ApiTitle (其他推荐商品列表)
* @ApiSummary (其他推荐商品列表)
* @ApiMethod (GET)
* @ApiRoute (/api/goods/otherRecommendGoodsList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="order_id", type="inter", required=true, description="订单id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574941706",
"data": [
{
"id": 7,//商品id
"image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片路径
"name": "MONENT 动感系列",//商品名称
"tag": [//商品标签
"日式简约",
"隐秘乡奢",
"家庭情侣"
],
"style": [//商品规格
"主餐匙,茶匙各1件",
"古堡灰"
],
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
"image": "http://jinglong.springchunjia.cn/uploads/20191128/93971e55b83d1a09c1831f8197514305.png",
"name": "MONENT 动感系列",
"tag": [
"AB级",
"ABX级",
"ABN级"
],
"new_price": 2499,
"sale_price": 2599
},
],
})
*/
public function otherRecommendGoodsList(){
if($this->request->isGet()){
$order_id = $this->request->get('order_id');
$rule = config('verify.order_detail');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['order_id'=>$order_id])) {
$this->error($validate->getError());
}
//查询订单的商品所属品类id,品牌id
$res_o_goods = Common::selectSoftWhereData('ogoods',['o_id'=>$order_id],'id,g_id');
$goods_id_s = array_column($res_o_goods,'g_id');
$res_goods = Common::selectSoftWhereData('goods',['id'=>['in',$goods_id_s]],'id,t_id');
$t_id_s = array_column($res_goods,'t_id');
$limit = config('verify.goods_limit');
$arr = Common::goodsList(['t_id'=>['in',$t_id_s]],1,$this->uid,$limit,'hots desc',1);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
}
... ...
此 diff 太大无法显示。