feat(warehouse): 优化仓库产品编辑功能和变更日志
- 修改 WarehouseProductController 中的 edit 方法,增加 adminId 参数 - 更新 WarehouseProductLogic 中的 edit 方法,接收 adminId 参数 - 在 ChangeLogLists 中添加 admin_name 字段,关联管理员名称 - 调整 WarehouseProductLogic 中的 dec
This commit is contained in:
parent
148e6cf019
commit
1caae07bb9
@ -76,7 +76,7 @@ class WarehouseProductController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
$params['admin_id'] = $this->adminId;
|
$params['admin_id'] = $this->adminId;
|
||||||
$result = WarehouseProductLogic::edit($params);
|
$result = WarehouseProductLogic::edit($params,$this->adminId);
|
||||||
return $this->success('编辑成功', [], 1, 1);
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace app\admin\lists;
|
|||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\model\ChangeLog;
|
use app\common\model\ChangeLog;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChangeLog列表
|
* ChangeLog列表
|
||||||
@ -45,10 +45,14 @@ class ChangeLogLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return ChangeLog::where($this->searchWhere)
|
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)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()->each(function ($item) {
|
||||||
|
if($item->admin_id){
|
||||||
|
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||||
|
}}
|
||||||
|
)
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,15 +199,15 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
* @author admin
|
* @author admin
|
||||||
* @date 2024/07/31 16:55
|
* @date 2024/07/31 16:55
|
||||||
*/
|
*/
|
||||||
public static function edit(array $params)
|
public static function edit(array $params,$admin_id=0)
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$find = WarehouseOrder::where('id', $params['oid'])->find();
|
$find = WarehouseOrder::where('id', $params['oid'])->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
$res = WarehouseProduct::where('id', $params['id'])->withTrashed()->find();
|
$res = WarehouseProduct::where('id', $params['id'])->withTrashed()->find();
|
||||||
self::decStock($res);
|
self::decStock($res,$admin_id);
|
||||||
self::incStock($res, $params);
|
self::incStock($res, $params,$admin_id);
|
||||||
$datas = [
|
$datas = [
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'total_price' => $params['total_price'],
|
'total_price' => $params['total_price'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user