Usertakecash.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 用户提现申请
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Usertakecash extends Backend
  11. {
  12. /**
  13. * Usertakecash模型对象
  14. * @var \app\admin\model\Usertakecash
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Usertakecash;
  21. $this->view->assign("statusList", $this->model->getStatusList());
  22. }
  23. /**
  24. * 审核
  25. */
  26. public function audit(){
  27. $id = input('id');
  28. $info = Db::name('user_take_cash')
  29. ->where('id',$id)
  30. ->find();
  31. if ($this->request->isPost()) {
  32. $status = input('status',0);
  33. $data = [
  34. 'status' => $status,
  35. 'auditremark' => input('auditremark',''),
  36. 'audittime' => time(),
  37. 'updatetime' => time(),
  38. ];
  39. Db::startTrans();
  40. $rs = Db::name('user_take_cash')->where('id',$id)->update($data);
  41. if($rs === false){
  42. Db::rollback();
  43. $this->error('审核失败');
  44. }
  45. if($status == 2){
  46. //归还钱
  47. $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],'money',$info['money'],5,'提现拒绝退还:'.$info['money'],'take_cash',$info['id']);
  48. if($wallet_rs['status'] === false){
  49. Db::rollback();
  50. $this->error($wallet_rs['msg']);
  51. }
  52. }
  53. Db::commit();
  54. $this->success('审核完成');
  55. }
  56. $this->assign('row',$info);
  57. return $this->view->fetch();
  58. }
  59. }