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();
$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]);
}
}

View File

@ -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());
}
}