You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							61 lines
						
					
					
						
							1.9 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							61 lines
						
					
					
						
							1.9 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Admin\Forms;
							 | 
						|
								
							 | 
						|
								use App\Admin\Common\Auth;
							 | 
						|
								use App\Admin\Common\Rpc;
							 | 
						|
								use App\Libs\SsdbClient;
							 | 
						|
								use App\Models\ImsCjdcMarket;
							 | 
						|
								use App\Models\ImsCjdcOrderMain;
							 | 
						|
								use App\Models\v3\LanzuEmployees;
							 | 
						|
								use Dcat\Admin\Widgets\Form;
							 | 
						|
								use Symfony\Component\HttpFoundation\Response;
							 | 
						|
								
							 | 
						|
								class SelectHorseman extends Form
							 | 
						|
								{
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Handle the form request.
							 | 
						|
								     *
							 | 
						|
								     * @param array $input
							 | 
						|
								     *
							 | 
						|
								     * @return Response
							 | 
						|
								     */
							 | 
						|
								    protected $orderId;
							 | 
						|
								    public function handle(array $input)
							 | 
						|
								    {
							 | 
						|
								        $hid = $input['horseman_id'];
							 | 
						|
								        $oid = $input['order_id'];
							 | 
						|
								        $current_page = $input['current_page'] ?? 1;
							 | 
						|
								        $horseman = LanzuEmployees::getName($hid);//骑手名称
							 | 
						|
								        $result = ImsCjdcOrderMain::where('id',$oid)->update(['shipping_type'=>1,'horseman_id'=>$hid,'delivery_start_time'=>time(),'shipping_name'=>$horseman,'updated_at'=>time()]);
							 | 
						|
								        if ($result){
							 | 
						|
								            //>>1.指定骑手后,初始化骑手位置,默认将市场经纬做为骑手默认经纬
							 | 
						|
								            $row = ImsCjdcOrderMain::where('id',$oid)->select('market_id','global_order_id')->first();
							 | 
						|
								            $mid = $row->market_id;
							 | 
						|
								            $market = ImsCjdcMarket::where('id',$mid)->first();
							 | 
						|
								            $ssdb = SsdbClient::client(env('SSDB_HOST'), env('SSDB_PORT'));
							 | 
						|
								            $coordinate = $market->lng.','.$market->lat;
							 | 
						|
								            $ssdb->set("horseman_coordinate_{$hid}",$coordinate);
							 | 
						|
								            //>>2.配送开始后,给用户发送消息通知
							 | 
						|
								            Rpc::onlineDeliveryStart($row->global_order_id);
							 | 
						|
								
							 | 
						|
								            return $this->success('操作成功',"order?page={$current_page}");
							 | 
						|
								        }else{
							 | 
						|
								            return $this->error('操作失败');
							 | 
						|
								        }
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Build a form here.
							 | 
						|
								     */
							 | 
						|
								    public function form()
							 | 
						|
								    {
							 | 
						|
								        $this->select('horseman_id','配送员')
							 | 
						|
								            ->options(LanzuEmployees::getHorseman(Auth::getMarket()))
							 | 
						|
								            ->required();
							 | 
						|
								
							 | 
						|
								        $this->hidden('order_id');
							 | 
						|
								        $this->hidden('current_page');
							 | 
						|
								    }
							 | 
						|
								}
							 |