PlanRecord.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\admin\controller\wechat;
  3. use app\common\controller\Backend;
  4. use app\admin\model\WechatResponse;
  5. /**
  6. * 扣款服务签约列表
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class PlanRecord extends Backend
  11. {
  12. protected $model = null;
  13. // protected $noNeedRight = ['check_text_unique'];
  14. public function _initialize()
  15. {
  16. parent::_initialize();
  17. $this->model = model('WechatPlanRecord');
  18. }
  19. public function index()
  20. {
  21. //设置过滤方法
  22. $this->request->filter(['strip_tags', 'trim']);
  23. if ($this->request->isAjax()) {
  24. //如果发送的来源是Selectpage,则转发到Selectpage
  25. if ($this->request->request('keyField')) {
  26. $data = $this->selectpage()->getData();
  27. return $data;
  28. }
  29. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  30. /**
  31. * 获取企业信息
  32. */
  33. $where1 = is_sys_admin();
  34. $list = $this->model
  35. ->where($where)->where($where1)
  36. ->order($sort, $order)
  37. ->paginate($limit);
  38. // foreach ($list as $k => $v) {
  39. //
  40. // }
  41. $result = array("total" => $list->total(), "rows" => $list->items());
  42. return json($result);
  43. }
  44. return $this->view->fetch();
  45. }
  46. /**
  47. * 编辑
  48. */
  49. public function edit($ids = null)
  50. {
  51. $row = $this->model->get(['id' => $ids]);
  52. if (!$row) {
  53. $this->error(__('No Results were found'));
  54. }
  55. if ($this->request->isPost()) {
  56. $params = $this->request->post("row/a");
  57. if ($params) {
  58. $row->save($params);
  59. $this->success();
  60. }
  61. $this->error();
  62. }
  63. $this->view->assign("row", $row);
  64. return $this->view->fetch();
  65. }
  66. //
  67. // /**
  68. // * 判断价格是否唯一
  69. // * @internal
  70. // */
  71. // public function check_text_unique()
  72. // {
  73. // $row = $this->request->post("row/a");
  74. // $except = $this->request->post("except");
  75. // $text = isset($row['price']) ? $row['price'] : '';
  76. // if ($this->model->where('price', $text)->where(function ($query) use ($except) {
  77. // if ($except) {
  78. // $query->where('price', '<>', $except);
  79. // }
  80. // })->count() == 0) {
  81. // $this->success();
  82. // } else {
  83. // $this->error(__('Text already exists'));
  84. // }
  85. // }
  86. }