fix:depot

This commit is contained in:
LAPTOP-7SGDREK0\shiweijun
2025-02-28 09:59:04 +08:00
parent 01d70dd374
commit b139ea8db4

View File

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