You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.8 KiB

7 years ago
4 years ago
7 years ago
6 years ago
7 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Support\Facades\DB;
  4. use App\Common\ReturnData;
  5. use App\Common\Helper;
  6. use Illuminate\Http\Request;
  7. use App\Http\Logic\UserWithdrawLogic;
  8. use App\Http\Model\UserWithdraw;
  9. class UserWithdrawController extends BaseController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function getLogic()
  16. {
  17. return new UserWithdrawLogic();
  18. }
  19. public function index()
  20. {
  21. $where['delete_time'] = 0;
  22. $posts = $this->getLogic()->getPaginate($where, array('id', 'desc'));
  23. $data['posts'] = $posts;
  24. return view('admin.UserWithdraw.index', $data);
  25. }
  26. public function edit()
  27. {
  28. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  29. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  30. $data['id'] = $id;
  31. $data['post'] = object_to_array(DB::table('user_withdraw')->where('id', $id)->first(), 1);
  32. return view('admin.UserWithdraw.edit', $data);
  33. }
  34. public function doedit()
  35. {
  36. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;}
  37. unset($_POST["_token"]);
  38. if(DB::table('user_withdraw')->where('id', $id)->update($_POST))
  39. {
  40. success_jump('修改成功', route('admin_user'));
  41. }
  42. else
  43. {
  44. error_jump('修改失败');
  45. }
  46. }
  47. public function changeStatus()
  48. {
  49. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;}
  50. unset($_POST["_token"]);
  51. if(!isset($_POST["type"])){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  52. $user_withdraw = DB::table('user_withdraw')->where(['id'=>$id,'status'=>0])->first();
  53. if(!$user_withdraw){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  54. //0拒绝,1成功
  55. if($_POST["type"]==0)
  56. {
  57. $data['status'] = 4;
  58. //增加用户余额
  59. DB::table('user')->where(array('id'=>$user_withdraw->user_id))->increment('money', $user_withdraw->money);
  60. //添加用户余额记录
  61. DB::table('user_money')->insert(array('user_id'=>$user_withdraw->user_id,'type'=>0,'money'=>$user_withdraw->money,'des'=>'提现失败-返余额','user_money'=>DB::table('user')->where(array('id'=>$user_withdraw->user_id))->value('money'),'add_time'=>time()));
  62. }
  63. elseif($_POST["type"]==1)
  64. {
  65. $data['status'] = 2;
  66. }
  67. if(isset($data))
  68. {
  69. $res = DB::table('user_withdraw')->where('id', $id)->update($data);
  70. if(!$res){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
  71. }
  72. return ReturnData::create(ReturnData::SUCCESS);
  73. }
  74. }