| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -392,9 +392,9 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$id = (int)request()->input('id'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$fields = ['id', 'order_no', 'agent_product_id', 'num', 'price', 'title', 'picture', 'status', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$fields = ['id', 'agent_id', 'order_no', 'agent_product_id', 'num', 'price', 'title', 'picture', 'status', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								'pay_type', 'coupon_id', 'paid_money', 'paid_at', 'refund_info', 'verify_code', 'created_at']; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order = Order::query() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order = Order::with('agent:id,appid,appsecret') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->where('user_id', $this->user_id) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->find($id, $fields); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -405,6 +405,24 @@ class OrderController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//订单ID和核销码拼接,查询时通过订单ID和核销码来查询,这样核销码不用建索引
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order->verify_code = $order->verify_code ? $order->id . '-' . $order->verify_code : ''; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//如果有核销码,生成核销二维码
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($order->verify_code) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$config = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'app_id' => $order->agent->appid, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'secret' => $order->agent->appsecret, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$app = Factory::miniProgram($config); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$response = $app->app_code->getUnlimit($order->verify_code, ['path' => 'pages/verification/index']); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$filename = $response->saveAs(storage_path('app/public/verify_code'), $order->verify_code); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$order->verify_qrcode = Storage::disk('public')->url('verify_code/' . $filename); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							unset($order->agent, $order->agent_id); //必须unset掉$order->agent,否则会造成appsecret泄漏
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order->coupon = Coupon::query() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->whereIn('id', $order->coupon_id) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								->where(['agent_id' => $this->agent_id, 'agent_product_id' => $order->agent_product_id,]) | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |