| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -32,13 +32,18 @@ class SharePayController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//用户openid
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$openid = User::query()->where('id', $this->user_id)->value('openid'); //此处要用where,value()用find有BUG
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$user_info = User::query()->where('id', $this->user_id)->first(['agent_id', 'openid']); //此处要用where,value()用find有BUG
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$openid = $user_info['openid']; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$this->agent_id = $user_info['agent_id']; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order = Order::query()->whereIn('status', [Status::UNPAID, Status::PAY_EARNEST])->find($order_id); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if (!$order) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('订单不存在或已支付'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order->pay_user_id = $this->user_id; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$config = config('wechat.payment.default'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$config = array_merge($config, [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								'app_id' => 'wxb35ef055a4dd8ad4', | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -55,6 +60,7 @@ class SharePayController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'notify_url' => route('wxpay_notify', ['agent_id' => $this->agent_id]), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'trade_type' => 'JSAPI', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'openid' => $openid, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									'attach' => $this->user_id, //保存支付用户的user_id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//				'profit_sharing' => 'Y', //Y分账,N不分账,默认不分账,Y大写
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} catch (InvalidArgumentException | InvalidConfigException | GuzzleException $e) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |