Autoreply.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\controller\wechat;
  3. use app\admin\model\AdminLog;
  4. use app\common\controller\Backend;
  5. use app\common\model\WechatResponse;
  6. use think\Db;
  7. /**
  8. * 微信自动回复管理
  9. *
  10. * @icon fa fa-circle-o
  11. */
  12. class Autoreply extends Backend
  13. {
  14. protected $model = null;
  15. public function _initialize()
  16. {
  17. parent::_initialize();
  18. $this->model = model('WechatAutoreply');
  19. }
  20. /**
  21. * 编辑
  22. */
  23. public function edit($ids = NULL)
  24. {
  25. $row = Db::table($this->table)->where('id', $ids)->get();
  26. if (!$row)
  27. $this->error(__('No Results were found'));
  28. if ($this->request->isPost())
  29. {
  30. $this->code = -1;
  31. $params = $this->request->post("row/a");
  32. if ($params)
  33. {
  34. $row->save($params);
  35. AdminLog::record(__('Edit'), $ids);
  36. $this->code = 1;
  37. }
  38. return;
  39. }
  40. $response = WechatResponse::get(['eventkey' => $row['eventkey']]);
  41. $this->view->assign("response", $response);
  42. $this->view->assign("row", $row);
  43. }
  44. }