'总采购金额', 'desc' => '平台采购商品总支付金额', 'total_money' => WarehouseOrder::sum('total_price'), 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '已结算金额', 'desc' => '平台支付给供应商的金额', 'total_money' => WarehouseOrder::sum('completed_amount'), 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '未结算金额', 'desc' => '平台未支付给供应商的金额', 'total_money' => WarehouseOrder::sum('outstanding_amount'), 'value' => [], 'type' => 1, ]; $store_stock_1 = StoreBranchProduct::where('stock', '>', 0)->sum('stock'); $store_stock_2 = WarehouseProductStorege::where('nums', '>', 0)->sum('nums'); $topData[] = [ 'title' => '总商品库存', 'desc' => '平台统计商品总库存、含门店仓库', 'total_money' => bcadd($store_stock_1, $store_stock_2, 2), 'cash_title' => 0, 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '总仓库库存', 'desc' => '平台统计仓库库存', 'total_money' => WarehouseProductStorege::sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '海吉星仓库库存', 'desc' => '平台统计海吉星仓库库存', 'total_money' => WarehouseProductStorege::where('warehouse_id', 1)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '泸县集采集配库存', 'desc' => '平台统计泸县集采集配库存', 'total_money' => WarehouseProductStorege::where('warehouse_id', 2)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, ]; $topData[] = [ 'title' => '总门店库存', 'desc' => '平台统计门店库存', 'total_money' => StoreBranchProduct::sum('stock'), 'cash_title' => 0, 'value' => [], 'type' => 1, ]; $data['series'] = []; foreach ($topData as $k => $v) { // $data['x'] = $Chain['out']['x']; $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]['type'] = $v['type']; } return $data; } /** * 统计门店仓库总库存 * @return array */ public static function total_warehouse_list($parmas,$type=1) { if($type==1){ $list=StoreBranchProduct::where('stock','>',0)->where('product_id',$parmas['product_id']) ->select()->each(function ($item){ $item->system_store = SystemStore::where('id',$item['store_id'])->value('name'); $item->total_price = bcmul($item->purchase,$item->stock,2); }); $count=StoreBranchProduct::where('stock','>',0)->where('product_id',$parmas['product_id']) ->count(); }else{ $list=WarehouseProductStorege::where('nums','>',0)->where('product_id',$parmas['product_id'])->select()->each(function ($item){ $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); $find = StoreProduct::where('id',$item['product_id'])->find(); $item->store_name=$find['store_name']; $item->image=$find['image']; $item->purchase=$find['purchase']; if($find['purchase']>0 && $item->nums>0){ $item->total_price = bcmul($find['purchase'],$item->nums,2); }else{ $item->total_price = 0; } }); $count=WarehouseProductStorege::where('nums','>',0)->where('product_id',$parmas['product_id'])->count(); } return ['lists'=>$list,'count'=>$count]; } }