fix(purchase_order): 修复采购单列表字段缺失

- 在 PurchaseOrderLists 类的 lists 方法中添加了 'warehouse_id' 字段
- 移除了不必要的 'batch' 字段
This commit is contained in:
mkm 2025-03-03 11:38:13 +08:00
parent ce19974294
commit 4bc701a546
7 changed files with 430 additions and 1 deletions

View File

@ -0,0 +1,48 @@
<?php
namespace app\psi\controller\warehouse;
use app\admin\controller\BaseAdminController;
use app\psi\lists\warehouse\WarehouseLists;
use app\psi\logic\warehouse\WarehouseLogic;
/**
* 仓库模块控制器
* Class WarehouseController
* @package app\psi\controller\warehouse
*/
class WarehouseController extends BaseAdminController
{
/**
* @notes 获取仓库模块列表
* @return \think\response\Json
* @author admin
* @date 2025/03/03 09:41
*/
public function lists()
{
return $this->dataLists(new WarehouseLists());
}
/**
* @notes 添加仓库模块
* @return \think\response\Json
* @author admin
* @date 2025/03/03 09:41
*/
public function add()
{
$params =$this->request->post();
$result = WarehouseLogic::add($params);
return $this->success('添加成功', [], 1, 1);
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace app\psi\controller\warehouse_storege;
use app\admin\controller\BaseAdminController;
use app\common\model\psi\warehouse_storege\WarehouseStorege;
use app\psi\lists\warehouse_storege\WarehouseStoregeLists;
use app\psi\logic\warehouse_storege\WarehouseStoregeLogic;
/**
* PsiWarehouseStorege控制器
* Class WarehouseStoregeController
* @package app\psi\controller\warehouse_storege
*/
class WarehouseStoregeController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author admin
* @date 2025/03/03 11:07
*/
public function lists()
{
return $this->dataLists(new WarehouseStoregeLists());
}
public function edit()
{
$params = $this->request->post();
$result = WarehouseStoregeLogic::edit($params,$this->adminId);
return $this->success('编辑成功', [], 1, 1);
}
public function verify(){
$params=$this->request->post();
WarehouseStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]);
return $this->success('操作成功',[],1,1);
}
}

View File

@ -48,7 +48,7 @@ class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterf
public function lists(): array public function lists(): array
{ {
return PurchaseOrder::where($this->searchWhere) return PurchaseOrder::where($this->searchWhere)
->field(['id', 'code', 'admin_id', 'batch', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type']) ->field(['id', 'code', 'admin_id','warehouse_id', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($item) { ->select()->each(function ($item) {

View File

@ -0,0 +1,65 @@
<?php
namespace app\psi\lists\warehouse;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\psi\warehouse\Warehouse;
use app\common\lists\ListsSearchInterface;
/**
* 仓库模块列表
* Class WarehouseLists
* @package app\psi\listswarehouse
*/
class WarehouseLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2025/03/03 09:41
*/
public function setSearch(): array
{
return [
'=' => ['name', 'contacts', 'tel', 'address', 'notes', 'sort'],
];
}
/**
* @notes 获取仓库模块列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2025/03/03 09:41
*/
public function lists(): array
{
return Warehouse::where($this->searchWhere)
->field(['id', 'name', 'contacts', 'tel', 'address', 'notes', 'sort'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取仓库模块数量
* @return int
* @author admin
* @date 2025/03/03 09:41
*/
public function count(): int
{
return Warehouse::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace app\psi\lists\warehouse_storege;
use app\common\lists\BaseDataLists;
use app\common\model\psi\warehouse_storege\WarehouseStorege;
use app\common\lists\ListsSearchInterface;
/**
* PsiWarehouseStorege列表
* Class WarehouseStoregeLists
* @package app\psi\listswarehouse_storege
*/
class WarehouseStoregeLists extends BaseDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2025/03/03 11:07
*/
public function setSearch(): array
{
return [
'=' => ['warehouse_id', 'product_id', 'nums', 'is_verify', 'price'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2025/03/03 11:07
*/
public function lists(): array
{
return WarehouseStorege::where($this->searchWhere)
->field(['id', 'warehouse_id', 'product_id', 'nums', 'is_verify', 'price'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author admin
* @date 2025/03/03 11:07
*/
public function count(): int
{
return WarehouseStorege::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace app\psi\logic\warehouse;
use app\common\model\psi\warehouse\Warehouse;
use app\common\logic\BaseLogic;
use Exception;
use think\facade\Db;
/**
* 仓库模块逻辑
* Class WarehouseLogic
* @package app\psi\logic\warehouse
*/
class WarehouseLogic extends BaseLogic
{
/**
* @notes 添加仓库模块
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 09:41
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
Warehouse::create([
'name' => $params['name'],
'contacts' => $params['contacts'],
'tel' => $params['tel'],
'address' => $params['address'],
'notes' => $params['notes'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Throwable $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* @notes 编辑仓库模块
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 09:41
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Warehouse::where('id', $params['id'])->update([
'name' => $params['name'],
'contacts' => $params['contacts'],
'tel' => $params['tel'],
'address' => $params['address'],
'notes' => $params['notes'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Throwable $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* @notes 删除仓库模块
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 09:41
*/
public static function delete(array $params): bool
{
return PsiWarehouse::destroy($params['id']);
}
/**
* @notes 获取仓库模块详情
* @param $params
* @return array
* @author admin
* @date 2025/03/03 09:41
*/
public static function detail($params): array
{
return PsiWarehouse::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace app\psi\logic\warehouse_storege;
use app\common\model\psi\warehouse_storege\WarehouseStorege;
use app\common\logic\BaseLogic;
use Exception;
use think\facade\Db;
/**
* PsiWarehouseStorege逻辑
* Class WarehouseStoregeLogic
* @package app\psi\logic\warehouse_storege
*/
class WarehouseStoregeLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 11:07
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
WarehouseStorege::create([
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'nums' => $params['nums'],
'is_verify' => $params['is_verify'],
'price' => $params['price']
]);
Db::commit();
return true;
} catch (\Throwable $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 11:07
*/
public static function edit(array $params,$admin_id=0): bool
{
if (empty($params['remark'])) {
throw new Exception('请输入备注');
}
Db::startTrans();
try {
$find=WarehouseStorege::where('id',$params['id'])->find();
if($find){
$find->save(['nums'=>$params['nums']]);
// SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url(),$admin_id, $params['remark']);
}
Db::commit();
return true;
} catch (\Throwable $th) {
Db::rollback();
throw new Exception($th->getMessage());
}
return false;
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author admin
* @date 2025/03/03 11:07
*/
public static function delete(array $params): bool
{
return WarehouseStorege::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author admin
* @date 2025/03/03 11:07
*/
public static function detail($params): array
{
return WarehouseStorege::findOrEmpty($params['id'])->toArray();
}
}