feat: 修改了仓库和商品相关的功能,包括库存统计、商品列表展示等

This commit is contained in:
mkm 2024-08-23 16:58:49 +08:00
parent 884f319ddb
commit 907584a400
7 changed files with 25 additions and 11 deletions

View File

@ -312,7 +312,7 @@ class WorkbenchController extends BaseAdminController
public function total_warehouse_product_list()
{
$parmas=$this->request->get();
$data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1);
$data =WarehouseLogic::total_warehouse_product_list($parmas,$parmas['type']??1);
return $this->data($data);
}
}

View File

@ -209,6 +209,7 @@ class WarehouseOrderController extends BaseAdminController
public function export()
{
$id = $this->request->post('id');
$type = $this->request->post('type');
$xlsx = new OrderDetail();
$order = WarehouseOrder::where('id', $id)->findOrEmpty();
$system_store = SystemStore::where('id', $order['store_id'])->value('name');
@ -218,7 +219,12 @@ class WarehouseOrderController extends BaseAdminController
$find = StoreProduct::where('id', $value->product_id)->find();
$value->store_name = $find['store_name'] ?? '';
$value->store_info = $find['store_info'] ?? '';
if($type==2){
$value->price = $find['price'];
$value->total_price=bcmul($find['price'],$value['nums'],2);
}else{
$value->price = $value['purchase'];
}
$value->cart_num = $value['nums'];
if (!empty($find['unit'])) {
$value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');

View File

@ -60,6 +60,7 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa
}
$user_ship=UserShip::where('id',$find['user_ship'])->value('title');
$item->nickname=$name.'('.$user_ship.')';
// $item->id_card=$name.'('.$user_ship.')';
}
})
->toArray();

View File

@ -129,6 +129,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
'purchase' => '采购价',
'cost' => '商户',
'price' => '零售',
'bar_code' => '条码',
];
return $data;
}

View File

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

View File

@ -56,7 +56,7 @@ class WarehouseLogic extends BaseLogic
'title' => '总商品库存',
'desc' => '平台统计商品总库存、含门店仓库',
'total_money' => bcadd($store_stock_1, $store_stock_2, 2),
'cash_title' => 0,
'cash_title' => 1,
'value' => [],
'type' => 1,
];
@ -64,7 +64,7 @@ class WarehouseLogic extends BaseLogic
'title' => '总仓库库存',
'desc' => '平台统计仓库库存',
'total_money' => WarehouseProductStorege::sum('nums'),
'cash_title' => 0,
'cash_title' => 1,
'value' => [],
'type' => 1,
];
@ -72,7 +72,7 @@ class WarehouseLogic extends BaseLogic
'title' => '海吉星仓库库存',
'desc' => '平台统计海吉星仓库库存',
'total_money' => WarehouseProductStorege::where('warehouse_id', 1)->sum('nums'),
'cash_title' => 0,
'cash_title' => 1,
'value' => [],
'type' => 1,
];
@ -80,7 +80,7 @@ class WarehouseLogic extends BaseLogic
'title' => '泸县集采集配库存',
'desc' => '平台统计泸县集采集配库存',
'total_money' => WarehouseProductStorege::where('warehouse_id', 2)->sum('nums'),
'cash_title' => 0,
'cash_title' => 1,
'value' => [],
'type' => 1,
];
@ -88,7 +88,7 @@ class WarehouseLogic extends BaseLogic
'title' => '总门店库存',
'desc' => '平台统计门店库存',
'total_money' => StoreBranchProduct::sum('stock'),
'cash_title' => 0,
'cash_title' => 1,
'value' => [],
'type' => 1,
@ -156,7 +156,7 @@ class WarehouseLogic extends BaseLogic
$count=WarehouseProduct::where($where)->count();
}elseif($type==2){
//已结算采购价
$where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]];
$where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1],['is_pay','=',1]];
$list=WarehouseProduct::where($where)->select()->each(function ($item){
$item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name');
$item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name');
@ -167,7 +167,7 @@ class WarehouseLogic extends BaseLogic
$count=WarehouseProduct::where($where)->count();
}elseif($type==3){
//未结算采购价
$where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]];
$where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1],['is_pay','=',0]];
$list=WarehouseProduct::where($where)->select()->each(function ($item){
$item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name');
$item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name');

View File

@ -216,10 +216,15 @@ class IndexController extends BaseApiController
$distanceSql = "SQRT(POW(69.1 * (latitude - {$latitude}), 2) +
POW(69.1 * ({$longitude} - longitude) * COS(latitude / 57.3), 2))";
$find = SystemStore::field("id, name,abbreviation, {$distanceSql} AS distance")
->where('is_show', '=', 1)
->where('latitude', '<>', '')
->where('longitude', '<>', '')
->order('distance', 'asc') // 根据距离排序
->find();
if (!$find) {
$store_id = getenv('STORE_ID') ?? 1;
$find = SystemStore::where('id', $store_id)->find();
}
} else {
$store_id = getenv('STORE_ID') ?? 1;
$find = SystemStore::where('id', $store_id)->find();