feat(system_store_storage): 添加编辑库存功能

This commit is contained in:
mkm 2024-06-08 21:33:34 +08:00
parent bf1940eb00
commit f5185ea377

View File

@ -7,6 +7,8 @@ use app\store\controller\BaseAdminController;
use app\store\lists\system_store_storage\SystemStoreStorageLists;
use app\admin\logic\system_store_storage\SystemStoreStorageLogic;
use app\admin\validate\system_store_storage\SystemStoreStorageValidate;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\system_store_storage\SystemStoreStorage;
use hg\apidoc\annotation as ApiDoc;
@ -30,6 +32,20 @@ class SystemStoreStorageController extends BaseAdminController
return $this->dataLists(new SystemStoreStorageLists());
}
public function edit()
{
$id = $this->request->post('id',0);
if($id==0){
return $this->fail('参数错误');
}
$res=SystemStoreStorage::where(['id' => $id,'store_id'=>$this->adminInfo['store_id']])->update(['status'=>1,'staff_id'=>$this->adminId]);
if($res){
$find=SystemStoreStorage::where(['id' => $id])->find();
StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->inc('stock',$find['nums'])->update();
return $this->success('操作成功',[]);
}
return $this->fail('操作失败');
}
}