OrderAftersales.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\admin\controller\shop;
  3. use app\common\controller\Backend;
  4. /**
  5. * 退货单管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class OrderAftersales extends Backend
  10. {
  11. /**
  12. * OrderAftersales模型对象
  13. * @var \app\admin\model\shop\OrderAftersales
  14. */
  15. protected $model = null;
  16. protected $relationSearch = true;
  17. protected $searchFields = 'id,OrderGoods.order_sn';
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new \app\admin\model\shop\OrderAftersales;
  22. $this->view->assign("typeList", $this->model->getTypeList());
  23. $this->view->assign("statusList", $this->model->getStatusList());
  24. }
  25. /**
  26. * 查看
  27. */
  28. public function index()
  29. {
  30. //设置过滤方法
  31. $this->request->filter(['strip_tags', 'trim']);
  32. if ($this->request->isAjax()) {
  33. //如果发送的来源是Selectpage,则转发到Selectpage
  34. if ($this->request->request('keyField')) {
  35. return $this->selectpage();
  36. }
  37. list($where, $sort, $order, $offset, $limit, $page, $alias, $bind) = $this->buildparams();
  38. $list = $this->model
  39. ->with(['User', 'OrderGoods'])
  40. ->alias(['order_goods' => 'OrderGoods'])
  41. ->where($where)
  42. ->order($sort, $order)
  43. ->paginate($limit);
  44. foreach ($list as $index => $item) {
  45. if ($item->user) {
  46. $item->user->visible(['id', 'nickname', 'avatar']);
  47. }
  48. }
  49. $result = array("total" => $list->total(), "rows" => $list->items());
  50. return json($result);
  51. }
  52. return $this->view->fetch();
  53. }
  54. public function edit($ids = null)
  55. {
  56. $order_goods_id = $this->request->param("order_goods_id");
  57. if ($order_goods_id) {
  58. $row = $this->model->where('order_goods_id', $order_goods_id)->order('id', 'desc')->find();
  59. if ($row) {
  60. $ids = $row['id'];
  61. }
  62. }
  63. return parent::edit($ids);
  64. }
  65. }