正在显示
1 个修改的文件
包含
9 行增加
和
4 行删除
@@ -214,7 +214,7 @@ class Goods extends Api | @@ -214,7 +214,7 @@ class Goods extends Api | ||
214 | "msg": "成功", | 214 | "msg": "成功", |
215 | "time": "1553832106", | 215 | "time": "1553832106", |
216 | "data": [ | 216 | "data": [ |
217 | - { | 217 | + "data":[{ |
218 | "id": 1, | 218 | "id": 1, |
219 | "type": 0, //类型 0:个人 1:企业 | 219 | "type": 0, //类型 0:个人 1:企业 |
220 | "title": "我的垃圾商品1", //商品名称 | 220 | "title": "我的垃圾商品1", //商品名称 |
@@ -223,9 +223,11 @@ class Goods extends Api | @@ -223,9 +223,11 @@ class Goods extends Api | ||
223 | "stock": 1000, //商品库存 | 223 | "stock": 1000, //商品库存 |
224 | "address": "天津市南开区卫津路", //上门地址 | 224 | "address": "天津市南开区卫津路", //上门地址 |
225 | "pre_time": "2019-03-19 14:36:08", //预约时间 | 225 | "pre_time": "2019-03-19 14:36:08", //预约时间 |
226 | + "introduction" : "商品描述", | ||
226 | "description" : "商品详情", | 227 | "description" : "商品详情", |
227 | "images": "/uploads/20190319/8e17442bd500a4842d456a95ec022826.jpg,/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg" | 228 | "images": "/uploads/20190319/8e17442bd500a4842d456a95ec022826.jpg,/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg" |
228 | - } | 229 | + }], |
230 | + "comment_count":"5"//商品评价条数 | ||
229 | ] | 231 | ] |
230 | }) | 232 | }) |
231 | */ | 233 | */ |
@@ -237,16 +239,19 @@ class Goods extends Api | @@ -237,16 +239,19 @@ class Goods extends Api | ||
237 | if (!$validate->check(['id'=>$goods_id])) { | 239 | if (!$validate->check(['id'=>$goods_id])) { |
238 | $this->error($validate->getError()); | 240 | $this->error($validate->getError()); |
239 | } | 241 | } |
242 | + $comment_count = Db::table('gc_comment') | ||
243 | + ->where(['uid'=>$this->user_id,'p_id'=>$goods_id]) | ||
244 | + ->count(); | ||
240 | $data = Db::table('gc_product') | 245 | $data = Db::table('gc_product') |
241 | ->alias('p') | 246 | ->alias('p') |
242 | ->join('gc_user u','p.uid = u.id','LEFT') | 247 | ->join('gc_user u','p.uid = u.id','LEFT') |
243 | ->where(['p.id'=>$goods_id,'p.status'=>$this->normal,'u.status'=>'normal']) | 248 | ->where(['p.id'=>$goods_id,'p.status'=>$this->normal,'u.status'=>'normal']) |
244 | - ->field('p.id,u.type,u.mobile,p.title,p.price,p.stock,u.address,p.pre_time,p.description,p.images') | 249 | + ->field('p.id,u.type,u.mobile,p.title,p.price,p.stock,u.address,p.pre_time,p.introduction,p.description,p.images') |
245 | ->select(); | 250 | ->select(); |
246 | foreach($data as &$value){ | 251 | foreach($data as &$value){ |
247 | $value['pre_time'] = date('Y-m-d H:i:s',$value['pre_time']); | 252 | $value['pre_time'] = date('Y-m-d H:i:s',$value['pre_time']); |
248 | } | 253 | } |
249 | - $this->success('成功', $data); | 254 | + $this->success('成功', ['data'=>$data,'comment_count'=>$comment_count]); |
250 | }else{ | 255 | }else{ |
251 | $this->error('请求方式错误'); | 256 | $this->error('请求方式错误'); |
252 | } | 257 | } |
-
请 注册 或 登录 后发表评论