This commit is contained in:
mkm 2023-11-04 11:03:57 +08:00
parent 93a45242f2
commit 868fb3ea44
2 changed files with 16 additions and 20 deletions

View File

@ -109,6 +109,9 @@ class CloudWarehouse extends BaseController
]; ];
$count=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->count(); $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(); $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]); return app('json')->success(['count'=>$count,'list'=>$select]);
} }
} }

View File

@ -140,30 +140,23 @@ class StoreMicro extends BaseController
} }
public function eadtProduct(){ public function eadtProduct(){
$product_id = $this->request->param('id', 0); $id = $this->request->param('id', 0);
if ($product_id==0) return app('json')->fail('商品id不能为空'); $image = $this->request->param('image', '');
$price = $this->request->param('price', 0); $slider_image = $this->request->param('slider_image', '');
if ($price==0) return app('json')->fail('价格不能为空');
$stock = $this->request->param('stock', 0); if ($slider_image=='') return app('json')->fail('轮播图不能为空');
if ($stock==0) return app('json')->fail('库存不能为空'); if ($image=='') 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();
try { try {
Db::name('store_product')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); $res=Db::name('product_library')->where('id',$id)->update(['image'=>$image,'slider_image'=>$slider_image]);
Db::name('store_product_attr_value')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); if($res){
// 提交事务 return app('json')->success('更新成功');
Db::commit(); }else{
return app('json')->success(['data'=>'','msg'=>'更新成功']); return app('json')->fail('更新失败');
}
} catch (\Exception $e) { } catch (\Exception $e) {
// 回滚事务 // 回滚事务
Db::rollback();
return app('json')->fail($e->getMessage()); return app('json')->fail($e->getMessage());
} }
} }