| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -3,6 +3,9 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					namespace App\Admin\Extensions\Grid; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\ProductStatus; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\IndustryProduct; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\Supplier; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\SystemSetting; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Admin; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Dcat\Admin\Grid\RowAction; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Http\Request; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Support\Facades\DB; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -41,7 +44,29 @@ class AuditIndustryProduct extends RowAction | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$industry->status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$industry->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//如果是拒绝,返还冻结金额
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//如果是通过,扣除交易金,如果拒绝返还冻结金额
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$single = SystemSetting::val('single', 'price'); //单人头交易金
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$supplier = Supplier::find(Admin::user()->id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$change_deposit = $single * $industry->stock * $industry->service_persons; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($industry->status == ProductStatus::ON_SALE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($supplier->deposit_normal < $change_deposit) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										throw new \Exception('交易金不足,无法扣除'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->deposit_normal = $supplier->deposit_normal - $change_deposit; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->deposit_frozen = $supplier->deposit_frozen + $change_deposit; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} else if ($industry->status == ProductStatus::REFUSE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($supplier->deposit_frozen < $change_deposit) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										throw new \Exception('冻结金不足,无法扣除'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->deposit_normal = $supplier->deposit_normal + $change_deposit; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->deposit_frozen = $supplier->deposit_frozen - $change_deposit; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplier->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								DB::commit(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->response()->success("审核成功")->refresh(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |