添加批量入库,修改门店库存列表

This commit is contained in:
lewis 2025-01-14 11:08:47 +08:00
parent 3e6410302c
commit e2014342bd
4 changed files with 22 additions and 7 deletions

View File

@ -94,5 +94,13 @@ class SystemStoreStorageController extends BaseAdminController
return $this->data($result);
}
/**
* @notes 批量确认入库
*/
public function batchConfirm()
{
SystemStoreStorageLogic::editAll([], $this->adminId);
return $this->success('操作成功',[]);
}
}

View File

@ -45,14 +45,17 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
*/
public function lists(): array
{
if (!empty($this->params['product_name'])) {
$productIds = StoreProduct::where('store_name', 'like', '%' . $this->params['product_name'] . '%')->column('id');
$this->searchWhere[] = ['product_id', 'in', $productIds];
}
return SystemStoreStorage::where($this->searchWhere)
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status'])
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
$item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
if ($item['staff_id'] > 0) {
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
} else {

View File

@ -82,7 +82,7 @@ class StoreBranchProductLogic extends BaseLogic
Db::startTrans();
try {
$storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray();
StoreBranchProduct::update(['stock' => $params['stock'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]);
StoreBranchProduct::update(['stock' => $params['stock'], 'sales' => $params['sales'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]);
SqlChannelLog('StoreBranchProduct', $params['id'], $params['stock'], 0, Request()->url(), $admin_id);
Db::commit();
return true;

View File

@ -73,7 +73,7 @@ class SystemStoreStorageLogic extends BaseLogic
$branch_product->save();
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id);
}else{
$storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty();
$storeProduct = StoreProduct::where('id', $find['product_id'])->withTrashed()->findOrEmpty();
$storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct);
$storeBranchProduct->stock = $find['nums'];
$storeBranchProduct->save();
@ -93,12 +93,16 @@ class SystemStoreStorageLogic extends BaseLogic
}
}
public static function editAll(array $params): bool
public static function editAll(array $params, $adminId = 0): bool
{
$list = SystemStoreStorage::where(['store_id' => $params['store_id'], 'status' => 0])->column('id');
$where = ['status' => 0];
if (isset($params['store_id'])) {
$where['store_id'] = $params['store_id'];
}
$list = SystemStoreStorage::where($where)->column('id');
foreach ($list as $item) {
$params['id'] = $item;
self::edit($params);
self::edit($params, $adminId);
}
return true;
}