链街Dcat后台
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

6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
  1. <?php
  2. namespace App\Admin\Forms;
  3. use App\Admin\Common\Auth;
  4. use App\Admin\Common\Rpc;
  5. use App\Libs\SsdbClient;
  6. use App\Models\ImsCjdcMarket;
  7. use App\Models\ImsCjdcOrderMain;
  8. use App\Models\v3\LanzuEmployees;
  9. use Dcat\Admin\Widgets\Form;
  10. use Symfony\Component\HttpFoundation\Response;
  11. class SelectHorseman extends Form
  12. {
  13. /**
  14. * Handle the form request.
  15. *
  16. * @param array $input
  17. *
  18. * @return Response
  19. */
  20. protected $orderId;
  21. public function handle(array $input)
  22. {
  23. $hid = $input['horseman_id'];
  24. $oid = $input['order_id'];
  25. $current_page = $input['current_page'] ?? 1;
  26. $horseman = LanzuEmployees::getName($hid);//骑手名称
  27. $result = ImsCjdcOrderMain::where('id',$oid)->update(['shipping_type'=>1,'horseman_id'=>$hid,'delivery_start_time'=>time(),'shipping_name'=>$horseman,'updated_at'=>time()]);
  28. if ($result){
  29. //>>1.指定骑手后,初始化骑手位置,默认将市场经纬做为骑手默认经纬
  30. $row = ImsCjdcOrderMain::where('id',$oid)->select('market_id','global_order_id')->first();
  31. $mid = $row->market_id;
  32. $market = ImsCjdcMarket::where('id',$mid)->first();
  33. $ssdb = SsdbClient::client(env('SSDB_HOST'), env('SSDB_PORT'));
  34. $coordinate = $market->lng.','.$market->lat;
  35. $ssdb->set("horseman_coordinate_{$hid}",$coordinate);
  36. //>>2.配送开始后,给用户发送消息通知
  37. Rpc::onlineDeliveryStart($row->global_order_id);
  38. return $this->success('操作成功',"order?page={$current_page}");
  39. }else{
  40. return $this->error('操作失败');
  41. }
  42. }
  43. /**
  44. * Build a form here.
  45. */
  46. public function form()
  47. {
  48. $this->select('horseman_id','配送员')
  49. ->options(LanzuEmployees::getHorseman(Auth::getMarket()))
  50. ->required();
  51. $this->hidden('order_id');
  52. $this->hidden('current_page');
  53. }
  54. }