| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -5,6 +5,7 @@ namespace App\AdminSupplier\Controllers; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\AdminSupplier\Metrics\Examples\FinanceStatistics; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\AdminAgent\Metrics\Examples\ProductStatistics; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\OrderStatus; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\PayType; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\Order; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\OrderProductItem; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Admin; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -34,12 +35,16 @@ class FinanceStatisticsController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//金额
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$price = OrderProductItem::query()->where('supplier_id',Admin::user()->id)->whereHas('order',function ($query) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$query->complete(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$query->complete()->where('pay_type','=',PayType::OFFLINE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//利润
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$costPrice = OrderProductItem::query()->where('supplier_id',Admin::user()->id)->whereHas('order',function ($query) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$query->complete(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$onlinePrice = OrderProductItem::query()->where('supplier_id',Admin::user()->id)->whereHas('order',function ($query) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$query->complete()->where('pay_type','!=',PayType::OFFLINE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							////利润
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//$costPrice = OrderProductItem::query()->where('supplier_id',Admin::user()->id)->whereHas('order',function ($query) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//	$query->complete();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//});
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//已完成订单
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$count = OrderProductItem::query()->where('supplier_id',Admin::user()->id)->whereHas('order',function ($query) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -48,14 +53,15 @@ class FinanceStatisticsController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$dateTime = request('created_at', 0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($dateTime) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$price->whereBetween('created_at',$dateTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$costPrice->whereBetween('created_at',$dateTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$count->whereBetween('created_at',$dateTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$price->whereBetween('created_at',[$dateTime['start'] . ' 00:00:00',$dateTime['end'].' 23:59:59']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//$costPrice->whereBetween('created_at',[$dateTime['start'] . ' 00:00:00',$dateTime['end'].' 23:59:59'])
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$count->whereBetween('created_at',[$dateTime['start'] . ' 00:00:00',$dateTime['end'].' 23:59:59']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$onlinePrice->whereBetween('created_at',[$dateTime['start'] . ' 00:00:00',$dateTime['end'].' 23:59:59']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$price = $price->sum('price'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$costPrice = $costPrice->sum('price'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$profit = bcsub($price,$costPrice,2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$onlinePrice = $onlinePrice->sum('price'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$profit = bcadd($price,$onlinePrice,2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$count = $count->count(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return $content | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->body( | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -79,10 +85,21 @@ class FinanceStatisticsController extends AdminController | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->body(function (Row $row) use ($price, $profit, $count) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->body(function (Row $row) use ($price, $profit, $count,$onlinePrice) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(3, function (Column $column) use ($onlinePrice) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$column->row(Card::make('线上金额', function () use ($onlinePrice) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											return <<<HTML | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    <h2 class="ml-1 font-large-1 text-primary">$onlinePrice</h2> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					</div> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					HTML; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										})); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(4, function (Column $column) use ($price) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$column->row(Card::make('金额', function () use ($price) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(3, function (Column $column) use ($price) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$column->row(Card::make('线下金额', function () use ($price) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											return <<<HTML | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    <h2 class="ml-1 font-large-1 text-primary">$price</h2> | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -91,7 +108,7 @@ HTML; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										})); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(4, function (Column $column) use ($profit) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(3, function (Column $column) use ($profit) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$column->row(Card::make('利润', function () use ($profit) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											return <<<HTML | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -102,7 +119,7 @@ HTML; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(4, function (Column $column) use ($count) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$row->column(3, function (Column $column) use ($count) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$column->row(Card::make('已完成订单', function () use ($count) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											return <<<HTML | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |