feat(inventory_store): 优化门店盘存列表和生成逻辑
- 在 InventoryStoreLists 中添加了对管理员、员工、门店和商品名称的关联查询 - 在 InventoryStoreLogic 中增加了对当日数据已生成的检查,避免重复生成 -
This commit is contained in:
parent
ea5687eabe
commit
d3d3556038
@ -6,7 +6,10 @@ namespace app\admin\lists\inventory_store;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_store\InventoryStore;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
/**
|
||||
* 门店盘存列表
|
||||
@ -53,6 +56,18 @@ class InventoryStoreLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
2 => '盘点完成',
|
||||
default => '未知',
|
||||
};
|
||||
if($item->admin_id){
|
||||
$item->admin_name = Admin::where('id',$item->admin_id)->value('name');
|
||||
}
|
||||
if($item->staff_id){
|
||||
$item->staff_name = SystemStoreStaff::where('id',$item->staff_id)->value('staff_name');
|
||||
}
|
||||
if($item->store_id){
|
||||
$item->store_name = SystemStore::where('id',$item->store_id)->value('name');
|
||||
}
|
||||
if($item->product_id){
|
||||
$item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
@ -30,7 +30,11 @@ class InventoryStoreLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr=(new StoreBranchProduct())->field('product_id,store_id,stock as nums')->select()->toArray();
|
||||
$find=InventoryStore::where('store_id', $params['store_id'])->whereDay('create_time')->find();
|
||||
if($find){
|
||||
throw new BusinessException('今日数据已生成');
|
||||
}
|
||||
$arr=StoreBranchProduct::where('store_id',$params['store_id'])->field('product_id,store_id,stock as nums')->select()->toArray();
|
||||
(new InventoryStore())->saveAll($arr);
|
||||
Db::commit();
|
||||
return true;
|
||||
@ -99,16 +103,4 @@ class InventoryStoreLogic extends BaseLogic
|
||||
return InventoryStore::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店盘存详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return InventoryStore::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user