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