Orders.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use app\common\model\OrderLogistics;
  5. /**
  6. *
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Orders extends Backend
  11. {
  12. /**
  13. * Orders模型对象
  14. * @var \app\admin\model\Orders
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Orders;
  21. $this->assign('status',$this->model::getStatus());
  22. $this->assign('pay_types',$this->model::getPayTypes());
  23. }
  24. public function import()
  25. {
  26. parent::import();
  27. }
  28. /**
  29. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  30. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  31. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  32. */
  33. /**
  34. * 查看
  35. */
  36. public function index()
  37. {
  38. //当前是否为关联查询
  39. $this->relationSearch = true;
  40. //设置过滤方法
  41. $this->request->filter(['strip_tags', 'trim']);
  42. if ($this->request->isAjax()) {
  43. //如果发送的来源是Selectpage,则转发到Selectpage
  44. if ($this->request->request('keyField')) {
  45. return $this->selectpage();
  46. }
  47. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  48. $list = $this->model
  49. ->with(['user'])
  50. ->where($where)
  51. ->order($sort, $order)
  52. ->paginate($limit);
  53. foreach ($list as $row) {
  54. }
  55. $result = array("total" => $list->total(), "rows" => $list->items());
  56. return json($result);
  57. }
  58. return $this->view->fetch();
  59. }
  60. public function send($ids){
  61. $order=$this->model->find($ids);
  62. if($this->request->isGet()){
  63. $this->assign('row',$order);
  64. $this->assign('companys',\app\common\model\LogisticsCompany::all());
  65. return $this->fetch();
  66. }else{
  67. $data=input('row/a');
  68. $this->validate($data,[
  69. 'com_id'=>['require',],
  70. 'trans_no'=>['require'],
  71. ]);
  72. /*if($order->logistics){
  73. $this->error('已发货无法再次发货');
  74. }*/
  75. $order->makeSend($order->logistics,$data);
  76. $this->success();
  77. }
  78. }
  79. }