| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -128,17 +128,12 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$ap = AgentProduct::query() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->where('id', $formData['id']) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->with('coupon') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->with('product') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->with(['coupon', 'product', 'agentCloudProduct:id,price']) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->has('product') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->first(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!$ap || !$ap->product) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$this->error('产品不存在或已下架'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//TODO 供应商产品需要判断组合产品库存
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($ap->stock < $formData['num'] || $ap->product->stock < $formData['num']) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$this->error('对不起,库存不足'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$coupon_ids = []; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($ap->coupon) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -150,7 +145,6 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							DB::beginTransaction(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$price = $this->calc($ap->price, $formData['num'], $formData['pay_type'], $ap); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$title = $ap->title; //产品标题
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//供应商产品表减库存
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$product_ids = explode(',', $ap->product_ids); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -184,7 +178,7 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'price' => $price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'name' => $formData['name'], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'mobile' => $formData['mobile'], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'title' => $title, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'title' => $ap->title, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'picture' => $ap->picture, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'agent_product_id' => $ap->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'product_id' => $ap->product_id, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -194,6 +188,8 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'coupon_id' => join(',', $coupon_ids), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'guide_id' => $ap->guide_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'timeout' => $timeout, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'agent_cloud_pid' => $ap->agent_cloud_pid, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'agent_cloud_price' => $ap->agentCloudProduct->price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//存入订单产品表
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |