Scorelog.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. /**
  5. * 积分变动管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Scorelog extends Backend
  10. {
  11. /**
  12. * Log模型对象
  13. * @var \app\admin\model\user\score\Log
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\user\score\Log;
  20. }
  21. /**
  22. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  23. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  24. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  25. */
  26. public function add()
  27. {
  28. if ($this->request->isPost()) {
  29. $row = $this->request->post("row/a");
  30. $user_id = isset($row['user_id']) ? $row['user_id'] : 0;
  31. $score = isset($row['score']) ? $row['score'] : 0;
  32. $memo = isset($row['memo']) ? $row['memo'] : '';
  33. if (!$user_id || !$score) {
  34. $this->error("积分和会员ID不能为空");
  35. }
  36. \app\common\model\User::score($score, $user_id, $memo);
  37. $this->success("添加成功");
  38. }
  39. return parent::add();
  40. }
  41. }