feat: 修改了商品库存编辑功能
This commit is contained in:
parent
98da00e975
commit
a5953e3170
@ -55,13 +55,14 @@ class StoreBranchProductController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
d(1);
|
$params =$this->request->post();
|
||||||
$params = (new StoreProductValidate())->post()->goCheck('edit');
|
foreach($params['data'] as $k=>$v){
|
||||||
$result = StoreProductLogic::edit($params);
|
StoreProductLogic::stock($v);
|
||||||
if (true === $result) {
|
if(StoreProductLogic::hasError()){
|
||||||
return $this->success('编辑成功', [], 1, 1);
|
return $this->fail(StoreProductLogic::getError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this->fail(StoreProductLogic::getError());
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,4 +257,21 @@ class StoreProductLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加库存
|
||||||
|
*/
|
||||||
|
public static function stock($data){
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
StoreBranchProduct::where(['id' => $data['id']])->inc('stock',$data['stock'])->update();
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user