作者 景龙
1 个管道 的构建 失败 耗费 0 秒

增加商品详情评论条数

... ... @@ -214,7 +214,7 @@ class Goods extends Api
"msg": "成功",
"time": "1553832106",
"data": [
{
"data":[{
"id": 1,
"type": 0, //类型 0:个人 1:企业
"title": "我的垃圾商品1", //商品名称
... ... @@ -223,9 +223,11 @@ class Goods extends Api
"stock": 1000, //商品库存
"address": "天津市南开区卫津路", //上门地址
"pre_time": "2019-03-19 14:36:08", //预约时间
"introduction" : "商品描述",
"description" : "商品详情",
"images": "/uploads/20190319/8e17442bd500a4842d456a95ec022826.jpg,/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg"
}
}],
"comment_count":"5"//商品评价条数
]
})
*/
... ... @@ -237,16 +239,19 @@ class Goods extends Api
if (!$validate->check(['id'=>$goods_id])) {
$this->error($validate->getError());
}
$comment_count = Db::table('gc_comment')
->where(['uid'=>$this->user_id,'p_id'=>$goods_id])
->count();
$data = Db::table('gc_product')
->alias('p')
->join('gc_user u','p.uid = u.id','LEFT')
->where(['p.id'=>$goods_id,'p.status'=>$this->normal,'u.status'=>'normal'])
->field('p.id,u.type,u.mobile,p.title,p.price,p.stock,u.address,p.pre_time,p.description,p.images')
->field('p.id,u.type,u.mobile,p.title,p.price,p.stock,u.address,p.pre_time,p.introduction,p.description,p.images')
->select();
foreach($data as &$value){
$value['pre_time'] = date('Y-m-d H:i:s',$value['pre_time']);
}
$this->success('成功', $data);
$this->success('成功', ['data'=>$data,'comment_count'=>$comment_count]);
}else{
$this->error('请求方式错误');
}
... ...