fix:depot
This commit is contained in:
@@ -594,6 +594,8 @@ class DepotService extends BaseService{
|
||||
|
||||
public function recycle():array
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
$materialId = (int)$this->request->input('material_id');
|
||||
$supplierId = (int)$this->request->input('supplier_id');
|
||||
$number = (double)$this->request->input('number');
|
||||
@@ -652,12 +654,21 @@ class DepotService extends BaseService{
|
||||
|
||||
if (!$saleInfo->save() || !$depotRecycle->save() || !$materialStock->save()) throw new ErrException('回收发生异常');
|
||||
|
||||
DB::commit();
|
||||
} catch (ErrException $error) {
|
||||
Db::rollBack();
|
||||
throw new ErrException($error->getMessage());
|
||||
}
|
||||
|
||||
|
||||
return $this->return->success();
|
||||
|
||||
}
|
||||
|
||||
public function recycleUpdate():array
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
$id = (int)$this->request->input('id');
|
||||
$number = (double)$this->request->input('number');
|
||||
|
||||
@@ -691,6 +702,11 @@ class DepotService extends BaseService{
|
||||
throw new ErrException('回收数量不能大于出库数量');
|
||||
|
||||
if (!$info->save() || !$materialStock->save() || !$saleInfo->save()) throw new ErrException('商品回收数量修改失败');
|
||||
DB::commit();
|
||||
} catch (ErrException $error) {
|
||||
Db::rollBack();
|
||||
throw new ErrException($error->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
|
||||
@@ -698,6 +714,8 @@ class DepotService extends BaseService{
|
||||
|
||||
public function recycleDelete():array
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
if (RoleCode::WAREHOUSE != $this->roleId && RoleCode::SUPER_ADMIN != $this->roleId && RoleCode::ADMIN != $this->roleId)
|
||||
@@ -731,6 +749,12 @@ class DepotService extends BaseService{
|
||||
if (!$info->save() || !$materialStock->save() || !$saleInfo->save())
|
||||
throw new ErrException('商品回收删除失败');
|
||||
|
||||
DB::commit();
|
||||
} catch (ErrException $error) {
|
||||
Db::rollBack();
|
||||
throw new ErrException($error->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
@@ -763,6 +787,8 @@ class DepotService extends BaseService{
|
||||
|
||||
public function recycleAudit():array
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
$id = (int)$this->request->input('id');
|
||||
$status = (int)$this->request->input('status');
|
||||
|
||||
@@ -834,6 +860,12 @@ class DepotService extends BaseService{
|
||||
|
||||
if (!$info->save()) throw new ErrException('回收审核异常');
|
||||
|
||||
DB::commit();
|
||||
} catch (ErrException $error) {
|
||||
Db::rollBack();
|
||||
throw new ErrException($error->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user