feat(warehouse): 优化仓库产品编辑功能和变更日志

- 修改 WarehouseProductController 中的 edit 方法,增加 adminId 参数
- 更新 WarehouseProductLogic 中的 edit 方法,接收 adminId 参数
- 在 ChangeLogLists 中添加 admin_name 字段,关联管理员名称
- 调整 WarehouseProductLogic 中的 dec
This commit is contained in:
mkm 2025-01-06 14:15:12 +08:00
parent 148e6cf019
commit 1caae07bb9
3 changed files with 11 additions and 7 deletions

View File

@ -76,7 +76,7 @@ class WarehouseProductController extends BaseAdminController
{
$params = $this->request->post();
$params['admin_id'] = $this->adminId;
$result = WarehouseProductLogic::edit($params);
$result = WarehouseProductLogic::edit($params,$this->adminId);
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -6,7 +6,7 @@ namespace app\admin\lists;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\ChangeLog;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
/**
* ChangeLog列表
@ -45,10 +45,14 @@ class ChangeLogLists extends BaseAdminDataLists implements ListsSearchInterface
public function lists(): array
{
return ChangeLog::where($this->searchWhere)
->field(['id', 'model', 'link_id', 'nums', 'pm', 'url', 'mark'])
->field(['id', 'admin_id','model', 'link_id', 'nums', 'pm', 'url', 'mark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->select()->each(function ($item) {
if($item->admin_id){
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
}}
)
->toArray();
}

View File

@ -199,15 +199,15 @@ class WarehouseProductLogic extends BaseLogic
* @author admin
* @date 2024/07/31 16:55
*/
public static function edit(array $params)
public static function edit(array $params,$admin_id=0)
{
Db::startTrans();
try {
$find = WarehouseOrder::where('id', $params['oid'])->find();
if ($find) {
$res = WarehouseProduct::where('id', $params['id'])->withTrashed()->find();
self::decStock($res);
self::incStock($res, $params);
self::decStock($res,$admin_id);
self::incStock($res, $params,$admin_id);
$datas = [
'nums' => $params['nums'],
'total_price' => $params['total_price'],