Index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare (strict_types = 1);
  11. namespace app\admin\controller\user;
  12. use app\common\controller\Backend;
  13. use think\annotation\route\Group;
  14. use app\admin\traits\Actions;
  15. use app\common\model\User;
  16. use app\common\model\UserLog;
  17. use think\annotation\route\Route;
  18. #[Group("user/index")]
  19. class Index extends Backend
  20. {
  21. protected $noNeedRight = ['index'];
  22. use Actions;
  23. protected function _initialize()
  24. {
  25. parent::_initialize();
  26. $this->model = new User();
  27. }
  28. #[Route('POST,GET','recharge')]
  29. public function recharge($ids)
  30. {
  31. if($this->request->isPost()){
  32. $module_type=$this->request->post('row.module_type');
  33. $change_type=$this->request->post('row.recharge_type');
  34. $change=$this->request->post('row.change/d');
  35. $remark=$this->request->post('row.remark');
  36. $order_no=time().rand(1000,9999);
  37. switch ($module_type){
  38. case 'score':
  39. UserLog::addScoreLog($ids,$change_type,$change,$order_no,$remark);
  40. break;
  41. case 'balance':
  42. UserLog::addBalanceLog($ids,$change_type,$change,$order_no,$remark);
  43. break;
  44. }
  45. $this->success();
  46. }else{
  47. $user=User::find($ids);
  48. $this->assign('moduletype',UserLog::TYPE);
  49. $this->assign('user',$user);
  50. return $this->fetch();
  51. }
  52. }
  53. #[Route('GET','test')]
  54. public function test()
  55. {
  56. return $this->fetch();
  57. }
  58. #[Route('GET,JSON','detail')]
  59. public function detail($ids)
  60. {
  61. if($this->request->isAjax()){
  62. $this->model=new UserLog();
  63. $where=[];
  64. $where[]=['type','=',$this->request->get('type')];
  65. $where[]=['user_id','=',$ids];
  66. [$where, $order, $limit, $with] = $this->buildparams($where);
  67. $list = $this->model
  68. ->where($where)
  69. ->order($order)
  70. ->paginate($limit);
  71. $result = ['total' => $list->total(), 'rows' => $list->items()];
  72. return json($result);
  73. }else{
  74. $user=User::find($ids);
  75. $this->assign('moduletype',UserLog::TYPE);
  76. $this->assign('user',$user);
  77. return $this->fetch();
  78. }
  79. }
  80. }