链街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.

64 lines
1.8 KiB

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