feat(库存): 添加类型三的负库存查询功能
- 在 WorkbenchController 中增加对类型三的处理逻辑 - 新增 WarehouseProductStoregeTwoLists 类实现仓库商品存储列表查询 - 支持按仓库 ID 和商品 ID 搜索 - 可对库存数量进行排序 - 实现负库存列表导出功能
This commit is contained in:
parent
942a04f514
commit
b28e68966f
app/admin
@ -17,6 +17,7 @@ namespace app\admin\controller;
|
||||
use app\admin\lists\statistics\StoreProductLists;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupLists;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupMonthLists;
|
||||
use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeTwoLists;
|
||||
use app\admin\logic\statistic\ProductStatisticLogic;
|
||||
use app\admin\logic\statistic\TradeStatisticLogic;
|
||||
use app\admin\logic\statistic\UserStatisticLogic;
|
||||
@ -322,6 +323,9 @@ class WorkbenchController extends BaseAdminController
|
||||
public function negative_inventory()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
if($parmas['type'] == 3){
|
||||
return $this->dataLists(new WarehouseProductStoregeTwoLists());
|
||||
}
|
||||
$data = WarehouseLogic::negativeInventory($parmas);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\warehouse_product_storege;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 仓库商品存储列表
|
||||
* Class WarehouseProductStoregeTwoLists
|
||||
* @package app\admin\listswarehouse_product_storege
|
||||
*/
|
||||
class WarehouseProductStoregeTwoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['warehouse_id', 'product_id'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['nums' => 'nums'];
|
||||
}
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['id' => 'desc', 'nums' => 'desc',];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品存储列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('store_name')) {
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$this->searchWhere[] = ['nums', '<=', 0];
|
||||
return WarehouseProductStorege::where($this->searchWhere)
|
||||
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->select()->each(function ($item) {
|
||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||
$find = StoreProduct::where('id', $item->product_id)->withTrashed()->find();
|
||||
$item->store_name = $find->store_name;
|
||||
$item->image = $find->image;
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['stock'] = $item['nums'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品存储数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseProductStorege::where($this->searchWhere)->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
|
||||
return '仓库商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
|
||||
$data = [
|
||||
'warehouse_name' => '仓库名称',
|
||||
'product_id' => '商品id',
|
||||
'store_name' => '商品名称',
|
||||
'unit_name' => '单位',
|
||||
'stock' => '数量',
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user