Sharingfees.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\controller\general;
  3. use app\common\model\ProductLists;
  4. use app\common\controller\Backend;
  5. /**
  6. * 手续费分润设置管理
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Sharingfees extends Backend
  11. {
  12. /**
  13. * Sharingfees模型对象
  14. * @var \app\admin\model\general\Sharingfees
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\common\model\Sharingfees;
  21. }
  22. public function index()
  23. {
  24. //设置过滤方法
  25. $this->request->filter(['strip_tags', 'trim']);
  26. if (false === $this->request->isAjax()) {
  27. return $this->view->fetch();
  28. }
  29. //如果发送的来源是 Selectpage,则转发到 Selectpage
  30. if ($this->request->request('keyField')) {
  31. return $this->selectpage();
  32. }
  33. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  34. $list = $this->model
  35. ->where($where)
  36. ->order($sort, $order)
  37. ->paginate($limit);
  38. $productLists = new ProductLists;
  39. foreach ($list as $key => $value) {
  40. $name =$productLists->where('id', 'in', $value->product_id)->column('zh_name');
  41. $list[$key]['product_id'] = implode(',', $name);
  42. }
  43. $result = ['total' => $list->total(), 'rows' => $list->items()];
  44. return json($result);
  45. }
  46. }