diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index edc7c85d..041b6b42 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -109,6 +109,9 @@ class CloudWarehouse extends BaseController ]; $count=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->count(); $select=Db::name('store_product')->whereIn('product_id',$cloud_product)->where($where)->select(); + if(!$select){ + $count=0; + } return app('json')->success(['count'=>$count,'list'=>$select]); } } \ No newline at end of file diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index da7eab0b..07b28748 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -140,30 +140,23 @@ class StoreMicro extends BaseController } public function eadtProduct(){ - $product_id = $this->request->param('id', 0); - if ($product_id==0) return app('json')->fail('商品id不能为空'); - $price = $this->request->param('price', 0); - if ($price==0) return app('json')->fail('价格不能为空'); - $stock = $this->request->param('stock', 0); - if ($stock==0) return app('json')->fail('库存不能为空'); - $user = $this->request->userInfo(); - $mer_id =Db::name('store_service')->where('uid',$user['uid'])->where('status',1)->value('mer_id'); - if ($mer_id==0) return app('json')->fail('商户id不能为空'); - $data = [ - 'price'=>$price, - 'stock'=>$stock, - ]; - Db::startTrans(); + $id = $this->request->param('id', 0); + $image = $this->request->param('image', ''); + $slider_image = $this->request->param('slider_image', ''); + + if ($slider_image=='') return app('json')->fail('轮播图不能为空'); + if ($image=='') return app('json')->fail('首屏图不能为空'); + try { - Db::name('store_product')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); - Db::name('store_product_attr_value')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); - // 提交事务 - Db::commit(); - return app('json')->success(['data'=>'','msg'=>'更新成功']); + $res=Db::name('product_library')->where('id',$id)->update(['image'=>$image,'slider_image'=>$slider_image]); + if($res){ + return app('json')->success('更新成功'); + }else{ + return app('json')->fail('更新失败'); + } } catch (\Exception $e) { // 回滚事务 - Db::rollback(); return app('json')->fail($e->getMessage()); } }