添加批量入库,修改门店库存列表
This commit is contained in:
parent
3e6410302c
commit
e2014342bd
@ -94,5 +94,13 @@ class SystemStoreStorageController extends BaseAdminController
|
|||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 批量确认入库
|
||||||
|
*/
|
||||||
|
public function batchConfirm()
|
||||||
|
{
|
||||||
|
SystemStoreStorageLogic::editAll([], $this->adminId);
|
||||||
|
return $this->success('操作成功',[]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -45,14 +45,17 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
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)
|
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)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
|
$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');
|
||||||
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
|
|
||||||
if ($item['staff_id'] > 0) {
|
if ($item['staff_id'] > 0) {
|
||||||
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
|
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +82,7 @@ class StoreBranchProductLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray();
|
$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);
|
SqlChannelLog('StoreBranchProduct', $params['id'], $params['stock'], 0, Request()->url(), $admin_id);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +73,7 @@ class SystemStoreStorageLogic extends BaseLogic
|
|||||||
$branch_product->save();
|
$branch_product->save();
|
||||||
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id);
|
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id);
|
||||||
}else{
|
}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 = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct);
|
||||||
$storeBranchProduct->stock = $find['nums'];
|
$storeBranchProduct->stock = $find['nums'];
|
||||||
$storeBranchProduct->save();
|
$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) {
|
foreach ($list as $item) {
|
||||||
$params['id'] = $item;
|
$params['id'] = $item;
|
||||||
self::edit($params);
|
self::edit($params, $adminId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user