Withdrawals.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace app\admin\controller\bonus;
  3. use app\common\controller\Backend;
  4. use app\common\model\User;
  5. use think\Db;
  6. /**
  7. *
  8. *
  9. * @icon fa fa-circle-o
  10. */
  11. class Withdrawals extends Backend
  12. {
  13. /**
  14. * Withdrawals模型对象
  15. * @var \app\admin\model\Withdrawals
  16. */
  17. protected $model = null;
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new \app\admin\model\Withdrawals;
  22. }
  23. /**
  24. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  25. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  26. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  27. */
  28. /**
  29. * 查看
  30. */
  31. public function index()
  32. {
  33. //当前是否为关联查询
  34. $this->relationSearch = false;
  35. //设置过滤方法
  36. $this->request->filter(['strip_tags']);
  37. if ($this->request->isAjax())
  38. {
  39. //如果发送的来源是Selectpage,则转发到Selectpage
  40. if ($this->request->request('keyField'))
  41. {
  42. return $this->selectpage();
  43. }
  44. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  45. $total = $this->model
  46. ->where($where)
  47. ->order($sort, $order)
  48. ->count();
  49. $list = $this->model
  50. ->where($where)
  51. ->order($sort, $order)
  52. ->limit($offset, $limit)
  53. ->select();
  54. foreach ($list as $k=>$row) {
  55. $list[$k]['money_type_name']=get_money_name_byident($row['money_type']);
  56. $list[$k]['status_desc']=get_recharge_status($row['process_status']);
  57. }
  58. $result = array("total" => $total, "rows" => $list);
  59. return json($result);
  60. }
  61. return $this->view->fetch();
  62. }
  63. /* 审核 */
  64. function view()
  65. {
  66. $ids = input('ids');
  67. $info=$this->model->where(['id'=>$ids,'process_status'=>1])->find();
  68. if(!$info)
  69. {
  70. $this->error("信息不存在,或已审核");
  71. }else{
  72. $res=$this->model->where(array('id'=>$ids))->update(['process_status'=>2,'confirm_date'=>time()]);
  73. if($res)
  74. {
  75. $this->success('审核完成');
  76. }else{
  77. $this->error('审核失败');
  78. }
  79. }
  80. }
  81. /*拒绝 */
  82. function refuse()
  83. {
  84. if ($this->request->isPost()) {
  85. $params = $this->request->post();
  86. $info=$this->model->where('id',$params['id'])->find();
  87. if(empty($info))
  88. {
  89. $this->error("信息不存在");
  90. }
  91. $user = User::where(['id'=> $info['userid']])->find();
  92. if(empty($user)){
  93. $this->error("用户信息不存在");
  94. }
  95. DB::startTrans();
  96. $res1=$this->model->where('id',$params['id'])->update(['process_status'=>-1,'remark'=>$params['remark'],'confirm_date'=>time()]);
  97. if(!$res1){
  98. DB::rollback();
  99. $this->error('审核失败');
  100. }
  101. $balance = $user->usdt;
  102. $user->usdt = $user->usdt + $info['amount'];
  103. $user->updatetime = time();
  104. if(!$user->save()){
  105. DB::rollback();
  106. $this->error('审核失败');
  107. }
  108. // 流水明细
  109. $changedata=[
  110. 'userid'=> $info['userid'],
  111. 'type'=> 5,
  112. 'money'=> $info['amount'],
  113. 'balance'=> $balance,
  114. 'relevant_userid'=> $info['userid'],
  115. 'status'=>1,
  116. 'create_time'=>time(),
  117. 'remark'=>'USDT余额提现拒绝返还',
  118. 'user_name'=>$user->username? $user->username : '系统',
  119. 'relevant_name'=>$user->username? $user->username : '系统',
  120. ];
  121. if(!Db::name('detailed_bonus')->insertGetId($changedata)){
  122. DB::rollback();
  123. $this->error('审核失败');
  124. }
  125. DB::commit();
  126. $this->success('审核完成');
  127. }
  128. $ids=input('ids');
  129. $this->view->assign('id',$ids);
  130. return $this->view->fetch();
  131. }
  132. function toshow()
  133. {
  134. $ids=input('ids');
  135. $info=$this->model->where('id',$ids)->find();
  136. $this->view->assign('prc',$info['prc']);
  137. return $this->view->fetch();
  138. }
  139. }