仓库列表优化

This commit is contained in:
devil 2020-08-18 19:39:06 +08:00
parent 9d08a0e3aa
commit 7347d29bd7
4 changed files with 55 additions and 4 deletions

View File

@ -153,7 +153,11 @@ class Warehousegoods
$ids = array_unique(Db::name('WarehouseGoods')->column('warehouse_id'));
if(!empty($ids))
{
$result = Db::name('Warehouse')->field('id,name')->where(['id'=>$ids, 'is_delete_time'=>0])->select();
$ret = WarehouseService::WarehouseIdsAllList($ids);
if($ret['code'] == 0)
{
$result = $ret['data'];
}
}
return $result;
}

View File

@ -8,10 +8,12 @@
{__block__}
{{/block}}
<!-- 扩展信息 -->
{{block name="form_extend"}}
<div class="am-alert am-alert-warning" data-am-alert>
<button type="button" class="am-close">&times;</button>
<p>1. 权重(数值越大权重越高、扣除库存按照权重依次扣除)</p>
<p>2. 删除(数据仅软删除、删除后仓库将不可用、仅数据库中保留数据)</p>
<p>1. 权重数值越大代表权重越高、扣除库存按照权重依次扣除)</p>
<p>2. 仓库仅软删除、删除后将不可用、仅数据库中保留数据)可以自行删除关联的商品数据</p>
<p>3. 仓库停用和删除、关联的商品库存会立即释放</p>
</div>
{{/block}}

View File

@ -14,6 +14,7 @@ use think\Db;
use app\service\ResourcesService;
use app\service\GoodsService;
use app\service\UserService;
use app\service\WarehouseService;
/**
* 仓库商品服务层
@ -87,7 +88,15 @@ class WarehouseGoodsService
// 仓库名称
if(in_array('warehouse_id', $keys))
{
$warehouse = Db::name('Warehouse')->where(['id'=>array_column($data, 'warehouse_id')])->column('name', 'id');
$warehouse = [];
$w_ret = WarehouseService::WarehouseIdsAllList(array_column($data, 'warehouse_id'));
if(!empty($w_ret['data']))
{
foreach($w_ret['data'] as $wv)
{
$warehouse[$wv['id']] = $wv['name'];
}
}
}
// 数据处理

View File

@ -338,5 +338,41 @@ class WarehouseService
}
return DataReturn('处理成功', 0);
}
/**
* 通过库存id获取所有的仓库列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-08-18
* @desc description
* @param [array] $ids [仓库id]
*/
public static function WarehouseIdsAllList($ids)
{
$result = [];
$data = Db::name('Warehouse')->field('id,name,is_enable,is_delete_time')->where(['id'=>array_unique($ids)])->select();
if(!empty($data))
{
foreach($data as $v)
{
$err = [];
if($v['is_enable'] != 1)
{
$err[] = '未启用';
}
if($v['is_delete_time'] > 0)
{
$err[] = '已删除';
}
if(!empty($err))
{
$v['name'] .= '('.implode('/', $err).')';
}
$result[] = $v;
}
}
return DataReturn('处理成功', 0, $result);
}
}
?>