feat: 添加仓库统计和仓库列表功能

This commit is contained in:
mkm 2024-08-22 12:04:58 +08:00
parent 90902e255b
commit 7440c2a046
7 changed files with 35 additions and 8 deletions

View File

@ -280,4 +280,14 @@ class WorkbenchController extends BaseAdminController
$data=WarehouseLogic::total_warehouse();
return $this->data($data);
}
/**
* 统计仓库
* @return array
*/
public function warehouse_list()
{
$data=WarehouseLogic::warehouse_list();
return $this->data($data);
}
}

View File

@ -115,6 +115,9 @@ class StoreBranchProductController extends BaseAdminController
{
$params = (new StoreProductValidate())->post()->goCheck('delete');
StoreBranchProductLogic::delete($params);
if(StoreBranchProductLogic::hasError()){
return $this->fail(StoreBranchProductLogic::getError());
}
return $this->success('删除成功', [], 1, 1);
}

View File

@ -32,7 +32,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['oid'],
'=' => ['oid','product_id'],
];
}
@ -49,7 +49,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
public function lists(): array
{
return StoreOrderCartInfo::where($this->searchWhere)
->field('cart_info,product_id,store_id,cart_num,price,total_price')->limit($this->limitOffset, $this->limitLength)
->field('cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item) {
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find();
if($find){

View File

@ -99,8 +99,10 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
}
if ($item->product_id) {
$find = StoreProduct::where('id', $item->product_id)->field('image,store_name')->find();
$item->store_name = $find->store_name . '|' . $item->product_id;
$item->image = $find->image;
if($find){
$item->store_name = $find->store_name . '|' . $item->product_id;
$item->image = $find->image;
}
} else {
$item->store_name = '';
}

View File

@ -4,10 +4,12 @@ namespace app\admin\logic\statistic;
use app\common\logic\BaseLogic;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_product\StoreProduct;
use app\common\model\user\User;
use app\common\model\user\UserVisit;
use app\common\model\user_recharge\UserRecharge;
use Exception;
/**
* Class 仓库统计
* @package app\services\statistic
@ -15,7 +17,8 @@ use Exception;
class WarehouseLogic extends BaseLogic
{
public static function total_warehouse(){
public static function total_warehouse()
{
$topData[] = [
'title' => '总采购金额',
'desc' => '平台采购商品总支付金额',
@ -86,10 +89,14 @@ class WarehouseLogic extends BaseLogic
$data['series'][$k]['name'] = $v['title'];
$data['series'][$k]['desc'] = $v['desc'];
$data['series'][$k]['total_value'] = $v['total_money'];
$data['series'][$k]['total_money'] = $v['cash_title']??'';
$data['series'][$k]['total_money'] = $v['cash_title'] ?? '';
$data['series'][$k]['type'] = $v['type'];
}
return $data;
}
public static function warehouse_list() {
// StoreProduct::where('is_show',1)->
}
}

View File

@ -117,6 +117,11 @@ class StoreBranchProductLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
$stock=StoreBranchProduct::where('id', $params['id'])->value('stock');
if($stock>0){
self::setError('商品库存不为0,无法删除');
return false;
}
return StoreBranchProduct::destroy($params['id']);
}

View File

@ -43,7 +43,7 @@ class WarehouseProductLogic extends BaseLogic
if ($params['financial_pm'] == 0) {
$after_nums = $storege['nums'] - $params['nums'];
if ($after_nums < 0) {
throw new BusinessException('库存不足');
throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']);
}
WarehouseProductStorege::where('id', $storege['id'])->dec('nums', $params['nums'])->update();
} else {